diff options
author | beck <> | 2014-04-17 13:37:50 +0000 |
---|---|---|
committer | beck <> | 2014-04-17 13:37:50 +0000 |
commit | bddb7c686e3d1aeb156722adc64b6c35ae720f87 (patch) | |
tree | 7595a93a27385c367802aa17ecf20f96551cf14d /src/lib/libcrypto/pkcs12 | |
parent | ecec66222d758996a4ff2671ca5026d9ede5ef76 (diff) | |
download | openbsd-bddb7c686e3d1aeb156722adc64b6c35ae720f87.tar.gz openbsd-bddb7c686e3d1aeb156722adc64b6c35ae720f87.tar.bz2 openbsd-bddb7c686e3d1aeb156722adc64b6c35ae720f87.zip |
Change library to use intrinsic memory allocation functions instead of
OPENSSL_foo wrappers. This changes:
OPENSSL_malloc->malloc
OPENSSL_free->free
OPENSSL_relloc->realloc
OPENSSL_freeFunc->free
Diffstat (limited to 'src/lib/libcrypto/pkcs12')
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_decr.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_key.c | 18 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_kiss.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_mutl.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_utl.c | 4 |
5 files changed, 20 insertions, 20 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c index 9d3557e8d7..9a73c21866 100644 --- a/src/lib/libcrypto/pkcs12/p12_decr.c +++ b/src/lib/libcrypto/pkcs12/p12_decr.c | |||
@@ -65,7 +65,7 @@ | |||
65 | 65 | ||
66 | 66 | ||
67 | /* Encrypt/Decrypt a buffer based on password and algor, result in a | 67 | /* Encrypt/Decrypt a buffer based on password and algor, result in a |
68 | * OPENSSL_malloc'ed buffer | 68 | * malloc'ed buffer |
69 | */ | 69 | */ |
70 | 70 | ||
71 | unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, | 71 | unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, |
@@ -84,14 +84,14 @@ unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, | |||
84 | return NULL; | 84 | return NULL; |
85 | } | 85 | } |
86 | 86 | ||
87 | if(!(out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { | 87 | if(!(out = malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { |
88 | PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE); | 88 | PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE); |
89 | goto err; | 89 | goto err; |
90 | } | 90 | } |
91 | 91 | ||
92 | if (!EVP_CipherUpdate(&ctx, out, &i, in, inlen)) | 92 | if (!EVP_CipherUpdate(&ctx, out, &i, in, inlen)) |
93 | { | 93 | { |
94 | OPENSSL_free(out); | 94 | free(out); |
95 | out = NULL; | 95 | out = NULL; |
96 | PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_EVP_LIB); | 96 | PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_EVP_LIB); |
97 | goto err; | 97 | goto err; |
@@ -99,7 +99,7 @@ unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, | |||
99 | 99 | ||
100 | outlen = i; | 100 | outlen = i; |
101 | if(!EVP_CipherFinal_ex(&ctx, out + i, &i)) { | 101 | if(!EVP_CipherFinal_ex(&ctx, out + i, &i)) { |
102 | OPENSSL_free(out); | 102 | free(out); |
103 | out = NULL; | 103 | out = NULL; |
104 | PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_CIPHERFINAL_ERROR); | 104 | PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_CIPHERFINAL_ERROR); |
105 | goto err; | 105 | goto err; |
@@ -146,7 +146,7 @@ void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, | |||
146 | ret = ASN1_item_d2i(NULL, &p, outlen, it); | 146 | ret = ASN1_item_d2i(NULL, &p, outlen, it); |
147 | if (zbuf) OPENSSL_cleanse(out, outlen); | 147 | if (zbuf) OPENSSL_cleanse(out, outlen); |
148 | if(!ret) PKCS12err(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I,PKCS12_R_DECODE_ERROR); | 148 | if(!ret) PKCS12err(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I,PKCS12_R_DECODE_ERROR); |
149 | OPENSSL_free(out); | 149 | free(out); |
150 | return ret; | 150 | return ret; |
151 | } | 151 | } |
152 | 152 | ||
@@ -173,11 +173,11 @@ ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *i | |||
173 | if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data, | 173 | if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data, |
174 | &oct->length, 1)) { | 174 | &oct->length, 1)) { |
175 | PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT,PKCS12_R_ENCRYPT_ERROR); | 175 | PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT,PKCS12_R_ENCRYPT_ERROR); |
176 | OPENSSL_free(in); | 176 | free(in); |
177 | return NULL; | 177 | return NULL; |
178 | } | 178 | } |
179 | if (zbuf) OPENSSL_cleanse(in, inlen); | 179 | if (zbuf) OPENSSL_cleanse(in, inlen); |
180 | OPENSSL_free(in); | 180 | free(in); |
181 | return oct; | 181 | return oct; |
182 | } | 182 | } |
183 | 183 | ||
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c index 61d58502fd..b3672a95e5 100644 --- a/src/lib/libcrypto/pkcs12/p12_key.c +++ b/src/lib/libcrypto/pkcs12/p12_key.c | |||
@@ -95,7 +95,7 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, | |||
95 | return 0; | 95 | return 0; |
96 | if(unipass) { | 96 | if(unipass) { |
97 | OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */ | 97 | OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */ |
98 | OPENSSL_free(unipass); | 98 | free(unipass); |
99 | } | 99 | } |
100 | return ret; | 100 | return ret; |
101 | } | 101 | } |
@@ -135,14 +135,14 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, | |||
135 | u = EVP_MD_size (md_type); | 135 | u = EVP_MD_size (md_type); |
136 | if (u < 0) | 136 | if (u < 0) |
137 | return 0; | 137 | return 0; |
138 | D = OPENSSL_malloc (v); | 138 | D = malloc (v); |
139 | Ai = OPENSSL_malloc (u); | 139 | Ai = malloc (u); |
140 | B = OPENSSL_malloc (v + 1); | 140 | B = malloc (v + 1); |
141 | Slen = v * ((saltlen+v-1)/v); | 141 | Slen = v * ((saltlen+v-1)/v); |
142 | if(passlen) Plen = v * ((passlen+v-1)/v); | 142 | if(passlen) Plen = v * ((passlen+v-1)/v); |
143 | else Plen = 0; | 143 | else Plen = 0; |
144 | Ilen = Slen + Plen; | 144 | Ilen = Slen + Plen; |
145 | I = OPENSSL_malloc (Ilen); | 145 | I = malloc (Ilen); |
146 | Ij = BN_new(); | 146 | Ij = BN_new(); |
147 | Bpl1 = BN_new(); | 147 | Bpl1 = BN_new(); |
148 | if (!D || !Ai || !B || !I || !Ij || !Bpl1) | 148 | if (!D || !Ai || !B || !I || !Ij || !Bpl1) |
@@ -209,10 +209,10 @@ err: | |||
209 | PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI,ERR_R_MALLOC_FAILURE); | 209 | PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI,ERR_R_MALLOC_FAILURE); |
210 | 210 | ||
211 | end: | 211 | end: |
212 | OPENSSL_free (Ai); | 212 | free (Ai); |
213 | OPENSSL_free (B); | 213 | free (B); |
214 | OPENSSL_free (D); | 214 | free (D); |
215 | OPENSSL_free (I); | 215 | free (I); |
216 | BN_free (Ij); | 216 | BN_free (Ij); |
217 | BN_free (Bpl1); | 217 | BN_free (Bpl1); |
218 | EVP_MD_CTX_cleanup(&ctx); | 218 | EVP_MD_CTX_cleanup(&ctx); |
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c index 206b1b0b18..bc1fcff45d 100644 --- a/src/lib/libcrypto/pkcs12/p12_kiss.c +++ b/src/lib/libcrypto/pkcs12/p12_kiss.c | |||
@@ -271,7 +271,7 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen, | |||
271 | len = ASN1_STRING_to_UTF8(&data, fname); | 271 | len = ASN1_STRING_to_UTF8(&data, fname); |
272 | if(len > 0) { | 272 | if(len > 0) { |
273 | r = X509_alias_set1(x509, data, len); | 273 | r = X509_alias_set1(x509, data, len); |
274 | OPENSSL_free(data); | 274 | free(data); |
275 | if (!r) | 275 | if (!r) |
276 | { | 276 | { |
277 | X509_free(x509); | 277 | X509_free(x509); |
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c index 96de1bd11e..98128e31cb 100644 --- a/src/lib/libcrypto/pkcs12/p12_mutl.c +++ b/src/lib/libcrypto/pkcs12/p12_mutl.c | |||
@@ -169,7 +169,7 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, | |||
169 | } | 169 | } |
170 | if (!saltlen) saltlen = PKCS12_SALT_LEN; | 170 | if (!saltlen) saltlen = PKCS12_SALT_LEN; |
171 | p12->mac->salt->length = saltlen; | 171 | p12->mac->salt->length = saltlen; |
172 | if (!(p12->mac->salt->data = OPENSSL_malloc (saltlen))) { | 172 | if (!(p12->mac->salt->data = malloc (saltlen))) { |
173 | PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); | 173 | PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); |
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
diff --git a/src/lib/libcrypto/pkcs12/p12_utl.c b/src/lib/libcrypto/pkcs12/p12_utl.c index 59c6f453f6..9c58036169 100644 --- a/src/lib/libcrypto/pkcs12/p12_utl.c +++ b/src/lib/libcrypto/pkcs12/p12_utl.c | |||
@@ -68,7 +68,7 @@ unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, | |||
68 | unsigned char *unitmp; | 68 | unsigned char *unitmp; |
69 | if (asclen == -1) asclen = strlen(asc); | 69 | if (asclen == -1) asclen = strlen(asc); |
70 | ulen = asclen*2 + 2; | 70 | ulen = asclen*2 + 2; |
71 | if (!(unitmp = OPENSSL_malloc(ulen))) return NULL; | 71 | if (!(unitmp = malloc(ulen))) return NULL; |
72 | for (i = 0; i < ulen - 2; i+=2) { | 72 | for (i = 0; i < ulen - 2; i+=2) { |
73 | unitmp[i] = 0; | 73 | unitmp[i] = 0; |
74 | unitmp[i + 1] = asc[i>>1]; | 74 | unitmp[i + 1] = asc[i>>1]; |
@@ -89,7 +89,7 @@ char *OPENSSL_uni2asc(unsigned char *uni, int unilen) | |||
89 | /* If no terminating zero allow for one */ | 89 | /* If no terminating zero allow for one */ |
90 | if (!unilen || uni[unilen - 1]) asclen++; | 90 | if (!unilen || uni[unilen - 1]) asclen++; |
91 | uni++; | 91 | uni++; |
92 | if (!(asctmp = OPENSSL_malloc(asclen))) return NULL; | 92 | if (!(asctmp = malloc(asclen))) return NULL; |
93 | for (i = 0; i < unilen; i+=2) asctmp[i>>1] = uni[i]; | 93 | for (i = 0; i < unilen; i+=2) asctmp[i>>1] = uni[i]; |
94 | asctmp[asclen - 1] = 0; | 94 | asctmp[asclen - 1] = 0; |
95 | return asctmp; | 95 | return asctmp; |