Loading CHANGES +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,13 @@ Changes between 0.9.8k and 1.0 [xx XXX xxxx] *) Extensive audit of libcrypto with DEBUG_UNUSED. Fix many cases where return value is ignored. NB. The functions RAND_add(), RAND_seed(), BIO_set_cipher() and some obscure PEM functions were changed so they can now return an error. The RAND changes required a change to the RAND_METHOD structure. [Steve Henson] *) New macro __owur for "OpenSSL Warn Unused Result". This makes use of a gcc attribute to warn if the result of a function is ignored. This is enable if DEBUG_UNUSED is set. Add to several functions in evp.h Loading crypto/asn1/a_digest.c +4 −2 Original line number Diff line number Diff line Loading @@ -87,7 +87,8 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, p=str; i2d(data,&p); EVP_Digest(str, i, md, len, type, NULL); if (!EVP_Digest(str, i, md, len, type, NULL)) return 0; OPENSSL_free(str); return(1); } Loading @@ -104,7 +105,8 @@ int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, i=ASN1_item_i2d(asn,&str, it); if (!str) return(0); EVP_Digest(str, i, md, len, type, NULL); if (!EVP_Digest(str, i, md, len, type, NULL)) return 0; OPENSSL_free(str); return(1); } Loading crypto/asn1/a_sign.c +6 −6 Original line number Diff line number Diff line Loading @@ -184,9 +184,9 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2, p=buf_in; i2d(data,&p); EVP_SignInit_ex(&ctx,type, NULL); EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, if (!EVP_SignInit_ex(&ctx,type, NULL) || !EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl) || !EVP_SignFinal(&ctx,(unsigned char *)buf_out, (unsigned int *)&outl,pkey)) { outl=0; Loading Loading @@ -270,9 +270,9 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, goto err; } EVP_SignInit_ex(&ctx,type, NULL); EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, if (!EVP_SignInit_ex(&ctx,type, NULL) || !EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl) || !EVP_SignFinal(&ctx,(unsigned char *)buf_out, (unsigned int *)&outl,pkey)) { outl=0; Loading crypto/asn1/a_verify.c +13 −3 Original line number Diff line number Diff line Loading @@ -101,8 +101,13 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature, p=buf_in; i2d(data,&p); EVP_VerifyInit_ex(&ctx,type, NULL); EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_VerifyInit_ex(&ctx,type, NULL) || !EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl)) { ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB); ret=0; goto err; } OPENSSL_cleanse(buf_in,(unsigned int)inl); OPENSSL_free(buf_in); Loading Loading @@ -173,7 +178,12 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signat goto err; } EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl)) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ERR_R_EVP_LIB); ret=0; goto err; } OPENSSL_cleanse(buf_in,(unsigned int)inl); OPENSSL_free(buf_in); Loading crypto/asn1/n_pkey.c +24 −14 Original line number Diff line number Diff line Loading @@ -129,6 +129,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, unsigned char buf[256],*zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); if (a == NULL) return(0); Loading Loading @@ -206,24 +207,28 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, i = strlen((char *)buf); /* If the key is used for SGC the algorithm is modified a little. */ if(sgckey) { EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL); if (!EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL)) goto err; memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); if (!EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL)) goto err; OPENSSL_cleanse(buf,256); /* Encrypt private key in place */ zz = enckey->enckey->digest->data; EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL); EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen); EVP_EncryptFinal_ex(&ctx,zz + i,&j); EVP_CIPHER_CTX_cleanup(&ctx); if (!EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL)) goto err; if (!EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen)) goto err; if (!EVP_EncryptFinal_ex(&ctx,zz + i,&j)) goto err; ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp); err: EVP_CIPHER_CTX_cleanup(&ctx); NETSCAPE_ENCRYPTED_PKEY_free(enckey); NETSCAPE_PKEY_free(pkey); return(ret); Loading Loading @@ -289,6 +294,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, const unsigned char *zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); i=cb((char *)buf,256,"Enter Private Key password:",0); if (i != 0) Loading @@ -299,19 +305,22 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, i = strlen((char *)buf); if(sgckey){ EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL); if (!EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL)) goto err; memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); if (!EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL)) goto err; OPENSSL_cleanse(buf,256); EVP_CIPHER_CTX_init(&ctx); EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL); EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length); EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j); EVP_CIPHER_CTX_cleanup(&ctx); if (!EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL)) goto err; if (!EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length)) goto err; if (!EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j)) goto err; os->length=i+j; zz=os->data; Loading @@ -329,6 +338,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, goto err; } err: EVP_CIPHER_CTX_cleanup(&ctx); NETSCAPE_PKEY_free(pkey); return(ret); } Loading Loading
CHANGES +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,13 @@ Changes between 0.9.8k and 1.0 [xx XXX xxxx] *) Extensive audit of libcrypto with DEBUG_UNUSED. Fix many cases where return value is ignored. NB. The functions RAND_add(), RAND_seed(), BIO_set_cipher() and some obscure PEM functions were changed so they can now return an error. The RAND changes required a change to the RAND_METHOD structure. [Steve Henson] *) New macro __owur for "OpenSSL Warn Unused Result". This makes use of a gcc attribute to warn if the result of a function is ignored. This is enable if DEBUG_UNUSED is set. Add to several functions in evp.h Loading
crypto/asn1/a_digest.c +4 −2 Original line number Diff line number Diff line Loading @@ -87,7 +87,8 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, p=str; i2d(data,&p); EVP_Digest(str, i, md, len, type, NULL); if (!EVP_Digest(str, i, md, len, type, NULL)) return 0; OPENSSL_free(str); return(1); } Loading @@ -104,7 +105,8 @@ int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, i=ASN1_item_i2d(asn,&str, it); if (!str) return(0); EVP_Digest(str, i, md, len, type, NULL); if (!EVP_Digest(str, i, md, len, type, NULL)) return 0; OPENSSL_free(str); return(1); } Loading
crypto/asn1/a_sign.c +6 −6 Original line number Diff line number Diff line Loading @@ -184,9 +184,9 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2, p=buf_in; i2d(data,&p); EVP_SignInit_ex(&ctx,type, NULL); EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, if (!EVP_SignInit_ex(&ctx,type, NULL) || !EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl) || !EVP_SignFinal(&ctx,(unsigned char *)buf_out, (unsigned int *)&outl,pkey)) { outl=0; Loading Loading @@ -270,9 +270,9 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, goto err; } EVP_SignInit_ex(&ctx,type, NULL); EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, if (!EVP_SignInit_ex(&ctx,type, NULL) || !EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl) || !EVP_SignFinal(&ctx,(unsigned char *)buf_out, (unsigned int *)&outl,pkey)) { outl=0; Loading
crypto/asn1/a_verify.c +13 −3 Original line number Diff line number Diff line Loading @@ -101,8 +101,13 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature, p=buf_in; i2d(data,&p); EVP_VerifyInit_ex(&ctx,type, NULL); EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_VerifyInit_ex(&ctx,type, NULL) || !EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl)) { ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB); ret=0; goto err; } OPENSSL_cleanse(buf_in,(unsigned int)inl); OPENSSL_free(buf_in); Loading Loading @@ -173,7 +178,12 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signat goto err; } EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); if (!EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl)) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY,ERR_R_EVP_LIB); ret=0; goto err; } OPENSSL_cleanse(buf_in,(unsigned int)inl); OPENSSL_free(buf_in); Loading
crypto/asn1/n_pkey.c +24 −14 Original line number Diff line number Diff line Loading @@ -129,6 +129,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, unsigned char buf[256],*zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); if (a == NULL) return(0); Loading Loading @@ -206,24 +207,28 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, i = strlen((char *)buf); /* If the key is used for SGC the algorithm is modified a little. */ if(sgckey) { EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL); if (!EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL)) goto err; memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); if (!EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL)) goto err; OPENSSL_cleanse(buf,256); /* Encrypt private key in place */ zz = enckey->enckey->digest->data; EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL); EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen); EVP_EncryptFinal_ex(&ctx,zz + i,&j); EVP_CIPHER_CTX_cleanup(&ctx); if (!EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL)) goto err; if (!EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen)) goto err; if (!EVP_EncryptFinal_ex(&ctx,zz + i,&j)) goto err; ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp); err: EVP_CIPHER_CTX_cleanup(&ctx); NETSCAPE_ENCRYPTED_PKEY_free(enckey); NETSCAPE_PKEY_free(pkey); return(ret); Loading Loading @@ -289,6 +294,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, const unsigned char *zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); i=cb((char *)buf,256,"Enter Private Key password:",0); if (i != 0) Loading @@ -299,19 +305,22 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, i = strlen((char *)buf); if(sgckey){ EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL); if (!EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL)) goto err; memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); if (!EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL)) goto err; OPENSSL_cleanse(buf,256); EVP_CIPHER_CTX_init(&ctx); EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL); EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length); EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j); EVP_CIPHER_CTX_cleanup(&ctx); if (!EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL)) goto err; if (!EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length)) goto err; if (!EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j)) goto err; os->length=i+j; zz=os->data; Loading @@ -329,6 +338,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, goto err; } err: EVP_CIPHER_CTX_cleanup(&ctx); NETSCAPE_PKEY_free(pkey); return(ret); } Loading