Changes from 0.9.7.
This commit is contained in:
parent
ffe8370a18
commit
84bf37057c
3
CHANGES
3
CHANGES
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
Changes between 0.9.7c and 0.9.7d [xx XXX XXXX]
|
Changes between 0.9.7c and 0.9.7d [xx XXX XXXX]
|
||||||
|
|
||||||
*)
|
*) Use the correct content when signing type "other".
|
||||||
|
[Steve Henson]
|
||||||
|
|
||||||
Changes between 0.9.7b and 0.9.7c [30 Sep 2003]
|
Changes between 0.9.7b and 0.9.7c [30 Sep 2003]
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
|||||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||||
AES_decrypt(tmp, tmp, key);
|
AES_decrypt(tmp, tmp, key);
|
||||||
for(n=0; n < len; ++n)
|
for(n=0; n < len; ++n)
|
||||||
out[n] ^= ivec[n];
|
out[n] = tmp[n] ^ ivec[n];
|
||||||
memcpy(ivec, tmp, AES_BLOCK_SIZE);
|
memcpy(ivec, tmp, AES_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
crypto/mem.c
10
crypto/mem.c
@ -352,11 +352,15 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
|
|||||||
realloc_debug_func(str, NULL, num, file, line, 0);
|
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||||
ret=malloc_ex_func(num,file,line);
|
ret=malloc_ex_func(num,file,line);
|
||||||
if(ret)
|
if(ret)
|
||||||
|
{
|
||||||
memcpy(ret,str,old_len);
|
memcpy(ret,str,old_len);
|
||||||
OPENSSL_cleanse(str,old_len);
|
OPENSSL_cleanse(str,old_len);
|
||||||
free_func(str);
|
free_func(str);
|
||||||
|
}
|
||||||
#ifdef LEVITTE_DEBUG_MEM
|
#ifdef LEVITTE_DEBUG_MEM
|
||||||
fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num);
|
fprintf(stderr,
|
||||||
|
"LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n",
|
||||||
|
str, ret, num);
|
||||||
#endif
|
#endif
|
||||||
if (realloc_debug_func != NULL)
|
if (realloc_debug_func != NULL)
|
||||||
realloc_debug_func(str, ret, num, file, line, 1);
|
realloc_debug_func(str, ret, num, file, line, 1);
|
||||||
|
@ -91,17 +91,19 @@ static int PKCS7_type_is_other(PKCS7* p7)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PKCS7_type_is_octet_string(PKCS7* p7)
|
static ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7)
|
||||||
{
|
{
|
||||||
if ( 0==PKCS7_type_is_other(p7) )
|
if ( PKCS7_type_is_data(p7))
|
||||||
return 0;
|
return p7->d.data;
|
||||||
|
if ( PKCS7_type_is_other(p7) && p7->d.other
|
||||||
return (V_ASN1_OCTET_STRING==p7->d.other->type) ? 1 : 0;
|
&& (p7->d.other->type == V_ASN1_OCTET_STRING))
|
||||||
|
return p7->d.other->value.octet_string;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
|
BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
|
||||||
{
|
{
|
||||||
int i,j;
|
int i;
|
||||||
BIO *out=NULL,*btmp=NULL;
|
BIO *out=NULL,*btmp=NULL;
|
||||||
X509_ALGOR *xa;
|
X509_ALGOR *xa;
|
||||||
const EVP_MD *evp_md;
|
const EVP_MD *evp_md;
|
||||||
@ -159,8 +161,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
j=OBJ_obj2nid(xa->algorithm);
|
evp_md=EVP_get_digestbyobj(xa->algorithm);
|
||||||
evp_md=EVP_get_digestbyname(OBJ_nid2sn(j));
|
|
||||||
if (evp_md == NULL)
|
if (evp_md == NULL)
|
||||||
{
|
{
|
||||||
PKCS7err(PKCS7_F_PKCS7_DATAINIT,PKCS7_R_UNKNOWN_DIGEST_TYPE);
|
PKCS7err(PKCS7_F_PKCS7_DATAINIT,PKCS7_R_UNKNOWN_DIGEST_TYPE);
|
||||||
@ -250,29 +251,22 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
|
|||||||
btmp=NULL;
|
btmp=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bio == NULL) {
|
if (bio == NULL)
|
||||||
|
{
|
||||||
if (PKCS7_is_detached(p7))
|
if (PKCS7_is_detached(p7))
|
||||||
bio=BIO_new(BIO_s_null());
|
bio=BIO_new(BIO_s_null());
|
||||||
else {
|
else
|
||||||
if (PKCS7_type_is_signed(p7) ) {
|
{
|
||||||
if ( PKCS7_type_is_data(p7->d.sign->contents)) {
|
ASN1_OCTET_STRING *os;
|
||||||
ASN1_OCTET_STRING *os;
|
os = PKCS7_get_octet_string(p7->d.sign->contents);
|
||||||
os=p7->d.sign->contents->d.data;
|
if (os && os->length > 0)
|
||||||
if (os->length > 0)
|
bio = BIO_new_mem_buf(os->data, os->length);
|
||||||
bio = BIO_new_mem_buf(os->data, os->length);
|
if(bio == NULL)
|
||||||
}
|
{
|
||||||
else if ( PKCS7_type_is_octet_string(p7->d.sign->contents) ) {
|
|
||||||
ASN1_OCTET_STRING *os;
|
|
||||||
os=p7->d.sign->contents->d.other->value.octet_string;
|
|
||||||
if (os->length > 0)
|
|
||||||
bio = BIO_new_mem_buf(os->data, os->length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(bio == NULL) {
|
|
||||||
bio=BIO_new(BIO_s_mem());
|
bio=BIO_new(BIO_s_mem());
|
||||||
BIO_set_mem_eof_return(bio,0);
|
BIO_set_mem_eof_return(bio,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BIO_push(out,bio);
|
BIO_push(out,bio);
|
||||||
bio=NULL;
|
bio=NULL;
|
||||||
@ -311,7 +305,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case NID_pkcs7_signed:
|
case NID_pkcs7_signed:
|
||||||
data_body=p7->d.sign->contents->d.data;
|
data_body=PKCS7_get_octet_string(p7->d.sign->contents);
|
||||||
md_sk=p7->d.sign->md_algs;
|
md_sk=p7->d.sign->md_algs;
|
||||||
break;
|
break;
|
||||||
case NID_pkcs7_signedAndEnveloped:
|
case NID_pkcs7_signedAndEnveloped:
|
||||||
@ -319,7 +313,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
|||||||
md_sk=p7->d.signed_and_enveloped->md_algs;
|
md_sk=p7->d.signed_and_enveloped->md_algs;
|
||||||
data_body=p7->d.signed_and_enveloped->enc_data->enc_data;
|
data_body=p7->d.signed_and_enveloped->enc_data->enc_data;
|
||||||
enc_alg=p7->d.signed_and_enveloped->enc_data->algorithm;
|
enc_alg=p7->d.signed_and_enveloped->enc_data->algorithm;
|
||||||
evp_cipher=EVP_get_cipherbyname(OBJ_nid2sn(OBJ_obj2nid(enc_alg->algorithm)));
|
evp_cipher=EVP_get_cipherbyobj(enc_alg->algorithm);
|
||||||
if (evp_cipher == NULL)
|
if (evp_cipher == NULL)
|
||||||
{
|
{
|
||||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
|
PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
|
||||||
@ -331,7 +325,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
|||||||
rsk=p7->d.enveloped->recipientinfo;
|
rsk=p7->d.enveloped->recipientinfo;
|
||||||
enc_alg=p7->d.enveloped->enc_data->algorithm;
|
enc_alg=p7->d.enveloped->enc_data->algorithm;
|
||||||
data_body=p7->d.enveloped->enc_data->enc_data;
|
data_body=p7->d.enveloped->enc_data->enc_data;
|
||||||
evp_cipher=EVP_get_cipherbyname(OBJ_nid2sn(OBJ_obj2nid(enc_alg->algorithm)));
|
evp_cipher=EVP_get_cipherbyobj(enc_alg->algorithm);
|
||||||
if (evp_cipher == NULL)
|
if (evp_cipher == NULL)
|
||||||
{
|
{
|
||||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
|
PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
|
||||||
@ -357,7 +351,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
|||||||
}
|
}
|
||||||
|
|
||||||
j=OBJ_obj2nid(xa->algorithm);
|
j=OBJ_obj2nid(xa->algorithm);
|
||||||
evp_md=EVP_get_digestbyname(OBJ_nid2sn(j));
|
evp_md=EVP_get_digestbynid(j);
|
||||||
if (evp_md == NULL)
|
if (evp_md == NULL)
|
||||||
{
|
{
|
||||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNKNOWN_DIGEST_TYPE);
|
PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNKNOWN_DIGEST_TYPE);
|
||||||
@ -531,9 +525,9 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
|
|||||||
break;
|
break;
|
||||||
case NID_pkcs7_signed:
|
case NID_pkcs7_signed:
|
||||||
si_sk=p7->d.sign->signer_info;
|
si_sk=p7->d.sign->signer_info;
|
||||||
os=p7->d.sign->contents->d.data;
|
os=PKCS7_get_octet_string(p7->d.sign->contents);
|
||||||
/* If detached data then the content is excluded */
|
/* If detached data then the content is excluded */
|
||||||
if(p7->detached) {
|
if(PKCS7_type_is_data(p7->d.sign->contents) && p7->detached) {
|
||||||
M_ASN1_OCTET_STRING_free(os);
|
M_ASN1_OCTET_STRING_free(os);
|
||||||
p7->d.sign->contents->d.data = NULL;
|
p7->d.sign->contents->d.data = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user