diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_init.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_init.c b/src/lib/libcrypto/pkcs12/p12_init.c index e9c55ea265..b4da7be77c 100644 --- a/src/lib/libcrypto/pkcs12/p12_init.c +++ b/src/lib/libcrypto/pkcs12/p12_init.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: p12_init.c,v 1.7 2014/06/12 15:49:30 deraadt Exp $ */ | 1 | /* $OpenBSD: p12_init.c,v 1.8 2014/07/08 09:24:53 jsing Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -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,31 +62,35 @@ | |||
62 | 62 | ||
63 | /* Initialise a PKCS12 structure to take data */ | 63 | /* Initialise a PKCS12 structure to take data */ |
64 | 64 | ||
65 | PKCS12 *PKCS12_init(int mode) | 65 | PKCS12 * |
66 | PKCS12_init(int mode) | ||
66 | { | 67 | { |
67 | PKCS12 *pkcs12; | 68 | PKCS12 *pkcs12; |
69 | |||
68 | if (!(pkcs12 = PKCS12_new())) { | 70 | if (!(pkcs12 = PKCS12_new())) { |
69 | PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); | 71 | PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); |
70 | return NULL; | 72 | return NULL; |
71 | } | 73 | } |
72 | ASN1_INTEGER_set(pkcs12->version, 3); | 74 | ASN1_INTEGER_set(pkcs12->version, 3); |
73 | pkcs12->authsafes->type = OBJ_nid2obj(mode); | 75 | pkcs12->authsafes->type = OBJ_nid2obj(mode); |
74 | switch (mode) { | 76 | switch (mode) { |
75 | case NID_pkcs7_data: | 77 | case NID_pkcs7_data: |
76 | if (!(pkcs12->authsafes->d.data = | 78 | if (!(pkcs12->authsafes->d.data = |
77 | M_ASN1_OCTET_STRING_new())) { | 79 | M_ASN1_OCTET_STRING_new())) { |
78 | PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); | 80 | PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); |
79 | goto err; | 81 | goto err; |
80 | } | 82 | } |
81 | break; | 83 | break; |
82 | default: | 84 | default: |
83 | PKCS12err(PKCS12_F_PKCS12_INIT, | 85 | PKCS12err(PKCS12_F_PKCS12_INIT, |
84 | PKCS12_R_UNSUPPORTED_PKCS12_MODE); | 86 | PKCS12_R_UNSUPPORTED_PKCS12_MODE); |
85 | goto err; | 87 | goto err; |
86 | } | 88 | } |
87 | 89 | ||
88 | return pkcs12; | 90 | return pkcs12; |
91 | |||
89 | err: | 92 | err: |
90 | if (pkcs12 != NULL) PKCS12_free(pkcs12); | 93 | if (pkcs12 != NULL) |
94 | PKCS12_free(pkcs12); | ||
91 | return NULL; | 95 | return NULL; |
92 | } | 96 | } |