summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp')
-rw-r--r--src/lib/libcrypto/evp/Makefile70
-rw-r--r--src/lib/libcrypto/evp/bio_ok.c103
-rw-r--r--src/lib/libcrypto/evp/c_allc.c18
-rw-r--r--src/lib/libcrypto/evp/evptests.txt13
-rw-r--r--src/lib/libcrypto/evp/m_mdc2.c2
-rw-r--r--src/lib/libcrypto/evp/m_sha.c1
6 files changed, 158 insertions, 49 deletions
diff --git a/src/lib/libcrypto/evp/Makefile b/src/lib/libcrypto/evp/Makefile
index 82825e5299..0fe1b96bff 100644
--- a/src/lib/libcrypto/evp/Makefile
+++ b/src/lib/libcrypto/evp/Makefile
@@ -28,7 +28,8 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
28 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ 28 bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
29 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \ 29 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
30 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \ 30 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c \
31 e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c 31 e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c evp_fips.c \
32 e_aes_cbc_hmac_sha1.c e_rc4_hmac_md5.c
32 33
33LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \ 34LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
34 e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\ 35 e_des.o e_bf.o e_idea.o e_des3.o e_camellia.o\
@@ -40,7 +41,8 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
40 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \ 41 bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \
41 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \ 42 c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \
42 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o \ 43 evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o \
43 e_old.o pmeth_lib.o pmeth_fn.o pmeth_gn.o m_sigver.o 44 e_old.o pmeth_lib.o pmeth_fn.o pmeth_gn.o m_sigver.o evp_fips.o \
45 e_aes_cbc_hmac_sha1.o e_rc4_hmac_md5.o
44 46
45SRC= $(LIBSRC) 47SRC= $(LIBSRC)
46 48
@@ -189,11 +191,27 @@ e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
189e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 191e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
190e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 192e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
191e_aes.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h 193e_aes.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
192e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 194e_aes.o: ../../include/openssl/modes.h ../../include/openssl/obj_mac.h
193e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 195e_aes.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
194e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h 196e_aes.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h e_aes.c 197e_aes.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
196e_aes.o: evp_locl.h 198e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
199e_aes.o: ../modes/modes_lcl.h e_aes.c evp_locl.h
200e_aes_cbc_hmac_sha1.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
201e_aes_cbc_hmac_sha1.o: ../../include/openssl/bio.h
202e_aes_cbc_hmac_sha1.o: ../../include/openssl/crypto.h
203e_aes_cbc_hmac_sha1.o: ../../include/openssl/e_os2.h
204e_aes_cbc_hmac_sha1.o: ../../include/openssl/evp.h
205e_aes_cbc_hmac_sha1.o: ../../include/openssl/obj_mac.h
206e_aes_cbc_hmac_sha1.o: ../../include/openssl/objects.h
207e_aes_cbc_hmac_sha1.o: ../../include/openssl/opensslconf.h
208e_aes_cbc_hmac_sha1.o: ../../include/openssl/opensslv.h
209e_aes_cbc_hmac_sha1.o: ../../include/openssl/ossl_typ.h
210e_aes_cbc_hmac_sha1.o: ../../include/openssl/safestack.h
211e_aes_cbc_hmac_sha1.o: ../../include/openssl/sha.h
212e_aes_cbc_hmac_sha1.o: ../../include/openssl/stack.h
213e_aes_cbc_hmac_sha1.o: ../../include/openssl/symhacks.h e_aes_cbc_hmac_sha1.c
214e_aes_cbc_hmac_sha1.o: evp_locl.h
197e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 215e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
198e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h 216e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h
199e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 217e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
@@ -279,7 +297,18 @@ e_rc4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
279e_rc4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 297e_rc4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
280e_rc4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h 298e_rc4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h
281e_rc4.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 299e_rc4.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
282e_rc4.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc4.c 300e_rc4.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc4.c evp_locl.h
301e_rc4_hmac_md5.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
302e_rc4_hmac_md5.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
303e_rc4_hmac_md5.o: ../../include/openssl/evp.h ../../include/openssl/md5.h
304e_rc4_hmac_md5.o: ../../include/openssl/obj_mac.h
305e_rc4_hmac_md5.o: ../../include/openssl/objects.h
306e_rc4_hmac_md5.o: ../../include/openssl/opensslconf.h
307e_rc4_hmac_md5.o: ../../include/openssl/opensslv.h
308e_rc4_hmac_md5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h
309e_rc4_hmac_md5.o: ../../include/openssl/safestack.h
310e_rc4_hmac_md5.o: ../../include/openssl/stack.h
311e_rc4_hmac_md5.o: ../../include/openssl/symhacks.h e_rc4_hmac_md5.c
283e_rc5.o: ../../e_os.h ../../include/openssl/bio.h 312e_rc5.o: ../../e_os.h ../../include/openssl/bio.h
284e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 313e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
285e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 314e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -349,6 +378,13 @@ evp_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
349evp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 378evp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
350evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 379evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
351evp_err.o: ../../include/openssl/symhacks.h evp_err.c 380evp_err.o: ../../include/openssl/symhacks.h evp_err.c
381evp_fips.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
382evp_fips.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
383evp_fips.o: ../../include/openssl/evp.h ../../include/openssl/obj_mac.h
384evp_fips.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
385evp_fips.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
386evp_fips.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
387evp_fips.o: ../../include/openssl/symhacks.h evp_fips.c
352evp_key.o: ../../e_os.h ../../include/openssl/asn1.h 388evp_key.o: ../../e_os.h ../../include/openssl/asn1.h
353evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 389evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
354evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 390evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
@@ -383,7 +419,7 @@ evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
383evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 419evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
384evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 420evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
385evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 421evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
386evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c 422evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h evp_pbe.c
387evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h 423evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
388evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 424evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
389evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 425evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
@@ -456,7 +492,7 @@ m_md4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
456m_md4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 492m_md4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
457m_md4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 493m_md4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
458m_md4.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 494m_md4.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
459m_md4.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md4.c 495m_md4.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h m_md4.c
460m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 496m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
461m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 497m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
462m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 498m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -469,7 +505,7 @@ m_md5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
469m_md5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 505m_md5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
470m_md5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 506m_md5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
471m_md5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 507m_md5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
472m_md5.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md5.c 508m_md5.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h m_md5.c
473m_mdc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 509m_mdc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
474m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 510m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
475m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h 511m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
@@ -484,7 +520,7 @@ m_mdc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
484m_mdc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 520m_mdc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
485m_mdc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 521m_mdc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
486m_mdc2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h 522m_mdc2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
487m_mdc2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_mdc2.c 523m_mdc2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h m_mdc2.c
488m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 524m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
489m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 525m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
490m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 526m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -510,7 +546,8 @@ m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h
510m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 546m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
511m_ripemd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 547m_ripemd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
512m_ripemd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 548m_ripemd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
513m_ripemd.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_ripemd.c 549m_ripemd.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h
550m_ripemd.o: m_ripemd.c
514m_sha.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 551m_sha.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
515m_sha.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 552m_sha.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
516m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 553m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -523,7 +560,7 @@ m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
523m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 560m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
524m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 561m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
525m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 562m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
526m_sha.o: ../cryptlib.h m_sha.c 563m_sha.o: ../cryptlib.h evp_locl.h m_sha.c
527m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 564m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
528m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 565m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
529m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 566m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -563,7 +600,7 @@ m_wp.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
563m_wp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 600m_wp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
564m_wp.o: ../../include/openssl/symhacks.h ../../include/openssl/whrlpool.h 601m_wp.o: ../../include/openssl/symhacks.h ../../include/openssl/whrlpool.h
565m_wp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 602m_wp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
566m_wp.o: ../cryptlib.h m_wp.c 603m_wp.o: ../cryptlib.h evp_locl.h m_wp.c
567names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 604names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
568names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 605names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
569names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 606names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
@@ -601,7 +638,8 @@ p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
601p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h 638p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
602p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 639p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
603p5_crpt2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 640p5_crpt2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
604p5_crpt2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt2.c 641p5_crpt2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h
642p5_crpt2.o: p5_crpt2.c
605p_dec.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h 643p_dec.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
606p_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 644p_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
607p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h 645p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c
index 98bc1ab409..e64335353f 100644
--- a/src/lib/libcrypto/evp/bio_ok.c
+++ b/src/lib/libcrypto/evp/bio_ok.c
@@ -133,10 +133,10 @@ static int ok_new(BIO *h);
133static int ok_free(BIO *data); 133static int ok_free(BIO *data);
134static long ok_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); 134static long ok_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
135 135
136static void sig_out(BIO* b); 136static int sig_out(BIO* b);
137static void sig_in(BIO* b); 137static int sig_in(BIO* b);
138static void block_out(BIO* b); 138static int block_out(BIO* b);
139static void block_in(BIO* b); 139static int block_in(BIO* b);
140#define OK_BLOCK_SIZE (1024*4) 140#define OK_BLOCK_SIZE (1024*4)
141#define OK_BLOCK_BLOCK 4 141#define OK_BLOCK_BLOCK 4
142#define IOBS (OK_BLOCK_SIZE+ OK_BLOCK_BLOCK+ 3*EVP_MAX_MD_SIZE) 142#define IOBS (OK_BLOCK_SIZE+ OK_BLOCK_BLOCK+ 3*EVP_MAX_MD_SIZE)
@@ -266,10 +266,24 @@ static int ok_read(BIO *b, char *out, int outl)
266 ctx->buf_len+= i; 266 ctx->buf_len+= i;
267 267
268 /* no signature yet -- check if we got one */ 268 /* no signature yet -- check if we got one */
269 if (ctx->sigio == 1) sig_in(b); 269 if (ctx->sigio == 1)
270 {
271 if (!sig_in(b))
272 {
273 BIO_clear_retry_flags(b);
274 return 0;
275 }
276 }
270 277
271 /* signature ok -- check if we got block */ 278 /* signature ok -- check if we got block */
272 if (ctx->sigio == 0) block_in(b); 279 if (ctx->sigio == 0)
280 {
281 if (!block_in(b))
282 {
283 BIO_clear_retry_flags(b);
284 return 0;
285 }
286 }
273 287
274 /* invalid block -- cancel */ 288 /* invalid block -- cancel */
275 if (ctx->cont <= 0) break; 289 if (ctx->cont <= 0) break;
@@ -293,7 +307,8 @@ static int ok_write(BIO *b, const char *in, int inl)
293 307
294 if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0)) return(0); 308 if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0)) return(0);
295 309
296 if(ctx->sigio) sig_out(b); 310 if(ctx->sigio && !sig_out(b))
311 return 0;
297 312
298 do{ 313 do{
299 BIO_clear_retry_flags(b); 314 BIO_clear_retry_flags(b);
@@ -332,7 +347,11 @@ static int ok_write(BIO *b, const char *in, int inl)
332 347
333 if(ctx->buf_len >= OK_BLOCK_SIZE+ OK_BLOCK_BLOCK) 348 if(ctx->buf_len >= OK_BLOCK_SIZE+ OK_BLOCK_BLOCK)
334 { 349 {
335 block_out(b); 350 if (!block_out(b))
351 {
352 BIO_clear_retry_flags(b);
353 return 0;
354 }
336 } 355 }
337 }while(inl > 0); 356 }while(inl > 0);
338 357
@@ -379,7 +398,8 @@ static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
379 case BIO_CTRL_FLUSH: 398 case BIO_CTRL_FLUSH:
380 /* do a final write */ 399 /* do a final write */
381 if(ctx->blockout == 0) 400 if(ctx->blockout == 0)
382 block_out(b); 401 if (!block_out(b))
402 return 0;
383 403
384 while (ctx->blockout) 404 while (ctx->blockout)
385 { 405 {
@@ -408,7 +428,8 @@ static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
408 break; 428 break;
409 case BIO_C_SET_MD: 429 case BIO_C_SET_MD:
410 md=ptr; 430 md=ptr;
411 EVP_DigestInit_ex(&ctx->md, md, NULL); 431 if (!EVP_DigestInit_ex(&ctx->md, md, NULL))
432 return 0;
412 b->init=1; 433 b->init=1;
413 break; 434 break;
414 case BIO_C_GET_MD: 435 case BIO_C_GET_MD:
@@ -455,7 +476,7 @@ static void longswap(void *_ptr, size_t len)
455 } 476 }
456} 477}
457 478
458static void sig_out(BIO* b) 479static int sig_out(BIO* b)
459 { 480 {
460 BIO_OK_CTX *ctx; 481 BIO_OK_CTX *ctx;
461 EVP_MD_CTX *md; 482 EVP_MD_CTX *md;
@@ -463,9 +484,10 @@ static void sig_out(BIO* b)
463 ctx=b->ptr; 484 ctx=b->ptr;
464 md=&ctx->md; 485 md=&ctx->md;
465 486
466 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return; 487 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return 1;
467 488
468 EVP_DigestInit_ex(md, md->digest, NULL); 489 if (!EVP_DigestInit_ex(md, md->digest, NULL))
490 goto berr;
469 /* FIXME: there's absolutely no guarantee this makes any sense at all, 491 /* FIXME: there's absolutely no guarantee this makes any sense at all,
470 * particularly now EVP_MD_CTX has been restructured. 492 * particularly now EVP_MD_CTX has been restructured.
471 */ 493 */
@@ -474,14 +496,20 @@ static void sig_out(BIO* b)
474 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); 496 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size);
475 ctx->buf_len+= md->digest->md_size; 497 ctx->buf_len+= md->digest->md_size;
476 498
477 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); 499 if (!EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)))
478 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL); 500 goto berr;
501 if (!EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL))
502 goto berr;
479 ctx->buf_len+= md->digest->md_size; 503 ctx->buf_len+= md->digest->md_size;
480 ctx->blockout= 1; 504 ctx->blockout= 1;
481 ctx->sigio= 0; 505 ctx->sigio= 0;
506 return 1;
507 berr:
508 BIO_clear_retry_flags(b);
509 return 0;
482 } 510 }
483 511
484static void sig_in(BIO* b) 512static int sig_in(BIO* b)
485 { 513 {
486 BIO_OK_CTX *ctx; 514 BIO_OK_CTX *ctx;
487 EVP_MD_CTX *md; 515 EVP_MD_CTX *md;
@@ -491,15 +519,18 @@ static void sig_in(BIO* b)
491 ctx=b->ptr; 519 ctx=b->ptr;
492 md=&ctx->md; 520 md=&ctx->md;
493 521
494 if((int)(ctx->buf_len-ctx->buf_off) < 2*md->digest->md_size) return; 522 if((int)(ctx->buf_len-ctx->buf_off) < 2*md->digest->md_size) return 1;
495 523
496 EVP_DigestInit_ex(md, md->digest, NULL); 524 if (!EVP_DigestInit_ex(md, md->digest, NULL))
525 goto berr;
497 memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size); 526 memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size);
498 longswap(md->md_data, md->digest->md_size); 527 longswap(md->md_data, md->digest->md_size);
499 ctx->buf_off+= md->digest->md_size; 528 ctx->buf_off+= md->digest->md_size;
500 529
501 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); 530 if (!EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)))
502 EVP_DigestFinal_ex(md, tmp, NULL); 531 goto berr;
532 if (!EVP_DigestFinal_ex(md, tmp, NULL))
533 goto berr;
503 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; 534 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0;
504 ctx->buf_off+= md->digest->md_size; 535 ctx->buf_off+= md->digest->md_size;
505 if(ret == 1) 536 if(ret == 1)
@@ -516,9 +547,13 @@ static void sig_in(BIO* b)
516 { 547 {
517 ctx->cont= 0; 548 ctx->cont= 0;
518 } 549 }
550 return 1;
551 berr:
552 BIO_clear_retry_flags(b);
553 return 0;
519 } 554 }
520 555
521static void block_out(BIO* b) 556static int block_out(BIO* b)
522 { 557 {
523 BIO_OK_CTX *ctx; 558 BIO_OK_CTX *ctx;
524 EVP_MD_CTX *md; 559 EVP_MD_CTX *md;
@@ -532,13 +567,20 @@ static void block_out(BIO* b)
532 ctx->buf[1]=(unsigned char)(tl>>16); 567 ctx->buf[1]=(unsigned char)(tl>>16);
533 ctx->buf[2]=(unsigned char)(tl>>8); 568 ctx->buf[2]=(unsigned char)(tl>>8);
534 ctx->buf[3]=(unsigned char)(tl); 569 ctx->buf[3]=(unsigned char)(tl);
535 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); 570 if (!EVP_DigestUpdate(md,
536 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL); 571 (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl))
572 goto berr;
573 if (!EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL))
574 goto berr;
537 ctx->buf_len+= md->digest->md_size; 575 ctx->buf_len+= md->digest->md_size;
538 ctx->blockout= 1; 576 ctx->blockout= 1;
577 return 1;
578 berr:
579 BIO_clear_retry_flags(b);
580 return 0;
539 } 581 }
540 582
541static void block_in(BIO* b) 583static int block_in(BIO* b)
542 { 584 {
543 BIO_OK_CTX *ctx; 585 BIO_OK_CTX *ctx;
544 EVP_MD_CTX *md; 586 EVP_MD_CTX *md;
@@ -554,10 +596,13 @@ static void block_in(BIO* b)
554 tl|=ctx->buf[2]; tl<<=8; 596 tl|=ctx->buf[2]; tl<<=8;
555 tl|=ctx->buf[3]; 597 tl|=ctx->buf[3];
556 598
557 if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return; 599 if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return 1;
558 600
559 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); 601 if (!EVP_DigestUpdate(md,
560 EVP_DigestFinal_ex(md, tmp, NULL); 602 (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl))
603 goto berr;
604 if (!EVP_DigestFinal_ex(md, tmp, NULL))
605 goto berr;
561 if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0) 606 if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0)
562 { 607 {
563 /* there might be parts from next block lurking around ! */ 608 /* there might be parts from next block lurking around ! */
@@ -571,5 +616,9 @@ static void block_in(BIO* b)
571 { 616 {
572 ctx->cont= 0; 617 ctx->cont= 0;
573 } 618 }
619 return 1;
620 berr:
621 BIO_clear_retry_flags(b);
622 return 0;
574 } 623 }
575 624
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c
index c5f9268378..2a45d435e5 100644
--- a/src/lib/libcrypto/evp/c_allc.c
+++ b/src/lib/libcrypto/evp/c_allc.c
@@ -98,6 +98,9 @@ void OpenSSL_add_all_ciphers(void)
98#ifndef OPENSSL_NO_RC4 98#ifndef OPENSSL_NO_RC4
99 EVP_add_cipher(EVP_rc4()); 99 EVP_add_cipher(EVP_rc4());
100 EVP_add_cipher(EVP_rc4_40()); 100 EVP_add_cipher(EVP_rc4_40());
101#ifndef OPENSSL_NO_MD5
102 EVP_add_cipher(EVP_rc4_hmac_md5());
103#endif
101#endif 104#endif
102 105
103#ifndef OPENSSL_NO_IDEA 106#ifndef OPENSSL_NO_IDEA
@@ -166,9 +169,9 @@ void OpenSSL_add_all_ciphers(void)
166 EVP_add_cipher(EVP_aes_128_cfb1()); 169 EVP_add_cipher(EVP_aes_128_cfb1());
167 EVP_add_cipher(EVP_aes_128_cfb8()); 170 EVP_add_cipher(EVP_aes_128_cfb8());
168 EVP_add_cipher(EVP_aes_128_ofb()); 171 EVP_add_cipher(EVP_aes_128_ofb());
169#if 0
170 EVP_add_cipher(EVP_aes_128_ctr()); 172 EVP_add_cipher(EVP_aes_128_ctr());
171#endif 173 EVP_add_cipher(EVP_aes_128_gcm());
174 EVP_add_cipher(EVP_aes_128_xts());
172 EVP_add_cipher_alias(SN_aes_128_cbc,"AES128"); 175 EVP_add_cipher_alias(SN_aes_128_cbc,"AES128");
173 EVP_add_cipher_alias(SN_aes_128_cbc,"aes128"); 176 EVP_add_cipher_alias(SN_aes_128_cbc,"aes128");
174 EVP_add_cipher(EVP_aes_192_ecb()); 177 EVP_add_cipher(EVP_aes_192_ecb());
@@ -177,9 +180,8 @@ void OpenSSL_add_all_ciphers(void)
177 EVP_add_cipher(EVP_aes_192_cfb1()); 180 EVP_add_cipher(EVP_aes_192_cfb1());
178 EVP_add_cipher(EVP_aes_192_cfb8()); 181 EVP_add_cipher(EVP_aes_192_cfb8());
179 EVP_add_cipher(EVP_aes_192_ofb()); 182 EVP_add_cipher(EVP_aes_192_ofb());
180#if 0
181 EVP_add_cipher(EVP_aes_192_ctr()); 183 EVP_add_cipher(EVP_aes_192_ctr());
182#endif 184 EVP_add_cipher(EVP_aes_192_gcm());
183 EVP_add_cipher_alias(SN_aes_192_cbc,"AES192"); 185 EVP_add_cipher_alias(SN_aes_192_cbc,"AES192");
184 EVP_add_cipher_alias(SN_aes_192_cbc,"aes192"); 186 EVP_add_cipher_alias(SN_aes_192_cbc,"aes192");
185 EVP_add_cipher(EVP_aes_256_ecb()); 187 EVP_add_cipher(EVP_aes_256_ecb());
@@ -188,11 +190,15 @@ void OpenSSL_add_all_ciphers(void)
188 EVP_add_cipher(EVP_aes_256_cfb1()); 190 EVP_add_cipher(EVP_aes_256_cfb1());
189 EVP_add_cipher(EVP_aes_256_cfb8()); 191 EVP_add_cipher(EVP_aes_256_cfb8());
190 EVP_add_cipher(EVP_aes_256_ofb()); 192 EVP_add_cipher(EVP_aes_256_ofb());
191#if 0
192 EVP_add_cipher(EVP_aes_256_ctr()); 193 EVP_add_cipher(EVP_aes_256_ctr());
193#endif 194 EVP_add_cipher(EVP_aes_256_gcm());
195 EVP_add_cipher(EVP_aes_256_xts());
194 EVP_add_cipher_alias(SN_aes_256_cbc,"AES256"); 196 EVP_add_cipher_alias(SN_aes_256_cbc,"AES256");
195 EVP_add_cipher_alias(SN_aes_256_cbc,"aes256"); 197 EVP_add_cipher_alias(SN_aes_256_cbc,"aes256");
198#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
199 EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1());
200 EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1());
201#endif
196#endif 202#endif
197 203
198#ifndef OPENSSL_NO_CAMELLIA 204#ifndef OPENSSL_NO_CAMELLIA
diff --git a/src/lib/libcrypto/evp/evptests.txt b/src/lib/libcrypto/evp/evptests.txt
index beb12144b6..c273707c14 100644
--- a/src/lib/libcrypto/evp/evptests.txt
+++ b/src/lib/libcrypto/evp/evptests.txt
@@ -158,6 +158,19 @@ AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7B
158AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0 158AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0
159AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0 159AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0
160 160
161# AES Counter test vectors from RFC3686
162aes-128-ctr:AE6852F8121067CC4BF7A5765577F39E:00000030000000000000000000000001:53696E676C6520626C6F636B206D7367:E4095D4FB7A7B3792D6175A3261311B8:1
163aes-128-ctr:7E24067817FAE0D743D6CE1F32539163:006CB6DBC0543B59DA48D90B00000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:5104A106168A72D9790D41EE8EDAD388EB2E1EFC46DA57C8FCE630DF9141BE28:1
164aes-128-ctr:7691BE035E5020A8AC6E618529F9A0DC:00E0017B27777F3F4A1786F000000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:C1CF48A89F2FFDD9CF4652E9EFDB72D74540A42BDE6D7836D59A5CEAAEF3105325B2072F:1
165
166aes-192-ctr:16AF5B145FC9F579C175F93E3BFB0EED863D06CCFDB78515:0000004836733C147D6D93CB00000001:53696E676C6520626C6F636B206D7367:4B55384FE259C9C84E7935A003CBE928:1
167aes-192-ctr:7C5CB2401B3DC33C19E7340819E0F69C678C3DB8E6F6A91A:0096B03B020C6EADC2CB500D00000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:453243FC609B23327EDFAAFA7131CD9F8490701C5AD4A79CFC1FE0FF42F4FB00:1
168aes-192-ctr:02BF391EE8ECB159B959617B0965279BF59B60A786D3E0FE:0007BDFD5CBD60278DCC091200000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:96893FC55E5C722F540B7DD1DDF7E758D288BC95C69165884536C811662F2188ABEE0935:1
169
170aes-256-ctr:776BEFF2851DB06F4C8A0542C8696F6C6A81AF1EEC96B4D37FC1D689E6C1C104:00000060DB5672C97AA8F0B200000001:53696E676C6520626C6F636B206D7367:145AD01DBF824EC7560863DC71E3E0C0:1
171aes-256-ctr:F6D66D6BD52D59BB0796365879EFF886C66DD51A5B6A99744B50590C87A23884:00FAAC24C1585EF15A43D87500000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:F05E231B3894612C49EE000B804EB2A9B8306B508F839D6A5530831D9344AF1C:1
172aes-256-ctr:FF7A617CE69148E4F1726E2F43581DE2AA62D9F805532EDFF1EED687FB54153D:001CC5B751A51D70A1C1114800000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:EB6C52821D0BBBF7CE7594462ACA4FAAB407DF866569FD07F48CC0B583D6071F1EC0E6B8:1
173
161# DES ECB tests (from destest) 174# DES ECB tests (from destest)
162 175
163DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7 176DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c
index b08d559803..3602bed316 100644
--- a/src/lib/libcrypto/evp/m_mdc2.c
+++ b/src/lib/libcrypto/evp/m_mdc2.c
@@ -69,6 +69,8 @@
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70#endif 70#endif
71 71
72#include "evp_locl.h"
73
72static int init(EVP_MD_CTX *ctx) 74static int init(EVP_MD_CTX *ctx)
73 { return MDC2_Init(ctx->md_data); } 75 { return MDC2_Init(ctx->md_data); }
74 76
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c
index acccc8f92d..8769cdd42f 100644
--- a/src/lib/libcrypto/evp/m_sha.c
+++ b/src/lib/libcrypto/evp/m_sha.c
@@ -67,6 +67,7 @@
67#ifndef OPENSSL_NO_RSA 67#ifndef OPENSSL_NO_RSA
68#include <openssl/rsa.h> 68#include <openssl/rsa.h>
69#endif 69#endif
70#include "evp_locl.h"
70 71
71static int init(EVP_MD_CTX *ctx) 72static int init(EVP_MD_CTX *ctx)
72 { return SHA_Init(ctx->md_data); } 73 { return SHA_Init(ctx->md_data); }