6 Commits

Author SHA1 Message Date
David Benjamin 729648fb79 Rename EVP_R_EXPECTING_AN_EC_KEY_KEY to match OpenSSL
EC_KEY_KEY looks very silly. In OpenSSL, this is
EVP_R_EXPECTING_A_EC_KEY. It's a little odd that they say "a EC key"
instead of "an EC key", but ah well. (They do say "an RSA key".) May as
well match.

Update-Note: Code search finds no references to the BoringSSL name, so
this is not expected to impact anything.

Change-Id: I7563645fd269e4a62fbc46de2647f06bde00e1e4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81428
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Lily Chen <chlily@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Lily Chen <chlily@google.com>
2025-08-18 16:36:18 -07:00
David Benjamin 33d1049b1f Switch the license to Apache 2.0, matching OpenSSL upstream
We use the standard Apache 2.0 file header, described in "APPENDIX: How
to apply the Apache License to your work."

This was primarily automated by running:

  git ls-tree -r --name-only HEAD | xargs go run ./util/relicense.go

See go/boringssl-relicensing-triage for the results of triaging the
output of the tool.

As part of this, switch from taking fiat-crypto under MIT license to
Apache 2.0. (It is licensed under MIT OR Apache-2.0 OR BSD-1-Clause.)

The copyright_summary tool can also be used to confirm we didn't
accidentally drop any copyright lines:

  # Run before the CL
  git grep -l Copyright | xargs go run ./util/copyright_summary.go  -out /tmp/old.json
  # Run after the CL
  git grep -l Copyright | xargs go run ./util/copyright_summary.go  -compare /tmp/old.json

Bug: 364634028
Change-Id: I17c50e761e9d077a1f92e25969e50ed35e320c59
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/75852
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-02-03 15:05:16 -08:00
David Benjamin 4854ec106f Apply OpenSSL's "copyright consolidation" changes
This applies the OpenSSL "copyright consolidation" process from the
following upstream changes:

* https://github.com/openssl/openssl/commit/e0a651945cb5a70a2abd9902c0fd3e9759d35867
* https://github.com/openssl/openssl/commit/3fb2cf1ad19feaf6f7c571b49bd9e320eb4daf31
* https://github.com/openssl/openssl/commit/ac3d0e13777a0f0533792ed8fdd7de485675a3a2
* https://github.com/openssl/openssl/commit/c2f312f5c2379e1dcb6b3678bda27f7544508ee6
* https://github.com/openssl/openssl/commit/596d6b7e1ca5aa24700098e262cb1625f256343f
* https://github.com/openssl/openssl/commit/e18cf66aaf44b4d476625b2416386b051007d495
* https://github.com/openssl/openssl/commit/846e33c729311169d9c988ceba29484b3783f244
* https://github.com/openssl/openssl/commit/440e5d805f449d662520313b33fd90aeee86980b
* https://github.com/openssl/openssl/commit/21dcbebc6e35419f1842f39a125374ea1ba45693
* https://github.com/openssl/openssl/commit/6286757141a8c6e14d647ec733634ae0c83d9887
* https://github.com/openssl/openssl/commit/4f22f40507fea3f272637eb8e00cadf1f34b10d9
* https://github.com/openssl/openssl/commit/d2e9e320186f0917cc940f46bdf1a7e4120da9b0
* https://github.com/openssl/openssl/commit/2039c421b0e5b75ffcf6a88e39cc09089b4303dc
* https://github.com/openssl/openssl/commit/b1322259d93cf6b6286f9febcd468b6a9f577d91
* https://github.com/openssl/openssl/commit/aa6bb1352b1026b20a23b49da4efdcf171926eb0
* https://github.com/openssl/openssl/commit/b6cff313cbb1d0381b329fe4f6a8f009cdb270e4
* https://github.com/openssl/openssl/commit/9e20068958b8c1772067299dda7df0b8a82283b4
* https://github.com/openssl/openssl/commit/6aa36e8e5a062e31543e7796f0351ff9628832ce
* https://github.com/openssl/openssl/commit/44c8a5e2b9af8909844cc002c53049311634b314

This was mostly automated, but partially manual. The automated portion
can be reproduced by checking OpenSSL to commit
44c8a5e2b9af8909844cc002c53049311634b314, and running the following:

  git grep -l -E 'Copyright remains Eric Young|Copyright.*The OpenSSL Project\.|Written by.*for the OpenSSL Project' crypto/ decrepit/ include/ ssl/ | grep -v objects.go > files.txt
  cat files.txt | xargs -n1 perl -i ./util/copyright.pl

From there, some years were fixed up manually according to
go/openssl-copyright-consolidation-comparison (internal-only).

Three files required additional manual fixing:

- crypto/ecdh_extra/ecdh_extra.cc
- crypto/fipsmodule/ecdh/ecdh.cc.inc
- include/openssl/ecdh.h

These files have an OpenSSL header, but *after* a different header, so
the script does not correctly detect the now redundant OpenSSL header.
They were manually modified to remove it. This matches what seems to
have been done to crypto/ec/ecdh_ossl.c in OpenSSL's
4f22f40507fea3f272637eb8e00cadf1f34b10d9.

Bug: 364634028
Change-Id: I79a559a409ebe2476f2cb8a48a488ac5dd77c90a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/74710
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-01-03 13:56:35 -08:00
David Benjamin e57ab142c0 Add some barebones support for DH in EVP
OpenSSH needs this. Features that have been intentionally omitted for
now:

- X9.42-style Diffie-Hellman ("DHX"). We continue not to support this.
  Use ECDH or X25519 instead.

- SPKI and PKCS#8 serialization. Use ECDH or X25519 instead. The format
  is a bit ill-defined. Moreover, until we solve the serialization
  aspects of https://crbug.com/boringssl/497, adding them would put this
  legacy algorithm on path for every caller.

- Most of the random options like stapling a KDF, etc. Though I did add
  EVP_PKEY_CTX_set_dh_pad because it's the only way to undo OpenSSL's
  bug where they chop off leading zeros by default.

- Parameter generation. Diffie-Hellman parameters should not be
  generated at runtime.

This means you need to bootstrap with a DH object and then wrap it in an
EVP_PKEY. This matches the limitations of the EVP API in OpenSSL 1.1.x.
Unfortunately the OpenSSL 3.x APIs are unsuitable for many, many
reasons, so I expect when we get further along in
https://crbug.com/boringssl/535, we'll have established some patterns
here that we can apply to EVP_PKEY_DH too.

Change-Id: I34b4e8799afb266ea5602a70115cc2146f19c6a7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67207
Reviewed-by: Theo Buehler <theorbuehler@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2024-03-21 03:34:31 +00:00
Dan McArdle d9ee55a89f Refactor HPKE API to include explicit length parameters.
Bug: 275
Change-Id: I724e9315b860e230e8fed92de34d89a875ef043c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46184
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-03-19 17:24:14 +00:00
David Benjamin c9d3265a92 Generalize make_errors.go to allow EVP covering multiple directories.
In doing so, this switches make_errors.go to take library names as
parameters rather than detecting it from the CWD. (I considered
detecting it, but then we'd need to map evp -> crypto/whatever and
crypto/whatever -> evp in both directions.)

Since crypto/hpke currently sits in the EVP namespace, I've gone ahead
and added that, so it should be easier to define new errors in
crypto/hpke. I've not added crypto/cipher, etc., yet. Moving those will
be a breaking change (consumers that put ERR_LIB_CIPHER and ERR_LIB_EVP
in a switch/case need patches).

Bug: 398
Change-Id: Ibae2afd46e076891fa517c377b540b2e492516f0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46264
Reviewed-by: Adam Langley <agl@google.com>
2021-03-19 16:39:08 +00:00