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/evp | |
| 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/evp')
| -rw-r--r-- | src/lib/libcrypto/evp/Makefile | 51 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/bio_b64.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/digest.c | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/e_aes.c | 21 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/e_aes_cbc_hmac_sha1.c | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/e_des3.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp.h | 14 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp_err.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_dss.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_dss1.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_sha1.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/p5_crpt2.c | 40 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/p_sign.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/p_verify.c | 2 |
14 files changed, 108 insertions, 55 deletions
diff --git a/src/lib/libcrypto/evp/Makefile b/src/lib/libcrypto/evp/Makefile index 0fe1b96bff..0447b442bc 100644 --- a/src/lib/libcrypto/evp/Makefile +++ b/src/lib/libcrypto/evp/Makefile | |||
| @@ -67,7 +67,7 @@ files: | |||
| 67 | links: | 67 | links: |
| 68 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | 68 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) |
| 69 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | 69 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) |
| 70 | cp $(TESTDATA) ../../test | 70 | @[ -f $(TESTDATA) ] && cp $(TESTDATA) ../../test && echo "$(TESTDATA) -> ../../test/$(TESTDATA)" |
| 71 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | 71 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) |
| 72 | 72 | ||
| 73 | install: | 73 | install: |
| @@ -356,6 +356,20 @@ evp_acnf.o: ../../include/openssl/opensslconf.h | |||
| 356 | evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 356 | evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 357 | evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 357 | evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
| 358 | evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c | 358 | evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c |
| 359 | evp_cnf.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 360 | evp_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 361 | evp_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
| 362 | evp_cnf.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 363 | evp_cnf.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | ||
| 364 | evp_cnf.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h | ||
| 365 | evp_cnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 366 | evp_cnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 367 | evp_cnf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 368 | evp_cnf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 369 | evp_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 370 | evp_cnf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 371 | evp_cnf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 372 | evp_cnf.o: ../../include/openssl/x509v3.h ../cryptlib.h evp_cnf.c | ||
| 359 | evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h | 373 | evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h |
| 360 | evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 374 | evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 361 | evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 375 | evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| @@ -437,28 +451,22 @@ evp_pkey.o: ../asn1/asn1_locl.h ../cryptlib.h evp_pkey.c | |||
| 437 | m_dss.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | 451 | m_dss.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 438 | m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 452 | m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 439 | m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 453 | m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 440 | m_dss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 454 | m_dss.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 441 | m_dss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h | 455 | m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 442 | m_dss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | 456 | m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 443 | m_dss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 457 | m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 444 | m_dss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 445 | m_dss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 446 | m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 458 | m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 447 | m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 459 | m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 448 | m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 449 | m_dss.o: ../cryptlib.h m_dss.c | 460 | m_dss.o: ../cryptlib.h m_dss.c |
| 450 | m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | 461 | m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 451 | m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 462 | m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 452 | m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 463 | m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
| 453 | m_dss1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 464 | m_dss1.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 454 | m_dss1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h | 465 | m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 455 | m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | 466 | m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 456 | m_dss1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 467 | m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 457 | m_dss1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 458 | m_dss1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 459 | m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 468 | m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 460 | m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 469 | m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 461 | m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 462 | m_dss1.o: ../cryptlib.h m_dss1.c | 470 | m_dss1.o: ../cryptlib.h m_dss1.c |
| 463 | m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h | 471 | m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h |
| 464 | m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 472 | m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| @@ -563,16 +571,13 @@ m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | |||
| 563 | m_sha.o: ../cryptlib.h evp_locl.h m_sha.c | 571 | m_sha.o: ../cryptlib.h evp_locl.h m_sha.c |
| 564 | m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h | 572 | m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 565 | m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 573 | m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
| 566 | m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h | 574 | m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 567 | m_sha1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h | 575 | m_sha1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 568 | m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 576 | m_sha1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 569 | m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 577 | m_sha1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 570 | m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 578 | m_sha1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rsa.h |
| 571 | m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 572 | m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h | ||
| 573 | m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 579 | m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 574 | m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 580 | m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 575 | m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 576 | m_sha1.o: ../cryptlib.h m_sha1.c | 581 | m_sha1.o: ../cryptlib.h m_sha1.c |
| 577 | m_sigver.o: ../../e_os.h ../../include/openssl/asn1.h | 582 | m_sigver.o: ../../e_os.h ../../include/openssl/asn1.h |
| 578 | m_sigver.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 583 | m_sigver.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c index 72a2a67277..ac6d441aad 100644 --- a/src/lib/libcrypto/evp/bio_b64.c +++ b/src/lib/libcrypto/evp/bio_b64.c | |||
| @@ -264,7 +264,7 @@ static int b64_read(BIO *b, char *out, int outl) | |||
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | /* we fell off the end without starting */ | 266 | /* we fell off the end without starting */ |
| 267 | if (j == i) | 267 | if ((j == i) && (num == 0)) |
| 268 | { | 268 | { |
| 269 | /* Is this is one long chunk?, if so, keep on | 269 | /* Is this is one long chunk?, if so, keep on |
| 270 | * reading until a new line. */ | 270 | * reading until a new line. */ |
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index 467e6b5ae9..d14e8e48d5 100644 --- a/src/lib/libcrypto/evp/digest.c +++ b/src/lib/libcrypto/evp/digest.c | |||
| @@ -267,6 +267,7 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) | |||
| 267 | return FIPS_digestfinal(ctx, md, size); | 267 | return FIPS_digestfinal(ctx, md, size); |
| 268 | #else | 268 | #else |
| 269 | int ret; | 269 | int ret; |
| 270 | |||
| 270 | OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); | 271 | OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); |
| 271 | ret=ctx->digest->final(ctx,md); | 272 | ret=ctx->digest->final(ctx,md); |
| 272 | if (size != NULL) | 273 | if (size != NULL) |
| @@ -365,8 +366,11 @@ int EVP_Digest(const void *data, size_t count, | |||
| 365 | 366 | ||
| 366 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) | 367 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) |
| 367 | { | 368 | { |
| 368 | EVP_MD_CTX_cleanup(ctx); | 369 | if (ctx) |
| 369 | OPENSSL_free(ctx); | 370 | { |
| 371 | EVP_MD_CTX_cleanup(ctx); | ||
| 372 | OPENSSL_free(ctx); | ||
| 373 | } | ||
| 370 | } | 374 | } |
| 371 | 375 | ||
| 372 | /* This call frees resources associated with the context */ | 376 | /* This call frees resources associated with the context */ |
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c index 1e4af0cb75..c7869b69ef 100644 --- a/src/lib/libcrypto/evp/e_aes.c +++ b/src/lib/libcrypto/evp/e_aes.c | |||
| @@ -842,7 +842,10 @@ static int aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | |||
| 842 | gctx->ctr = NULL; | 842 | gctx->ctr = NULL; |
| 843 | break; | 843 | break; |
| 844 | } | 844 | } |
| 845 | else | ||
| 845 | #endif | 846 | #endif |
| 847 | (void)0; /* terminate potentially open 'else' */ | ||
| 848 | |||
| 846 | AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks); | 849 | AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks); |
| 847 | CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f)AES_encrypt); | 850 | CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f)AES_encrypt); |
| 848 | #ifdef AES_CTR_ASM | 851 | #ifdef AES_CTR_ASM |
| @@ -969,8 +972,6 @@ static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 969 | 972 | ||
| 970 | if (!gctx->iv_set) | 973 | if (!gctx->iv_set) |
| 971 | return -1; | 974 | return -1; |
| 972 | if (!ctx->encrypt && gctx->taglen < 0) | ||
| 973 | return -1; | ||
| 974 | if (in) | 975 | if (in) |
| 975 | { | 976 | { |
| 976 | if (out == NULL) | 977 | if (out == NULL) |
| @@ -1012,6 +1013,8 @@ static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 1012 | { | 1013 | { |
| 1013 | if (!ctx->encrypt) | 1014 | if (!ctx->encrypt) |
| 1014 | { | 1015 | { |
| 1016 | if (gctx->taglen < 0) | ||
| 1017 | return -1; | ||
| 1015 | if (CRYPTO_gcm128_finish(&gctx->gcm, | 1018 | if (CRYPTO_gcm128_finish(&gctx->gcm, |
| 1016 | ctx->buf, gctx->taglen) != 0) | 1019 | ctx->buf, gctx->taglen) != 0) |
| 1017 | return -1; | 1020 | return -1; |
| @@ -1083,14 +1086,17 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | |||
| 1083 | xctx->xts.block1 = (block128_f)vpaes_decrypt; | 1086 | xctx->xts.block1 = (block128_f)vpaes_decrypt; |
| 1084 | } | 1087 | } |
| 1085 | 1088 | ||
| 1086 | vpaes_set_encrypt_key(key + ctx->key_len/2, | 1089 | vpaes_set_encrypt_key(key + ctx->key_len/2, |
| 1087 | ctx->key_len * 4, &xctx->ks2); | 1090 | ctx->key_len * 4, &xctx->ks2); |
| 1088 | xctx->xts.block2 = (block128_f)vpaes_encrypt; | 1091 | xctx->xts.block2 = (block128_f)vpaes_encrypt; |
| 1089 | 1092 | ||
| 1090 | xctx->xts.key1 = &xctx->ks1; | 1093 | xctx->xts.key1 = &xctx->ks1; |
| 1091 | break; | 1094 | break; |
| 1092 | } | 1095 | } |
| 1096 | else | ||
| 1093 | #endif | 1097 | #endif |
| 1098 | (void)0; /* terminate potentially open 'else' */ | ||
| 1099 | |||
| 1094 | if (enc) | 1100 | if (enc) |
| 1095 | { | 1101 | { |
| 1096 | AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1); | 1102 | AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1); |
| @@ -1217,6 +1223,7 @@ static int aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | |||
| 1217 | vpaes_set_encrypt_key(key, ctx->key_len*8, &cctx->ks); | 1223 | vpaes_set_encrypt_key(key, ctx->key_len*8, &cctx->ks); |
| 1218 | CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, | 1224 | CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, |
| 1219 | &cctx->ks, (block128_f)vpaes_encrypt); | 1225 | &cctx->ks, (block128_f)vpaes_encrypt); |
| 1226 | cctx->str = NULL; | ||
| 1220 | cctx->key_set = 1; | 1227 | cctx->key_set = 1; |
| 1221 | break; | 1228 | break; |
| 1222 | } | 1229 | } |
diff --git a/src/lib/libcrypto/evp/e_aes_cbc_hmac_sha1.c b/src/lib/libcrypto/evp/e_aes_cbc_hmac_sha1.c index 483e04b605..fb2c884a78 100644 --- a/src/lib/libcrypto/evp/e_aes_cbc_hmac_sha1.c +++ b/src/lib/libcrypto/evp/e_aes_cbc_hmac_sha1.c | |||
| @@ -328,10 +328,11 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 328 | 328 | ||
| 329 | if (res!=SHA_CBLOCK) continue; | 329 | if (res!=SHA_CBLOCK) continue; |
| 330 | 330 | ||
| 331 | mask = 0-((inp_len+8-j)>>(sizeof(j)*8-1)); | 331 | /* j is not incremented yet */ |
| 332 | mask = 0-((inp_len+7-j)>>(sizeof(j)*8-1)); | ||
| 332 | data->u[SHA_LBLOCK-1] |= bitlen&mask; | 333 | data->u[SHA_LBLOCK-1] |= bitlen&mask; |
| 333 | sha1_block_data_order(&key->md,data,1); | 334 | sha1_block_data_order(&key->md,data,1); |
| 334 | mask &= 0-((j-inp_len-73)>>(sizeof(j)*8-1)); | 335 | mask &= 0-((j-inp_len-72)>>(sizeof(j)*8-1)); |
| 335 | pmac->u[0] |= key->md.h0 & mask; | 336 | pmac->u[0] |= key->md.h0 & mask; |
| 336 | pmac->u[1] |= key->md.h1 & mask; | 337 | pmac->u[1] |= key->md.h1 & mask; |
| 337 | pmac->u[2] |= key->md.h2 & mask; | 338 | pmac->u[2] |= key->md.h2 & mask; |
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c index 1e69972662..8d7b7de292 100644 --- a/src/lib/libcrypto/evp/e_des3.c +++ b/src/lib/libcrypto/evp/e_des3.c | |||
| @@ -101,7 +101,7 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 101 | static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 101 | static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 102 | const unsigned char *in, size_t inl) | 102 | const unsigned char *in, size_t inl) |
| 103 | { | 103 | { |
| 104 | if (inl>=EVP_MAXCHUNK) | 104 | while (inl>=EVP_MAXCHUNK) |
| 105 | { | 105 | { |
| 106 | DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, | 106 | DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, |
| 107 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 107 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |
| @@ -132,7 +132,7 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 132 | printf("\n"); | 132 | printf("\n"); |
| 133 | } | 133 | } |
| 134 | #endif /* KSSL_DEBUG */ | 134 | #endif /* KSSL_DEBUG */ |
| 135 | if (inl>=EVP_MAXCHUNK) | 135 | while (inl>=EVP_MAXCHUNK) |
| 136 | { | 136 | { |
| 137 | DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, | 137 | DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, |
| 138 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 138 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |
| @@ -151,7 +151,7 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 151 | static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 151 | static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 152 | const unsigned char *in, size_t inl) | 152 | const unsigned char *in, size_t inl) |
| 153 | { | 153 | { |
| 154 | if (inl>=EVP_MAXCHUNK) | 154 | while (inl>=EVP_MAXCHUNK) |
| 155 | { | 155 | { |
| 156 | DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, | 156 | DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, |
| 157 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | 157 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, |
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index 3b1fa87576..faeb3c24e6 100644 --- a/src/lib/libcrypto/evp/evp.h +++ b/src/lib/libcrypto/evp/evp.h | |||
| @@ -788,8 +788,8 @@ const EVP_CIPHER *EVP_aes_128_cfb128(void); | |||
| 788 | # define EVP_aes_128_cfb EVP_aes_128_cfb128 | 788 | # define EVP_aes_128_cfb EVP_aes_128_cfb128 |
| 789 | const EVP_CIPHER *EVP_aes_128_ofb(void); | 789 | const EVP_CIPHER *EVP_aes_128_ofb(void); |
| 790 | const EVP_CIPHER *EVP_aes_128_ctr(void); | 790 | const EVP_CIPHER *EVP_aes_128_ctr(void); |
| 791 | const EVP_CIPHER *EVP_aes_128_gcm(void); | ||
| 792 | const EVP_CIPHER *EVP_aes_128_ccm(void); | 791 | const EVP_CIPHER *EVP_aes_128_ccm(void); |
| 792 | const EVP_CIPHER *EVP_aes_128_gcm(void); | ||
| 793 | const EVP_CIPHER *EVP_aes_128_xts(void); | 793 | const EVP_CIPHER *EVP_aes_128_xts(void); |
| 794 | const EVP_CIPHER *EVP_aes_192_ecb(void); | 794 | const EVP_CIPHER *EVP_aes_192_ecb(void); |
| 795 | const EVP_CIPHER *EVP_aes_192_cbc(void); | 795 | const EVP_CIPHER *EVP_aes_192_cbc(void); |
| @@ -799,8 +799,8 @@ const EVP_CIPHER *EVP_aes_192_cfb128(void); | |||
| 799 | # define EVP_aes_192_cfb EVP_aes_192_cfb128 | 799 | # define EVP_aes_192_cfb EVP_aes_192_cfb128 |
| 800 | const EVP_CIPHER *EVP_aes_192_ofb(void); | 800 | const EVP_CIPHER *EVP_aes_192_ofb(void); |
| 801 | const EVP_CIPHER *EVP_aes_192_ctr(void); | 801 | const EVP_CIPHER *EVP_aes_192_ctr(void); |
| 802 | const EVP_CIPHER *EVP_aes_192_gcm(void); | ||
| 803 | const EVP_CIPHER *EVP_aes_192_ccm(void); | 802 | const EVP_CIPHER *EVP_aes_192_ccm(void); |
| 803 | const EVP_CIPHER *EVP_aes_192_gcm(void); | ||
| 804 | const EVP_CIPHER *EVP_aes_256_ecb(void); | 804 | const EVP_CIPHER *EVP_aes_256_ecb(void); |
| 805 | const EVP_CIPHER *EVP_aes_256_cbc(void); | 805 | const EVP_CIPHER *EVP_aes_256_cbc(void); |
| 806 | const EVP_CIPHER *EVP_aes_256_cfb1(void); | 806 | const EVP_CIPHER *EVP_aes_256_cfb1(void); |
| @@ -809,8 +809,8 @@ const EVP_CIPHER *EVP_aes_256_cfb128(void); | |||
| 809 | # define EVP_aes_256_cfb EVP_aes_256_cfb128 | 809 | # define EVP_aes_256_cfb EVP_aes_256_cfb128 |
| 810 | const EVP_CIPHER *EVP_aes_256_ofb(void); | 810 | const EVP_CIPHER *EVP_aes_256_ofb(void); |
| 811 | const EVP_CIPHER *EVP_aes_256_ctr(void); | 811 | const EVP_CIPHER *EVP_aes_256_ctr(void); |
| 812 | const EVP_CIPHER *EVP_aes_256_gcm(void); | ||
| 813 | const EVP_CIPHER *EVP_aes_256_ccm(void); | 812 | const EVP_CIPHER *EVP_aes_256_ccm(void); |
| 813 | const EVP_CIPHER *EVP_aes_256_gcm(void); | ||
| 814 | const EVP_CIPHER *EVP_aes_256_xts(void); | 814 | const EVP_CIPHER *EVP_aes_256_xts(void); |
| 815 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) | 815 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) |
| 816 | const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); | 816 | const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); |
| @@ -1242,6 +1242,8 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, | |||
| 1242 | int (*ctrl_str)(EVP_PKEY_CTX *ctx, | 1242 | int (*ctrl_str)(EVP_PKEY_CTX *ctx, |
| 1243 | const char *type, const char *value)); | 1243 | const char *type, const char *value)); |
| 1244 | 1244 | ||
| 1245 | void EVP_add_alg_module(void); | ||
| 1246 | |||
| 1245 | /* BEGIN ERROR CODES */ | 1247 | /* BEGIN ERROR CODES */ |
| 1246 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 1248 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 1247 | * made after this point may be overwritten when the script is next run. | 1249 | * made after this point may be overwritten when the script is next run. |
| @@ -1256,6 +1258,7 @@ void ERR_load_EVP_strings(void); | |||
| 1256 | #define EVP_F_AES_INIT_KEY 133 | 1258 | #define EVP_F_AES_INIT_KEY 133 |
| 1257 | #define EVP_F_AES_XTS 172 | 1259 | #define EVP_F_AES_XTS 172 |
| 1258 | #define EVP_F_AES_XTS_CIPHER 175 | 1260 | #define EVP_F_AES_XTS_CIPHER 175 |
| 1261 | #define EVP_F_ALG_MODULE_INIT 177 | ||
| 1259 | #define EVP_F_CAMELLIA_INIT_KEY 159 | 1262 | #define EVP_F_CAMELLIA_INIT_KEY 159 |
| 1260 | #define EVP_F_CMAC_INIT 173 | 1263 | #define EVP_F_CMAC_INIT 173 |
| 1261 | #define EVP_F_D2I_PKEY 100 | 1264 | #define EVP_F_D2I_PKEY 100 |
| @@ -1349,15 +1352,19 @@ void ERR_load_EVP_strings(void); | |||
| 1349 | #define EVP_R_DIFFERENT_PARAMETERS 153 | 1352 | #define EVP_R_DIFFERENT_PARAMETERS 153 |
| 1350 | #define EVP_R_DISABLED_FOR_FIPS 163 | 1353 | #define EVP_R_DISABLED_FOR_FIPS 163 |
| 1351 | #define EVP_R_ENCODE_ERROR 115 | 1354 | #define EVP_R_ENCODE_ERROR 115 |
| 1355 | #define EVP_R_ERROR_LOADING_SECTION 165 | ||
| 1356 | #define EVP_R_ERROR_SETTING_FIPS_MODE 166 | ||
| 1352 | #define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 | 1357 | #define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 |
| 1353 | #define EVP_R_EXPECTING_AN_RSA_KEY 127 | 1358 | #define EVP_R_EXPECTING_AN_RSA_KEY 127 |
| 1354 | #define EVP_R_EXPECTING_A_DH_KEY 128 | 1359 | #define EVP_R_EXPECTING_A_DH_KEY 128 |
| 1355 | #define EVP_R_EXPECTING_A_DSA_KEY 129 | 1360 | #define EVP_R_EXPECTING_A_DSA_KEY 129 |
| 1356 | #define EVP_R_EXPECTING_A_ECDSA_KEY 141 | 1361 | #define EVP_R_EXPECTING_A_ECDSA_KEY 141 |
| 1357 | #define EVP_R_EXPECTING_A_EC_KEY 142 | 1362 | #define EVP_R_EXPECTING_A_EC_KEY 142 |
| 1363 | #define EVP_R_FIPS_MODE_NOT_SUPPORTED 167 | ||
| 1358 | #define EVP_R_INITIALIZATION_ERROR 134 | 1364 | #define EVP_R_INITIALIZATION_ERROR 134 |
| 1359 | #define EVP_R_INPUT_NOT_INITIALIZED 111 | 1365 | #define EVP_R_INPUT_NOT_INITIALIZED 111 |
| 1360 | #define EVP_R_INVALID_DIGEST 152 | 1366 | #define EVP_R_INVALID_DIGEST 152 |
| 1367 | #define EVP_R_INVALID_FIPS_MODE 168 | ||
| 1361 | #define EVP_R_INVALID_KEY_LENGTH 130 | 1368 | #define EVP_R_INVALID_KEY_LENGTH 130 |
| 1362 | #define EVP_R_INVALID_OPERATION 148 | 1369 | #define EVP_R_INVALID_OPERATION 148 |
| 1363 | #define EVP_R_IV_TOO_LARGE 102 | 1370 | #define EVP_R_IV_TOO_LARGE 102 |
| @@ -1382,6 +1389,7 @@ void ERR_load_EVP_strings(void); | |||
| 1382 | #define EVP_R_TOO_LARGE 164 | 1389 | #define EVP_R_TOO_LARGE 164 |
| 1383 | #define EVP_R_UNKNOWN_CIPHER 160 | 1390 | #define EVP_R_UNKNOWN_CIPHER 160 |
| 1384 | #define EVP_R_UNKNOWN_DIGEST 161 | 1391 | #define EVP_R_UNKNOWN_DIGEST 161 |
| 1392 | #define EVP_R_UNKNOWN_OPTION 169 | ||
| 1385 | #define EVP_R_UNKNOWN_PBE_ALGORITHM 121 | 1393 | #define EVP_R_UNKNOWN_PBE_ALGORITHM 121 |
| 1386 | #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 | 1394 | #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 |
| 1387 | #define EVP_R_UNSUPPORTED_ALGORITHM 156 | 1395 | #define EVP_R_UNSUPPORTED_ALGORITHM 156 |
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c index db0f76d59b..08eab9882f 100644 --- a/src/lib/libcrypto/evp/evp_err.c +++ b/src/lib/libcrypto/evp/evp_err.c | |||
| @@ -75,6 +75,7 @@ static ERR_STRING_DATA EVP_str_functs[]= | |||
| 75 | {ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, | 75 | {ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, |
| 76 | {ERR_FUNC(EVP_F_AES_XTS), "AES_XTS"}, | 76 | {ERR_FUNC(EVP_F_AES_XTS), "AES_XTS"}, |
| 77 | {ERR_FUNC(EVP_F_AES_XTS_CIPHER), "AES_XTS_CIPHER"}, | 77 | {ERR_FUNC(EVP_F_AES_XTS_CIPHER), "AES_XTS_CIPHER"}, |
| 78 | {ERR_FUNC(EVP_F_ALG_MODULE_INIT), "ALG_MODULE_INIT"}, | ||
| 78 | {ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"}, | 79 | {ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"}, |
| 79 | {ERR_FUNC(EVP_F_CMAC_INIT), "CMAC_INIT"}, | 80 | {ERR_FUNC(EVP_F_CMAC_INIT), "CMAC_INIT"}, |
| 80 | {ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, | 81 | {ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, |
| @@ -171,15 +172,19 @@ static ERR_STRING_DATA EVP_str_reasons[]= | |||
| 171 | {ERR_REASON(EVP_R_DIFFERENT_PARAMETERS) ,"different parameters"}, | 172 | {ERR_REASON(EVP_R_DIFFERENT_PARAMETERS) ,"different parameters"}, |
| 172 | {ERR_REASON(EVP_R_DISABLED_FOR_FIPS) ,"disabled for fips"}, | 173 | {ERR_REASON(EVP_R_DISABLED_FOR_FIPS) ,"disabled for fips"}, |
| 173 | {ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"}, | 174 | {ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"}, |
| 175 | {ERR_REASON(EVP_R_ERROR_LOADING_SECTION) ,"error loading section"}, | ||
| 176 | {ERR_REASON(EVP_R_ERROR_SETTING_FIPS_MODE),"error setting fips mode"}, | ||
| 174 | {ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"}, | 177 | {ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"}, |
| 175 | {ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"}, | 178 | {ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"}, |
| 176 | {ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"}, | 179 | {ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"}, |
| 177 | {ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"}, | 180 | {ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"}, |
| 178 | {ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) ,"expecting a ecdsa key"}, | 181 | {ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) ,"expecting a ecdsa key"}, |
| 179 | {ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) ,"expecting a ec key"}, | 182 | {ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) ,"expecting a ec key"}, |
| 183 | {ERR_REASON(EVP_R_FIPS_MODE_NOT_SUPPORTED),"fips mode not supported"}, | ||
| 180 | {ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"}, | 184 | {ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"}, |
| 181 | {ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"}, | 185 | {ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"}, |
| 182 | {ERR_REASON(EVP_R_INVALID_DIGEST) ,"invalid digest"}, | 186 | {ERR_REASON(EVP_R_INVALID_DIGEST) ,"invalid digest"}, |
| 187 | {ERR_REASON(EVP_R_INVALID_FIPS_MODE) ,"invalid fips mode"}, | ||
| 183 | {ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"}, | 188 | {ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"}, |
| 184 | {ERR_REASON(EVP_R_INVALID_OPERATION) ,"invalid operation"}, | 189 | {ERR_REASON(EVP_R_INVALID_OPERATION) ,"invalid operation"}, |
| 185 | {ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"}, | 190 | {ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"}, |
| @@ -204,6 +209,7 @@ static ERR_STRING_DATA EVP_str_reasons[]= | |||
| 204 | {ERR_REASON(EVP_R_TOO_LARGE) ,"too large"}, | 209 | {ERR_REASON(EVP_R_TOO_LARGE) ,"too large"}, |
| 205 | {ERR_REASON(EVP_R_UNKNOWN_CIPHER) ,"unknown cipher"}, | 210 | {ERR_REASON(EVP_R_UNKNOWN_CIPHER) ,"unknown cipher"}, |
| 206 | {ERR_REASON(EVP_R_UNKNOWN_DIGEST) ,"unknown digest"}, | 211 | {ERR_REASON(EVP_R_UNKNOWN_DIGEST) ,"unknown digest"}, |
| 212 | {ERR_REASON(EVP_R_UNKNOWN_OPTION) ,"unknown option"}, | ||
| 207 | {ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"}, | 213 | {ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"}, |
| 208 | {ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"}, | 214 | {ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"}, |
| 209 | {ERR_REASON(EVP_R_UNSUPPORTED_ALGORITHM) ,"unsupported algorithm"}, | 215 | {ERR_REASON(EVP_R_UNSUPPORTED_ALGORITHM) ,"unsupported algorithm"}, |
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c index 4ad63ada6f..6fb7e9a861 100644 --- a/src/lib/libcrypto/evp/m_dss.c +++ b/src/lib/libcrypto/evp/m_dss.c | |||
| @@ -60,7 +60,7 @@ | |||
| 60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 61 | #include <openssl/evp.h> | 61 | #include <openssl/evp.h> |
| 62 | #include <openssl/objects.h> | 62 | #include <openssl/objects.h> |
| 63 | #include <openssl/x509.h> | 63 | #include <openssl/sha.h> |
| 64 | #ifndef OPENSSL_NO_DSA | 64 | #ifndef OPENSSL_NO_DSA |
| 65 | #include <openssl/dsa.h> | 65 | #include <openssl/dsa.h> |
| 66 | #endif | 66 | #endif |
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c index f80170efeb..2df362a670 100644 --- a/src/lib/libcrypto/evp/m_dss1.c +++ b/src/lib/libcrypto/evp/m_dss1.c | |||
| @@ -63,7 +63,7 @@ | |||
| 63 | 63 | ||
| 64 | #include <openssl/evp.h> | 64 | #include <openssl/evp.h> |
| 65 | #include <openssl/objects.h> | 65 | #include <openssl/objects.h> |
| 66 | #include <openssl/x509.h> | 66 | #include <openssl/sha.h> |
| 67 | #ifndef OPENSSL_NO_DSA | 67 | #ifndef OPENSSL_NO_DSA |
| 68 | #include <openssl/dsa.h> | 68 | #include <openssl/dsa.h> |
| 69 | #endif | 69 | #endif |
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c index 3cb11f1ebb..bd0c01ad3c 100644 --- a/src/lib/libcrypto/evp/m_sha1.c +++ b/src/lib/libcrypto/evp/m_sha1.c | |||
| @@ -65,7 +65,7 @@ | |||
| 65 | 65 | ||
| 66 | #include <openssl/evp.h> | 66 | #include <openssl/evp.h> |
| 67 | #include <openssl/objects.h> | 67 | #include <openssl/objects.h> |
| 68 | #include <openssl/x509.h> | 68 | #include <openssl/sha.h> |
| 69 | #ifndef OPENSSL_NO_RSA | 69 | #ifndef OPENSSL_NO_RSA |
| 70 | #include <openssl/rsa.h> | 70 | #include <openssl/rsa.h> |
| 71 | #endif | 71 | #endif |
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c index 975d004df4..fe3c6c8813 100644 --- a/src/lib/libcrypto/evp/p5_crpt2.c +++ b/src/lib/libcrypto/evp/p5_crpt2.c | |||
| @@ -85,19 +85,24 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, | |||
| 85 | unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4]; | 85 | unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4]; |
| 86 | int cplen, j, k, tkeylen, mdlen; | 86 | int cplen, j, k, tkeylen, mdlen; |
| 87 | unsigned long i = 1; | 87 | unsigned long i = 1; |
| 88 | HMAC_CTX hctx; | 88 | HMAC_CTX hctx_tpl, hctx; |
| 89 | 89 | ||
| 90 | mdlen = EVP_MD_size(digest); | 90 | mdlen = EVP_MD_size(digest); |
| 91 | if (mdlen < 0) | 91 | if (mdlen < 0) |
| 92 | return 0; | 92 | return 0; |
| 93 | 93 | ||
| 94 | HMAC_CTX_init(&hctx); | 94 | HMAC_CTX_init(&hctx_tpl); |
| 95 | p = out; | 95 | p = out; |
| 96 | tkeylen = keylen; | 96 | tkeylen = keylen; |
| 97 | if(!pass) | 97 | if(!pass) |
| 98 | passlen = 0; | 98 | passlen = 0; |
| 99 | else if(passlen == -1) | 99 | else if(passlen == -1) |
| 100 | passlen = strlen(pass); | 100 | passlen = strlen(pass); |
| 101 | if (!HMAC_Init_ex(&hctx_tpl, pass, passlen, digest, NULL)) | ||
| 102 | { | ||
| 103 | HMAC_CTX_cleanup(&hctx_tpl); | ||
| 104 | return 0; | ||
| 105 | } | ||
| 101 | while(tkeylen) | 106 | while(tkeylen) |
| 102 | { | 107 | { |
| 103 | if(tkeylen > mdlen) | 108 | if(tkeylen > mdlen) |
| @@ -111,19 +116,36 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, | |||
| 111 | itmp[1] = (unsigned char)((i >> 16) & 0xff); | 116 | itmp[1] = (unsigned char)((i >> 16) & 0xff); |
| 112 | itmp[2] = (unsigned char)((i >> 8) & 0xff); | 117 | itmp[2] = (unsigned char)((i >> 8) & 0xff); |
| 113 | itmp[3] = (unsigned char)(i & 0xff); | 118 | itmp[3] = (unsigned char)(i & 0xff); |
| 114 | if (!HMAC_Init_ex(&hctx, pass, passlen, digest, NULL) | 119 | if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) |
| 115 | || !HMAC_Update(&hctx, salt, saltlen) | ||
| 116 | || !HMAC_Update(&hctx, itmp, 4) | ||
| 117 | || !HMAC_Final(&hctx, digtmp, NULL)) | ||
| 118 | { | 120 | { |
| 121 | HMAC_CTX_cleanup(&hctx_tpl); | ||
| 122 | return 0; | ||
| 123 | } | ||
| 124 | if (!HMAC_Update(&hctx, salt, saltlen) | ||
| 125 | || !HMAC_Update(&hctx, itmp, 4) | ||
| 126 | || !HMAC_Final(&hctx, digtmp, NULL)) | ||
| 127 | { | ||
| 128 | HMAC_CTX_cleanup(&hctx_tpl); | ||
| 119 | HMAC_CTX_cleanup(&hctx); | 129 | HMAC_CTX_cleanup(&hctx); |
| 120 | return 0; | 130 | return 0; |
| 121 | } | 131 | } |
| 132 | HMAC_CTX_cleanup(&hctx); | ||
| 122 | memcpy(p, digtmp, cplen); | 133 | memcpy(p, digtmp, cplen); |
| 123 | for(j = 1; j < iter; j++) | 134 | for(j = 1; j < iter; j++) |
| 124 | { | 135 | { |
| 125 | HMAC(digest, pass, passlen, | 136 | if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) |
| 126 | digtmp, mdlen, digtmp, NULL); | 137 | { |
| 138 | HMAC_CTX_cleanup(&hctx_tpl); | ||
| 139 | return 0; | ||
| 140 | } | ||
| 141 | if (!HMAC_Update(&hctx, digtmp, mdlen) | ||
| 142 | || !HMAC_Final(&hctx, digtmp, NULL)) | ||
| 143 | { | ||
| 144 | HMAC_CTX_cleanup(&hctx_tpl); | ||
| 145 | HMAC_CTX_cleanup(&hctx); | ||
| 146 | return 0; | ||
| 147 | } | ||
| 148 | HMAC_CTX_cleanup(&hctx); | ||
| 127 | for(k = 0; k < cplen; k++) | 149 | for(k = 0; k < cplen; k++) |
| 128 | p[k] ^= digtmp[k]; | 150 | p[k] ^= digtmp[k]; |
| 129 | } | 151 | } |
| @@ -131,7 +153,7 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, | |||
| 131 | i++; | 153 | i++; |
| 132 | p+= cplen; | 154 | p+= cplen; |
| 133 | } | 155 | } |
| 134 | HMAC_CTX_cleanup(&hctx); | 156 | HMAC_CTX_cleanup(&hctx_tpl); |
| 135 | #ifdef DEBUG_PKCS5V2 | 157 | #ifdef DEBUG_PKCS5V2 |
| 136 | fprintf(stderr, "Password:\n"); | 158 | fprintf(stderr, "Password:\n"); |
| 137 | h__dump (pass, passlen); | 159 | h__dump (pass, passlen); |
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c index dfa48c157c..8afb664306 100644 --- a/src/lib/libcrypto/evp/p_sign.c +++ b/src/lib/libcrypto/evp/p_sign.c | |||
| @@ -80,7 +80,7 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | |||
| 80 | { | 80 | { |
| 81 | unsigned char m[EVP_MAX_MD_SIZE]; | 81 | unsigned char m[EVP_MAX_MD_SIZE]; |
| 82 | unsigned int m_len; | 82 | unsigned int m_len; |
| 83 | int i=0,ok=0,v; | 83 | int i = 0,ok = 0,v; |
| 84 | EVP_MD_CTX tmp_ctx; | 84 | EVP_MD_CTX tmp_ctx; |
| 85 | EVP_PKEY_CTX *pkctx = NULL; | 85 | EVP_PKEY_CTX *pkctx = NULL; |
| 86 | 86 | ||
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c index 5f5c409f45..c66d63ccf8 100644 --- a/src/lib/libcrypto/evp/p_verify.c +++ b/src/lib/libcrypto/evp/p_verify.c | |||
| @@ -67,7 +67,7 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, | |||
| 67 | { | 67 | { |
| 68 | unsigned char m[EVP_MAX_MD_SIZE]; | 68 | unsigned char m[EVP_MAX_MD_SIZE]; |
| 69 | unsigned int m_len; | 69 | unsigned int m_len; |
| 70 | int i=-1,ok=0,v; | 70 | int i = 0,ok = 0,v; |
| 71 | EVP_MD_CTX tmp_ctx; | 71 | EVP_MD_CTX tmp_ctx; |
| 72 | EVP_PKEY_CTX *pkctx = NULL; | 72 | EVP_PKEY_CTX *pkctx = NULL; |
| 73 | 73 | ||
