diff options
author | 2014-04-17 13:37:48 +0000 | |
---|---|---|
committer | 2014-04-17 13:37:48 +0000 | |
commit | 6f3a6cb14ff86acbae89a0395ba3cdc01e85fa54 (patch) | |
tree | e7ca531f41f3403bf7f04411c40317e859a02460 /lib/libcrypto/rsa | |
parent | Revert unintended whitespace changes. (diff) | |
download | wireguard-openbsd-6f3a6cb14ff86acbae89a0395ba3cdc01e85fa54.tar.xz wireguard-openbsd-6f3a6cb14ff86acbae89a0395ba3cdc01e85fa54.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 'lib/libcrypto/rsa')
-rw-r--r-- | lib/libcrypto/rsa/rsa_ameth.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_eay.c | 16 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_lib.c | 12 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_oaep.c | 10 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_pmeth.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_pss.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_saos.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_sign.c | 8 |
8 files changed, 38 insertions, 38 deletions
diff --git a/lib/libcrypto/rsa/rsa_ameth.c b/lib/libcrypto/rsa/rsa_ameth.c index 5a2062f903a..fdd11835ad9 100644 --- a/lib/libcrypto/rsa/rsa_ameth.c +++ b/lib/libcrypto/rsa/rsa_ameth.c @@ -78,7 +78,7 @@ static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) V_ASN1_NULL, NULL, penc, penclen)) return 1; - OPENSSL_free(penc); + free(penc); return 0; } @@ -201,7 +201,7 @@ static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv) update_buflen(x->iqmp, &buf_len); } - m=(unsigned char *)OPENSSL_malloc(buf_len+10); + m=(unsigned char *)malloc(buf_len+10); if (m == NULL) { RSAerr(RSA_F_DO_RSA_PRINT,ERR_R_MALLOC_FAILURE); @@ -248,7 +248,7 @@ static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv) } ret=1; err: - if (m != NULL) OPENSSL_free(m); + if (m != NULL) free(m); return(ret); } diff --git a/lib/libcrypto/rsa/rsa_eay.c b/lib/libcrypto/rsa/rsa_eay.c index 88ee2cb557f..dcf0c16a8f6 100644 --- a/lib/libcrypto/rsa/rsa_eay.c +++ b/lib/libcrypto/rsa/rsa_eay.c @@ -185,7 +185,7 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from, f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num=BN_num_bytes(rsa->n); - buf = OPENSSL_malloc(num); + buf = malloc(num); if (!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,ERR_R_MALLOC_FAILURE); @@ -247,7 +247,7 @@ err: if (buf != NULL) { OPENSSL_cleanse(buf,num); - OPENSSL_free(buf); + free(buf); } return(r); } @@ -366,7 +366,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); - buf = OPENSSL_malloc(num); + buf = malloc(num); if(!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE); @@ -484,7 +484,7 @@ err: if (buf != NULL) { OPENSSL_cleanse(buf,num); - OPENSSL_free(buf); + free(buf); } return(r); } @@ -509,7 +509,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); - buf = OPENSSL_malloc(num); + buf = malloc(num); if(!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE); @@ -624,7 +624,7 @@ err: if (buf != NULL) { OPENSSL_cleanse(buf,num); - OPENSSL_free(buf); + free(buf); } return(r); } @@ -666,7 +666,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num=BN_num_bytes(rsa->n); - buf = OPENSSL_malloc(num); + buf = malloc(num); if(!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,ERR_R_MALLOC_FAILURE); @@ -729,7 +729,7 @@ err: if (buf != NULL) { OPENSSL_cleanse(buf,num); - OPENSSL_free(buf); + free(buf); } return(r); } diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index 9e3f7dafcda..e99a3627dc7 100644 --- a/lib/libcrypto/rsa/rsa_lib.c +++ b/lib/libcrypto/rsa/rsa_lib.c @@ -125,7 +125,7 @@ RSA *RSA_new_method(ENGINE *engine) { RSA *ret; - ret=(RSA *)OPENSSL_malloc(sizeof(RSA)); + ret=(RSA *)malloc(sizeof(RSA)); if (ret == NULL) { RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE); @@ -139,7 +139,7 @@ RSA *RSA_new_method(ENGINE *engine) if (!ENGINE_init(engine)) { RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB); - OPENSSL_free(ret); + free(ret); return NULL; } ret->engine = engine; @@ -154,7 +154,7 @@ RSA *RSA_new_method(ENGINE *engine) RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); - OPENSSL_free(ret); + free(ret); return NULL; } } @@ -184,7 +184,7 @@ RSA *RSA_new_method(ENGINE *engine) if (ret->engine) ENGINE_finish(ret->engine); #endif - OPENSSL_free(ret); + free(ret); return(NULL); } @@ -195,7 +195,7 @@ RSA *RSA_new_method(ENGINE *engine) ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); - OPENSSL_free(ret); + free(ret); ret=NULL; } return(ret); @@ -240,7 +240,7 @@ void RSA_free(RSA *r) if (r->blinding != NULL) BN_BLINDING_free(r->blinding); if (r->mt_blinding != NULL) BN_BLINDING_free(r->mt_blinding); if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data); - OPENSSL_free(r); + free(r); } int RSA_up_ref(RSA *r) diff --git a/lib/libcrypto/rsa/rsa_oaep.c b/lib/libcrypto/rsa/rsa_oaep.c index af4d24a56ef..a107e89b81c 100644 --- a/lib/libcrypto/rsa/rsa_oaep.c +++ b/lib/libcrypto/rsa/rsa_oaep.c @@ -70,7 +70,7 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, 20); #endif - dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH); + dbmask = malloc(emlen - SHA_DIGEST_LENGTH); if (dbmask == NULL) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); @@ -87,7 +87,7 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, for (i = 0; i < SHA_DIGEST_LENGTH; i++) seed[i] ^= seedmask[i]; - OPENSSL_free(dbmask); + free(dbmask); return 1; } @@ -121,7 +121,7 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, } dblen = num - SHA_DIGEST_LENGTH; - db = OPENSSL_malloc(dblen + num); + db = malloc(dblen + num); if (db == NULL) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); @@ -172,14 +172,14 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, memcpy(to, db + i, mlen); } } - OPENSSL_free(db); + free(db); return mlen; decoding_err: /* to avoid chosen ciphertext attacks, the error message should not reveal * which kind of decoding error happened */ RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR); - if (db != NULL) OPENSSL_free(db); + if (db != NULL) free(db); return -1; } diff --git a/lib/libcrypto/rsa/rsa_pmeth.c b/lib/libcrypto/rsa/rsa_pmeth.c index d706d35ff6b..adec632b3bf 100644 --- a/lib/libcrypto/rsa/rsa_pmeth.c +++ b/lib/libcrypto/rsa/rsa_pmeth.c @@ -93,7 +93,7 @@ typedef struct static int pkey_rsa_init(EVP_PKEY_CTX *ctx) { RSA_PKEY_CTX *rctx; - rctx = OPENSSL_malloc(sizeof(RSA_PKEY_CTX)); + rctx = malloc(sizeof(RSA_PKEY_CTX)); if (!rctx) return 0; rctx->nbits = 1024; @@ -135,7 +135,7 @@ static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk) { if (ctx->tbuf) return 1; - ctx->tbuf = OPENSSL_malloc(EVP_PKEY_size(pk->pkey)); + ctx->tbuf = malloc(EVP_PKEY_size(pk->pkey)); if (!ctx->tbuf) return 0; return 1; @@ -149,8 +149,8 @@ static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx) if (rctx->pub_exp) BN_free(rctx->pub_exp); if (rctx->tbuf) - OPENSSL_free(rctx->tbuf); - OPENSSL_free(rctx); + free(rctx->tbuf); + free(rctx); } } static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, diff --git a/lib/libcrypto/rsa/rsa_pss.c b/lib/libcrypto/rsa/rsa_pss.c index 5f9f533d0ce..75e8c185335 100644 --- a/lib/libcrypto/rsa/rsa_pss.c +++ b/lib/libcrypto/rsa/rsa_pss.c @@ -133,7 +133,7 @@ int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, } maskedDBLen = emLen - hLen - 1; H = EM + maskedDBLen; - DB = OPENSSL_malloc(maskedDBLen); + DB = malloc(maskedDBLen); if (!DB) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, ERR_R_MALLOC_FAILURE); @@ -177,7 +177,7 @@ int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, err: if (DB) - OPENSSL_free(DB); + free(DB); EVP_MD_CTX_cleanup(&ctx); return ret; @@ -239,7 +239,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, } if (sLen > 0) { - salt = OPENSSL_malloc(sLen); + salt = malloc(sLen); if (!salt) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1,ERR_R_MALLOC_FAILURE); @@ -289,7 +289,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, err: if (salt) - OPENSSL_free(salt); + free(salt); return ret; diff --git a/lib/libcrypto/rsa/rsa_saos.c b/lib/libcrypto/rsa/rsa_saos.c index f98e0a80a6c..ee5473a184b 100644 --- a/lib/libcrypto/rsa/rsa_saos.c +++ b/lib/libcrypto/rsa/rsa_saos.c @@ -82,7 +82,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type, RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); return(0); } - s=(unsigned char *)OPENSSL_malloc((unsigned int)j+1); + s=(unsigned char *)malloc((unsigned int)j+1); if (s == NULL) { RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE); @@ -97,7 +97,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type, *siglen=i; OPENSSL_cleanse(s,(unsigned int)j+1); - OPENSSL_free(s); + free(s); return(ret); } @@ -117,7 +117,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype, return(0); } - s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen); + s=(unsigned char *)malloc((unsigned int)siglen); if (s == NULL) { RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE); @@ -143,7 +143,7 @@ err: if (s != NULL) { OPENSSL_cleanse(s,(unsigned int)siglen); - OPENSSL_free(s); + free(s); } return(ret); } diff --git a/lib/libcrypto/rsa/rsa_sign.c b/lib/libcrypto/rsa/rsa_sign.c index fa3239ab30a..71d6bb3ce42 100644 --- a/lib/libcrypto/rsa/rsa_sign.c +++ b/lib/libcrypto/rsa/rsa_sign.c @@ -120,7 +120,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len, return(0); } if(type != NID_md5_sha1) { - tmps=(unsigned char *)OPENSSL_malloc((unsigned int)j+1); + tmps=(unsigned char *)malloc((unsigned int)j+1); if (tmps == NULL) { RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE); @@ -138,7 +138,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len, if(type != NID_md5_sha1) { OPENSSL_cleanse(tmps,(unsigned int)j+1); - OPENSSL_free(tmps); + free(tmps); } return(ret); } @@ -169,7 +169,7 @@ int int_rsa_verify(int dtype, const unsigned char *m, return 1; } - s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen); + s=(unsigned char *)malloc((unsigned int)siglen); if (s == NULL) { RSAerr(RSA_F_INT_RSA_VERIFY,ERR_R_MALLOC_FAILURE); @@ -281,7 +281,7 @@ err: if (s != NULL) { OPENSSL_cleanse(s,(unsigned int)siglen); - OPENSSL_free(s); + free(s); } return(ret); } |