You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BoringSSL: Don't support parameterless DSA keys in SPKIs AND Set an EVP_PKEY's algorithm and data together (#3057)
*Note*: to be rebased on #3056.
### Description of changes:
#### BoringSSL commit
google/boringssl@1bc58a3:
"Don't support parameterless DSA keys in SPKIs"
Changes (2 files):
- **crypto/evp_extra/p_dsa_asn1.c** — Removed the `CBS_len(params) == 0`
branch in `dsa_pub_decode` that created an empty `DSA_new()` without
parameters. Parameterless DSA keys in
`SubjectPublicKeyInfo` will no longer parse. This does not impact TLS,
where we have never supported DSA.
- **crypto/evp_extra/evp_tests.txt** — Updated the
DSA-1024-SPKI-No-Params test to expect `DECODE_ERROR` instead of
successful parsing.
#### BoringSSL commit
google/boringssl@b0ef87e:
"Set an EVP_PKEY's algorithm and data together"
Changes (8 files):
- **crypto/fipsmodule/evp/evp.c** — Replaced `evp_pkey_set_method` with
`evp_pkey_set0(pkey, method, pkey_data)` which sets `method`, `type`,
and `data` atomically. Removed `free_it` from
`pkey_set_type` (uses `evp_pkey_set0(pkey, NULL, NULL)` instead).
`EVP_PKEY_new_raw_*` functions set `method` via `evp_pkey_set0` before
calling callbacks.
- In `evp_pkey_set0` implementation: BoringSSL doesn't have the `type`
field — it derives the `type` from `ameth` at query time via
`EVP_PKEY_id()`. AWS-LC stores type as a separate field
that must be kept in sync.
- **crypto/evp_extra/internal.h** — Updated declaration
- **crypto/evp_extra/evp_asn1.c** — Moved `pub_decode`/`priv_decode`
NULL checks earlier; set method via `evp_pkey_set0` before calling
decode callbacks
- **crypto/evp_extra/p_dh_asn1.c**, **crypto/evp_extra/p_x25519.c**,
**crypto/fipsmodule/evp/p_ed25519.c** — Use `evp_pkey_set0` in keygen
- **crypto/fipsmodule/evp/p_kem.c**, **crypto/fipsmodule/evp/p_pqdsa.c**
— Create key first, then `evp_pkey_set0(pkey, method, key)` together
### Adaptations for AWS-LC:
ed25519/x25519 set_priv_raw/set_pub_raw callbacks are shared with
ed25519ph (AWS-LC specific), so the method must be set by the caller
before invoking the callback, not by the
callback itself.
#### Details
crypto/fipsmodule/evp/evp.c:
- `EVP_PKEY_new_raw_private_key` — calls `evp_pkey_set0(ret, method,
NULL)` then `method->set_priv_raw(...)`
- `EVP_PKEY_new_raw_public_key` — calls `evp_pkey_set0(ret, method,
NULL)` then `method->set_pub_raw(...)`
crypto/evp_extra/evp_asn1.c:
- `EVP_parse_public_key` — calls `evp_pkey_set0(ret, method, NULL)` then
`method->pub_decode(...)`
- `EVP_parse_private_key` — calls `evp_pkey_set0(ret, method, NULL)`
then `method->priv_decode(...)`
In BoringSSL's version, all four of these just called
`method->callback(ret, ...)` directly (no `method` pre-setting), and the
callbacks themselves called evp_pkey_set0. We couldn't do that because
the ed25519 callbacks are shared with ed25519ph.
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
---------
Co-authored-by: David Benjamin <davidben@google.com>
0 commit comments