diff options
| author | miod <> | 2014-04-13 15:25:35 +0000 |
|---|---|---|
| committer | miod <> | 2014-04-13 15:25:35 +0000 |
| commit | d2b3c9742a7df4ab87384039c99682d1944f66d7 (patch) | |
| tree | 74f4ff344980894c7c9ceeab9b81176ac7572566 /src/lib/libcrypto/pem/pem_lib.c | |
| parent | dbf195d7fd4efbe4ee578f1dc5c72e7f3deadf18 (diff) | |
| download | openbsd-d2b3c9742a7df4ab87384039c99682d1944f66d7.tar.gz openbsd-d2b3c9742a7df4ab87384039c99682d1944f66d7.tar.bz2 openbsd-d2b3c9742a7df4ab87384039c99682d1944f66d7.zip | |
Merge conflicts; remove MacOS, Netware, OS/2, VMS and Windows build machinery.
Diffstat (limited to 'src/lib/libcrypto/pem/pem_lib.c')
| -rw-r--r-- | src/lib/libcrypto/pem/pem_lib.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c index cfc89a9921..5a421fc4b6 100644 --- a/src/lib/libcrypto/pem/pem_lib.c +++ b/src/lib/libcrypto/pem/pem_lib.c | |||
| @@ -394,7 +394,8 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, | |||
| 394 | goto err; | 394 | goto err; |
| 395 | /* The 'iv' is used as the iv and as a salt. It is | 395 | /* The 'iv' is used as the iv and as a salt. It is |
| 396 | * NOT taken from the BytesToKey function */ | 396 | * NOT taken from the BytesToKey function */ |
| 397 | EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL); | 397 | if (!EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL)) |
| 398 | goto err; | ||
| 398 | 399 | ||
| 399 | if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf,PEM_BUFSIZE); | 400 | if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf,PEM_BUFSIZE); |
| 400 | 401 | ||
| @@ -406,12 +407,15 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, | |||
| 406 | /* k=strlen(buf); */ | 407 | /* k=strlen(buf); */ |
| 407 | 408 | ||
| 408 | EVP_CIPHER_CTX_init(&ctx); | 409 | EVP_CIPHER_CTX_init(&ctx); |
| 409 | EVP_EncryptInit_ex(&ctx,enc,NULL,key,iv); | 410 | ret = 1; |
| 410 | EVP_EncryptUpdate(&ctx,data,&j,data,i); | 411 | if (!EVP_EncryptInit_ex(&ctx,enc,NULL,key,iv) |
| 411 | EVP_EncryptFinal_ex(&ctx,&(data[j]),&i); | 412 | || !EVP_EncryptUpdate(&ctx,data,&j,data,i) |
| 413 | || !EVP_EncryptFinal_ex(&ctx,&(data[j]),&i)) | ||
| 414 | ret = 0; | ||
| 412 | EVP_CIPHER_CTX_cleanup(&ctx); | 415 | EVP_CIPHER_CTX_cleanup(&ctx); |
| 416 | if (ret == 0) | ||
| 417 | goto err; | ||
| 413 | i+=j; | 418 | i+=j; |
| 414 | ret=1; | ||
| 415 | } | 419 | } |
| 416 | else | 420 | else |
| 417 | { | 421 | { |
| @@ -459,14 +463,17 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen, | |||
| 459 | ebcdic2ascii(buf, buf, klen); | 463 | ebcdic2ascii(buf, buf, klen); |
| 460 | #endif | 464 | #endif |
| 461 | 465 | ||
| 462 | EVP_BytesToKey(cipher->cipher,EVP_md5(),&(cipher->iv[0]), | 466 | if (!EVP_BytesToKey(cipher->cipher,EVP_md5(),&(cipher->iv[0]), |
| 463 | (unsigned char *)buf,klen,1,key,NULL); | 467 | (unsigned char *)buf,klen,1,key,NULL)) |
| 468 | return 0; | ||
| 464 | 469 | ||
| 465 | j=(int)len; | 470 | j=(int)len; |
| 466 | EVP_CIPHER_CTX_init(&ctx); | 471 | EVP_CIPHER_CTX_init(&ctx); |
| 467 | EVP_DecryptInit_ex(&ctx,cipher->cipher,NULL, key,&(cipher->iv[0])); | 472 | o = EVP_DecryptInit_ex(&ctx,cipher->cipher,NULL, key,&(cipher->iv[0])); |
| 468 | EVP_DecryptUpdate(&ctx,data,&i,data,j); | 473 | if (o) |
| 469 | o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j); | 474 | o = EVP_DecryptUpdate(&ctx,data,&i,data,j); |
| 475 | if (o) | ||
| 476 | o = EVP_DecryptFinal_ex(&ctx,&(data[i]),&j); | ||
| 470 | EVP_CIPHER_CTX_cleanup(&ctx); | 477 | EVP_CIPHER_CTX_cleanup(&ctx); |
| 471 | OPENSSL_cleanse((char *)buf,sizeof(buf)); | 478 | OPENSSL_cleanse((char *)buf,sizeof(buf)); |
| 472 | OPENSSL_cleanse((char *)key,sizeof(key)); | 479 | OPENSSL_cleanse((char *)key,sizeof(key)); |
