if(a==NULL) return;
X509_ALGOR_free(a->keyfunc);
X509_ALGOR_free(a->encryption);
- Free ((char *)a);
+ OPENSSL_free (a);
}
int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
M_ASN1_INTEGER_free(a->iter);
M_ASN1_INTEGER_free(a->keylength);
X509_ALGOR_free(a->prf);
- Free ((char *)a);
+ OPENSSL_free (a);
}
/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
ASN1_OBJECT *obj;
alg_nid = EVP_CIPHER_type(cipher);
- obj = OBJ_nid2obj(alg_nid);
- if(!obj || !obj->data) {
+ if(alg_nid == NID_undef) {
ASN1err(ASN1_F_PKCS5_PBE2_SET,
ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
goto err;
}
+ obj = OBJ_nid2obj(alg_nid);
if(!(pbe2 = PBE2PARAM_new())) goto merr;
if(!(scheme->parameter = ASN1_TYPE_new())) goto merr;
/* Create random IV */
- RAND_bytes(iv, EVP_CIPHER_iv_length(cipher));
+ if (RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0)
+ goto err;
/* Dummy cipherinit to just setup the IV */
EVP_CipherInit(&ctx, cipher, NULL, iv, 0);
if(!(osalt = M_ASN1_OCTET_STRING_new())) goto merr;
if (!saltlen) saltlen = PKCS5_SALT_LEN;
- if (!(osalt->data = Malloc (saltlen))) goto merr;
+ if (!(osalt->data = OPENSSL_malloc (saltlen))) goto merr;
osalt->length = saltlen;
if (salt) memcpy (osalt->data, salt, saltlen);
- else RAND_bytes (osalt->data, saltlen);
+ else if (RAND_pseudo_bytes (osalt->data, saltlen) < 0) goto merr;
if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr;