diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/p8_pkey.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/p8_pkey.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c index c95d7e55a0..6c5577ee1e 100644 --- a/src/lib/libcrypto/asn1/p8_pkey.c +++ b/src/lib/libcrypto/asn1/p8_pkey.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -62,16 +62,16 @@ | |||
| 62 | #include <openssl/x509.h> | 62 | #include <openssl/x509.h> |
| 63 | 63 | ||
| 64 | /* Minor tweak to operation: zero private key data */ | 64 | /* Minor tweak to operation: zero private key data */ |
| 65 | static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, | 65 | static int |
| 66 | void *exarg) | 66 | pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) |
| 67 | { | 67 | { |
| 68 | /* Since the structure must still be valid use ASN1_OP_FREE_PRE */ | 68 | /* Since the structure must still be valid use ASN1_OP_FREE_PRE */ |
| 69 | if(operation == ASN1_OP_FREE_PRE) { | 69 | if (operation == ASN1_OP_FREE_PRE) { |
| 70 | PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; | 70 | PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; |
| 71 | if (key->pkey->value.octet_string) | 71 | if (key->pkey->value.octet_string) |
| 72 | OPENSSL_cleanse(key->pkey->value.octet_string->data, | 72 | OPENSSL_cleanse(key->pkey->value.octet_string->data, |
| 73 | key->pkey->value.octet_string->length); | 73 | key->pkey->value.octet_string->length); |
| 74 | } | 74 | } |
| 75 | return 1; | 75 | return 1; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| @@ -84,12 +84,12 @@ ASN1_SEQUENCE_cb(PKCS8_PRIV_KEY_INFO, pkey_cb) = { | |||
| 84 | 84 | ||
| 85 | IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) | 85 | IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) |
| 86 | 86 | ||
| 87 | int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, | 87 | int |
| 88 | int version, | 88 | PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version, |
| 89 | int ptype, void *pval, | 89 | int ptype, void *pval, unsigned char *penc, int penclen) |
| 90 | unsigned char *penc, int penclen) | ||
| 91 | { | 90 | { |
| 92 | unsigned char **ppenc = NULL; | 91 | unsigned char **ppenc = NULL; |
| 92 | |||
| 93 | if (version >= 0) { | 93 | if (version >= 0) { |
| 94 | if (!ASN1_INTEGER_set(priv->version, version)) | 94 | if (!ASN1_INTEGER_set(priv->version, version)) |
| 95 | return 0; | 95 | return 0; |
| @@ -118,14 +118,13 @@ int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, | |||
| 118 | return 1; | 118 | return 1; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, | 121 | int |
| 122 | const unsigned char **pk, int *ppklen, | 122 | PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, |
| 123 | X509_ALGOR **pa, | 123 | X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8) |
| 124 | PKCS8_PRIV_KEY_INFO *p8) | ||
| 125 | { | 124 | { |
| 126 | if (ppkalg) | 125 | if (ppkalg) |
| 127 | *ppkalg = p8->pkeyalg->algorithm; | 126 | *ppkalg = p8->pkeyalg->algorithm; |
| 128 | if(p8->pkey->type == V_ASN1_OCTET_STRING) { | 127 | if (p8->pkey->type == V_ASN1_OCTET_STRING) { |
| 129 | p8->broken = PKCS8_OK; | 128 | p8->broken = PKCS8_OK; |
| 130 | if (pk) { | 129 | if (pk) { |
| 131 | *pk = p8->pkey->value.octet_string->data; | 130 | *pk = p8->pkey->value.octet_string->data; |
| @@ -137,11 +136,9 @@ int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, | |||
| 137 | *pk = p8->pkey->value.sequence->data; | 136 | *pk = p8->pkey->value.sequence->data; |
| 138 | *ppklen = p8->pkey->value.sequence->length; | 137 | *ppklen = p8->pkey->value.sequence->length; |
| 139 | } | 138 | } |
| 140 | } | 139 | } else |
| 141 | else | ||
| 142 | return 0; | 140 | return 0; |
| 143 | if (pa) | 141 | if (pa) |
| 144 | *pa = p8->pkeyalg; | 142 | *pa = p8->pkeyalg; |
| 145 | return 1; | 143 | return 1; |
| 146 | } | 144 | } |
| 147 | |||
