aboutsummaryrefslogtreecommitdiff
path: root/crypto/asn1
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-05-27 12:34:03 +0200
committerRichard Levitte <levitte@openssl.org>2021-06-09 17:00:10 +0200
commit6a2b8ff392a304bbb106528653397b864acc53fa (patch)
tree75bd836ad9cec6eec65f270fd4db4b893f73b939 /crypto/asn1
parent320fc032b98cc452c5dc96600b16da40b155123b (diff)
downloadopenssl-6a2b8ff392a304bbb106528653397b864acc53fa.zip
openssl-6a2b8ff392a304bbb106528653397b864acc53fa.tar.gz
openssl-6a2b8ff392a304bbb106528653397b864acc53fa.tar.bz2
Decoding PKCS#8: separate decoding of encrypted and unencrypted PKCS#8
This has us switch from the 'structure' "pkcs8" to "PrivateKeyInfo", which is sensible considering we already have "SubjectPublicKeyInfo". We also add "EncryptedPrivateKeyInfo", and use it for a special decoder that detects and decrypts an EncryptedPrivateKeyInfo structured DER blob into a PrivateKeyInfo structured DER blob and passes that on to the next decoder implementation. The result of this change is that PKCS#8 decryption should only happen once per decoding instead of once for every expected key type. Furthermore, this new decoder implementation sets the data type to the OID of the algorithmIdentifier field, thus reducing how many decoder implementations are tentativaly run further down the call chain. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15498)
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/d2i_pr.c2
-rw-r--r--crypto/asn1/i2d_evp.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c
index 3b28460..720b7fd 100644
--- a/crypto/asn1/d2i_pr.c
+++ b/crypto/asn1/d2i_pr.c
@@ -32,7 +32,7 @@ d2i_PrivateKey_decoder(int keytype, EVP_PKEY **a, const unsigned char **pp,
EVP_PKEY *pkey = NULL, *bak_a = NULL;
EVP_PKEY **ppkey = &pkey;
const char *key_name = NULL;
- const char *input_structures[] = { "type-specific", "pkcs8", NULL };
+ const char *input_structures[] = { "type-specific", "PrivateKeyInfo", NULL };
int i, ret;
if (keytype != EVP_PKEY_NONE) {
diff --git a/crypto/asn1/i2d_evp.c b/crypto/asn1/i2d_evp.c
index e1d5b7c..8b36388 100644
--- a/crypto/asn1/i2d_evp.c
+++ b/crypto/asn1/i2d_evp.c
@@ -97,7 +97,7 @@ int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp)
if (evp_pkey_is_provided(a)) {
static const struct type_and_structure_st output_info[] = {
{ "DER", "type-specific" },
- { "DER", "pkcs8" },
+ { "DER", "PrivateKeyInfo" },
{ NULL, }
};