Add a generic SubjectPublicKeyInfo decoder
authorMatt Caswell <matt@openssl.org>
Tue, 8 Jun 2021 10:49:06 +0000 (11:49 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 14 Jun 2021 08:43:01 +0000 (09:43 +0100)
commit8c7c1c84cbaa38a4053404883d666ea8dff81b3a
treee775c97857d6cf816b94573bcbad11e68ed691fb
parent1c49be8673713d2ceb03a63be03531d9b28a46bd
Add a generic SubjectPublicKeyInfo decoder

Previously all the SubjectPublicKeyInfo decoders were specific to a key
type. We would iterate over all them until a match was found for the correct
key type. Each one would fully decode the key before then testing whether
it was a match or not - throwing it away if not. This was very inefficient.

Instead we introduce a generic SubjectPublicKeyInfo decoder which figures
out what type of key is contained within it, before subsequently passing on
the data to a key type specific SubjectPublicKeyInfo decoder.

Fixes #15646

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15662)
crypto/ec/ec_backend.c
crypto/x509/x_pubkey.c
include/crypto/ec.h
include/crypto/x509.h
providers/decoders.inc
providers/implementations/encode_decode/build.info
providers/implementations/encode_decode/decode_der2key.c
providers/implementations/encode_decode/decode_spki2typespki.c [new file with mode: 0644]
providers/implementations/encode_decode/endecoder_common.c
providers/implementations/encode_decode/endecoder_local.h
providers/implementations/include/prov/implementations.h