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/Makefile733
-rw-r--r--src/lib/libcrypto/evp/bio_md.c11
-rw-r--r--src/lib/libcrypto/evp/bio_ok.c575
-rw-r--r--src/lib/libcrypto/evp/c_allc.c224
-rw-r--r--src/lib/libcrypto/evp/c_alld.c114
-rw-r--r--src/lib/libcrypto/evp/digest.c28
-rw-r--r--src/lib/libcrypto/evp/e_acss.c85
-rw-r--r--src/lib/libcrypto/evp/e_aes.c1273
-rw-r--r--src/lib/libcrypto/evp/e_des3.c3
-rw-r--r--src/lib/libcrypto/evp/e_dsa.c71
-rw-r--r--src/lib/libcrypto/evp/e_null.c4
-rw-r--r--src/lib/libcrypto/evp/e_rc2.c3
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c1
-rw-r--r--src/lib/libcrypto/evp/e_rc5.c126
-rw-r--r--src/lib/libcrypto/evp/e_seed.c83
-rw-r--r--src/lib/libcrypto/evp/evp.h99
-rw-r--r--src/lib/libcrypto/evp/evp_acnf.c73
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c95
-rw-r--r--src/lib/libcrypto/evp/evp_err.c19
-rw-r--r--src/lib/libcrypto/evp/evp_key.c27
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c4
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h40
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c5
-rw-r--r--src/lib/libcrypto/evp/evp_test.c450
-rw-r--r--src/lib/libcrypto/evp/evptests.txt321
-rw-r--r--src/lib/libcrypto/evp/m_dss.c2
-rw-r--r--src/lib/libcrypto/evp/m_dss1.c3
-rw-r--r--src/lib/libcrypto/evp/m_md2.c101
-rw-r--r--src/lib/libcrypto/evp/m_md4.c2
-rw-r--r--src/lib/libcrypto/evp/m_md5.c1
-rw-r--r--src/lib/libcrypto/evp/m_mdc2.c101
-rw-r--r--src/lib/libcrypto/evp/m_ripemd.c1
-rw-r--r--src/lib/libcrypto/evp/m_sha.c100
-rw-r--r--src/lib/libcrypto/evp/m_sha1.c5
-rw-r--r--src/lib/libcrypto/evp/names.c5
-rw-r--r--src/lib/libcrypto/evp/openbsd_hw.c446
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c33
-rw-r--r--src/lib/libcrypto/evp/p5_crpt2.c89
-rw-r--r--src/lib/libcrypto/evp/p_open.c3
-rw-r--r--src/lib/libcrypto/evp/p_seal.c3
-rw-r--r--src/lib/libcrypto/evp/p_sign.c10
-rw-r--r--src/lib/libcrypto/evp/p_verify.c10
42 files changed, 3736 insertions, 1646 deletions
diff --git a/src/lib/libcrypto/evp/Makefile b/src/lib/libcrypto/evp/Makefile
new file mode 100644
index 0000000000..82825e5299
--- /dev/null
+++ b/src/lib/libcrypto/evp/Makefile
@@ -0,0 +1,733 @@
1#
2# OpenSSL/crypto/evp/Makefile
3#
4
5DIR= evp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=evp_test.c
17TESTDATA=evptests.txt
18APPS=
19
20LIB=$(TOP)/libcrypto.a
21LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
22 e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\
23 e_rc4.c e_aes.c names.c e_seed.c \
24 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \
25 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c m_wp.c \
26 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c\
27 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.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 \
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
32
33LIBOBJ= 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_rc4.o e_aes.o names.o e_seed.o \
36 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \
37 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o m_wp.o \
38 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o m_ecdsa.o\
39 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
40 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 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
45SRC= $(LIBSRC)
46
47EXHEADER= evp.h
48HEADER= evp_locl.h $(EXHEADER)
49
50ALL= $(GENERAL) $(SRC) $(HEADER)
51
52top:
53 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
54
55all: lib
56
57lib: $(LIBOBJ)
58 $(AR) $(LIB) $(LIBOBJ)
59 $(RANLIB) $(LIB) || echo Never mind.
60 @touch lib
61
62files:
63 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
64
65links:
66 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
67 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
68 cp $(TESTDATA) ../../test
69 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
70
71install:
72 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
73 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
74 do \
75 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
76 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
77 done;
78
79tags:
80 ctags $(SRC)
81
82tests:
83
84lint:
85 lint -DLINT $(INCLUDES) $(SRC)>fluff
86
87depend:
88 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
89 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
90
91dclean:
92 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
93 mv -f Makefile.new $(MAKEFILE)
94
95clean:
96 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
97
98# DO NOT DELETE THIS LINE -- make depend depends on it.
99
100bio_b64.o: ../../e_os.h ../../include/openssl/asn1.h
101bio_b64.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
102bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
103bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h
104bio_b64.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
105bio_b64.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
106bio_b64.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
107bio_b64.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
108bio_b64.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_b64.c
109bio_enc.o: ../../e_os.h ../../include/openssl/asn1.h
110bio_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
111bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
112bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
113bio_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
114bio_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
115bio_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
116bio_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
117bio_enc.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_enc.c
118bio_md.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
119bio_md.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
121bio_md.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
122bio_md.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
123bio_md.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
124bio_md.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
125bio_md.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
126bio_md.o: ../cryptlib.h bio_md.c
127bio_ok.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
128bio_ok.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
129bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
130bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
131bio_ok.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
132bio_ok.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
133bio_ok.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
134bio_ok.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
135bio_ok.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_ok.c
136c_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
137c_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
138c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
139c_all.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
140c_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h
141c_all.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
142c_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
143c_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
144c_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
145c_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
146c_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
147c_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
148c_all.o: ../cryptlib.h c_all.c
149c_allc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
150c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
151c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
152c_allc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
153c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
154c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
155c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
156c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
157c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
158c_allc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
159c_allc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
160c_allc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
161c_allc.o: ../cryptlib.h c_allc.c
162c_alld.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
163c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
164c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
165c_alld.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
166c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
167c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
168c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
169c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
170c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
171c_alld.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
172c_alld.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
173c_alld.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
174c_alld.o: ../cryptlib.h c_alld.c
175digest.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
176digest.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
177digest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
178digest.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
179digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h
180digest.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
181digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
182digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
183digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
184digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
185digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
186digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
187digest.o: ../cryptlib.h digest.c
188e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
189e_aes.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
190e_aes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
191e_aes.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
192e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
193e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
194e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
195e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h e_aes.c
196e_aes.o: evp_locl.h
197e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
198e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/buffer.h
199e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
200e_bf.o: ../../include/openssl/err.h ../../include/openssl/evp.h
201e_bf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
202e_bf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
203e_bf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
204e_bf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
205e_bf.o: ../../include/openssl/symhacks.h ../cryptlib.h e_bf.c evp_locl.h
206e_camellia.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
207e_camellia.o: ../../include/openssl/camellia.h ../../include/openssl/crypto.h
208e_camellia.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
209e_camellia.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
210e_camellia.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
211e_camellia.o: ../../include/openssl/opensslconf.h
212e_camellia.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
213e_camellia.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
214e_camellia.o: ../../include/openssl/symhacks.h e_camellia.c evp_locl.h
215e_cast.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
216e_cast.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
217e_cast.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
218e_cast.o: ../../include/openssl/err.h ../../include/openssl/evp.h
219e_cast.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
220e_cast.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
221e_cast.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
222e_cast.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
223e_cast.o: ../../include/openssl/symhacks.h ../cryptlib.h e_cast.c evp_locl.h
224e_des.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
225e_des.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
226e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
227e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
228e_des.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
229e_des.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
230e_des.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
231e_des.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
232e_des.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
233e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
234e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h
235e_des3.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
236e_des3.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
237e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
238e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
239e_des3.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
240e_des3.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
241e_des3.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
242e_des3.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
243e_des3.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
244e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
245e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h
246e_idea.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
247e_idea.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
248e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
249e_idea.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
250e_idea.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
251e_idea.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
252e_idea.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
253e_idea.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
254e_idea.o: ../../include/openssl/symhacks.h ../cryptlib.h e_idea.c evp_locl.h
255e_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
256e_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
257e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
258e_null.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
259e_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
260e_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
261e_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
262e_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
263e_null.o: ../cryptlib.h e_null.c
264e_old.o: e_old.c
265e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
266e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
267e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
268e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
269e_rc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
270e_rc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
271e_rc2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
272e_rc2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
273e_rc2.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc2.c evp_locl.h
274e_rc4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
275e_rc4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
276e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
277e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
278e_rc4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
279e_rc4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
280e_rc4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc4.h
281e_rc4.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
282e_rc4.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc4.c
283e_rc5.o: ../../e_os.h ../../include/openssl/bio.h
284e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
285e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
286e_rc5.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
287e_rc5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
288e_rc5.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
289e_rc5.o: ../../include/openssl/symhacks.h ../cryptlib.h e_rc5.c
290e_seed.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
291e_seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
292e_seed.o: ../../include/openssl/err.h ../../include/openssl/evp.h
293e_seed.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
294e_seed.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
295e_seed.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
296e_seed.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h
297e_seed.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
298e_seed.o: e_seed.c evp_locl.h
299e_xcbc_d.o: ../../e_os.h ../../include/openssl/asn1.h
300e_xcbc_d.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
301e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
302e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
303e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
304e_xcbc_d.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
305e_xcbc_d.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
306e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
307e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
308e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
309e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c
310e_xcbc_d.o: evp_locl.h
311encode.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
312encode.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
313encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
314encode.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
315encode.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
316encode.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
317encode.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
318encode.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
319encode.o: ../cryptlib.h encode.c
320evp_acnf.o: ../../e_os.h ../../include/openssl/asn1.h
321evp_acnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
322evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
323evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
324evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
325evp_acnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
326evp_acnf.o: ../../include/openssl/opensslconf.h
327evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
328evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
329evp_acnf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_acnf.c
330evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h
331evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
332evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
333evp_enc.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
334evp_enc.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
335evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
336evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
337evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
338evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
339evp_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
340evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
341evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
342evp_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
343evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h
344evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
345evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
346evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
347evp_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
348evp_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
349evp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
350evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
351evp_err.o: ../../include/openssl/symhacks.h evp_err.c
352evp_key.o: ../../e_os.h ../../include/openssl/asn1.h
353evp_key.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
354evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
355evp_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
356evp_key.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
357evp_key.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
358evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
359evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
360evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
361evp_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
362evp_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
363evp_key.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
364evp_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_key.c
365evp_lib.o: ../../e_os.h ../../include/openssl/asn1.h
366evp_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
367evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
368evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
369evp_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
370evp_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
371evp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
372evp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
373evp_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_lib.c
374evp_pbe.o: ../../e_os.h ../../include/openssl/asn1.h
375evp_pbe.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
376evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
377evp_pbe.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
378evp_pbe.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
379evp_pbe.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
380evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
381evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
382evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
383evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
384evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
385evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
386evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c
387evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
388evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
389evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
390evp_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
391evp_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
392evp_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
393evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
394evp_pkey.o: ../../include/openssl/opensslconf.h
395evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
396evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
397evp_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
398evp_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
399evp_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
400evp_pkey.o: ../asn1/asn1_locl.h ../cryptlib.h evp_pkey.c
401m_dss.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
402m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
403m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
404m_dss.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
405m_dss.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
406m_dss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
407m_dss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
408m_dss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
409m_dss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
410m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
411m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
412m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
413m_dss.o: ../cryptlib.h m_dss.c
414m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
415m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
416m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
417m_dss1.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
418m_dss1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
419m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
420m_dss1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
421m_dss1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
422m_dss1.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
423m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
424m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
425m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
426m_dss1.o: ../cryptlib.h m_dss1.c
427m_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h
428m_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
429m_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
430m_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
431m_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
432m_ecdsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
433m_ecdsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
434m_ecdsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
435m_ecdsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
436m_ecdsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
437m_ecdsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
438m_ecdsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
439m_ecdsa.o: ../cryptlib.h m_ecdsa.c
440m_md2.o: ../../e_os.h ../../include/openssl/bio.h
441m_md2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
442m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
443m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
444m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
445m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
446m_md2.o: ../../include/openssl/symhacks.h ../cryptlib.h m_md2.c
447m_md4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
448m_md4.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
449m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
450m_md4.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
451m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h
452m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md4.h
453m_md4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
454m_md4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
455m_md4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
456m_md4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
457m_md4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
458m_md4.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
459m_md4.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md4.c
460m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
461m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
462m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
463m_md5.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
464m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
465m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md5.h
466m_md5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
467m_md5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
468m_md5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
469m_md5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
470m_md5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
471m_md5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
472m_md5.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md5.c
473m_mdc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
474m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
475m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
476m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
477m_mdc2.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
478m_mdc2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
479m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/mdc2.h
480m_mdc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
481m_mdc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
482m_mdc2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
483m_mdc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
484m_mdc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
485m_mdc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
486m_mdc2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
487m_mdc2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_mdc2.c
488m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
489m_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
490m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
491m_null.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
492m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h
493m_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
494m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
495m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
496m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
497m_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
498m_null.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
499m_null.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_null.c
500m_ripemd.o: ../../e_os.h ../../include/openssl/asn1.h
501m_ripemd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
502m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
503m_ripemd.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
504m_ripemd.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
505m_ripemd.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
506m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
507m_ripemd.o: ../../include/openssl/opensslconf.h
508m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
509m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h
510m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
511m_ripemd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
512m_ripemd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
513m_ripemd.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_ripemd.c
514m_sha.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
515m_sha.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
516m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
517m_sha.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
518m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h
519m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
520m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
521m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
522m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
523m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
524m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
525m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
526m_sha.o: ../cryptlib.h m_sha.c
527m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
528m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
529m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
530m_sha1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
531m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
532m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
533m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
534m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
535m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
536m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
537m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
538m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
539m_sha1.o: ../cryptlib.h m_sha1.c
540m_sigver.o: ../../e_os.h ../../include/openssl/asn1.h
541m_sigver.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
542m_sigver.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
543m_sigver.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
544m_sigver.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
545m_sigver.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
546m_sigver.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
547m_sigver.o: ../../include/openssl/opensslconf.h
548m_sigver.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
549m_sigver.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
550m_sigver.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
551m_sigver.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
552m_sigver.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_locl.h
553m_sigver.o: m_sigver.c
554m_wp.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
555m_wp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
556m_wp.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
557m_wp.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
558m_wp.o: ../../include/openssl/err.h ../../include/openssl/evp.h
559m_wp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
560m_wp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
561m_wp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
562m_wp.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
563m_wp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
564m_wp.o: ../../include/openssl/symhacks.h ../../include/openssl/whrlpool.h
565m_wp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
566m_wp.o: ../cryptlib.h m_wp.c
567names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
568names.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
569names.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
570names.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
571names.o: ../../include/openssl/err.h ../../include/openssl/evp.h
572names.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
573names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
574names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
575names.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
576names.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
577names.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
578names.o: ../../include/openssl/x509_vfy.h ../cryptlib.h names.c
579p5_crpt.o: ../../e_os.h ../../include/openssl/asn1.h
580p5_crpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
581p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
582p5_crpt.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
583p5_crpt.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
584p5_crpt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
585p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
586p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
587p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
588p5_crpt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
589p5_crpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
590p5_crpt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
591p5_crpt.o: ../cryptlib.h p5_crpt.c
592p5_crpt2.o: ../../e_os.h ../../include/openssl/asn1.h
593p5_crpt2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
594p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
595p5_crpt2.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
596p5_crpt2.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
597p5_crpt2.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
598p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
599p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
600p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
601p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
602p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
603p5_crpt2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
604p5_crpt2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt2.c
605p_dec.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
606p_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
607p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
608p_dec.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
609p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h
610p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
611p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
612p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
613p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
614p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
615p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
616p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
617p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c
618p_enc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
619p_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
620p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
621p_enc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
622p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
623p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
624p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
625p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
626p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
627p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
628p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
629p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
630p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c
631p_lib.o: ../../e_os.h ../../include/openssl/asn1.h
632p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
633p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
634p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
635p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
636p_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
637p_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
638p_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
639p_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
640p_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
641p_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
642p_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
643p_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
644p_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
645p_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
646p_lib.o: ../asn1/asn1_locl.h ../cryptlib.h p_lib.c
647p_open.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
648p_open.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
649p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
650p_open.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
651p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h
652p_open.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
653p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
654p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
655p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
656p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
657p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
658p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
659p_open.o: ../cryptlib.h p_open.c
660p_seal.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
661p_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
662p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
663p_seal.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
664p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h
665p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
666p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
667p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
668p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
669p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
670p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
671p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
672p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c
673p_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
674p_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
675p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
676p_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
677p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
678p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
679p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
680p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
681p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
682p_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
683p_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
684p_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_sign.c
685p_verify.o: ../../e_os.h ../../include/openssl/asn1.h
686p_verify.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
687p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
688p_verify.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
689p_verify.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
690p_verify.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
691p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
692p_verify.o: ../../include/openssl/opensslconf.h
693p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
694p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
695p_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
696p_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
697p_verify.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_verify.c
698pmeth_fn.o: ../../e_os.h ../../include/openssl/asn1.h
699pmeth_fn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
700pmeth_fn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
701pmeth_fn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
702pmeth_fn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
703pmeth_fn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
704pmeth_fn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
705pmeth_fn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
706pmeth_fn.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
707pmeth_fn.o: pmeth_fn.c
708pmeth_gn.o: ../../e_os.h ../../include/openssl/asn1.h
709pmeth_gn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
710pmeth_gn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
711pmeth_gn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
712pmeth_gn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
713pmeth_gn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
714pmeth_gn.o: ../../include/openssl/opensslconf.h
715pmeth_gn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
716pmeth_gn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
717pmeth_gn.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
718pmeth_gn.o: pmeth_gn.c
719pmeth_lib.o: ../../e_os.h ../../include/openssl/asn1.h
720pmeth_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
721pmeth_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
722pmeth_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
723pmeth_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
724pmeth_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
725pmeth_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
726pmeth_lib.o: ../../include/openssl/objects.h
727pmeth_lib.o: ../../include/openssl/opensslconf.h
728pmeth_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
729pmeth_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
730pmeth_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
731pmeth_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
732pmeth_lib.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h
733pmeth_lib.o: evp_locl.h pmeth_lib.c
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c
index 144fdfd56a..9841e32e1a 100644
--- a/src/lib/libcrypto/evp/bio_md.c
+++ b/src/lib/libcrypto/evp/bio_md.c
@@ -153,12 +153,8 @@ static int md_write(BIO *b, const char *in, int inl)
153 { 153 {
154 if (ret > 0) 154 if (ret > 0)
155 { 155 {
156 if (!EVP_DigestUpdate(ctx,(const unsigned char *)in, 156 EVP_DigestUpdate(ctx,(const unsigned char *)in,
157 (unsigned int)ret)) 157 (unsigned int)ret);
158 {
159 BIO_clear_retry_flags(b);
160 return 0;
161 }
162 } 158 }
163 } 159 }
164 if(b->next_bio != NULL) 160 if(b->next_bio != NULL)
@@ -224,8 +220,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
224 case BIO_CTRL_DUP: 220 case BIO_CTRL_DUP:
225 dbio=ptr; 221 dbio=ptr;
226 dctx=dbio->ptr; 222 dctx=dbio->ptr;
227 if (!EVP_MD_CTX_copy_ex(dctx,ctx)) 223 EVP_MD_CTX_copy_ex(dctx,ctx);
228 return 0;
229 b->init=1; 224 b->init=1;
230 break; 225 break;
231 default: 226 default:
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c
new file mode 100644
index 0000000000..98bc1ab409
--- /dev/null
+++ b/src/lib/libcrypto/evp/bio_ok.c
@@ -0,0 +1,575 @@
1/* crypto/evp/bio_ok.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/*
60 From: Arne Ansper <arne@cyber.ee>
61
62 Why BIO_f_reliable?
63
64 I wrote function which took BIO* as argument, read data from it
65 and processed it. Then I wanted to store the input file in
66 encrypted form. OK I pushed BIO_f_cipher to the BIO stack
67 and everything was OK. BUT if user types wrong password
68 BIO_f_cipher outputs only garbage and my function crashes. Yes
69 I can and I should fix my function, but BIO_f_cipher is
70 easy way to add encryption support to many existing applications
71 and it's hard to debug and fix them all.
72
73 So I wanted another BIO which would catch the incorrect passwords and
74 file damages which cause garbage on BIO_f_cipher's output.
75
76 The easy way is to push the BIO_f_md and save the checksum at
77 the end of the file. However there are several problems with this
78 approach:
79
80 1) you must somehow separate checksum from actual data.
81 2) you need lot's of memory when reading the file, because you
82 must read to the end of the file and verify the checksum before
83 letting the application to read the data.
84
85 BIO_f_reliable tries to solve both problems, so that you can
86 read and write arbitrary long streams using only fixed amount
87 of memory.
88
89 BIO_f_reliable splits data stream into blocks. Each block is prefixed
90 with it's length and suffixed with it's digest. So you need only
91 several Kbytes of memory to buffer single block before verifying
92 it's digest.
93
94 BIO_f_reliable goes further and adds several important capabilities:
95
96 1) the digest of the block is computed over the whole stream
97 -- so nobody can rearrange the blocks or remove or replace them.
98
99 2) to detect invalid passwords right at the start BIO_f_reliable
100 adds special prefix to the stream. In order to avoid known plain-text
101 attacks this prefix is generated as follows:
102
103 *) digest is initialized with random seed instead of
104 standardized one.
105 *) same seed is written to output
106 *) well-known text is then hashed and the output
107 of the digest is also written to output.
108
109 reader can now read the seed from stream, hash the same string
110 and then compare the digest output.
111
112 Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I
113 initially wrote and tested this code on x86 machine and wrote the
114 digests out in machine-dependent order :( There are people using
115 this code and I cannot change this easily without making existing
116 data files unreadable.
117
118*/
119
120#include <stdio.h>
121#include <errno.h>
122#include <assert.h>
123#include "cryptlib.h"
124#include <openssl/buffer.h>
125#include <openssl/bio.h>
126#include <openssl/evp.h>
127#include <openssl/rand.h>
128
129static int ok_write(BIO *h, const char *buf, int num);
130static int ok_read(BIO *h, char *buf, int size);
131static long ok_ctrl(BIO *h, int cmd, long arg1, void *arg2);
132static int ok_new(BIO *h);
133static int ok_free(BIO *data);
134static long ok_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
135
136static void sig_out(BIO* b);
137static void sig_in(BIO* b);
138static void block_out(BIO* b);
139static void block_in(BIO* b);
140#define OK_BLOCK_SIZE (1024*4)
141#define OK_BLOCK_BLOCK 4
142#define IOBS (OK_BLOCK_SIZE+ OK_BLOCK_BLOCK+ 3*EVP_MAX_MD_SIZE)
143#define WELLKNOWN "The quick brown fox jumped over the lazy dog's back."
144
145typedef struct ok_struct
146 {
147 size_t buf_len;
148 size_t buf_off;
149 size_t buf_len_save;
150 size_t buf_off_save;
151 int cont; /* <= 0 when finished */
152 int finished;
153 EVP_MD_CTX md;
154 int blockout; /* output block is ready */
155 int sigio; /* must process signature */
156 unsigned char buf[IOBS];
157 } BIO_OK_CTX;
158
159static BIO_METHOD methods_ok=
160 {
161 BIO_TYPE_CIPHER,"reliable",
162 ok_write,
163 ok_read,
164 NULL, /* ok_puts, */
165 NULL, /* ok_gets, */
166 ok_ctrl,
167 ok_new,
168 ok_free,
169 ok_callback_ctrl,
170 };
171
172BIO_METHOD *BIO_f_reliable(void)
173 {
174 return(&methods_ok);
175 }
176
177static int ok_new(BIO *bi)
178 {
179 BIO_OK_CTX *ctx;
180
181 ctx=(BIO_OK_CTX *)OPENSSL_malloc(sizeof(BIO_OK_CTX));
182 if (ctx == NULL) return(0);
183
184 ctx->buf_len=0;
185 ctx->buf_off=0;
186 ctx->buf_len_save=0;
187 ctx->buf_off_save=0;
188 ctx->cont=1;
189 ctx->finished=0;
190 ctx->blockout= 0;
191 ctx->sigio=1;
192
193 EVP_MD_CTX_init(&ctx->md);
194
195 bi->init=0;
196 bi->ptr=(char *)ctx;
197 bi->flags=0;
198 return(1);
199 }
200
201static int ok_free(BIO *a)
202 {
203 if (a == NULL) return(0);
204 EVP_MD_CTX_cleanup(&((BIO_OK_CTX *)a->ptr)->md);
205 OPENSSL_cleanse(a->ptr,sizeof(BIO_OK_CTX));
206 OPENSSL_free(a->ptr);
207 a->ptr=NULL;
208 a->init=0;
209 a->flags=0;
210 return(1);
211 }
212
213static int ok_read(BIO *b, char *out, int outl)
214 {
215 int ret=0,i,n;
216 BIO_OK_CTX *ctx;
217
218 if (out == NULL) return(0);
219 ctx=(BIO_OK_CTX *)b->ptr;
220
221 if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0)) return(0);
222
223 while(outl > 0)
224 {
225
226 /* copy clean bytes to output buffer */
227 if (ctx->blockout)
228 {
229 i=ctx->buf_len-ctx->buf_off;
230 if (i > outl) i=outl;
231 memcpy(out,&(ctx->buf[ctx->buf_off]),i);
232 ret+=i;
233 out+=i;
234 outl-=i;
235 ctx->buf_off+=i;
236
237 /* all clean bytes are out */
238 if (ctx->buf_len == ctx->buf_off)
239 {
240 ctx->buf_off=0;
241
242 /* copy start of the next block into proper place */
243 if(ctx->buf_len_save- ctx->buf_off_save > 0)
244 {
245 ctx->buf_len= ctx->buf_len_save- ctx->buf_off_save;
246 memmove(ctx->buf, &(ctx->buf[ctx->buf_off_save]),
247 ctx->buf_len);
248 }
249 else
250 {
251 ctx->buf_len=0;
252 }
253 ctx->blockout= 0;
254 }
255 }
256
257 /* output buffer full -- cancel */
258 if (outl == 0) break;
259
260 /* no clean bytes in buffer -- fill it */
261 n=IOBS- ctx->buf_len;
262 i=BIO_read(b->next_bio,&(ctx->buf[ctx->buf_len]),n);
263
264 if (i <= 0) break; /* nothing new */
265
266 ctx->buf_len+= i;
267
268 /* no signature yet -- check if we got one */
269 if (ctx->sigio == 1) sig_in(b);
270
271 /* signature ok -- check if we got block */
272 if (ctx->sigio == 0) block_in(b);
273
274 /* invalid block -- cancel */
275 if (ctx->cont <= 0) break;
276
277 }
278
279 BIO_clear_retry_flags(b);
280 BIO_copy_next_retry(b);
281 return(ret);
282 }
283
284static int ok_write(BIO *b, const char *in, int inl)
285 {
286 int ret=0,n,i;
287 BIO_OK_CTX *ctx;
288
289 if (inl <= 0) return inl;
290
291 ctx=(BIO_OK_CTX *)b->ptr;
292 ret=inl;
293
294 if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0)) return(0);
295
296 if(ctx->sigio) sig_out(b);
297
298 do{
299 BIO_clear_retry_flags(b);
300 n=ctx->buf_len-ctx->buf_off;
301 while (ctx->blockout && n > 0)
302 {
303 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);
304 if (i <= 0)
305 {
306 BIO_copy_next_retry(b);
307 if(!BIO_should_retry(b))
308 ctx->cont= 0;
309 return(i);
310 }
311 ctx->buf_off+=i;
312 n-=i;
313 }
314
315 /* at this point all pending data has been written */
316 ctx->blockout= 0;
317 if (ctx->buf_len == ctx->buf_off)
318 {
319 ctx->buf_len=OK_BLOCK_BLOCK;
320 ctx->buf_off=0;
321 }
322
323 if ((in == NULL) || (inl <= 0)) return(0);
324
325 n= (inl+ ctx->buf_len > OK_BLOCK_SIZE+ OK_BLOCK_BLOCK) ?
326 (int)(OK_BLOCK_SIZE+OK_BLOCK_BLOCK-ctx->buf_len) : inl;
327
328 memcpy((unsigned char *)(&(ctx->buf[ctx->buf_len])),(unsigned char *)in,n);
329 ctx->buf_len+= n;
330 inl-=n;
331 in+=n;
332
333 if(ctx->buf_len >= OK_BLOCK_SIZE+ OK_BLOCK_BLOCK)
334 {
335 block_out(b);
336 }
337 }while(inl > 0);
338
339 BIO_clear_retry_flags(b);
340 BIO_copy_next_retry(b);
341 return(ret);
342 }
343
344static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
345 {
346 BIO_OK_CTX *ctx;
347 EVP_MD *md;
348 const EVP_MD **ppmd;
349 long ret=1;
350 int i;
351
352 ctx=b->ptr;
353
354 switch (cmd)
355 {
356 case BIO_CTRL_RESET:
357 ctx->buf_len=0;
358 ctx->buf_off=0;
359 ctx->buf_len_save=0;
360 ctx->buf_off_save=0;
361 ctx->cont=1;
362 ctx->finished=0;
363 ctx->blockout= 0;
364 ctx->sigio=1;
365 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
366 break;
367 case BIO_CTRL_EOF: /* More to read */
368 if (ctx->cont <= 0)
369 ret=1;
370 else
371 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
372 break;
373 case BIO_CTRL_PENDING: /* More to read in buffer */
374 case BIO_CTRL_WPENDING: /* More to read in buffer */
375 ret=ctx->blockout ? ctx->buf_len-ctx->buf_off : 0;
376 if (ret <= 0)
377 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
378 break;
379 case BIO_CTRL_FLUSH:
380 /* do a final write */
381 if(ctx->blockout == 0)
382 block_out(b);
383
384 while (ctx->blockout)
385 {
386 i=ok_write(b,NULL,0);
387 if (i < 0)
388 {
389 ret=i;
390 break;
391 }
392 }
393
394 ctx->finished=1;
395 ctx->buf_off=ctx->buf_len=0;
396 ctx->cont=(int)ret;
397
398 /* Finally flush the underlying BIO */
399 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
400 break;
401 case BIO_C_DO_STATE_MACHINE:
402 BIO_clear_retry_flags(b);
403 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
404 BIO_copy_next_retry(b);
405 break;
406 case BIO_CTRL_INFO:
407 ret=(long)ctx->cont;
408 break;
409 case BIO_C_SET_MD:
410 md=ptr;
411 EVP_DigestInit_ex(&ctx->md, md, NULL);
412 b->init=1;
413 break;
414 case BIO_C_GET_MD:
415 if (b->init)
416 {
417 ppmd=ptr;
418 *ppmd=ctx->md.digest;
419 }
420 else
421 ret=0;
422 break;
423 default:
424 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
425 break;
426 }
427 return(ret);
428 }
429
430static long ok_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
431 {
432 long ret=1;
433
434 if (b->next_bio == NULL) return(0);
435 switch (cmd)
436 {
437 default:
438 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
439 break;
440 }
441 return(ret);
442 }
443
444static void longswap(void *_ptr, size_t len)
445{ const union { long one; char little; } is_endian = {1};
446
447 if (is_endian.little) {
448 size_t i;
449 unsigned char *p=_ptr,c;
450
451 for(i= 0;i < len;i+= 4) {
452 c=p[0],p[0]=p[3],p[3]=c;
453 c=p[1],p[1]=p[2],p[2]=c;
454 }
455 }
456}
457
458static void sig_out(BIO* b)
459 {
460 BIO_OK_CTX *ctx;
461 EVP_MD_CTX *md;
462
463 ctx=b->ptr;
464 md=&ctx->md;
465
466 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return;
467
468 EVP_DigestInit_ex(md, md->digest, NULL);
469 /* FIXME: there's absolutely no guarantee this makes any sense at all,
470 * particularly now EVP_MD_CTX has been restructured.
471 */
472 RAND_pseudo_bytes(md->md_data, md->digest->md_size);
473 memcpy(&(ctx->buf[ctx->buf_len]), md->md_data, md->digest->md_size);
474 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size);
475 ctx->buf_len+= md->digest->md_size;
476
477 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
478 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL);
479 ctx->buf_len+= md->digest->md_size;
480 ctx->blockout= 1;
481 ctx->sigio= 0;
482 }
483
484static void sig_in(BIO* b)
485 {
486 BIO_OK_CTX *ctx;
487 EVP_MD_CTX *md;
488 unsigned char tmp[EVP_MAX_MD_SIZE];
489 int ret= 0;
490
491 ctx=b->ptr;
492 md=&ctx->md;
493
494 if((int)(ctx->buf_len-ctx->buf_off) < 2*md->digest->md_size) return;
495
496 EVP_DigestInit_ex(md, md->digest, NULL);
497 memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size);
498 longswap(md->md_data, md->digest->md_size);
499 ctx->buf_off+= md->digest->md_size;
500
501 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
502 EVP_DigestFinal_ex(md, tmp, NULL);
503 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0;
504 ctx->buf_off+= md->digest->md_size;
505 if(ret == 1)
506 {
507 ctx->sigio= 0;
508 if(ctx->buf_len != ctx->buf_off)
509 {
510 memmove(ctx->buf, &(ctx->buf[ctx->buf_off]), ctx->buf_len- ctx->buf_off);
511 }
512 ctx->buf_len-= ctx->buf_off;
513 ctx->buf_off= 0;
514 }
515 else
516 {
517 ctx->cont= 0;
518 }
519 }
520
521static void block_out(BIO* b)
522 {
523 BIO_OK_CTX *ctx;
524 EVP_MD_CTX *md;
525 unsigned long tl;
526
527 ctx=b->ptr;
528 md=&ctx->md;
529
530 tl= ctx->buf_len- OK_BLOCK_BLOCK;
531 ctx->buf[0]=(unsigned char)(tl>>24);
532 ctx->buf[1]=(unsigned char)(tl>>16);
533 ctx->buf[2]=(unsigned char)(tl>>8);
534 ctx->buf[3]=(unsigned char)(tl);
535 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl);
536 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL);
537 ctx->buf_len+= md->digest->md_size;
538 ctx->blockout= 1;
539 }
540
541static void block_in(BIO* b)
542 {
543 BIO_OK_CTX *ctx;
544 EVP_MD_CTX *md;
545 unsigned long tl= 0;
546 unsigned char tmp[EVP_MAX_MD_SIZE];
547
548 ctx=b->ptr;
549 md=&ctx->md;
550
551 assert(sizeof(tl)>=OK_BLOCK_BLOCK); /* always true */
552 tl =ctx->buf[0]; tl<<=8;
553 tl|=ctx->buf[1]; tl<<=8;
554 tl|=ctx->buf[2]; tl<<=8;
555 tl|=ctx->buf[3];
556
557 if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return;
558
559 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl);
560 EVP_DigestFinal_ex(md, tmp, NULL);
561 if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0)
562 {
563 /* there might be parts from next block lurking around ! */
564 ctx->buf_off_save= tl+ OK_BLOCK_BLOCK+ md->digest->md_size;
565 ctx->buf_len_save= ctx->buf_len;
566 ctx->buf_off= OK_BLOCK_BLOCK;
567 ctx->buf_len= tl+ OK_BLOCK_BLOCK;
568 ctx->blockout= 1;
569 }
570 else
571 {
572 ctx->cont= 0;
573 }
574 }
575
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c
new file mode 100644
index 0000000000..c5f9268378
--- /dev/null
+++ b/src/lib/libcrypto/evp/c_allc.c
@@ -0,0 +1,224 @@
1/* crypto/evp/c_allc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_ciphers(void)
66 {
67
68#ifndef OPENSSL_NO_DES
69 EVP_add_cipher(EVP_des_cfb());
70 EVP_add_cipher(EVP_des_cfb1());
71 EVP_add_cipher(EVP_des_cfb8());
72 EVP_add_cipher(EVP_des_ede_cfb());
73 EVP_add_cipher(EVP_des_ede3_cfb());
74 EVP_add_cipher(EVP_des_ede3_cfb1());
75 EVP_add_cipher(EVP_des_ede3_cfb8());
76
77 EVP_add_cipher(EVP_des_ofb());
78 EVP_add_cipher(EVP_des_ede_ofb());
79 EVP_add_cipher(EVP_des_ede3_ofb());
80
81 EVP_add_cipher(EVP_desx_cbc());
82 EVP_add_cipher_alias(SN_desx_cbc,"DESX");
83 EVP_add_cipher_alias(SN_desx_cbc,"desx");
84
85 EVP_add_cipher(EVP_des_cbc());
86 EVP_add_cipher_alias(SN_des_cbc,"DES");
87 EVP_add_cipher_alias(SN_des_cbc,"des");
88 EVP_add_cipher(EVP_des_ede_cbc());
89 EVP_add_cipher(EVP_des_ede3_cbc());
90 EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
91 EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");
92
93 EVP_add_cipher(EVP_des_ecb());
94 EVP_add_cipher(EVP_des_ede());
95 EVP_add_cipher(EVP_des_ede3());
96#endif
97
98#ifndef OPENSSL_NO_RC4
99 EVP_add_cipher(EVP_rc4());
100 EVP_add_cipher(EVP_rc4_40());
101#endif
102
103#ifndef OPENSSL_NO_IDEA
104 EVP_add_cipher(EVP_idea_ecb());
105 EVP_add_cipher(EVP_idea_cfb());
106 EVP_add_cipher(EVP_idea_ofb());
107 EVP_add_cipher(EVP_idea_cbc());
108 EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
109 EVP_add_cipher_alias(SN_idea_cbc,"idea");
110#endif
111
112#ifndef OPENSSL_NO_SEED
113 EVP_add_cipher(EVP_seed_ecb());
114 EVP_add_cipher(EVP_seed_cfb());
115 EVP_add_cipher(EVP_seed_ofb());
116 EVP_add_cipher(EVP_seed_cbc());
117 EVP_add_cipher_alias(SN_seed_cbc,"SEED");
118 EVP_add_cipher_alias(SN_seed_cbc,"seed");
119#endif
120
121#ifndef OPENSSL_NO_RC2
122 EVP_add_cipher(EVP_rc2_ecb());
123 EVP_add_cipher(EVP_rc2_cfb());
124 EVP_add_cipher(EVP_rc2_ofb());
125 EVP_add_cipher(EVP_rc2_cbc());
126 EVP_add_cipher(EVP_rc2_40_cbc());
127 EVP_add_cipher(EVP_rc2_64_cbc());
128 EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
129 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
130#endif
131
132#ifndef OPENSSL_NO_BF
133 EVP_add_cipher(EVP_bf_ecb());
134 EVP_add_cipher(EVP_bf_cfb());
135 EVP_add_cipher(EVP_bf_ofb());
136 EVP_add_cipher(EVP_bf_cbc());
137 EVP_add_cipher_alias(SN_bf_cbc,"BF");
138 EVP_add_cipher_alias(SN_bf_cbc,"bf");
139 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
140#endif
141
142#ifndef OPENSSL_NO_CAST
143 EVP_add_cipher(EVP_cast5_ecb());
144 EVP_add_cipher(EVP_cast5_cfb());
145 EVP_add_cipher(EVP_cast5_ofb());
146 EVP_add_cipher(EVP_cast5_cbc());
147 EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
148 EVP_add_cipher_alias(SN_cast5_cbc,"cast");
149 EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
150 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
151#endif
152
153#ifndef OPENSSL_NO_RC5
154 EVP_add_cipher(EVP_rc5_32_12_16_ecb());
155 EVP_add_cipher(EVP_rc5_32_12_16_cfb());
156 EVP_add_cipher(EVP_rc5_32_12_16_ofb());
157 EVP_add_cipher(EVP_rc5_32_12_16_cbc());
158 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
159 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
160#endif
161
162#ifndef OPENSSL_NO_AES
163 EVP_add_cipher(EVP_aes_128_ecb());
164 EVP_add_cipher(EVP_aes_128_cbc());
165 EVP_add_cipher(EVP_aes_128_cfb());
166 EVP_add_cipher(EVP_aes_128_cfb1());
167 EVP_add_cipher(EVP_aes_128_cfb8());
168 EVP_add_cipher(EVP_aes_128_ofb());
169#if 0
170 EVP_add_cipher(EVP_aes_128_ctr());
171#endif
172 EVP_add_cipher_alias(SN_aes_128_cbc,"AES128");
173 EVP_add_cipher_alias(SN_aes_128_cbc,"aes128");
174 EVP_add_cipher(EVP_aes_192_ecb());
175 EVP_add_cipher(EVP_aes_192_cbc());
176 EVP_add_cipher(EVP_aes_192_cfb());
177 EVP_add_cipher(EVP_aes_192_cfb1());
178 EVP_add_cipher(EVP_aes_192_cfb8());
179 EVP_add_cipher(EVP_aes_192_ofb());
180#if 0
181 EVP_add_cipher(EVP_aes_192_ctr());
182#endif
183 EVP_add_cipher_alias(SN_aes_192_cbc,"AES192");
184 EVP_add_cipher_alias(SN_aes_192_cbc,"aes192");
185 EVP_add_cipher(EVP_aes_256_ecb());
186 EVP_add_cipher(EVP_aes_256_cbc());
187 EVP_add_cipher(EVP_aes_256_cfb());
188 EVP_add_cipher(EVP_aes_256_cfb1());
189 EVP_add_cipher(EVP_aes_256_cfb8());
190 EVP_add_cipher(EVP_aes_256_ofb());
191#if 0
192 EVP_add_cipher(EVP_aes_256_ctr());
193#endif
194 EVP_add_cipher_alias(SN_aes_256_cbc,"AES256");
195 EVP_add_cipher_alias(SN_aes_256_cbc,"aes256");
196#endif
197
198#ifndef OPENSSL_NO_CAMELLIA
199 EVP_add_cipher(EVP_camellia_128_ecb());
200 EVP_add_cipher(EVP_camellia_128_cbc());
201 EVP_add_cipher(EVP_camellia_128_cfb());
202 EVP_add_cipher(EVP_camellia_128_cfb1());
203 EVP_add_cipher(EVP_camellia_128_cfb8());
204 EVP_add_cipher(EVP_camellia_128_ofb());
205 EVP_add_cipher_alias(SN_camellia_128_cbc,"CAMELLIA128");
206 EVP_add_cipher_alias(SN_camellia_128_cbc,"camellia128");
207 EVP_add_cipher(EVP_camellia_192_ecb());
208 EVP_add_cipher(EVP_camellia_192_cbc());
209 EVP_add_cipher(EVP_camellia_192_cfb());
210 EVP_add_cipher(EVP_camellia_192_cfb1());
211 EVP_add_cipher(EVP_camellia_192_cfb8());
212 EVP_add_cipher(EVP_camellia_192_ofb());
213 EVP_add_cipher_alias(SN_camellia_192_cbc,"CAMELLIA192");
214 EVP_add_cipher_alias(SN_camellia_192_cbc,"camellia192");
215 EVP_add_cipher(EVP_camellia_256_ecb());
216 EVP_add_cipher(EVP_camellia_256_cbc());
217 EVP_add_cipher(EVP_camellia_256_cfb());
218 EVP_add_cipher(EVP_camellia_256_cfb1());
219 EVP_add_cipher(EVP_camellia_256_cfb8());
220 EVP_add_cipher(EVP_camellia_256_ofb());
221 EVP_add_cipher_alias(SN_camellia_256_cbc,"CAMELLIA256");
222 EVP_add_cipher_alias(SN_camellia_256_cbc,"camellia256");
223#endif
224 }
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c
new file mode 100644
index 0000000000..311e1fe2f8
--- /dev/null
+++ b/src/lib/libcrypto/evp/c_alld.c
@@ -0,0 +1,114 @@
1/* crypto/evp/c_alld.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_digests(void)
66 {
67#ifndef OPENSSL_NO_MD4
68 EVP_add_digest(EVP_md4());
69#endif
70#ifndef OPENSSL_NO_MD5
71 EVP_add_digest(EVP_md5());
72 EVP_add_digest_alias(SN_md5,"ssl2-md5");
73 EVP_add_digest_alias(SN_md5,"ssl3-md5");
74#endif
75#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
76 EVP_add_digest(EVP_sha());
77#ifndef OPENSSL_NO_DSA
78 EVP_add_digest(EVP_dss());
79#endif
80#endif
81#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
82 EVP_add_digest(EVP_sha1());
83 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
84 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
85#ifndef OPENSSL_NO_DSA
86 EVP_add_digest(EVP_dss1());
87 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
88 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
89 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
90#endif
91#ifndef OPENSSL_NO_ECDSA
92 EVP_add_digest(EVP_ecdsa());
93#endif
94#endif
95#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
96 EVP_add_digest(EVP_mdc2());
97#endif
98#ifndef OPENSSL_NO_RIPEMD
99 EVP_add_digest(EVP_ripemd160());
100 EVP_add_digest_alias(SN_ripemd160,"ripemd");
101 EVP_add_digest_alias(SN_ripemd160,"rmd160");
102#endif
103#ifndef OPENSSL_NO_SHA256
104 EVP_add_digest(EVP_sha224());
105 EVP_add_digest(EVP_sha256());
106#endif
107#ifndef OPENSSL_NO_SHA512
108 EVP_add_digest(EVP_sha384());
109 EVP_add_digest(EVP_sha512());
110#endif
111#ifndef OPENSSL_NO_WHIRLPOOL
112 EVP_add_digest(EVP_whirlpool());
113#endif
114 }
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index 467e6b5ae9..982ba2b136 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -117,10 +117,6 @@
117#include <openssl/engine.h> 117#include <openssl/engine.h>
118#endif 118#endif
119 119
120#ifdef OPENSSL_FIPS
121#include <openssl/fips.h>
122#endif
123
124void EVP_MD_CTX_init(EVP_MD_CTX *ctx) 120void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
125 { 121 {
126 memset(ctx,'\0',sizeof *ctx); 122 memset(ctx,'\0',sizeof *ctx);
@@ -229,26 +225,12 @@ skip_to_init:
229 } 225 }
230 if (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) 226 if (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT)
231 return 1; 227 return 1;
232#ifdef OPENSSL_FIPS
233 if (FIPS_mode())
234 {
235 if (FIPS_digestinit(ctx, type))
236 return 1;
237 OPENSSL_free(ctx->md_data);
238 ctx->md_data = NULL;
239 return 0;
240 }
241#endif
242 return ctx->digest->init(ctx); 228 return ctx->digest->init(ctx);
243 } 229 }
244 230
245int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count) 231int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
246 { 232 {
247#ifdef OPENSSL_FIPS
248 return FIPS_digestupdate(ctx, data, count);
249#else
250 return ctx->update(ctx,data,count); 233 return ctx->update(ctx,data,count);
251#endif
252 } 234 }
253 235
254/* The caller can assume that this removes any secret data from the context */ 236/* The caller can assume that this removes any secret data from the context */
@@ -263,10 +245,8 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
263/* The caller can assume that this removes any secret data from the context */ 245/* The caller can assume that this removes any secret data from the context */
264int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) 246int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
265 { 247 {
266#ifdef OPENSSL_FIPS
267 return FIPS_digestfinal(ctx, md, size);
268#else
269 int ret; 248 int ret;
249
270 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); 250 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
271 ret=ctx->digest->final(ctx,md); 251 ret=ctx->digest->final(ctx,md);
272 if (size != NULL) 252 if (size != NULL)
@@ -278,7 +258,6 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
278 } 258 }
279 memset(ctx->md_data,0,ctx->digest->ctx_size); 259 memset(ctx->md_data,0,ctx->digest->ctx_size);
280 return ret; 260 return ret;
281#endif
282 } 261 }
283 262
284int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) 263int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
@@ -372,7 +351,6 @@ void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
372/* This call frees resources associated with the context */ 351/* This call frees resources associated with the context */
373int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) 352int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
374 { 353 {
375#ifndef OPENSSL_FIPS
376 /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final, 354 /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final,
377 * because sometimes only copies of the context are ever finalised. 355 * because sometimes only copies of the context are ever finalised.
378 */ 356 */
@@ -385,7 +363,6 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
385 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); 363 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size);
386 OPENSSL_free(ctx->md_data); 364 OPENSSL_free(ctx->md_data);
387 } 365 }
388#endif
389 if (ctx->pctx) 366 if (ctx->pctx)
390 EVP_PKEY_CTX_free(ctx->pctx); 367 EVP_PKEY_CTX_free(ctx->pctx);
391#ifndef OPENSSL_NO_ENGINE 368#ifndef OPENSSL_NO_ENGINE
@@ -394,9 +371,6 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
394 * functional reference we held for this reason. */ 371 * functional reference we held for this reason. */
395 ENGINE_finish(ctx->engine); 372 ENGINE_finish(ctx->engine);
396#endif 373#endif
397#ifdef OPENSSL_FIPS
398 FIPS_md_ctx_cleanup(ctx);
399#endif
400 memset(ctx,'\0',sizeof *ctx); 374 memset(ctx,'\0',sizeof *ctx);
401 375
402 return 1; 376 return 1;
diff --git a/src/lib/libcrypto/evp/e_acss.c b/src/lib/libcrypto/evp/e_acss.c
new file mode 100644
index 0000000000..9084a63d51
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_acss.c
@@ -0,0 +1,85 @@
1/* $Id: e_acss.c,v 1.3 2010/10/01 23:33:22 djm Exp $ */
2/*
3 * Copyright (c) 2004 The OpenBSD project
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef OPENSSL_NO_ACSS
19
20#include "cryptlib.h"
21#include <openssl/evp.h>
22#include <openssl/objects.h>
23#include "evp_locl.h"
24#include <openssl/acss.h>
25
26typedef struct {
27 ACSS_KEY ks;
28} EVP_ACSS_KEY;
29
30#define data(ctx) EVP_C_DATA(EVP_ACSS_KEY,ctx)
31
32static int acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
33 const unsigned char *iv, int enc);
34static int acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out,
35 const unsigned char *in, size_t inl);
36static int acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
37static const EVP_CIPHER acss_cipher = {
38 NID_undef,
39 1,5,0,
40 0,
41 acss_init_key,
42 acss_ciph,
43 NULL,
44 sizeof(EVP_ACSS_KEY),
45 NULL,
46 NULL,
47 acss_ctrl,
48 NULL
49};
50
51const
52EVP_CIPHER *EVP_acss(void)
53{
54 return(&acss_cipher);
55}
56
57static int
58acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
59 const unsigned char *iv, int enc)
60{
61 acss_setkey(&data(ctx)->ks,key,enc,ACSS_MODE1);
62 return 1;
63}
64
65static int
66acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
67 size_t inl)
68{
69 acss(&data(ctx)->ks,inl,in,out);
70 return 1;
71}
72
73static int
74acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
75{
76 switch(type) {
77 case EVP_CTRL_SET_ACSS_MODE:
78 data(ctx)->ks.mode = arg;
79 return 1;
80
81 default:
82 return -1;
83 }
84}
85#endif
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index 1e4af0cb75..bd6c0a3a62 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -1,5 +1,5 @@
1/* ==================================================================== 1/* ====================================================================
2 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. 2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
@@ -56,511 +56,57 @@
56#include <assert.h> 56#include <assert.h>
57#include <openssl/aes.h> 57#include <openssl/aes.h>
58#include "evp_locl.h" 58#include "evp_locl.h"
59#ifndef OPENSSL_FIPS 59
60#include "modes_lcl.h" 60static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
61#include <openssl/rand.h> 61 const unsigned char *iv, int enc);
62 62
63typedef struct 63typedef struct
64 { 64 {
65 AES_KEY ks; 65 AES_KEY ks;
66 block128_f block;
67 union {
68 cbc128_f cbc;
69 ctr128_f ctr;
70 } stream;
71 } EVP_AES_KEY; 66 } EVP_AES_KEY;
72 67
73typedef struct 68#define data(ctx) EVP_C_DATA(EVP_AES_KEY,ctx)
74 { 69
75 AES_KEY ks; /* AES key schedule to use */ 70IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY,
76 int key_set; /* Set if key initialised */ 71 NID_aes_128, 16, 16, 16, 128,
77 int iv_set; /* Set if an iv is set */ 72 0, aes_init_key, NULL,
78 GCM128_CONTEXT gcm; 73 EVP_CIPHER_set_asn1_iv,
79 unsigned char *iv; /* Temporary IV store */ 74 EVP_CIPHER_get_asn1_iv,
80 int ivlen; /* IV length */ 75 NULL)
81 int taglen; 76IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY,
82 int iv_gen; /* It is OK to generate IVs */ 77 NID_aes_192, 16, 24, 16, 128,
83 int tls_aad_len; /* TLS AAD length */ 78 0, aes_init_key, NULL,
84 ctr128_f ctr; 79 EVP_CIPHER_set_asn1_iv,
85 } EVP_AES_GCM_CTX; 80 EVP_CIPHER_get_asn1_iv,
86 81 NULL)
87typedef struct 82IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
88 { 83 NID_aes_256, 16, 32, 16, 128,
89 AES_KEY ks1, ks2; /* AES key schedules to use */ 84 0, aes_init_key, NULL,
90 XTS128_CONTEXT xts; 85 EVP_CIPHER_set_asn1_iv,
91 void (*stream)(const unsigned char *in, 86 EVP_CIPHER_get_asn1_iv,
92 unsigned char *out, size_t length, 87 NULL)
93 const AES_KEY *key1, const AES_KEY *key2, 88
94 const unsigned char iv[16]); 89#define IMPLEMENT_AES_CFBR(ksize,cbits) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16)
95 } EVP_AES_XTS_CTX; 90
96 91IMPLEMENT_AES_CFBR(128,1)
97typedef struct 92IMPLEMENT_AES_CFBR(192,1)
98 { 93IMPLEMENT_AES_CFBR(256,1)
99 AES_KEY ks; /* AES key schedule to use */ 94
100 int key_set; /* Set if key initialised */ 95IMPLEMENT_AES_CFBR(128,8)
101 int iv_set; /* Set if an iv is set */ 96IMPLEMENT_AES_CFBR(192,8)
102 int tag_set; /* Set if tag is valid */ 97IMPLEMENT_AES_CFBR(256,8)
103 int len_set; /* Set if message length set */
104 int L, M; /* L and M parameters from RFC3610 */
105 CCM128_CONTEXT ccm;
106 ccm128_f str;
107 } EVP_AES_CCM_CTX;
108
109#define MAXBITCHUNK ((size_t)1<<(sizeof(size_t)*8-4))
110
111#ifdef VPAES_ASM
112int vpaes_set_encrypt_key(const unsigned char *userKey, int bits,
113 AES_KEY *key);
114int vpaes_set_decrypt_key(const unsigned char *userKey, int bits,
115 AES_KEY *key);
116
117void vpaes_encrypt(const unsigned char *in, unsigned char *out,
118 const AES_KEY *key);
119void vpaes_decrypt(const unsigned char *in, unsigned char *out,
120 const AES_KEY *key);
121
122void vpaes_cbc_encrypt(const unsigned char *in,
123 unsigned char *out,
124 size_t length,
125 const AES_KEY *key,
126 unsigned char *ivec, int enc);
127#endif
128#ifdef BSAES_ASM
129void bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out,
130 size_t length, const AES_KEY *key,
131 unsigned char ivec[16], int enc);
132void bsaes_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out,
133 size_t len, const AES_KEY *key,
134 const unsigned char ivec[16]);
135void bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out,
136 size_t len, const AES_KEY *key1,
137 const AES_KEY *key2, const unsigned char iv[16]);
138void bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out,
139 size_t len, const AES_KEY *key1,
140 const AES_KEY *key2, const unsigned char iv[16]);
141#endif
142#ifdef AES_CTR_ASM
143void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out,
144 size_t blocks, const AES_KEY *key,
145 const unsigned char ivec[AES_BLOCK_SIZE]);
146#endif
147#ifdef AES_XTS_ASM
148void AES_xts_encrypt(const char *inp,char *out,size_t len,
149 const AES_KEY *key1, const AES_KEY *key2,
150 const unsigned char iv[16]);
151void AES_xts_decrypt(const char *inp,char *out,size_t len,
152 const AES_KEY *key1, const AES_KEY *key2,
153 const unsigned char iv[16]);
154#endif
155
156#if defined(AES_ASM) && !defined(I386_ONLY) && ( \
157 ((defined(__i386) || defined(__i386__) || \
158 defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \
159 defined(__x86_64) || defined(__x86_64__) || \
160 defined(_M_AMD64) || defined(_M_X64) || \
161 defined(__INTEL__) )
162
163extern unsigned int OPENSSL_ia32cap_P[2];
164
165#ifdef VPAES_ASM
166#define VPAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32)))
167#endif
168#ifdef BSAES_ASM
169#define BSAES_CAPABLE VPAES_CAPABLE
170#endif
171/*
172 * AES-NI section
173 */
174#define AESNI_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
175
176int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
177 AES_KEY *key);
178int aesni_set_decrypt_key(const unsigned char *userKey, int bits,
179 AES_KEY *key);
180
181void aesni_encrypt(const unsigned char *in, unsigned char *out,
182 const AES_KEY *key);
183void aesni_decrypt(const unsigned char *in, unsigned char *out,
184 const AES_KEY *key);
185
186void aesni_ecb_encrypt(const unsigned char *in,
187 unsigned char *out,
188 size_t length,
189 const AES_KEY *key,
190 int enc);
191void aesni_cbc_encrypt(const unsigned char *in,
192 unsigned char *out,
193 size_t length,
194 const AES_KEY *key,
195 unsigned char *ivec, int enc);
196
197void aesni_ctr32_encrypt_blocks(const unsigned char *in,
198 unsigned char *out,
199 size_t blocks,
200 const void *key,
201 const unsigned char *ivec);
202
203void aesni_xts_encrypt(const unsigned char *in,
204 unsigned char *out,
205 size_t length,
206 const AES_KEY *key1, const AES_KEY *key2,
207 const unsigned char iv[16]);
208
209void aesni_xts_decrypt(const unsigned char *in,
210 unsigned char *out,
211 size_t length,
212 const AES_KEY *key1, const AES_KEY *key2,
213 const unsigned char iv[16]);
214
215void aesni_ccm64_encrypt_blocks (const unsigned char *in,
216 unsigned char *out,
217 size_t blocks,
218 const void *key,
219 const unsigned char ivec[16],
220 unsigned char cmac[16]);
221
222void aesni_ccm64_decrypt_blocks (const unsigned char *in,
223 unsigned char *out,
224 size_t blocks,
225 const void *key,
226 const unsigned char ivec[16],
227 unsigned char cmac[16]);
228
229static int aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
230 const unsigned char *iv, int enc)
231 {
232 int ret, mode;
233 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
234
235 mode = ctx->cipher->flags & EVP_CIPH_MODE;
236 if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE)
237 && !enc)
238 {
239 ret = aesni_set_decrypt_key(key, ctx->key_len*8, ctx->cipher_data);
240 dat->block = (block128_f)aesni_decrypt;
241 dat->stream.cbc = mode==EVP_CIPH_CBC_MODE ?
242 (cbc128_f)aesni_cbc_encrypt :
243 NULL;
244 }
245 else {
246 ret = aesni_set_encrypt_key(key, ctx->key_len*8, ctx->cipher_data);
247 dat->block = (block128_f)aesni_encrypt;
248 if (mode==EVP_CIPH_CBC_MODE)
249 dat->stream.cbc = (cbc128_f)aesni_cbc_encrypt;
250 else if (mode==EVP_CIPH_CTR_MODE)
251 dat->stream.ctr = (ctr128_f)aesni_ctr32_encrypt_blocks;
252 else
253 dat->stream.cbc = NULL;
254 }
255
256 if(ret < 0)
257 {
258 EVPerr(EVP_F_AESNI_INIT_KEY,EVP_R_AES_KEY_SETUP_FAILED);
259 return 0;
260 }
261
262 return 1;
263 }
264
265static int aesni_cbc_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
266 const unsigned char *in, size_t len)
267{
268 aesni_cbc_encrypt(in,out,len,ctx->cipher_data,ctx->iv,ctx->encrypt);
269
270 return 1;
271}
272
273static int aesni_ecb_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
274 const unsigned char *in, size_t len)
275{
276 size_t bl = ctx->cipher->block_size;
277
278 if (len<bl) return 1;
279
280 aesni_ecb_encrypt(in,out,len,ctx->cipher_data,ctx->encrypt);
281
282 return 1;
283}
284
285#define aesni_ofb_cipher aes_ofb_cipher
286static int aesni_ofb_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
287 const unsigned char *in,size_t len);
288
289#define aesni_cfb_cipher aes_cfb_cipher
290static int aesni_cfb_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
291 const unsigned char *in,size_t len);
292
293#define aesni_cfb8_cipher aes_cfb8_cipher
294static int aesni_cfb8_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
295 const unsigned char *in,size_t len);
296
297#define aesni_cfb1_cipher aes_cfb1_cipher
298static int aesni_cfb1_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
299 const unsigned char *in,size_t len);
300
301#define aesni_ctr_cipher aes_ctr_cipher
302static int aesni_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
303 const unsigned char *in, size_t len);
304
305static int aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
306 const unsigned char *iv, int enc)
307 {
308 EVP_AES_GCM_CTX *gctx = ctx->cipher_data;
309 if (!iv && !key)
310 return 1;
311 if (key)
312 {
313 aesni_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks);
314 CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks,
315 (block128_f)aesni_encrypt);
316 gctx->ctr = (ctr128_f)aesni_ctr32_encrypt_blocks;
317 /* If we have an iv can set it directly, otherwise use
318 * saved IV.
319 */
320 if (iv == NULL && gctx->iv_set)
321 iv = gctx->iv;
322 if (iv)
323 {
324 CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen);
325 gctx->iv_set = 1;
326 }
327 gctx->key_set = 1;
328 }
329 else
330 {
331 /* If key set use IV, otherwise copy */
332 if (gctx->key_set)
333 CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen);
334 else
335 memcpy(gctx->iv, iv, gctx->ivlen);
336 gctx->iv_set = 1;
337 gctx->iv_gen = 0;
338 }
339 return 1;
340 }
341
342#define aesni_gcm_cipher aes_gcm_cipher
343static int aesni_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
344 const unsigned char *in, size_t len);
345
346static int aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
347 const unsigned char *iv, int enc)
348 {
349 EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
350 if (!iv && !key)
351 return 1;
352
353 if (key)
354 {
355 /* key_len is two AES keys */
356 if (enc)
357 {
358 aesni_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1);
359 xctx->xts.block1 = (block128_f)aesni_encrypt;
360 xctx->stream = aesni_xts_encrypt;
361 }
362 else
363 {
364 aesni_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1);
365 xctx->xts.block1 = (block128_f)aesni_decrypt;
366 xctx->stream = aesni_xts_decrypt;
367 }
368
369 aesni_set_encrypt_key(key + ctx->key_len/2,
370 ctx->key_len * 4, &xctx->ks2);
371 xctx->xts.block2 = (block128_f)aesni_encrypt;
372
373 xctx->xts.key1 = &xctx->ks1;
374 }
375
376 if (iv)
377 {
378 xctx->xts.key2 = &xctx->ks2;
379 memcpy(ctx->iv, iv, 16);
380 }
381
382 return 1;
383 }
384
385#define aesni_xts_cipher aes_xts_cipher
386static int aesni_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
387 const unsigned char *in, size_t len);
388
389static int aesni_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
390 const unsigned char *iv, int enc)
391 {
392 EVP_AES_CCM_CTX *cctx = ctx->cipher_data;
393 if (!iv && !key)
394 return 1;
395 if (key)
396 {
397 aesni_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks);
398 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
399 &cctx->ks, (block128_f)aesni_encrypt);
400 cctx->str = enc?(ccm128_f)aesni_ccm64_encrypt_blocks :
401 (ccm128_f)aesni_ccm64_decrypt_blocks;
402 cctx->key_set = 1;
403 }
404 if (iv)
405 {
406 memcpy(ctx->iv, iv, 15 - cctx->L);
407 cctx->iv_set = 1;
408 }
409 return 1;
410 }
411
412#define aesni_ccm_cipher aes_ccm_cipher
413static int aesni_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
414 const unsigned char *in, size_t len);
415
416#define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
417static const EVP_CIPHER aesni_##keylen##_##mode = { \
418 nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
419 flags|EVP_CIPH_##MODE##_MODE, \
420 aesni_init_key, \
421 aesni_##mode##_cipher, \
422 NULL, \
423 sizeof(EVP_AES_KEY), \
424 NULL,NULL,NULL,NULL }; \
425static const EVP_CIPHER aes_##keylen##_##mode = { \
426 nid##_##keylen##_##nmode,blocksize, \
427 keylen/8,ivlen, \
428 flags|EVP_CIPH_##MODE##_MODE, \
429 aes_init_key, \
430 aes_##mode##_cipher, \
431 NULL, \
432 sizeof(EVP_AES_KEY), \
433 NULL,NULL,NULL,NULL }; \
434const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
435{ return AESNI_CAPABLE?&aesni_##keylen##_##mode:&aes_##keylen##_##mode; }
436
437#define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \
438static const EVP_CIPHER aesni_##keylen##_##mode = { \
439 nid##_##keylen##_##mode,blocksize, \
440 (EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE?2:1)*keylen/8, ivlen, \
441 flags|EVP_CIPH_##MODE##_MODE, \
442 aesni_##mode##_init_key, \
443 aesni_##mode##_cipher, \
444 aes_##mode##_cleanup, \
445 sizeof(EVP_AES_##MODE##_CTX), \
446 NULL,NULL,aes_##mode##_ctrl,NULL }; \
447static const EVP_CIPHER aes_##keylen##_##mode = { \
448 nid##_##keylen##_##mode,blocksize, \
449 (EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE?2:1)*keylen/8, ivlen, \
450 flags|EVP_CIPH_##MODE##_MODE, \
451 aes_##mode##_init_key, \
452 aes_##mode##_cipher, \
453 aes_##mode##_cleanup, \
454 sizeof(EVP_AES_##MODE##_CTX), \
455 NULL,NULL,aes_##mode##_ctrl,NULL }; \
456const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
457{ return AESNI_CAPABLE?&aesni_##keylen##_##mode:&aes_##keylen##_##mode; }
458
459#else
460
461#define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \
462static const EVP_CIPHER aes_##keylen##_##mode = { \
463 nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \
464 flags|EVP_CIPH_##MODE##_MODE, \
465 aes_init_key, \
466 aes_##mode##_cipher, \
467 NULL, \
468 sizeof(EVP_AES_KEY), \
469 NULL,NULL,NULL,NULL }; \
470const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
471{ return &aes_##keylen##_##mode; }
472
473#define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \
474static const EVP_CIPHER aes_##keylen##_##mode = { \
475 nid##_##keylen##_##mode,blocksize, \
476 (EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE?2:1)*keylen/8, ivlen, \
477 flags|EVP_CIPH_##MODE##_MODE, \
478 aes_##mode##_init_key, \
479 aes_##mode##_cipher, \
480 aes_##mode##_cleanup, \
481 sizeof(EVP_AES_##MODE##_CTX), \
482 NULL,NULL,aes_##mode##_ctrl,NULL }; \
483const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
484{ return &aes_##keylen##_##mode; }
485#endif
486
487#define BLOCK_CIPHER_generic_pack(nid,keylen,flags) \
488 BLOCK_CIPHER_generic(nid,keylen,16,16,cbc,cbc,CBC,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
489 BLOCK_CIPHER_generic(nid,keylen,16,0,ecb,ecb,ECB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
490 BLOCK_CIPHER_generic(nid,keylen,1,16,ofb128,ofb,OFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
491 BLOCK_CIPHER_generic(nid,keylen,1,16,cfb128,cfb,CFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \
492 BLOCK_CIPHER_generic(nid,keylen,1,16,cfb1,cfb1,CFB,flags) \
493 BLOCK_CIPHER_generic(nid,keylen,1,16,cfb8,cfb8,CFB,flags) \
494 BLOCK_CIPHER_generic(nid,keylen,1,16,ctr,ctr,CTR,flags)
495 98
496static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 99static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
497 const unsigned char *iv, int enc) 100 const unsigned char *iv, int enc)
498 { 101 {
499 int ret, mode; 102 int ret;
500 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
501 103
502 mode = ctx->cipher->flags & EVP_CIPH_MODE; 104 if ((ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_CFB_MODE
503 if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE) 105 || (ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_OFB_MODE
504 && !enc) 106 || enc)
505#ifdef BSAES_CAPABLE 107 ret=AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
506 if (BSAES_CAPABLE && mode==EVP_CIPH_CBC_MODE)
507 {
508 ret = AES_set_decrypt_key(key,ctx->key_len*8,&dat->ks);
509 dat->block = (block128_f)AES_decrypt;
510 dat->stream.cbc = (cbc128_f)bsaes_cbc_encrypt;
511 }
512 else
513#endif
514#ifdef VPAES_CAPABLE
515 if (VPAES_CAPABLE)
516 {
517 ret = vpaes_set_decrypt_key(key,ctx->key_len*8,&dat->ks);
518 dat->block = (block128_f)vpaes_decrypt;
519 dat->stream.cbc = mode==EVP_CIPH_CBC_MODE ?
520 (cbc128_f)vpaes_cbc_encrypt :
521 NULL;
522 }
523 else
524#endif
525 {
526 ret = AES_set_decrypt_key(key,ctx->key_len*8,&dat->ks);
527 dat->block = (block128_f)AES_decrypt;
528 dat->stream.cbc = mode==EVP_CIPH_CBC_MODE ?
529 (cbc128_f)AES_cbc_encrypt :
530 NULL;
531 }
532 else 108 else
533#ifdef BSAES_CAPABLE 109 ret=AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
534 if (BSAES_CAPABLE && mode==EVP_CIPH_CTR_MODE)
535 {
536 ret = AES_set_encrypt_key(key,ctx->key_len*8,&dat->ks);
537 dat->block = (block128_f)AES_encrypt;
538 dat->stream.ctr = (ctr128_f)bsaes_ctr32_encrypt_blocks;
539 }
540 else
541#endif
542#ifdef VPAES_CAPABLE
543 if (VPAES_CAPABLE)
544 {
545 ret = vpaes_set_encrypt_key(key,ctx->key_len*8,&dat->ks);
546 dat->block = (block128_f)vpaes_encrypt;
547 dat->stream.cbc = mode==EVP_CIPH_CBC_MODE ?
548 (cbc128_f)vpaes_cbc_encrypt :
549 NULL;
550 }
551 else
552#endif
553 {
554 ret = AES_set_encrypt_key(key,ctx->key_len*8,&dat->ks);
555 dat->block = (block128_f)AES_encrypt;
556 dat->stream.cbc = mode==EVP_CIPH_CBC_MODE ?
557 (cbc128_f)AES_cbc_encrypt :
558 NULL;
559#ifdef AES_CTR_ASM
560 if (mode==EVP_CIPH_CTR_MODE)
561 dat->stream.ctr = (ctr128_f)AES_ctr32_encrypt;
562#endif
563 }
564 110
565 if(ret < 0) 111 if(ret < 0)
566 { 112 {
@@ -571,743 +117,4 @@ static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
571 return 1; 117 return 1;
572 } 118 }
573 119
574static int aes_cbc_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
575 const unsigned char *in, size_t len)
576{
577 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
578
579 if (dat->stream.cbc)
580 (*dat->stream.cbc)(in,out,len,&dat->ks,ctx->iv,ctx->encrypt);
581 else if (ctx->encrypt)
582 CRYPTO_cbc128_encrypt(in,out,len,&dat->ks,ctx->iv,dat->block);
583 else
584 CRYPTO_cbc128_encrypt(in,out,len,&dat->ks,ctx->iv,dat->block);
585
586 return 1;
587}
588
589static int aes_ecb_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
590 const unsigned char *in, size_t len)
591{
592 size_t bl = ctx->cipher->block_size;
593 size_t i;
594 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
595
596 if (len<bl) return 1;
597
598 for (i=0,len-=bl;i<=len;i+=bl)
599 (*dat->block)(in+i,out+i,&dat->ks);
600
601 return 1;
602}
603
604static int aes_ofb_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
605 const unsigned char *in,size_t len)
606{
607 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
608
609 CRYPTO_ofb128_encrypt(in,out,len,&dat->ks,
610 ctx->iv,&ctx->num,dat->block);
611 return 1;
612}
613
614static int aes_cfb_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
615 const unsigned char *in,size_t len)
616{
617 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
618
619 CRYPTO_cfb128_encrypt(in,out,len,&dat->ks,
620 ctx->iv,&ctx->num,ctx->encrypt,dat->block);
621 return 1;
622}
623
624static int aes_cfb8_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
625 const unsigned char *in,size_t len)
626{
627 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
628
629 CRYPTO_cfb128_8_encrypt(in,out,len,&dat->ks,
630 ctx->iv,&ctx->num,ctx->encrypt,dat->block);
631 return 1;
632}
633
634static int aes_cfb1_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
635 const unsigned char *in,size_t len)
636{
637 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
638
639 if (ctx->flags&EVP_CIPH_FLAG_LENGTH_BITS) {
640 CRYPTO_cfb128_1_encrypt(in,out,len,&dat->ks,
641 ctx->iv,&ctx->num,ctx->encrypt,dat->block);
642 return 1;
643 }
644
645 while (len>=MAXBITCHUNK) {
646 CRYPTO_cfb128_1_encrypt(in,out,MAXBITCHUNK*8,&dat->ks,
647 ctx->iv,&ctx->num,ctx->encrypt,dat->block);
648 len-=MAXBITCHUNK;
649 }
650 if (len)
651 CRYPTO_cfb128_1_encrypt(in,out,len*8,&dat->ks,
652 ctx->iv,&ctx->num,ctx->encrypt,dat->block);
653
654 return 1;
655}
656
657static int aes_ctr_cipher (EVP_CIPHER_CTX *ctx, unsigned char *out,
658 const unsigned char *in, size_t len)
659{
660 unsigned int num = ctx->num;
661 EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
662
663 if (dat->stream.ctr)
664 CRYPTO_ctr128_encrypt_ctr32(in,out,len,&dat->ks,
665 ctx->iv,ctx->buf,&num,dat->stream.ctr);
666 else
667 CRYPTO_ctr128_encrypt(in,out,len,&dat->ks,
668 ctx->iv,ctx->buf,&num,dat->block);
669 ctx->num = (size_t)num;
670 return 1;
671}
672
673BLOCK_CIPHER_generic_pack(NID_aes,128,EVP_CIPH_FLAG_FIPS)
674BLOCK_CIPHER_generic_pack(NID_aes,192,EVP_CIPH_FLAG_FIPS)
675BLOCK_CIPHER_generic_pack(NID_aes,256,EVP_CIPH_FLAG_FIPS)
676
677static int aes_gcm_cleanup(EVP_CIPHER_CTX *c)
678 {
679 EVP_AES_GCM_CTX *gctx = c->cipher_data;
680 OPENSSL_cleanse(&gctx->gcm, sizeof(gctx->gcm));
681 if (gctx->iv != c->iv)
682 OPENSSL_free(gctx->iv);
683 return 1;
684 }
685
686/* increment counter (64-bit int) by 1 */
687static void ctr64_inc(unsigned char *counter) {
688 int n=8;
689 unsigned char c;
690
691 do {
692 --n;
693 c = counter[n];
694 ++c;
695 counter[n] = c;
696 if (c) return;
697 } while (n);
698}
699
700static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
701 {
702 EVP_AES_GCM_CTX *gctx = c->cipher_data;
703 switch (type)
704 {
705 case EVP_CTRL_INIT:
706 gctx->key_set = 0;
707 gctx->iv_set = 0;
708 gctx->ivlen = c->cipher->iv_len;
709 gctx->iv = c->iv;
710 gctx->taglen = -1;
711 gctx->iv_gen = 0;
712 gctx->tls_aad_len = -1;
713 return 1;
714
715 case EVP_CTRL_GCM_SET_IVLEN:
716 if (arg <= 0)
717 return 0;
718#ifdef OPENSSL_FIPS
719 if (FIPS_module_mode() && !(c->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW)
720 && arg < 12)
721 return 0;
722#endif
723 /* Allocate memory for IV if needed */
724 if ((arg > EVP_MAX_IV_LENGTH) && (arg > gctx->ivlen))
725 {
726 if (gctx->iv != c->iv)
727 OPENSSL_free(gctx->iv);
728 gctx->iv = OPENSSL_malloc(arg);
729 if (!gctx->iv)
730 return 0;
731 }
732 gctx->ivlen = arg;
733 return 1;
734
735 case EVP_CTRL_GCM_SET_TAG:
736 if (arg <= 0 || arg > 16 || c->encrypt)
737 return 0;
738 memcpy(c->buf, ptr, arg);
739 gctx->taglen = arg;
740 return 1;
741
742 case EVP_CTRL_GCM_GET_TAG:
743 if (arg <= 0 || arg > 16 || !c->encrypt || gctx->taglen < 0)
744 return 0;
745 memcpy(ptr, c->buf, arg);
746 return 1;
747
748 case EVP_CTRL_GCM_SET_IV_FIXED:
749 /* Special case: -1 length restores whole IV */
750 if (arg == -1)
751 {
752 memcpy(gctx->iv, ptr, gctx->ivlen);
753 gctx->iv_gen = 1;
754 return 1;
755 }
756 /* Fixed field must be at least 4 bytes and invocation field
757 * at least 8.
758 */
759 if ((arg < 4) || (gctx->ivlen - arg) < 8)
760 return 0;
761 if (arg)
762 memcpy(gctx->iv, ptr, arg);
763 if (c->encrypt &&
764 RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0)
765 return 0;
766 gctx->iv_gen = 1;
767 return 1;
768
769 case EVP_CTRL_GCM_IV_GEN:
770 if (gctx->iv_gen == 0 || gctx->key_set == 0)
771 return 0;
772 CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen);
773 if (arg <= 0 || arg > gctx->ivlen)
774 arg = gctx->ivlen;
775 memcpy(ptr, gctx->iv + gctx->ivlen - arg, arg);
776 /* Invocation field will be at least 8 bytes in size and
777 * so no need to check wrap around or increment more than
778 * last 8 bytes.
779 */
780 ctr64_inc(gctx->iv + gctx->ivlen - 8);
781 gctx->iv_set = 1;
782 return 1;
783
784 case EVP_CTRL_GCM_SET_IV_INV:
785 if (gctx->iv_gen == 0 || gctx->key_set == 0 || c->encrypt)
786 return 0;
787 memcpy(gctx->iv + gctx->ivlen - arg, ptr, arg);
788 CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen);
789 gctx->iv_set = 1;
790 return 1;
791
792 case EVP_CTRL_AEAD_TLS1_AAD:
793 /* Save the AAD for later use */
794 if (arg != 13)
795 return 0;
796 memcpy(c->buf, ptr, arg);
797 gctx->tls_aad_len = arg;
798 {
799 unsigned int len=c->buf[arg-2]<<8|c->buf[arg-1];
800 /* Correct length for explicit IV */
801 len -= EVP_GCM_TLS_EXPLICIT_IV_LEN;
802 /* If decrypting correct for tag too */
803 if (!c->encrypt)
804 len -= EVP_GCM_TLS_TAG_LEN;
805 c->buf[arg-2] = len>>8;
806 c->buf[arg-1] = len & 0xff;
807 }
808 /* Extra padding: tag appended to record */
809 return EVP_GCM_TLS_TAG_LEN;
810
811 default:
812 return -1;
813
814 }
815 }
816
817static int aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
818 const unsigned char *iv, int enc)
819 {
820 EVP_AES_GCM_CTX *gctx = ctx->cipher_data;
821 if (!iv && !key)
822 return 1;
823 if (key)
824 { do {
825#ifdef BSAES_CAPABLE
826 if (BSAES_CAPABLE)
827 {
828 AES_set_encrypt_key(key,ctx->key_len*8,&gctx->ks);
829 CRYPTO_gcm128_init(&gctx->gcm,&gctx->ks,
830 (block128_f)AES_encrypt);
831 gctx->ctr = (ctr128_f)bsaes_ctr32_encrypt_blocks;
832 break;
833 }
834 else
835#endif
836#ifdef VPAES_CAPABLE
837 if (VPAES_CAPABLE)
838 {
839 vpaes_set_encrypt_key(key,ctx->key_len*8,&gctx->ks);
840 CRYPTO_gcm128_init(&gctx->gcm,&gctx->ks,
841 (block128_f)vpaes_encrypt);
842 gctx->ctr = NULL;
843 break;
844 }
845#endif
846 AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks);
847 CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f)AES_encrypt);
848#ifdef AES_CTR_ASM
849 gctx->ctr = (ctr128_f)AES_ctr32_encrypt;
850#else
851 gctx->ctr = NULL;
852#endif
853 } while (0);
854
855 /* If we have an iv can set it directly, otherwise use
856 * saved IV.
857 */
858 if (iv == NULL && gctx->iv_set)
859 iv = gctx->iv;
860 if (iv)
861 {
862 CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen);
863 gctx->iv_set = 1;
864 }
865 gctx->key_set = 1;
866 }
867 else
868 {
869 /* If key set use IV, otherwise copy */
870 if (gctx->key_set)
871 CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen);
872 else
873 memcpy(gctx->iv, iv, gctx->ivlen);
874 gctx->iv_set = 1;
875 gctx->iv_gen = 0;
876 }
877 return 1;
878 }
879
880/* Handle TLS GCM packet format. This consists of the last portion of the IV
881 * followed by the payload and finally the tag. On encrypt generate IV,
882 * encrypt payload and write the tag. On verify retrieve IV, decrypt payload
883 * and verify tag.
884 */
885
886static int aes_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
887 const unsigned char *in, size_t len)
888 {
889 EVP_AES_GCM_CTX *gctx = ctx->cipher_data;
890 int rv = -1;
891 /* Encrypt/decrypt must be performed in place */
892 if (out != in || len < (EVP_GCM_TLS_EXPLICIT_IV_LEN+EVP_GCM_TLS_TAG_LEN))
893 return -1;
894 /* Set IV from start of buffer or generate IV and write to start
895 * of buffer.
896 */
897 if (EVP_CIPHER_CTX_ctrl(ctx, ctx->encrypt ?
898 EVP_CTRL_GCM_IV_GEN : EVP_CTRL_GCM_SET_IV_INV,
899 EVP_GCM_TLS_EXPLICIT_IV_LEN, out) <= 0)
900 goto err;
901 /* Use saved AAD */
902 if (CRYPTO_gcm128_aad(&gctx->gcm, ctx->buf, gctx->tls_aad_len))
903 goto err;
904 /* Fix buffer and length to point to payload */
905 in += EVP_GCM_TLS_EXPLICIT_IV_LEN;
906 out += EVP_GCM_TLS_EXPLICIT_IV_LEN;
907 len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN;
908 if (ctx->encrypt)
909 {
910 /* Encrypt payload */
911 if (gctx->ctr)
912 {
913 if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm,
914 in, out, len,
915 gctx->ctr))
916 goto err;
917 }
918 else {
919 if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, len))
920 goto err;
921 }
922 out += len;
923 /* Finally write tag */
924 CRYPTO_gcm128_tag(&gctx->gcm, out, EVP_GCM_TLS_TAG_LEN);
925 rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN;
926 }
927 else
928 {
929 /* Decrypt */
930 if (gctx->ctr)
931 {
932 if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm,
933 in, out, len,
934 gctx->ctr))
935 goto err;
936 }
937 else {
938 if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, len))
939 goto err;
940 }
941 /* Retrieve tag */
942 CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf,
943 EVP_GCM_TLS_TAG_LEN);
944 /* If tag mismatch wipe buffer */
945 if (memcmp(ctx->buf, in + len, EVP_GCM_TLS_TAG_LEN))
946 {
947 OPENSSL_cleanse(out, len);
948 goto err;
949 }
950 rv = len;
951 }
952
953 err:
954 gctx->iv_set = 0;
955 gctx->tls_aad_len = -1;
956 return rv;
957 }
958
959static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
960 const unsigned char *in, size_t len)
961 {
962 EVP_AES_GCM_CTX *gctx = ctx->cipher_data;
963 /* If not set up, return error */
964 if (!gctx->key_set)
965 return -1;
966
967 if (gctx->tls_aad_len >= 0)
968 return aes_gcm_tls_cipher(ctx, out, in, len);
969
970 if (!gctx->iv_set)
971 return -1;
972 if (!ctx->encrypt && gctx->taglen < 0)
973 return -1;
974 if (in)
975 {
976 if (out == NULL)
977 {
978 if (CRYPTO_gcm128_aad(&gctx->gcm, in, len))
979 return -1;
980 }
981 else if (ctx->encrypt)
982 {
983 if (gctx->ctr)
984 {
985 if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm,
986 in, out, len,
987 gctx->ctr))
988 return -1;
989 }
990 else {
991 if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, len))
992 return -1;
993 }
994 }
995 else
996 {
997 if (gctx->ctr)
998 {
999 if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm,
1000 in, out, len,
1001 gctx->ctr))
1002 return -1;
1003 }
1004 else {
1005 if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, len))
1006 return -1;
1007 }
1008 }
1009 return len;
1010 }
1011 else
1012 {
1013 if (!ctx->encrypt)
1014 {
1015 if (CRYPTO_gcm128_finish(&gctx->gcm,
1016 ctx->buf, gctx->taglen) != 0)
1017 return -1;
1018 gctx->iv_set = 0;
1019 return 0;
1020 }
1021 CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, 16);
1022 gctx->taglen = 16;
1023 /* Don't reuse the IV */
1024 gctx->iv_set = 0;
1025 return 0;
1026 }
1027
1028 }
1029
1030#define CUSTOM_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 \
1031 | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \
1032 | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT)
1033
1034BLOCK_CIPHER_custom(NID_aes,128,1,12,gcm,GCM,
1035 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS)
1036BLOCK_CIPHER_custom(NID_aes,192,1,12,gcm,GCM,
1037 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS)
1038BLOCK_CIPHER_custom(NID_aes,256,1,12,gcm,GCM,
1039 EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS)
1040
1041static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
1042 {
1043 EVP_AES_XTS_CTX *xctx = c->cipher_data;
1044 if (type != EVP_CTRL_INIT)
1045 return -1;
1046 /* key1 and key2 are used as an indicator both key and IV are set */
1047 xctx->xts.key1 = NULL;
1048 xctx->xts.key2 = NULL;
1049 return 1;
1050 }
1051
1052static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1053 const unsigned char *iv, int enc)
1054 {
1055 EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
1056 if (!iv && !key)
1057 return 1;
1058
1059 if (key) do
1060 {
1061#ifdef AES_XTS_ASM
1062 xctx->stream = enc ? AES_xts_encrypt : AES_xts_decrypt;
1063#else
1064 xctx->stream = NULL;
1065#endif
1066 /* key_len is two AES keys */
1067#ifdef BSAES_CAPABLE
1068 if (BSAES_CAPABLE)
1069 xctx->stream = enc ? bsaes_xts_encrypt : bsaes_xts_decrypt;
1070 else
1071#endif
1072#ifdef VPAES_CAPABLE
1073 if (VPAES_CAPABLE)
1074 {
1075 if (enc)
1076 {
1077 vpaes_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1);
1078 xctx->xts.block1 = (block128_f)vpaes_encrypt;
1079 }
1080 else
1081 {
1082 vpaes_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1);
1083 xctx->xts.block1 = (block128_f)vpaes_decrypt;
1084 }
1085
1086 vpaes_set_encrypt_key(key + ctx->key_len/2,
1087 ctx->key_len * 4, &xctx->ks2);
1088 xctx->xts.block2 = (block128_f)vpaes_encrypt;
1089
1090 xctx->xts.key1 = &xctx->ks1;
1091 break;
1092 }
1093#endif
1094 if (enc)
1095 {
1096 AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1);
1097 xctx->xts.block1 = (block128_f)AES_encrypt;
1098 }
1099 else
1100 {
1101 AES_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1);
1102 xctx->xts.block1 = (block128_f)AES_decrypt;
1103 }
1104
1105 AES_set_encrypt_key(key + ctx->key_len/2,
1106 ctx->key_len * 4, &xctx->ks2);
1107 xctx->xts.block2 = (block128_f)AES_encrypt;
1108
1109 xctx->xts.key1 = &xctx->ks1;
1110 } while (0);
1111
1112 if (iv)
1113 {
1114 xctx->xts.key2 = &xctx->ks2;
1115 memcpy(ctx->iv, iv, 16);
1116 }
1117
1118 return 1;
1119 }
1120
1121static int aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1122 const unsigned char *in, size_t len)
1123 {
1124 EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
1125 if (!xctx->xts.key1 || !xctx->xts.key2)
1126 return 0;
1127 if (!out || !in || len<AES_BLOCK_SIZE)
1128 return 0;
1129#ifdef OPENSSL_FIPS
1130 /* Requirement of SP800-38E */
1131 if (FIPS_module_mode() && !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW) &&
1132 (len > (1UL<<20)*16))
1133 {
1134 EVPerr(EVP_F_AES_XTS_CIPHER, EVP_R_TOO_LARGE);
1135 return 0;
1136 }
1137#endif
1138 if (xctx->stream)
1139 (*xctx->stream)(in, out, len,
1140 xctx->xts.key1, xctx->xts.key2, ctx->iv);
1141 else if (CRYPTO_xts128_encrypt(&xctx->xts, ctx->iv, in, out, len,
1142 ctx->encrypt))
1143 return 0;
1144 return 1;
1145 }
1146
1147#define aes_xts_cleanup NULL
1148
1149#define XTS_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV \
1150 | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT)
1151
1152BLOCK_CIPHER_custom(NID_aes,128,1,16,xts,XTS,EVP_CIPH_FLAG_FIPS|XTS_FLAGS)
1153BLOCK_CIPHER_custom(NID_aes,256,1,16,xts,XTS,EVP_CIPH_FLAG_FIPS|XTS_FLAGS)
1154
1155static int aes_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
1156 {
1157 EVP_AES_CCM_CTX *cctx = c->cipher_data;
1158 switch (type)
1159 {
1160 case EVP_CTRL_INIT:
1161 cctx->key_set = 0;
1162 cctx->iv_set = 0;
1163 cctx->L = 8;
1164 cctx->M = 12;
1165 cctx->tag_set = 0;
1166 cctx->len_set = 0;
1167 return 1;
1168
1169 case EVP_CTRL_CCM_SET_IVLEN:
1170 arg = 15 - arg;
1171 case EVP_CTRL_CCM_SET_L:
1172 if (arg < 2 || arg > 8)
1173 return 0;
1174 cctx->L = arg;
1175 return 1;
1176
1177 case EVP_CTRL_CCM_SET_TAG:
1178 if ((arg & 1) || arg < 4 || arg > 16)
1179 return 0;
1180 if ((c->encrypt && ptr) || (!c->encrypt && !ptr))
1181 return 0;
1182 if (ptr)
1183 {
1184 cctx->tag_set = 1;
1185 memcpy(c->buf, ptr, arg);
1186 }
1187 cctx->M = arg;
1188 return 1;
1189
1190 case EVP_CTRL_CCM_GET_TAG:
1191 if (!c->encrypt || !cctx->tag_set)
1192 return 0;
1193 if(!CRYPTO_ccm128_tag(&cctx->ccm, ptr, (size_t)arg))
1194 return 0;
1195 cctx->tag_set = 0;
1196 cctx->iv_set = 0;
1197 cctx->len_set = 0;
1198 return 1;
1199
1200 default:
1201 return -1;
1202
1203 }
1204 }
1205
1206static int aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
1207 const unsigned char *iv, int enc)
1208 {
1209 EVP_AES_CCM_CTX *cctx = ctx->cipher_data;
1210 if (!iv && !key)
1211 return 1;
1212 if (key) do
1213 {
1214#ifdef VPAES_CAPABLE
1215 if (VPAES_CAPABLE)
1216 {
1217 vpaes_set_encrypt_key(key, ctx->key_len*8, &cctx->ks);
1218 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
1219 &cctx->ks, (block128_f)vpaes_encrypt);
1220 cctx->key_set = 1;
1221 break;
1222 }
1223#endif
1224 AES_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks);
1225 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
1226 &cctx->ks, (block128_f)AES_encrypt);
1227 cctx->str = NULL;
1228 cctx->key_set = 1;
1229 } while (0);
1230 if (iv)
1231 {
1232 memcpy(ctx->iv, iv, 15 - cctx->L);
1233 cctx->iv_set = 1;
1234 }
1235 return 1;
1236 }
1237
1238static int aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
1239 const unsigned char *in, size_t len)
1240 {
1241 EVP_AES_CCM_CTX *cctx = ctx->cipher_data;
1242 CCM128_CONTEXT *ccm = &cctx->ccm;
1243 /* If not set up, return error */
1244 if (!cctx->iv_set && !cctx->key_set)
1245 return -1;
1246 if (!ctx->encrypt && !cctx->tag_set)
1247 return -1;
1248 if (!out)
1249 {
1250 if (!in)
1251 {
1252 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L,len))
1253 return -1;
1254 cctx->len_set = 1;
1255 return len;
1256 }
1257 /* If have AAD need message length */
1258 if (!cctx->len_set && len)
1259 return -1;
1260 CRYPTO_ccm128_aad(ccm, in, len);
1261 return len;
1262 }
1263 /* EVP_*Final() doesn't return any data */
1264 if (!in)
1265 return 0;
1266 /* If not set length yet do it */
1267 if (!cctx->len_set)
1268 {
1269 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len))
1270 return -1;
1271 cctx->len_set = 1;
1272 }
1273 if (ctx->encrypt)
1274 {
1275 if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len,
1276 cctx->str) :
1277 CRYPTO_ccm128_encrypt(ccm, in, out, len))
1278 return -1;
1279 cctx->tag_set = 1;
1280 return len;
1281 }
1282 else
1283 {
1284 int rv = -1;
1285 if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len,
1286 cctx->str) :
1287 !CRYPTO_ccm128_decrypt(ccm, in, out, len))
1288 {
1289 unsigned char tag[16];
1290 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M))
1291 {
1292 if (!memcmp(tag, ctx->buf, cctx->M))
1293 rv = len;
1294 }
1295 }
1296 if (rv == -1)
1297 OPENSSL_cleanse(out, len);
1298 cctx->iv_set = 0;
1299 cctx->tag_set = 0;
1300 cctx->len_set = 0;
1301 return rv;
1302 }
1303
1304 }
1305
1306#define aes_ccm_cleanup NULL
1307
1308BLOCK_CIPHER_custom(NID_aes,128,1,12,ccm,CCM,EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS)
1309BLOCK_CIPHER_custom(NID_aes,192,1,12,ccm,CCM,EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS)
1310BLOCK_CIPHER_custom(NID_aes,256,1,12,ccm,CCM,EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS)
1311
1312#endif
1313#endif 120#endif
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c
index 1e69972662..3232cfe024 100644
--- a/src/lib/libcrypto/evp/e_des3.c
+++ b/src/lib/libcrypto/evp/e_des3.c
@@ -65,8 +65,6 @@
65#include <openssl/des.h> 65#include <openssl/des.h>
66#include <openssl/rand.h> 66#include <openssl/rand.h>
67 67
68#ifndef OPENSSL_FIPS
69
70static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 68static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
71 const unsigned char *iv,int enc); 69 const unsigned char *iv,int enc);
72 70
@@ -313,4 +311,3 @@ const EVP_CIPHER *EVP_des_ede3(void)
313 return &des_ede3_ecb; 311 return &des_ede3_ecb;
314} 312}
315#endif 313#endif
316#endif
diff --git a/src/lib/libcrypto/evp/e_dsa.c b/src/lib/libcrypto/evp/e_dsa.c
new file mode 100644
index 0000000000..b96f2738b3
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_dsa.c
@@ -0,0 +1,71 @@
1/* crypto/evp/e_dsa.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/objects.h>
63#include <openssl/x509.h>
64
65static EVP_PKEY_METHOD dss_method=
66 {
67 DSA_sign,
68 DSA_verify,
69 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3,NULL},
70 };
71
diff --git a/src/lib/libcrypto/evp/e_null.c b/src/lib/libcrypto/evp/e_null.c
index f0c1f78b5f..7cf50e1416 100644
--- a/src/lib/libcrypto/evp/e_null.c
+++ b/src/lib/libcrypto/evp/e_null.c
@@ -61,8 +61,6 @@
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63 63
64#ifndef OPENSSL_FIPS
65
66static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 64static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 const unsigned char *iv,int enc); 65 const unsigned char *iv,int enc);
68static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 66static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -101,4 +99,4 @@ static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
101 memcpy((char *)out,(const char *)in,inl); 99 memcpy((char *)out,(const char *)in,inl);
102 return 1; 100 return 1;
103 } 101 }
104#endif 102
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c
index d4c33b58d4..f78d781129 100644
--- a/src/lib/libcrypto/evp/e_rc2.c
+++ b/src/lib/libcrypto/evp/e_rc2.c
@@ -183,8 +183,7 @@ static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
183 key_bits =rc2_magic_to_meth((int)num); 183 key_bits =rc2_magic_to_meth((int)num);
184 if (!key_bits) 184 if (!key_bits)
185 return(-1); 185 return(-1);
186 if(i > 0 && !EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1)) 186 if(i > 0) EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1);
187 return -1;
188 EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); 187 EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
189 EVP_CIPHER_CTX_set_key_length(c, key_bits / 8); 188 EVP_CIPHER_CTX_set_key_length(c, key_bits / 8);
190 } 189 }
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index b4f6bda82d..8b5175e0fd 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -62,7 +62,6 @@
62#ifndef OPENSSL_NO_RC4 62#ifndef OPENSSL_NO_RC4
63 63
64#include <openssl/evp.h> 64#include <openssl/evp.h>
65#include "evp_locl.h"
66#include <openssl/objects.h> 65#include <openssl/objects.h>
67#include <openssl/rc4.h> 66#include <openssl/rc4.h>
68 67
diff --git a/src/lib/libcrypto/evp/e_rc5.c b/src/lib/libcrypto/evp/e_rc5.c
new file mode 100644
index 0000000000..19a10c6402
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_rc5.c
@@ -0,0 +1,126 @@
1/* crypto/evp/e_rc5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61
62#ifndef OPENSSL_NO_RC5
63
64#include <openssl/evp.h>
65#include <openssl/objects.h>
66#include "evp_locl.h"
67#include <openssl/rc5.h>
68
69static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
70 const unsigned char *iv,int enc);
71static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
72
73typedef struct
74 {
75 int rounds; /* number of rounds */
76 RC5_32_KEY ks; /* key schedule */
77 } EVP_RC5_KEY;
78
79#define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx)
80
81IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5,
82 8, RC5_32_KEY_LENGTH, 8, 64,
83 EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
84 r_32_12_16_init_key, NULL,
85 NULL, NULL, rc5_ctrl)
86
87static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
88 {
89 switch(type)
90 {
91 case EVP_CTRL_INIT:
92 data(c)->rounds = RC5_12_ROUNDS;
93 return 1;
94
95 case EVP_CTRL_GET_RC5_ROUNDS:
96 *(int *)ptr = data(c)->rounds;
97 return 1;
98
99 case EVP_CTRL_SET_RC5_ROUNDS:
100 switch(arg)
101 {
102 case RC5_8_ROUNDS:
103 case RC5_12_ROUNDS:
104 case RC5_16_ROUNDS:
105 data(c)->rounds = arg;
106 return 1;
107
108 default:
109 EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS);
110 return 0;
111 }
112
113 default:
114 return -1;
115 }
116 }
117
118static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
119 const unsigned char *iv, int enc)
120 {
121 RC5_32_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
122 key,data(ctx)->rounds);
123 return 1;
124 }
125
126#endif
diff --git a/src/lib/libcrypto/evp/e_seed.c b/src/lib/libcrypto/evp/e_seed.c
new file mode 100644
index 0000000000..2d1759d276
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_seed.c
@@ -0,0 +1,83 @@
1/* crypto/evp/e_seed.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 2007 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include <openssl/opensslconf.h>
57#ifndef OPENSSL_NO_SEED
58#include <openssl/evp.h>
59#include <openssl/err.h>
60#include <string.h>
61#include <assert.h>
62#include <openssl/seed.h>
63#include "evp_locl.h"
64
65static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc);
66
67typedef struct
68 {
69 SEED_KEY_SCHEDULE ks;
70 } EVP_SEED_KEY;
71
72IMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed,
73 16, 16, 16, 128,
74 0, seed_init_key, 0, 0, 0, 0)
75
76static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
77 const unsigned char *iv, int enc)
78 {
79 SEED_set_key(key, ctx->cipher_data);
80 return 1;
81 }
82
83#endif
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 0d1b20a7d3..da93e945f5 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -83,7 +83,7 @@
83#define EVP_RC5_32_12_16_KEY_SIZE 16 83#define EVP_RC5_32_12_16_KEY_SIZE 16
84*/ 84*/
85#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ 85#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */
86#define EVP_MAX_KEY_LENGTH 64 86#define EVP_MAX_KEY_LENGTH 32
87#define EVP_MAX_IV_LENGTH 16 87#define EVP_MAX_IV_LENGTH 16
88#define EVP_MAX_BLOCK_LENGTH 32 88#define EVP_MAX_BLOCK_LENGTH 32
89 89
@@ -116,7 +116,6 @@
116#define EVP_PKEY_DH NID_dhKeyAgreement 116#define EVP_PKEY_DH NID_dhKeyAgreement
117#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey 117#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
118#define EVP_PKEY_HMAC NID_hmac 118#define EVP_PKEY_HMAC NID_hmac
119#define EVP_PKEY_CMAC NID_cmac
120 119
121#ifdef __cplusplus 120#ifdef __cplusplus
122extern "C" { 121extern "C" {
@@ -217,8 +216,6 @@ typedef int evp_verify_method(int type,const unsigned char *m,
217 216
218#define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018 217#define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018
219 218
220#define EVP_MD_FLAG_FIPS 0x0400 /* Note if suitable for use in FIPS mode */
221
222/* Digest ctrls */ 219/* Digest ctrls */
223 220
224#define EVP_MD_CTRL_DIGALGID 0x1 221#define EVP_MD_CTRL_DIGALGID 0x1
@@ -328,10 +325,6 @@ struct evp_cipher_st
328#define EVP_CIPH_CBC_MODE 0x2 325#define EVP_CIPH_CBC_MODE 0x2
329#define EVP_CIPH_CFB_MODE 0x3 326#define EVP_CIPH_CFB_MODE 0x3
330#define EVP_CIPH_OFB_MODE 0x4 327#define EVP_CIPH_OFB_MODE 0x4
331#define EVP_CIPH_CTR_MODE 0x5
332#define EVP_CIPH_GCM_MODE 0x6
333#define EVP_CIPH_CCM_MODE 0x7
334#define EVP_CIPH_XTS_MODE 0x10001
335#define EVP_CIPH_MODE 0xF0007 328#define EVP_CIPH_MODE 0xF0007
336/* Set if variable length cipher */ 329/* Set if variable length cipher */
337#define EVP_CIPH_VARIABLE_LENGTH 0x8 330#define EVP_CIPH_VARIABLE_LENGTH 0x8
@@ -353,15 +346,6 @@ struct evp_cipher_st
353#define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000 346#define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000
354/* Buffer length in bits not bytes: CFB1 mode only */ 347/* Buffer length in bits not bytes: CFB1 mode only */
355#define EVP_CIPH_FLAG_LENGTH_BITS 0x2000 348#define EVP_CIPH_FLAG_LENGTH_BITS 0x2000
356/* Note if suitable for use in FIPS mode */
357#define EVP_CIPH_FLAG_FIPS 0x4000
358/* Allow non FIPS cipher in FIPS mode */
359#define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x8000
360/* Cipher handles any and all padding logic as well
361 * as finalisation.
362 */
363#define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000
364#define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000
365 349
366/* ctrl() values */ 350/* ctrl() values */
367 351
@@ -374,34 +358,7 @@ struct evp_cipher_st
374#define EVP_CTRL_RAND_KEY 0x6 358#define EVP_CTRL_RAND_KEY 0x6
375#define EVP_CTRL_PBE_PRF_NID 0x7 359#define EVP_CTRL_PBE_PRF_NID 0x7
376#define EVP_CTRL_COPY 0x8 360#define EVP_CTRL_COPY 0x8
377#define EVP_CTRL_GCM_SET_IVLEN 0x9 361#define EVP_CTRL_SET_ACSS_MODE 0x9
378#define EVP_CTRL_GCM_GET_TAG 0x10
379#define EVP_CTRL_GCM_SET_TAG 0x11
380#define EVP_CTRL_GCM_SET_IV_FIXED 0x12
381#define EVP_CTRL_GCM_IV_GEN 0x13
382#define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_GCM_SET_IVLEN
383#define EVP_CTRL_CCM_GET_TAG EVP_CTRL_GCM_GET_TAG
384#define EVP_CTRL_CCM_SET_TAG EVP_CTRL_GCM_SET_TAG
385#define EVP_CTRL_CCM_SET_L 0x14
386#define EVP_CTRL_CCM_SET_MSGLEN 0x15
387/* AEAD cipher deduces payload length and returns number of bytes
388 * required to store MAC and eventual padding. Subsequent call to
389 * EVP_Cipher even appends/verifies MAC.
390 */
391#define EVP_CTRL_AEAD_TLS1_AAD 0x16
392/* Used by composite AEAD ciphers, no-op in GCM, CCM... */
393#define EVP_CTRL_AEAD_SET_MAC_KEY 0x17
394/* Set the GCM invocation field, decrypt only */
395#define EVP_CTRL_GCM_SET_IV_INV 0x18
396
397/* GCM TLS constants */
398/* Length of fixed part of IV derived from PRF */
399#define EVP_GCM_TLS_FIXED_IV_LEN 4
400/* Length of explicit part of IV part of TLS records */
401#define EVP_GCM_TLS_EXPLICIT_IV_LEN 8
402/* Length of tag for TLS */
403#define EVP_GCM_TLS_TAG_LEN 16
404
405 362
406typedef struct evp_cipher_info_st 363typedef struct evp_cipher_info_st
407 { 364 {
@@ -419,7 +376,7 @@ struct evp_cipher_ctx_st
419 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ 376 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
420 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ 377 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
421 unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ 378 unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
422 int num; /* used by cfb/ofb/ctr mode */ 379 int num; /* used by cfb/ofb mode */
423 380
424 void *app_data; /* application stuff */ 381 void *app_data; /* application stuff */
425 int key_len; /* May change for variable length cipher */ 382 int key_len; /* May change for variable length cipher */
@@ -739,9 +696,6 @@ const EVP_MD *EVP_dev_crypto_md5(void);
739#ifndef OPENSSL_NO_RC4 696#ifndef OPENSSL_NO_RC4
740const EVP_CIPHER *EVP_rc4(void); 697const EVP_CIPHER *EVP_rc4(void);
741const EVP_CIPHER *EVP_rc4_40(void); 698const EVP_CIPHER *EVP_rc4_40(void);
742#ifndef OPENSSL_NO_MD5
743const EVP_CIPHER *EVP_rc4_hmac_md5(void);
744#endif
745#endif 699#endif
746#ifndef OPENSSL_NO_IDEA 700#ifndef OPENSSL_NO_IDEA
747const EVP_CIPHER *EVP_idea_ecb(void); 701const EVP_CIPHER *EVP_idea_ecb(void);
@@ -788,10 +742,9 @@ const EVP_CIPHER *EVP_aes_128_cfb8(void);
788const EVP_CIPHER *EVP_aes_128_cfb128(void); 742const EVP_CIPHER *EVP_aes_128_cfb128(void);
789# define EVP_aes_128_cfb EVP_aes_128_cfb128 743# define EVP_aes_128_cfb EVP_aes_128_cfb128
790const EVP_CIPHER *EVP_aes_128_ofb(void); 744const EVP_CIPHER *EVP_aes_128_ofb(void);
745#if 0
791const EVP_CIPHER *EVP_aes_128_ctr(void); 746const EVP_CIPHER *EVP_aes_128_ctr(void);
792const EVP_CIPHER *EVP_aes_128_gcm(void); 747#endif
793const EVP_CIPHER *EVP_aes_128_ccm(void);
794const EVP_CIPHER *EVP_aes_128_xts(void);
795const EVP_CIPHER *EVP_aes_192_ecb(void); 748const EVP_CIPHER *EVP_aes_192_ecb(void);
796const EVP_CIPHER *EVP_aes_192_cbc(void); 749const EVP_CIPHER *EVP_aes_192_cbc(void);
797const EVP_CIPHER *EVP_aes_192_cfb1(void); 750const EVP_CIPHER *EVP_aes_192_cfb1(void);
@@ -799,9 +752,9 @@ const EVP_CIPHER *EVP_aes_192_cfb8(void);
799const EVP_CIPHER *EVP_aes_192_cfb128(void); 752const EVP_CIPHER *EVP_aes_192_cfb128(void);
800# define EVP_aes_192_cfb EVP_aes_192_cfb128 753# define EVP_aes_192_cfb EVP_aes_192_cfb128
801const EVP_CIPHER *EVP_aes_192_ofb(void); 754const EVP_CIPHER *EVP_aes_192_ofb(void);
755#if 0
802const EVP_CIPHER *EVP_aes_192_ctr(void); 756const EVP_CIPHER *EVP_aes_192_ctr(void);
803const EVP_CIPHER *EVP_aes_192_gcm(void); 757#endif
804const EVP_CIPHER *EVP_aes_192_ccm(void);
805const EVP_CIPHER *EVP_aes_256_ecb(void); 758const EVP_CIPHER *EVP_aes_256_ecb(void);
806const EVP_CIPHER *EVP_aes_256_cbc(void); 759const EVP_CIPHER *EVP_aes_256_cbc(void);
807const EVP_CIPHER *EVP_aes_256_cfb1(void); 760const EVP_CIPHER *EVP_aes_256_cfb1(void);
@@ -809,15 +762,13 @@ const EVP_CIPHER *EVP_aes_256_cfb8(void);
809const EVP_CIPHER *EVP_aes_256_cfb128(void); 762const EVP_CIPHER *EVP_aes_256_cfb128(void);
810# define EVP_aes_256_cfb EVP_aes_256_cfb128 763# define EVP_aes_256_cfb EVP_aes_256_cfb128
811const EVP_CIPHER *EVP_aes_256_ofb(void); 764const EVP_CIPHER *EVP_aes_256_ofb(void);
765#if 0
812const EVP_CIPHER *EVP_aes_256_ctr(void); 766const EVP_CIPHER *EVP_aes_256_ctr(void);
813const EVP_CIPHER *EVP_aes_256_gcm(void);
814const EVP_CIPHER *EVP_aes_256_ccm(void);
815const EVP_CIPHER *EVP_aes_256_xts(void);
816#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
817const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
818const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
819#endif 767#endif
820#endif 768#endif
769#ifndef OPENSSL_NO_ACSS
770const EVP_CIPHER *EVP_acss(void);
771#endif
821#ifndef OPENSSL_NO_CAMELLIA 772#ifndef OPENSSL_NO_CAMELLIA
822const EVP_CIPHER *EVP_camellia_128_ecb(void); 773const EVP_CIPHER *EVP_camellia_128_ecb(void);
823const EVP_CIPHER *EVP_camellia_128_cbc(void); 774const EVP_CIPHER *EVP_camellia_128_cbc(void);
@@ -1100,22 +1051,13 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1100#define EVP_PKEY_CTRL_CMS_DECRYPT 10 1051#define EVP_PKEY_CTRL_CMS_DECRYPT 10
1101#define EVP_PKEY_CTRL_CMS_SIGN 11 1052#define EVP_PKEY_CTRL_CMS_SIGN 11
1102 1053
1103#define EVP_PKEY_CTRL_CIPHER 12
1104
1105#define EVP_PKEY_ALG_CTRL 0x1000 1054#define EVP_PKEY_ALG_CTRL 0x1000
1106 1055
1107 1056
1108#define EVP_PKEY_FLAG_AUTOARGLEN 2 1057#define EVP_PKEY_FLAG_AUTOARGLEN 2
1109/* Method handles all operations: don't assume any digest related
1110 * defaults.
1111 */
1112#define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4
1113 1058
1114const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type); 1059const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
1115EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags); 1060EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags);
1116void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
1117 const EVP_PKEY_METHOD *meth);
1118void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
1119void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth); 1061void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
1120int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth); 1062int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
1121 1063
@@ -1133,7 +1075,7 @@ int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
1133void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen); 1075void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
1134 1076
1135EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, 1077EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
1136 const unsigned char *key, int keylen); 1078 unsigned char *key, int keylen);
1137 1079
1138void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data); 1080void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
1139void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx); 1081void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
@@ -1252,13 +1194,9 @@ void ERR_load_EVP_strings(void);
1252/* Error codes for the EVP functions. */ 1194/* Error codes for the EVP functions. */
1253 1195
1254/* Function codes. */ 1196/* Function codes. */
1255#define EVP_F_AESNI_INIT_KEY 165 1197#define EVP_F_AESNI_INIT_KEY 165
1256#define EVP_F_AESNI_XTS_CIPHER 176
1257#define EVP_F_AES_INIT_KEY 133 1198#define EVP_F_AES_INIT_KEY 133
1258#define EVP_F_AES_XTS 172
1259#define EVP_F_AES_XTS_CIPHER 175
1260#define EVP_F_CAMELLIA_INIT_KEY 159 1199#define EVP_F_CAMELLIA_INIT_KEY 159
1261#define EVP_F_CMAC_INIT 173
1262#define EVP_F_D2I_PKEY 100 1200#define EVP_F_D2I_PKEY 100
1263#define EVP_F_DO_SIGVER_INIT 161 1201#define EVP_F_DO_SIGVER_INIT 161
1264#define EVP_F_DSAPKEY2PKCS8 134 1202#define EVP_F_DSAPKEY2PKCS8 134
@@ -1313,24 +1251,15 @@ void ERR_load_EVP_strings(void);
1313#define EVP_F_EVP_RIJNDAEL 126 1251#define EVP_F_EVP_RIJNDAEL 126
1314#define EVP_F_EVP_SIGNFINAL 107 1252#define EVP_F_EVP_SIGNFINAL 107
1315#define EVP_F_EVP_VERIFYFINAL 108 1253#define EVP_F_EVP_VERIFYFINAL 108
1316#define EVP_F_FIPS_CIPHERINIT 166
1317#define EVP_F_FIPS_CIPHER_CTX_COPY 170
1318#define EVP_F_FIPS_CIPHER_CTX_CTRL 167
1319#define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH 171
1320#define EVP_F_FIPS_DIGESTINIT 168
1321#define EVP_F_FIPS_MD_CTX_COPY 169
1322#define EVP_F_HMAC_INIT_EX 174
1323#define EVP_F_INT_CTX_NEW 157 1254#define EVP_F_INT_CTX_NEW 157
1324#define EVP_F_PKCS5_PBE_KEYIVGEN 117 1255#define EVP_F_PKCS5_PBE_KEYIVGEN 117
1325#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 1256#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
1326#define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 164
1327#define EVP_F_PKCS8_SET_BROKEN 112 1257#define EVP_F_PKCS8_SET_BROKEN 112
1328#define EVP_F_PKEY_SET_TYPE 158 1258#define EVP_F_PKEY_SET_TYPE 158
1329#define EVP_F_RC2_MAGIC_TO_METH 109 1259#define EVP_F_RC2_MAGIC_TO_METH 109
1330#define EVP_F_RC5_CTRL 125 1260#define EVP_F_RC5_CTRL 125
1331 1261
1332/* Reason codes. */ 1262/* Reason codes. */
1333#define EVP_R_AES_IV_SETUP_FAILED 162
1334#define EVP_R_AES_KEY_SETUP_FAILED 143 1263#define EVP_R_AES_KEY_SETUP_FAILED 143
1335#define EVP_R_ASN1_LIB 140 1264#define EVP_R_ASN1_LIB 140
1336#define EVP_R_BAD_BLOCK_LENGTH 136 1265#define EVP_R_BAD_BLOCK_LENGTH 136
@@ -1348,7 +1277,6 @@ void ERR_load_EVP_strings(void);
1348#define EVP_R_DECODE_ERROR 114 1277#define EVP_R_DECODE_ERROR 114
1349#define EVP_R_DIFFERENT_KEY_TYPES 101 1278#define EVP_R_DIFFERENT_KEY_TYPES 101
1350#define EVP_R_DIFFERENT_PARAMETERS 153 1279#define EVP_R_DIFFERENT_PARAMETERS 153
1351#define EVP_R_DISABLED_FOR_FIPS 163
1352#define EVP_R_ENCODE_ERROR 115 1280#define EVP_R_ENCODE_ERROR 115
1353#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 1281#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
1354#define EVP_R_EXPECTING_AN_RSA_KEY 127 1282#define EVP_R_EXPECTING_AN_RSA_KEY 127
@@ -1380,7 +1308,6 @@ void ERR_load_EVP_strings(void);
1380#define EVP_R_PRIVATE_KEY_DECODE_ERROR 145 1308#define EVP_R_PRIVATE_KEY_DECODE_ERROR 145
1381#define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146 1309#define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146
1382#define EVP_R_PUBLIC_KEY_NOT_RSA 106 1310#define EVP_R_PUBLIC_KEY_NOT_RSA 106
1383#define EVP_R_TOO_LARGE 164
1384#define EVP_R_UNKNOWN_CIPHER 160 1311#define EVP_R_UNKNOWN_CIPHER 160
1385#define EVP_R_UNKNOWN_DIGEST 161 1312#define EVP_R_UNKNOWN_DIGEST 161
1386#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 1313#define EVP_R_UNKNOWN_PBE_ALGORITHM 121
diff --git a/src/lib/libcrypto/evp/evp_acnf.c b/src/lib/libcrypto/evp/evp_acnf.c
new file mode 100644
index 0000000000..643a1864e8
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp_acnf.c
@@ -0,0 +1,73 @@
1/* evp_acnf.c */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2001.
4 */
5/* ====================================================================
6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include "cryptlib.h"
60#include <openssl/evp.h>
61#include <openssl/conf.h>
62
63
64/* Load all algorithms and configure OpenSSL.
65 * This function is called automatically when
66 * OPENSSL_LOAD_CONF is set.
67 */
68
69void OPENSSL_add_all_algorithms_conf(void)
70 {
71 OPENSSL_add_all_algorithms_noconf();
72 OPENSSL_config(NULL);
73 }
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index 0c54f05e6e..c268d25cb4 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -64,18 +64,8 @@
64#ifndef OPENSSL_NO_ENGINE 64#ifndef OPENSSL_NO_ENGINE
65#include <openssl/engine.h> 65#include <openssl/engine.h>
66#endif 66#endif
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70#include "evp_locl.h" 67#include "evp_locl.h"
71 68
72#ifdef OPENSSL_FIPS
73#define M_do_cipher(ctx, out, in, inl) FIPS_cipher(ctx, out, in, inl)
74#else
75#define M_do_cipher(ctx, out, in, inl) ctx->cipher->do_cipher(ctx, out, in, inl)
76#endif
77
78
79const char EVP_version[]="EVP" OPENSSL_VERSION_PTEXT; 69const char EVP_version[]="EVP" OPENSSL_VERSION_PTEXT;
80 70
81void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) 71void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
@@ -125,14 +115,10 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
125 /* Ensure a context left lying around from last time is cleared 115 /* Ensure a context left lying around from last time is cleared
126 * (the previous check attempted to avoid this if the same 116 * (the previous check attempted to avoid this if the same
127 * ENGINE and EVP_CIPHER could be used). */ 117 * ENGINE and EVP_CIPHER could be used). */
128 if (ctx->cipher) 118 EVP_CIPHER_CTX_cleanup(ctx);
129 { 119
130 unsigned long flags = ctx->flags; 120 /* Restore encrypt field: it is zeroed by cleanup */
131 EVP_CIPHER_CTX_cleanup(ctx); 121 ctx->encrypt = enc;
132 /* Restore encrypt and flags */
133 ctx->encrypt = enc;
134 ctx->flags = flags;
135 }
136#ifndef OPENSSL_NO_ENGINE 122#ifndef OPENSSL_NO_ENGINE
137 if(impl) 123 if(impl)
138 { 124 {
@@ -169,10 +155,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
169 ctx->engine = NULL; 155 ctx->engine = NULL;
170#endif 156#endif
171 157
172#ifdef OPENSSL_FIPS
173 if (FIPS_mode())
174 return FIPS_cipherinit(ctx, cipher, key, iv, enc);
175#endif
176 ctx->cipher=cipher; 158 ctx->cipher=cipher;
177 if (ctx->cipher->ctx_size) 159 if (ctx->cipher->ctx_size)
178 { 160 {
@@ -206,10 +188,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
206#ifndef OPENSSL_NO_ENGINE 188#ifndef OPENSSL_NO_ENGINE
207skip_to_init: 189skip_to_init:
208#endif 190#endif
209#ifdef OPENSSL_FIPS
210 if (FIPS_mode())
211 return FIPS_cipherinit(ctx, cipher, key, iv, enc);
212#endif
213 /* we assume block size is a power of 2 in *cryptUpdate */ 191 /* we assume block size is a power of 2 in *cryptUpdate */
214 OPENSSL_assert(ctx->cipher->block_size == 1 192 OPENSSL_assert(ctx->cipher->block_size == 1
215 || ctx->cipher->block_size == 8 193 || ctx->cipher->block_size == 8
@@ -236,13 +214,6 @@ skip_to_init:
236 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); 214 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
237 break; 215 break;
238 216
239 case EVP_CIPH_CTR_MODE:
240 ctx->num = 0;
241 /* Don't reuse IV for CTR mode */
242 if(iv)
243 memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx));
244 break;
245
246 default: 217 default:
247 return 0; 218 return 0;
248 break; 219 break;
@@ -309,16 +280,6 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
309 { 280 {
310 int i,j,bl; 281 int i,j,bl;
311 282
312 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER)
313 {
314 i = M_do_cipher(ctx, out, in, inl);
315 if (i < 0)
316 return 0;
317 else
318 *outl = i;
319 return 1;
320 }
321
322 if (inl <= 0) 283 if (inl <= 0)
323 { 284 {
324 *outl = 0; 285 *outl = 0;
@@ -327,7 +288,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
327 288
328 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) 289 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
329 { 290 {
330 if(M_do_cipher(ctx,out,in,inl)) 291 if(ctx->cipher->do_cipher(ctx,out,in,inl))
331 { 292 {
332 *outl=inl; 293 *outl=inl;
333 return 1; 294 return 1;
@@ -354,7 +315,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
354 { 315 {
355 j=bl-i; 316 j=bl-i;
356 memcpy(&(ctx->buf[i]),in,j); 317 memcpy(&(ctx->buf[i]),in,j);
357 if(!M_do_cipher(ctx,out,ctx->buf,bl)) return 0; 318 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0;
358 inl-=j; 319 inl-=j;
359 in+=j; 320 in+=j;
360 out+=bl; 321 out+=bl;
@@ -367,7 +328,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
367 inl-=i; 328 inl-=i;
368 if (inl > 0) 329 if (inl > 0)
369 { 330 {
370 if(!M_do_cipher(ctx,out,in,inl)) return 0; 331 if(!ctx->cipher->do_cipher(ctx,out,in,inl)) return 0;
371 *outl+=inl; 332 *outl+=inl;
372 } 333 }
373 334
@@ -389,16 +350,6 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
389 int n,ret; 350 int n,ret;
390 unsigned int i, b, bl; 351 unsigned int i, b, bl;
391 352
392 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER)
393 {
394 ret = M_do_cipher(ctx, out, NULL, 0);
395 if (ret < 0)
396 return 0;
397 else
398 *outl = ret;
399 return 1;
400 }
401
402 b=ctx->cipher->block_size; 353 b=ctx->cipher->block_size;
403 OPENSSL_assert(b <= sizeof ctx->buf); 354 OPENSSL_assert(b <= sizeof ctx->buf);
404 if (b == 1) 355 if (b == 1)
@@ -421,7 +372,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
421 n=b-bl; 372 n=b-bl;
422 for (i=bl; i<b; i++) 373 for (i=bl; i<b; i++)
423 ctx->buf[i]=n; 374 ctx->buf[i]=n;
424 ret=M_do_cipher(ctx,out,ctx->buf,b); 375 ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b);
425 376
426 377
427 if(ret) 378 if(ret)
@@ -436,19 +387,6 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
436 int fix_len; 387 int fix_len;
437 unsigned int b; 388 unsigned int b;
438 389
439 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER)
440 {
441 fix_len = M_do_cipher(ctx, out, in, inl);
442 if (fix_len < 0)
443 {
444 *outl = 0;
445 return 0;
446 }
447 else
448 *outl = fix_len;
449 return 1;
450 }
451
452 if (inl <= 0) 390 if (inl <= 0)
453 { 391 {
454 *outl = 0; 392 *outl = 0;
@@ -502,18 +440,8 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
502 { 440 {
503 int i,n; 441 int i,n;
504 unsigned int b; 442 unsigned int b;
505 *outl=0;
506
507 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER)
508 {
509 i = M_do_cipher(ctx, out, NULL, 0);
510 if (i < 0)
511 return 0;
512 else
513 *outl = i;
514 return 1;
515 }
516 443
444 *outl=0;
517 b=ctx->cipher->block_size; 445 b=ctx->cipher->block_size;
518 if (ctx->flags & EVP_CIPH_NO_PADDING) 446 if (ctx->flags & EVP_CIPH_NO_PADDING)
519 { 447 {
@@ -568,7 +496,6 @@ void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
568 496
569int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) 497int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
570 { 498 {
571#ifndef OPENSSL_FIPS
572 if (c->cipher != NULL) 499 if (c->cipher != NULL)
573 { 500 {
574 if(c->cipher->cleanup && !c->cipher->cleanup(c)) 501 if(c->cipher->cleanup && !c->cipher->cleanup(c))
@@ -579,16 +506,12 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
579 } 506 }
580 if (c->cipher_data) 507 if (c->cipher_data)
581 OPENSSL_free(c->cipher_data); 508 OPENSSL_free(c->cipher_data);
582#endif
583#ifndef OPENSSL_NO_ENGINE 509#ifndef OPENSSL_NO_ENGINE
584 if (c->engine) 510 if (c->engine)
585 /* The EVP_CIPHER we used belongs to an ENGINE, release the 511 /* The EVP_CIPHER we used belongs to an ENGINE, release the
586 * functional reference we held for this reason. */ 512 * functional reference we held for this reason. */
587 ENGINE_finish(c->engine); 513 ENGINE_finish(c->engine);
588#endif 514#endif
589#ifdef OPENSSL_FIPS
590 FIPS_cipher_ctx_cleanup(c);
591#endif
592 memset(c,0,sizeof(EVP_CIPHER_CTX)); 515 memset(c,0,sizeof(EVP_CIPHER_CTX));
593 return 1; 516 return 1;
594 } 517 }
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c
index db0f76d59b..6b585c7483 100644
--- a/src/lib/libcrypto/evp/evp_err.c
+++ b/src/lib/libcrypto/evp/evp_err.c
@@ -1,6 +1,6 @@
1/* crypto/evp/evp_err.c */ 1/* crypto/evp/evp_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -71,12 +71,8 @@
71static ERR_STRING_DATA EVP_str_functs[]= 71static ERR_STRING_DATA EVP_str_functs[]=
72 { 72 {
73{ERR_FUNC(EVP_F_AESNI_INIT_KEY), "AESNI_INIT_KEY"}, 73{ERR_FUNC(EVP_F_AESNI_INIT_KEY), "AESNI_INIT_KEY"},
74{ERR_FUNC(EVP_F_AESNI_XTS_CIPHER), "AESNI_XTS_CIPHER"},
75{ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, 74{ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"},
76{ERR_FUNC(EVP_F_AES_XTS), "AES_XTS"},
77{ERR_FUNC(EVP_F_AES_XTS_CIPHER), "AES_XTS_CIPHER"},
78{ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"}, 75{ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"},
79{ERR_FUNC(EVP_F_CMAC_INIT), "CMAC_INIT"},
80{ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, 76{ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"},
81{ERR_FUNC(EVP_F_DO_SIGVER_INIT), "DO_SIGVER_INIT"}, 77{ERR_FUNC(EVP_F_DO_SIGVER_INIT), "DO_SIGVER_INIT"},
82{ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"}, 78{ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"},
@@ -91,7 +87,7 @@ static ERR_STRING_DATA EVP_str_functs[]=
91{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, 87{ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"},
92{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"}, 88{ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"},
93{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"}, 89{ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"},
94{ERR_FUNC(EVP_F_EVP_MD_SIZE), "EVP_MD_size"}, 90{ERR_FUNC(EVP_F_EVP_MD_SIZE), "EVP_MD_SIZE"},
95{ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"}, 91{ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"},
96{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD), "EVP_PBE_alg_add"}, 92{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD), "EVP_PBE_alg_add"},
97{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD_TYPE), "EVP_PBE_alg_add_type"}, 93{ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD_TYPE), "EVP_PBE_alg_add_type"},
@@ -131,17 +127,9 @@ static ERR_STRING_DATA EVP_str_functs[]=
131{ERR_FUNC(EVP_F_EVP_RIJNDAEL), "EVP_RIJNDAEL"}, 127{ERR_FUNC(EVP_F_EVP_RIJNDAEL), "EVP_RIJNDAEL"},
132{ERR_FUNC(EVP_F_EVP_SIGNFINAL), "EVP_SignFinal"}, 128{ERR_FUNC(EVP_F_EVP_SIGNFINAL), "EVP_SignFinal"},
133{ERR_FUNC(EVP_F_EVP_VERIFYFINAL), "EVP_VerifyFinal"}, 129{ERR_FUNC(EVP_F_EVP_VERIFYFINAL), "EVP_VerifyFinal"},
134{ERR_FUNC(EVP_F_FIPS_CIPHERINIT), "FIPS_CIPHERINIT"},
135{ERR_FUNC(EVP_F_FIPS_CIPHER_CTX_COPY), "FIPS_CIPHER_CTX_COPY"},
136{ERR_FUNC(EVP_F_FIPS_CIPHER_CTX_CTRL), "FIPS_CIPHER_CTX_CTRL"},
137{ERR_FUNC(EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH), "FIPS_CIPHER_CTX_SET_KEY_LENGTH"},
138{ERR_FUNC(EVP_F_FIPS_DIGESTINIT), "FIPS_DIGESTINIT"},
139{ERR_FUNC(EVP_F_FIPS_MD_CTX_COPY), "FIPS_MD_CTX_COPY"},
140{ERR_FUNC(EVP_F_HMAC_INIT_EX), "HMAC_Init_ex"},
141{ERR_FUNC(EVP_F_INT_CTX_NEW), "INT_CTX_NEW"}, 130{ERR_FUNC(EVP_F_INT_CTX_NEW), "INT_CTX_NEW"},
142{ERR_FUNC(EVP_F_PKCS5_PBE_KEYIVGEN), "PKCS5_PBE_keyivgen"}, 131{ERR_FUNC(EVP_F_PKCS5_PBE_KEYIVGEN), "PKCS5_PBE_keyivgen"},
143{ERR_FUNC(EVP_F_PKCS5_V2_PBE_KEYIVGEN), "PKCS5_v2_PBE_keyivgen"}, 132{ERR_FUNC(EVP_F_PKCS5_V2_PBE_KEYIVGEN), "PKCS5_v2_PBE_keyivgen"},
144{ERR_FUNC(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN), "PKCS5_V2_PBKDF2_KEYIVGEN"},
145{ERR_FUNC(EVP_F_PKCS8_SET_BROKEN), "PKCS8_set_broken"}, 133{ERR_FUNC(EVP_F_PKCS8_SET_BROKEN), "PKCS8_set_broken"},
146{ERR_FUNC(EVP_F_PKEY_SET_TYPE), "PKEY_SET_TYPE"}, 134{ERR_FUNC(EVP_F_PKEY_SET_TYPE), "PKEY_SET_TYPE"},
147{ERR_FUNC(EVP_F_RC2_MAGIC_TO_METH), "RC2_MAGIC_TO_METH"}, 135{ERR_FUNC(EVP_F_RC2_MAGIC_TO_METH), "RC2_MAGIC_TO_METH"},
@@ -151,7 +139,6 @@ static ERR_STRING_DATA EVP_str_functs[]=
151 139
152static ERR_STRING_DATA EVP_str_reasons[]= 140static ERR_STRING_DATA EVP_str_reasons[]=
153 { 141 {
154{ERR_REASON(EVP_R_AES_IV_SETUP_FAILED) ,"aes iv setup failed"},
155{ERR_REASON(EVP_R_AES_KEY_SETUP_FAILED) ,"aes key setup failed"}, 142{ERR_REASON(EVP_R_AES_KEY_SETUP_FAILED) ,"aes key setup failed"},
156{ERR_REASON(EVP_R_ASN1_LIB) ,"asn1 lib"}, 143{ERR_REASON(EVP_R_ASN1_LIB) ,"asn1 lib"},
157{ERR_REASON(EVP_R_BAD_BLOCK_LENGTH) ,"bad block length"}, 144{ERR_REASON(EVP_R_BAD_BLOCK_LENGTH) ,"bad block length"},
@@ -169,7 +156,6 @@ static ERR_STRING_DATA EVP_str_reasons[]=
169{ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"}, 156{ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"},
170{ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"}, 157{ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"},
171{ERR_REASON(EVP_R_DIFFERENT_PARAMETERS) ,"different parameters"}, 158{ERR_REASON(EVP_R_DIFFERENT_PARAMETERS) ,"different parameters"},
172{ERR_REASON(EVP_R_DISABLED_FOR_FIPS) ,"disabled for fips"},
173{ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"}, 159{ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"},
174{ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"}, 160{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"}, 161{ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"},
@@ -201,7 +187,6 @@ static ERR_STRING_DATA EVP_str_reasons[]=
201{ERR_REASON(EVP_R_PRIVATE_KEY_DECODE_ERROR),"private key decode error"}, 187{ERR_REASON(EVP_R_PRIVATE_KEY_DECODE_ERROR),"private key decode error"},
202{ERR_REASON(EVP_R_PRIVATE_KEY_ENCODE_ERROR),"private key encode error"}, 188{ERR_REASON(EVP_R_PRIVATE_KEY_ENCODE_ERROR),"private key encode error"},
203{ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"}, 189{ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"},
204{ERR_REASON(EVP_R_TOO_LARGE) ,"too large"},
205{ERR_REASON(EVP_R_UNKNOWN_CIPHER) ,"unknown cipher"}, 190{ERR_REASON(EVP_R_UNKNOWN_CIPHER) ,"unknown cipher"},
206{ERR_REASON(EVP_R_UNKNOWN_DIGEST) ,"unknown digest"}, 191{ERR_REASON(EVP_R_UNKNOWN_DIGEST) ,"unknown digest"},
207{ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"}, 192{ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"},
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index 7961fbebf2..839d6a3a16 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -120,7 +120,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
120 unsigned char md_buf[EVP_MAX_MD_SIZE]; 120 unsigned char md_buf[EVP_MAX_MD_SIZE];
121 int niv,nkey,addmd=0; 121 int niv,nkey,addmd=0;
122 unsigned int mds=0,i; 122 unsigned int mds=0,i;
123 int rv = 0; 123
124 nkey=type->key_len; 124 nkey=type->key_len;
125 niv=type->iv_len; 125 niv=type->iv_len;
126 OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH); 126 OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH);
@@ -134,24 +134,17 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
134 if (!EVP_DigestInit_ex(&c,md, NULL)) 134 if (!EVP_DigestInit_ex(&c,md, NULL))
135 return 0; 135 return 0;
136 if (addmd++) 136 if (addmd++)
137 if (!EVP_DigestUpdate(&c,&(md_buf[0]),mds)) 137 EVP_DigestUpdate(&c,&(md_buf[0]),mds);
138 goto err; 138 EVP_DigestUpdate(&c,data,datal);
139 if (!EVP_DigestUpdate(&c,data,datal))
140 goto err;
141 if (salt != NULL) 139 if (salt != NULL)
142 if (!EVP_DigestUpdate(&c,salt,PKCS5_SALT_LEN)) 140 EVP_DigestUpdate(&c,salt,PKCS5_SALT_LEN);
143 goto err; 141 EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds);
144 if (!EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds))
145 goto err;
146 142
147 for (i=1; i<(unsigned int)count; i++) 143 for (i=1; i<(unsigned int)count; i++)
148 { 144 {
149 if (!EVP_DigestInit_ex(&c,md, NULL)) 145 EVP_DigestInit_ex(&c,md, NULL);
150 goto err; 146 EVP_DigestUpdate(&c,&(md_buf[0]),mds);
151 if (!EVP_DigestUpdate(&c,&(md_buf[0]),mds)) 147 EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds);
152 goto err;
153 if (!EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds))
154 goto err;
155 } 148 }
156 i=0; 149 i=0;
157 if (nkey) 150 if (nkey)
@@ -180,10 +173,8 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
180 } 173 }
181 if ((nkey == 0) && (niv == 0)) break; 174 if ((nkey == 0) && (niv == 0)) break;
182 } 175 }
183 rv = type->key_len;
184 err:
185 EVP_MD_CTX_cleanup(&c); 176 EVP_MD_CTX_cleanup(&c);
186 OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE); 177 OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE);
187 return rv; 178 return(type->key_len);
188 } 179 }
189 180
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index b180e4828a..40951a04f0 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -67,8 +67,6 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
67 67
68 if (c->cipher->set_asn1_parameters != NULL) 68 if (c->cipher->set_asn1_parameters != NULL)
69 ret=c->cipher->set_asn1_parameters(c,type); 69 ret=c->cipher->set_asn1_parameters(c,type);
70 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
71 ret=EVP_CIPHER_set_asn1_iv(c, type);
72 else 70 else
73 ret=-1; 71 ret=-1;
74 return(ret); 72 return(ret);
@@ -80,8 +78,6 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
80 78
81 if (c->cipher->get_asn1_parameters != NULL) 79 if (c->cipher->get_asn1_parameters != NULL)
82 ret=c->cipher->get_asn1_parameters(c,type); 80 ret=c->cipher->get_asn1_parameters(c,type);
83 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
84 ret=EVP_CIPHER_get_asn1_iv(c, type);
85 else 81 else
86 ret=-1; 82 ret=-1;
87 return(ret); 83 return(ret);
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index 08c0a66d39..292d74c188 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -343,43 +343,3 @@ struct evp_pkey_method_st
343 } /* EVP_PKEY_METHOD */; 343 } /* EVP_PKEY_METHOD */;
344 344
345void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); 345void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
346
347int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
348 ASN1_TYPE *param,
349 const EVP_CIPHER *c, const EVP_MD *md, int en_de);
350
351#ifdef OPENSSL_FIPS
352
353#ifdef OPENSSL_DOING_MAKEDEPEND
354#undef SHA1_Init
355#undef SHA1_Update
356#undef SHA224_Init
357#undef SHA256_Init
358#undef SHA384_Init
359#undef SHA512_Init
360#undef DES_set_key_unchecked
361#endif
362
363#define RIPEMD160_Init private_RIPEMD160_Init
364#define WHIRLPOOL_Init private_WHIRLPOOL_Init
365#define MD5_Init private_MD5_Init
366#define MD4_Init private_MD4_Init
367#define MD2_Init private_MD2_Init
368#define MDC2_Init private_MDC2_Init
369#define SHA_Init private_SHA_Init
370#define SHA1_Init private_SHA1_Init
371#define SHA224_Init private_SHA224_Init
372#define SHA256_Init private_SHA256_Init
373#define SHA384_Init private_SHA384_Init
374#define SHA512_Init private_SHA512_Init
375
376#define BF_set_key private_BF_set_key
377#define CAST_set_key private_CAST_set_key
378#define idea_set_encrypt_key private_idea_set_encrypt_key
379#define SEED_set_key private_SEED_set_key
380#define RC2_set_key private_RC2_set_key
381#define RC4_set_key private_RC4_set_key
382#define DES_set_key_unchecked private_DES_set_key_unchecked
383#define Camellia_set_key private_Camellia_set_key
384
385#endif
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index f8c32d825e..c9d932d205 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -61,7 +61,6 @@
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/pkcs12.h> 62#include <openssl/pkcs12.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include "evp_locl.h"
65 64
66/* Password based encryption (PBE) functions */ 65/* Password based encryption (PBE) functions */
67 66
@@ -88,10 +87,6 @@ static const EVP_PBE_CTL builtin_pbe[] =
88 {EVP_PBE_TYPE_OUTER, NID_pbeWithSHA1AndRC2_CBC, 87 {EVP_PBE_TYPE_OUTER, NID_pbeWithSHA1AndRC2_CBC,
89 NID_rc2_64_cbc, NID_sha1, PKCS5_PBE_keyivgen}, 88 NID_rc2_64_cbc, NID_sha1, PKCS5_PBE_keyivgen},
90 89
91#ifndef OPENSSL_NO_HMAC
92 {EVP_PBE_TYPE_OUTER, NID_id_pbkdf2, -1, -1, PKCS5_v2_PBKDF2_keyivgen},
93#endif
94
95 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And128BitRC4, 90 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And128BitRC4,
96 NID_rc4, NID_sha1, PKCS12_PBE_keyivgen}, 91 NID_rc4, NID_sha1, PKCS12_PBE_keyivgen},
97 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And40BitRC4, 92 {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And40BitRC4,
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c
new file mode 100644
index 0000000000..55c7cdfdcc
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp_test.c
@@ -0,0 +1,450 @@
1/* Written by Ben Laurie, 2001 */
2/*
3 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 */
49
50#include <stdio.h>
51#include <string.h>
52
53#include "../e_os.h"
54
55#include <openssl/opensslconf.h>
56#include <openssl/evp.h>
57#ifndef OPENSSL_NO_ENGINE
58#include <openssl/engine.h>
59#endif
60#include <openssl/err.h>
61#include <openssl/conf.h>
62
63static void hexdump(FILE *f,const char *title,const unsigned char *s,int l)
64 {
65 int n=0;
66
67 fprintf(f,"%s",title);
68 for( ; n < l ; ++n)
69 {
70 if((n%16) == 0)
71 fprintf(f,"\n%04x",n);
72 fprintf(f," %02x",s[n]);
73 }
74 fprintf(f,"\n");
75 }
76
77static int convert(unsigned char *s)
78 {
79 unsigned char *d;
80
81 for(d=s ; *s ; s+=2,++d)
82 {
83 unsigned int n;
84
85 if(!s[1])
86 {
87 fprintf(stderr,"Odd number of hex digits!");
88 EXIT(4);
89 }
90 sscanf((char *)s,"%2x",&n);
91 *d=(unsigned char)n;
92 }
93 return s-d;
94 }
95
96static char *sstrsep(char **string, const char *delim)
97 {
98 char isdelim[256];
99 char *token = *string;
100
101 if (**string == 0)
102 return NULL;
103
104 memset(isdelim, 0, 256);
105 isdelim[0] = 1;
106
107 while (*delim)
108 {
109 isdelim[(unsigned char)(*delim)] = 1;
110 delim++;
111 }
112
113 while (!isdelim[(unsigned char)(**string)])
114 {
115 (*string)++;
116 }
117
118 if (**string)
119 {
120 **string = 0;
121 (*string)++;
122 }
123
124 return token;
125 }
126
127static unsigned char *ustrsep(char **p,const char *sep)
128 { return (unsigned char *)sstrsep(p,sep); }
129
130static int test1_exit(int ec)
131 {
132 EXIT(ec);
133 return(0); /* To keep some compilers quiet */
134 }
135
136static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
137 const unsigned char *iv,int in,
138 const unsigned char *plaintext,int pn,
139 const unsigned char *ciphertext,int cn,
140 int encdec)
141 {
142 EVP_CIPHER_CTX ctx;
143 unsigned char out[4096];
144 int outl,outl2;
145
146 printf("Testing cipher %s%s\n",EVP_CIPHER_name(c),
147 (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)")));
148 hexdump(stdout,"Key",key,kn);
149 if(in)
150 hexdump(stdout,"IV",iv,in);
151 hexdump(stdout,"Plaintext",plaintext,pn);
152 hexdump(stdout,"Ciphertext",ciphertext,cn);
153
154 if(kn != c->key_len)
155 {
156 fprintf(stderr,"Key length doesn't match, got %d expected %lu\n",kn,
157 (unsigned long)c->key_len);
158 test1_exit(5);
159 }
160 EVP_CIPHER_CTX_init(&ctx);
161 if (encdec != 0)
162 {
163 if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv))
164 {
165 fprintf(stderr,"EncryptInit failed\n");
166 ERR_print_errors_fp(stderr);
167 test1_exit(10);
168 }
169 EVP_CIPHER_CTX_set_padding(&ctx,0);
170
171 if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn))
172 {
173 fprintf(stderr,"Encrypt failed\n");
174 ERR_print_errors_fp(stderr);
175 test1_exit(6);
176 }
177 if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2))
178 {
179 fprintf(stderr,"EncryptFinal failed\n");
180 ERR_print_errors_fp(stderr);
181 test1_exit(7);
182 }
183
184 if(outl+outl2 != cn)
185 {
186 fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n",
187 outl+outl2,cn);
188 test1_exit(8);
189 }
190
191 if(memcmp(out,ciphertext,cn))
192 {
193 fprintf(stderr,"Ciphertext mismatch\n");
194 hexdump(stderr,"Got",out,cn);
195 hexdump(stderr,"Expected",ciphertext,cn);
196 test1_exit(9);
197 }
198 }
199
200 if (encdec <= 0)
201 {
202 if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv))
203 {
204 fprintf(stderr,"DecryptInit failed\n");
205 ERR_print_errors_fp(stderr);
206 test1_exit(11);
207 }
208 EVP_CIPHER_CTX_set_padding(&ctx,0);
209
210 if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn))
211 {
212 fprintf(stderr,"Decrypt failed\n");
213 ERR_print_errors_fp(stderr);
214 test1_exit(6);
215 }
216 if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2))
217 {
218 fprintf(stderr,"DecryptFinal failed\n");
219 ERR_print_errors_fp(stderr);
220 test1_exit(7);
221 }
222
223 if(outl+outl2 != pn)
224 {
225 fprintf(stderr,"Plaintext length mismatch got %d expected %d\n",
226 outl+outl2,pn);
227 test1_exit(8);
228 }
229
230 if(memcmp(out,plaintext,pn))
231 {
232 fprintf(stderr,"Plaintext mismatch\n");
233 hexdump(stderr,"Got",out,pn);
234 hexdump(stderr,"Expected",plaintext,pn);
235 test1_exit(9);
236 }
237 }
238
239 EVP_CIPHER_CTX_cleanup(&ctx);
240
241 printf("\n");
242 }
243
244static int test_cipher(const char *cipher,const unsigned char *key,int kn,
245 const unsigned char *iv,int in,
246 const unsigned char *plaintext,int pn,
247 const unsigned char *ciphertext,int cn,
248 int encdec)
249 {
250 const EVP_CIPHER *c;
251
252 c=EVP_get_cipherbyname(cipher);
253 if(!c)
254 return 0;
255
256 test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec);
257
258 return 1;
259 }
260
261static int test_digest(const char *digest,
262 const unsigned char *plaintext,int pn,
263 const unsigned char *ciphertext, unsigned int cn)
264 {
265 const EVP_MD *d;
266 EVP_MD_CTX ctx;
267 unsigned char md[EVP_MAX_MD_SIZE];
268 unsigned int mdn;
269
270 d=EVP_get_digestbyname(digest);
271 if(!d)
272 return 0;
273
274 printf("Testing digest %s\n",EVP_MD_name(d));
275 hexdump(stdout,"Plaintext",plaintext,pn);
276 hexdump(stdout,"Digest",ciphertext,cn);
277
278 EVP_MD_CTX_init(&ctx);
279 if(!EVP_DigestInit_ex(&ctx,d, NULL))
280 {
281 fprintf(stderr,"DigestInit failed\n");
282 ERR_print_errors_fp(stderr);
283 EXIT(100);
284 }
285 if(!EVP_DigestUpdate(&ctx,plaintext,pn))
286 {
287 fprintf(stderr,"DigestUpdate failed\n");
288 ERR_print_errors_fp(stderr);
289 EXIT(101);
290 }
291 if(!EVP_DigestFinal_ex(&ctx,md,&mdn))
292 {
293 fprintf(stderr,"DigestFinal failed\n");
294 ERR_print_errors_fp(stderr);
295 EXIT(101);
296 }
297 EVP_MD_CTX_cleanup(&ctx);
298
299 if(mdn != cn)
300 {
301 fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn);
302 EXIT(102);
303 }
304
305 if(memcmp(md,ciphertext,cn))
306 {
307 fprintf(stderr,"Digest mismatch\n");
308 hexdump(stderr,"Got",md,cn);
309 hexdump(stderr,"Expected",ciphertext,cn);
310 EXIT(103);
311 }
312
313 printf("\n");
314
315 EVP_MD_CTX_cleanup(&ctx);
316
317 return 1;
318 }
319
320int main(int argc,char **argv)
321 {
322 const char *szTestFile;
323 FILE *f;
324
325 if(argc != 2)
326 {
327 fprintf(stderr,"%s <test file>\n",argv[0]);
328 EXIT(1);
329 }
330 CRYPTO_malloc_debug_init();
331 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
332 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
333
334 szTestFile=argv[1];
335
336 f=fopen(szTestFile,"r");
337 if(!f)
338 {
339 perror(szTestFile);
340 EXIT(2);
341 }
342
343 /* Load up the software EVP_CIPHER and EVP_MD definitions */
344 OpenSSL_add_all_ciphers();
345 OpenSSL_add_all_digests();
346#ifndef OPENSSL_NO_ENGINE
347 /* Load all compiled-in ENGINEs */
348 ENGINE_load_builtin_engines();
349#endif
350#if 0
351 OPENSSL_config();
352#endif
353#ifndef OPENSSL_NO_ENGINE
354 /* Register all available ENGINE implementations of ciphers and digests.
355 * This could perhaps be changed to "ENGINE_register_all_complete()"? */
356 ENGINE_register_all_ciphers();
357 ENGINE_register_all_digests();
358 /* If we add command-line options, this statement should be switchable.
359 * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if
360 * they weren't already initialised. */
361 /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
362#endif
363
364 for( ; ; )
365 {
366 char line[4096];
367 char *p;
368 char *cipher;
369 unsigned char *iv,*key,*plaintext,*ciphertext;
370 int encdec;
371 int kn,in,pn,cn;
372
373 if(!fgets((char *)line,sizeof line,f))
374 break;
375 if(line[0] == '#' || line[0] == '\n')
376 continue;
377 p=line;
378 cipher=sstrsep(&p,":");
379 key=ustrsep(&p,":");
380 iv=ustrsep(&p,":");
381 plaintext=ustrsep(&p,":");
382 ciphertext=ustrsep(&p,":");
383 if (p[-1] == '\n') {
384 p[-1] = '\0';
385 encdec = -1;
386 } else {
387 encdec = atoi(sstrsep(&p,"\n"));
388 }
389
390
391 kn=convert(key);
392 in=convert(iv);
393 pn=convert(plaintext);
394 cn=convert(ciphertext);
395
396 if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec)
397 && !test_digest(cipher,plaintext,pn,ciphertext,cn))
398 {
399#ifdef OPENSSL_NO_AES
400 if (strstr(cipher, "AES") == cipher)
401 {
402 fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
403 continue;
404 }
405#endif
406#ifdef OPENSSL_NO_DES
407 if (strstr(cipher, "DES") == cipher)
408 {
409 fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
410 continue;
411 }
412#endif
413#ifdef OPENSSL_NO_RC4
414 if (strstr(cipher, "RC4") == cipher)
415 {
416 fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
417 continue;
418 }
419#endif
420#ifdef OPENSSL_NO_CAMELLIA
421 if (strstr(cipher, "CAMELLIA") == cipher)
422 {
423 fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
424 continue;
425 }
426#endif
427#ifdef OPENSSL_NO_SEED
428 if (strstr(cipher, "SEED") == cipher)
429 {
430 fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
431 continue;
432 }
433#endif
434 fprintf(stderr,"Can't find %s\n",cipher);
435 EXIT(3);
436 }
437 }
438 fclose(f);
439
440#ifndef OPENSSL_NO_ENGINE
441 ENGINE_cleanup();
442#endif
443 EVP_cleanup();
444 CRYPTO_cleanup_all_ex_data();
445 ERR_remove_thread_state(NULL);
446 ERR_free_strings();
447 CRYPTO_mem_leaks_fp(stderr);
448
449 return 0;
450 }
diff --git a/src/lib/libcrypto/evp/evptests.txt b/src/lib/libcrypto/evp/evptests.txt
new file mode 100644
index 0000000000..beb12144b6
--- /dev/null
+++ b/src/lib/libcrypto/evp/evptests.txt
@@ -0,0 +1,321 @@
1#cipher:key:iv:plaintext:ciphertext:0/1(decrypt/encrypt)
2#digest:::input:output
3
4# SHA(1) tests (from shatest.c)
5SHA1:::616263:a9993e364706816aba3e25717850c26c9cd0d89d
6
7# MD5 tests (from md5test.c)
8MD5::::d41d8cd98f00b204e9800998ecf8427e
9MD5:::61:0cc175b9c0f1b6a831c399e269772661
10MD5:::616263:900150983cd24fb0d6963f7d28e17f72
11MD5:::6d65737361676520646967657374:f96b697d7cb7938d525a2f31aaf161d0
12MD5:::6162636465666768696a6b6c6d6e6f707172737475767778797a:c3fcd3d76192e4007dfb496cca67e13b
13MD5:::4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839:d174ab98d277d9f5a5611c2c9f419d9f
14MD5:::3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930:57edf4a22be3c955ac49da2e2107b67a
15
16# AES 128 ECB tests (from FIPS-197 test vectors, encrypt)
17
18AES-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A:1
19
20# AES 192 ECB tests (from FIPS-197 test vectors, encrypt)
21
22AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:1
23
24# AES 256 ECB tests (from FIPS-197 test vectors, encrypt)
25
26AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:1
27
28# AES 128 ECB tests (from NIST test vectors, encrypt)
29
30#AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F:1
31
32# AES 128 ECB tests (from NIST test vectors, decrypt)
33
34#AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000:0
35
36# AES 192 ECB tests (from NIST test vectors, decrypt)
37
38#AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000:0
39
40# AES 256 ECB tests (from NIST test vectors, decrypt)
41
42#AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000:0
43
44# AES 128 CBC tests (from NIST test vectors, encrypt)
45
46#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D:1
47
48# AES 192 CBC tests (from NIST test vectors, encrypt)
49
50#AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104:1
51
52# AES 256 CBC tests (from NIST test vectors, encrypt)
53
54#AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0:1
55
56# AES 128 CBC tests (from NIST test vectors, decrypt)
57
58#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000:0
59
60# AES tests from NIST document SP800-38A
61# For all ECB encrypts and decrypts, the transformed sequence is
62# AES-bits-ECB:key::plaintext:ciphertext:encdec
63# ECB-AES128.Encrypt and ECB-AES128.Decrypt
64AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:3AD77BB40D7A3660A89ECAF32466EF97
65AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:F5D3D58503B9699DE785895A96FDBAAF
66AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:43B1CD7F598ECE23881B00E3ED030688
67AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:7B0C785E27E8AD3F8223207104725DD4
68# ECB-AES192.Encrypt and ECB-AES192.Decrypt
69AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:BD334F1D6E45F25FF712A214571FA5CC
70AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:974104846D0AD3AD7734ECB3ECEE4EEF
71AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:EF7AFD2270E2E60ADCE0BA2FACE6444E
72AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:9A4B41BA738D6C72FB16691603C18E0E
73# ECB-AES256.Encrypt and ECB-AES256.Decrypt
74AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:F3EED1BDB5D2A03C064B5A7E3DB181F8
75AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:591CCB10D410ED26DC5BA74A31362870
76AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:B6ED21B99CA6F4F9F153E7B1BEAFED1D
77AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:23304B7A39F9F3FF067D8D8F9E24ECC7
78# For all CBC encrypts and decrypts, the transformed sequence is
79# AES-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec
80# CBC-AES128.Encrypt and CBC-AES128.Decrypt
81AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:7649ABAC8119B246CEE98E9B12E9197D
82AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:7649ABAC8119B246CEE98E9B12E9197D:AE2D8A571E03AC9C9EB76FAC45AF8E51:5086CB9B507219EE95DB113A917678B2
83AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:5086CB9B507219EE95DB113A917678B2:30C81C46A35CE411E5FBC1191A0A52EF:73BED6B8E3C1743B7116E69E22229516
84AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:73BED6B8E3C1743B7116E69E22229516:F69F2445DF4F9B17AD2B417BE66C3710:3FF1CAA1681FAC09120ECA307586E1A7
85# CBC-AES192.Encrypt and CBC-AES192.Decrypt
86AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:4F021DB243BC633D7178183A9FA071E8
87AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:4F021DB243BC633D7178183A9FA071E8:AE2D8A571E03AC9C9EB76FAC45AF8E51:B4D9ADA9AD7DEDF4E5E738763F69145A
88AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:B4D9ADA9AD7DEDF4E5E738763F69145A:30C81C46A35CE411E5FBC1191A0A52EF:571B242012FB7AE07FA9BAAC3DF102E0
89AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:571B242012FB7AE07FA9BAAC3DF102E0:F69F2445DF4F9B17AD2B417BE66C3710:08B0E27988598881D920A9E64F5615CD
90# CBC-AES256.Encrypt and CBC-AES256.Decrypt
91AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:F58C4C04D6E5F1BA779EABFB5F7BFBD6
92AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D
93AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461
94AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B
95# We don't support CFB{1,8}-AESxxx.{En,De}crypt
96# For all CFB128 encrypts and decrypts, the transformed sequence is
97# AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec
98# CFB128-AES128.Encrypt
99AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1
100AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:1
101AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:1
102AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:1
103# CFB128-AES128.Decrypt
104AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0
105AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:0
106AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:0
107AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:0
108# CFB128-AES192.Encrypt
109AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1
110AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:1
111AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:1
112AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:1
113# CFB128-AES192.Decrypt
114AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0
115AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:0
116AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:0
117AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:0
118# CFB128-AES256.Encrypt
119AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1
120AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:1
121AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:1
122AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:1
123# CFB128-AES256.Decrypt
124AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0
125AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:0
126AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:0
127AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:0
128# For all OFB encrypts and decrypts, the transformed sequence is
129# AES-bits-CFB:key:IV/output':plaintext:ciphertext:encdec
130# OFB-AES128.Encrypt
131AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1
132AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:1
133AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:1
134AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:1
135# OFB-AES128.Decrypt
136AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0
137AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:0
138AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:0
139AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:0
140# OFB-AES192.Encrypt
141AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1
142AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:1
143AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:1
144AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:1
145# OFB-AES192.Decrypt
146AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0
147AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:0
148AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:0
149AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:0
150# OFB-AES256.Encrypt
151AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1
152AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:1
153AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:1
154AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:1
155# OFB-AES256.Decrypt
156AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0
157AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:0
158AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0
159AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0
160
161# DES ECB tests (from destest)
162
163DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7
164DES-ECB:FFFFFFFFFFFFFFFF::FFFFFFFFFFFFFFFF:7359B2163E4EDC58
165DES-ECB:3000000000000000::1000000000000001:958E6E627A05557B
166DES-ECB:1111111111111111::1111111111111111:F40379AB9E0EC533
167DES-ECB:0123456789ABCDEF::1111111111111111:17668DFC7292532D
168DES-ECB:1111111111111111::0123456789ABCDEF:8A5AE1F81AB8F2DD
169DES-ECB:FEDCBA9876543210::0123456789ABCDEF:ED39D950FA74BCC4
170
171# DESX-CBC tests (from destest)
172DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:846B2914851E9A2954732F8AA0A611C115CDC2D7951B1053A63C5E03B21AA3C4
173
174# DES EDE3 CBC tests (from destest)
175DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675
176
177# RC4 tests (from rc4test)
178RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596
179RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879
180RC4:00000000000000000000000000000000::0000000000000000:de188941a3375d3a
181RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858
182RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf
183RC4:ef012345ef012345ef012345ef012345::00000000000000000000:d6a141a7ec3c38dfbd61
184
185
186# Camellia tests from RFC3713
187# For all ECB encrypts and decrypts, the transformed sequence is
188# CAMELLIA-bits-ECB:key::plaintext:ciphertext:encdec
189CAMELLIA-128-ECB:0123456789abcdeffedcba9876543210::0123456789abcdeffedcba9876543210:67673138549669730857065648eabe43
190CAMELLIA-192-ECB:0123456789abcdeffedcba98765432100011223344556677::0123456789abcdeffedcba9876543210:b4993401b3e996f84ee5cee7d79b09b9
191CAMELLIA-256-ECB:0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff::0123456789abcdeffedcba9876543210:9acc237dff16d76c20ef7c919e3a7509
192
193# ECB-CAMELLIA128.Encrypt
194CAMELLIA-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:77CF412067AF8270613529149919546F:1
195CAMELLIA-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:B22F3C36B72D31329EEE8ADDC2906C68:1
196CAMELLIA-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:2EDF1F3418D53B88841FC8985FB1ECF2:1
197
198# ECB-CAMELLIA128.Encrypt and ECB-CAMELLIA128.Decrypt
199CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:432FC5DCD628115B7C388D770B270C96
200CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:0BE1F14023782A22E8384C5ABB7FAB2B
201CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:A0A1ABCD1893AB6FE0FE5B65DF5F8636
202CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:E61925E0D5DFAA9BB29F815B3076E51A
203
204# ECB-CAMELLIA192.Encrypt and ECB-CAMELLIA192.Decrypt
205CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:CCCC6C4E138B45848514D48D0D3439D3
206CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:5713C62C14B2EC0F8393B6AFD6F5785A
207CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:B40ED2B60EB54D09D030CF511FEEF366
208CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:909DBD95799096748CB27357E73E1D26
209
210# ECB-CAMELLIA256.Encrypt and ECB-CAMELLIA256.Decrypt
211CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:BEFD219B112FA00098919CD101C9CCFA
212CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:C91D3A8F1AEA08A9386CF4B66C0169EA
213CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:A623D711DC5F25A51BB8A80D56397D28
214CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:7960109FB6DC42947FCFE59EA3C5EB6B
215
216# For all CBC encrypts and decrypts, the transformed sequence is
217# CAMELLIA-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec
218# CBC-CAMELLIA128.Encrypt and CBC-CAMELLIA128.Decrypt
219CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:1607CF494B36BBF00DAEB0B503C831AB
220CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:1607CF494B36BBF00DAEB0B503C831AB:AE2D8A571E03AC9C9EB76FAC45AF8E51:A2F2CF671629EF7840C5A5DFB5074887
221CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:A2F2CF671629EF7840C5A5DFB5074887:30C81C46A35CE411E5FBC1191A0A52EF:0F06165008CF8B8B5A63586362543E54
222CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:36A84CDAFD5F9A85ADA0F0A993D6D577:F69F2445DF4F9B17AD2B417BE66C3710:74C64268CDB8B8FAF5B34E8AF3732980
223
224# CBC-CAMELLIA192.Encrypt and CBC-CAMELLIA192.Decrypt
225CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:2A4830AB5AC4A1A2405955FD2195CF93
226CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2A4830AB5AC4A1A2405955FD2195CF93:AE2D8A571E03AC9C9EB76FAC45AF8E51:5D5A869BD14CE54264F892A6DD2EC3D5
227CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:5D5A869BD14CE54264F892A6DD2EC3D5:30C81C46A35CE411E5FBC1191A0A52EF:37D359C3349836D884E310ADDF68C449
228CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:37D359C3349836D884E310ADDF68C449:F69F2445DF4F9B17AD2B417BE66C3710:01FAAA930B4AB9916E9668E1428C6B08
229
230# CBC-CAMELLIA256.Encrypt and CBC-CAMELLIA256.Decrypt
231CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:E6CFA35FC02B134A4D2C0B6737AC3EDA
232CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E6CFA35FC02B134A4D2C0B6737AC3EDA:AE2D8A571E03AC9C9EB76FAC45AF8E51:36CBEB73BD504B4070B1B7DE2B21EB50
233CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:36CBEB73BD504B4070B1B7DE2B21EB50:30C81C46A35CE411E5FBC1191A0A52EF:E31A6055297D96CA3330CDF1B1860A83
234CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E31A6055297D96CA3330CDF1B1860A83:F69F2445DF4F9B17AD2B417BE66C3710:5D563F6D1CCCF236051C0C5C1C58F28F
235
236# We don't support CFB{1,8}-CAMELLIAxxx.{En,De}crypt
237# For all CFB128 encrypts and decrypts, the transformed sequence is
238# CAMELLIA-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec
239# CFB128-CAMELLIA128.Encrypt
240CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:1
241CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:14F7646187817EB586599146B82BD719:AE2D8A571E03AC9C9EB76FAC45AF8E51:A53D28BB82DF741103EA4F921A44880B:1
242CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:A53D28BB82DF741103EA4F921A44880B:30C81C46A35CE411E5FBC1191A0A52EF:9C2157A664626D1DEF9EA420FDE69B96:1
243CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:9C2157A664626D1DEF9EA420FDE69B96:F69F2445DF4F9B17AD2B417BE66C3710:742A25F0542340C7BAEF24CA8482BB09:1
244
245# CFB128-CAMELLIA128.Decrypt
246CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:0
247CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:14F7646187817EB586599146B82BD719:AE2D8A571E03AC9C9EB76FAC45AF8E51:A53D28BB82DF741103EA4F921A44880B:0
248CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:A53D28BB82DF741103EA4F921A44880B:30C81C46A35CE411E5FBC1191A0A52EF:9C2157A664626D1DEF9EA420FDE69B96:0
249CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:9C2157A664626D1DEF9EA420FDE69B96:F69F2445DF4F9B17AD2B417BE66C3710:742A25F0542340C7BAEF24CA8482BB09:0
250
251# CFB128-CAMELLIA192.Encrypt
252CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:1
253CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:C832BB9780677DAA82D9B6860DCD565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:86F8491627906D780C7A6D46EA331F98:1
254CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:86F8491627906D780C7A6D46EA331F98:30C81C46A35CE411E5FBC1191A0A52EF:69511CCE594CF710CB98BB63D7221F01:1
255CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:69511CCE594CF710CB98BB63D7221F01:F69F2445DF4F9B17AD2B417BE66C3710:D5B5378A3ABED55803F25565D8907B84:1
256
257# CFB128-CAMELLIA192.Decrypt
258CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:0
259CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:C832BB9780677DAA82D9B6860DCD565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:86F8491627906D780C7A6D46EA331F98:0
260CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:86F8491627906D780C7A6D46EA331F98:30C81C46A35CE411E5FBC1191A0A52EF:69511CCE594CF710CB98BB63D7221F01:0
261CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:69511CCE594CF710CB98BB63D7221F01:F69F2445DF4F9B17AD2B417BE66C3710:D5B5378A3ABED55803F25565D8907B84:0
262
263# CFB128-CAMELLIA256.Encrypt
264CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:1
265CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:CF6107BB0CEA7D7FB1BD31F5E7B06C93:AE2D8A571E03AC9C9EB76FAC45AF8E51:89BEDB4CCDD864EA11BA4CBE849B5E2B:1
266CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:89BEDB4CCDD864EA11BA4CBE849B5E2B:30C81C46A35CE411E5FBC1191A0A52EF:555FC3F34BDD2D54C62D9E3BF338C1C4:1
267CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:555FC3F34BDD2D54C62D9E3BF338C1C4:F69F2445DF4F9B17AD2B417BE66C3710:5953ADCE14DB8C7F39F1BD39F359BFFA:1
268
269# CFB128-CAMELLIA256.Decrypt
270CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:0
271CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:CF6107BB0CEA7D7FB1BD31F5E7B06C93:AE2D8A571E03AC9C9EB76FAC45AF8E51:89BEDB4CCDD864EA11BA4CBE849B5E2B:0
272CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:89BEDB4CCDD864EA11BA4CBE849B5E2B:30C81C46A35CE411E5FBC1191A0A52EF:555FC3F34BDD2D54C62D9E3BF338C1C4:0
273CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:555FC3F34BDD2D54C62D9E3BF338C1C4:F69F2445DF4F9B17AD2B417BE66C3710:5953ADCE14DB8C7F39F1BD39F359BFFA:0
274
275# For all OFB encrypts and decrypts, the transformed sequence is
276# CAMELLIA-bits-OFB:key:IV/output':plaintext:ciphertext:encdec
277# OFB-CAMELLIA128.Encrypt
278CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:1
279CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:25623DB569CA51E01482649977E28D84:1
280CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:C776634A60729DC657D12B9FCA801E98:1
281CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:D776379BE0E50825E681DA1A4C980E8E:1
282
283# OFB-CAMELLIA128.Decrypt
284CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:0
285CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:25623DB569CA51E01482649977E28D84:0
286CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:C776634A60729DC657D12B9FCA801E98:0
287CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:D776379BE0E50825E681DA1A4C980E8E:0
288
289# OFB-CAMELLIA192.Encrypt
290CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:1
291CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:8ECEB7D0350D72C7F78562AEBDF99339:1
292CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:BDD62DBBB9700846C53B507F544696F0:1
293CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:E28014E046B802F385C4C2E13EAD4A72:1
294
295# OFB-CAMELLIA192.Decrypt
296CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:0
297CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:8ECEB7D0350D72C7F78562AEBDF99339:0
298CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:BDD62DBBB9700846C53B507F544696F0:0
299CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:E28014E046B802F385C4C2E13EAD4A72:0
300
301# OFB-CAMELLIA256.Encrypt
302CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:1
303CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:127AD97E8E3994E4820027D7BA109368:1
304CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:6BFF6265A6A6B7A535BC65A80B17214E:1
305CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0A4A0404E26AA78A27CB271E8BF3CF20:1
306
307# OFB-CAMELLIA256.Decrypt
308CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:0
309CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:127AD97E8E3994E4820027D7BA109368:0
310CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:6BFF6265A6A6B7A535BC65A80B17214E:0
311CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0A4A0404E26AA78A27CB271E8BF3CF20:0
312
313# SEED test vectors from RFC4269
314SEED-ECB:00000000000000000000000000000000::000102030405060708090A0B0C0D0E0F:5EBAC6E0054E166819AFF1CC6D346CDB:0
315SEED-ECB:000102030405060708090A0B0C0D0E0F::00000000000000000000000000000000:C11F22F20140505084483597E4370F43:0
316SEED-ECB:4706480851E61BE85D74BFB3FD956185::83A2F8A288641FB9A4E9A5CC2F131C7D:EE54D13EBCAE706D226BC3142CD40D4A:0
317SEED-ECB:28DBC3BC49FFD87DCFA509B11D422BE7::B41E6BE2EBA84A148E2EED84593C5EC7:9B9B7BFCD1813CB95D0B3618F40F5122:0
318SEED-ECB:00000000000000000000000000000000::000102030405060708090A0B0C0D0E0F:5EBAC6E0054E166819AFF1CC6D346CDB:1
319SEED-ECB:000102030405060708090A0B0C0D0E0F::00000000000000000000000000000000:C11F22F20140505084483597E4370F43:1
320SEED-ECB:4706480851E61BE85D74BFB3FD956185::83A2F8A288641FB9A4E9A5CC2F131C7D:EE54D13EBCAE706D226BC3142CD40D4A:1
321SEED-ECB:28DBC3BC49FFD87DCFA509B11D422BE7::B41E6BE2EBA84A148E2EED84593C5EC7:9B9B7BFCD1813CB95D0B3618F40F5122:1
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c
index 4ad63ada6f..48c2689504 100644
--- a/src/lib/libcrypto/evp/m_dss.c
+++ b/src/lib/libcrypto/evp/m_dss.c
@@ -66,7 +66,6 @@
66#endif 66#endif
67 67
68#ifndef OPENSSL_NO_SHA 68#ifndef OPENSSL_NO_SHA
69#ifndef OPENSSL_FIPS
70 69
71static int init(EVP_MD_CTX *ctx) 70static int init(EVP_MD_CTX *ctx)
72 { return SHA1_Init(ctx->md_data); } 71 { return SHA1_Init(ctx->md_data); }
@@ -98,4 +97,3 @@ const EVP_MD *EVP_dss(void)
98 return(&dsa_md); 97 return(&dsa_md);
99 } 98 }
100#endif 99#endif
101#endif
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c
index f80170efeb..4f03fb70e0 100644
--- a/src/lib/libcrypto/evp/m_dss1.c
+++ b/src/lib/libcrypto/evp/m_dss1.c
@@ -68,8 +68,6 @@
68#include <openssl/dsa.h> 68#include <openssl/dsa.h>
69#endif 69#endif
70 70
71#ifndef OPENSSL_FIPS
72
73static int init(EVP_MD_CTX *ctx) 71static int init(EVP_MD_CTX *ctx)
74 { return SHA1_Init(ctx->md_data); } 72 { return SHA1_Init(ctx->md_data); }
75 73
@@ -100,4 +98,3 @@ const EVP_MD *EVP_dss1(void)
100 return(&dss1_md); 98 return(&dss1_md);
101 } 99 }
102#endif 100#endif
103#endif
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c
new file mode 100644
index 0000000000..5ce849f161
--- /dev/null
+++ b/src/lib/libcrypto/evp/m_md2.c
@@ -0,0 +1,101 @@
1/* crypto/evp/m_md2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61
62#ifndef OPENSSL_NO_MD2
63
64#include <openssl/evp.h>
65#include <openssl/objects.h>
66#include <openssl/x509.h>
67#include <openssl/md2.h>
68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h>
70#endif
71
72static int init(EVP_MD_CTX *ctx)
73 { return MD2_Init(ctx->md_data); }
74
75static int update(EVP_MD_CTX *ctx,const void *data,size_t count)
76 { return MD2_Update(ctx->md_data,data,count); }
77
78static int final(EVP_MD_CTX *ctx,unsigned char *md)
79 { return MD2_Final(md,ctx->md_data); }
80
81static const EVP_MD md2_md=
82 {
83 NID_md2,
84 NID_md2WithRSAEncryption,
85 MD2_DIGEST_LENGTH,
86 0,
87 init,
88 update,
89 final,
90 NULL,
91 NULL,
92 EVP_PKEY_RSA_method,
93 MD2_BLOCK,
94 sizeof(EVP_MD *)+sizeof(MD2_CTX),
95 };
96
97const EVP_MD *EVP_md2(void)
98 {
99 return(&md2_md);
100 }
101#endif
diff --git a/src/lib/libcrypto/evp/m_md4.c b/src/lib/libcrypto/evp/m_md4.c
index 6d47f61b27..1e0b7c5b42 100644
--- a/src/lib/libcrypto/evp/m_md4.c
+++ b/src/lib/libcrypto/evp/m_md4.c
@@ -69,8 +69,6 @@
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70#endif 70#endif
71 71
72#include "evp_locl.h"
73
74static int init(EVP_MD_CTX *ctx) 72static int init(EVP_MD_CTX *ctx)
75 { return MD4_Init(ctx->md_data); } 73 { return MD4_Init(ctx->md_data); }
76 74
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c
index 9a8bae0258..63c142119e 100644
--- a/src/lib/libcrypto/evp/m_md5.c
+++ b/src/lib/libcrypto/evp/m_md5.c
@@ -68,7 +68,6 @@
68#ifndef OPENSSL_NO_RSA 68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70#endif 70#endif
71#include "evp_locl.h"
72 71
73static int init(EVP_MD_CTX *ctx) 72static int init(EVP_MD_CTX *ctx)
74 { return MD5_Init(ctx->md_data); } 73 { return MD5_Init(ctx->md_data); }
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c
new file mode 100644
index 0000000000..b08d559803
--- /dev/null
+++ b/src/lib/libcrypto/evp/m_mdc2.c
@@ -0,0 +1,101 @@
1/* crypto/evp/m_mdc2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61
62#ifndef OPENSSL_NO_MDC2
63
64#include <openssl/evp.h>
65#include <openssl/objects.h>
66#include <openssl/x509.h>
67#include <openssl/mdc2.h>
68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h>
70#endif
71
72static int init(EVP_MD_CTX *ctx)
73 { return MDC2_Init(ctx->md_data); }
74
75static int update(EVP_MD_CTX *ctx,const void *data,size_t count)
76 { return MDC2_Update(ctx->md_data,data,count); }
77
78static int final(EVP_MD_CTX *ctx,unsigned char *md)
79 { return MDC2_Final(md,ctx->md_data); }
80
81static const EVP_MD mdc2_md=
82 {
83 NID_mdc2,
84 NID_mdc2WithRSA,
85 MDC2_DIGEST_LENGTH,
86 0,
87 init,
88 update,
89 final,
90 NULL,
91 NULL,
92 EVP_PKEY_RSA_ASN1_OCTET_STRING_method,
93 MDC2_BLOCK,
94 sizeof(EVP_MD *)+sizeof(MDC2_CTX),
95 };
96
97const EVP_MD *EVP_mdc2(void)
98 {
99 return(&mdc2_md);
100 }
101#endif
diff --git a/src/lib/libcrypto/evp/m_ripemd.c b/src/lib/libcrypto/evp/m_ripemd.c
index 7bf4804cf8..a1d60ee78d 100644
--- a/src/lib/libcrypto/evp/m_ripemd.c
+++ b/src/lib/libcrypto/evp/m_ripemd.c
@@ -68,7 +68,6 @@
68#ifndef OPENSSL_NO_RSA 68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h> 69#include <openssl/rsa.h>
70#endif 70#endif
71#include "evp_locl.h"
72 71
73static int init(EVP_MD_CTX *ctx) 72static int init(EVP_MD_CTX *ctx)
74 { return RIPEMD160_Init(ctx->md_data); } 73 { return RIPEMD160_Init(ctx->md_data); }
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c
new file mode 100644
index 0000000000..acccc8f92d
--- /dev/null
+++ b/src/lib/libcrypto/evp/m_sha.c
@@ -0,0 +1,100 @@
1/* crypto/evp/m_sha.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61
62#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
63
64#include <openssl/evp.h>
65#include <openssl/objects.h>
66#include <openssl/x509.h>
67#ifndef OPENSSL_NO_RSA
68#include <openssl/rsa.h>
69#endif
70
71static int init(EVP_MD_CTX *ctx)
72 { return SHA_Init(ctx->md_data); }
73
74static int update(EVP_MD_CTX *ctx,const void *data,size_t count)
75 { return SHA_Update(ctx->md_data,data,count); }
76
77static int final(EVP_MD_CTX *ctx,unsigned char *md)
78 { return SHA_Final(md,ctx->md_data); }
79
80static const EVP_MD sha_md=
81 {
82 NID_sha,
83 NID_shaWithRSAEncryption,
84 SHA_DIGEST_LENGTH,
85 0,
86 init,
87 update,
88 final,
89 NULL,
90 NULL,
91 EVP_PKEY_RSA_method,
92 SHA_CBLOCK,
93 sizeof(EVP_MD *)+sizeof(SHA_CTX),
94 };
95
96const EVP_MD *EVP_sha(void)
97 {
98 return(&sha_md);
99 }
100#endif
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c
index 3cb11f1ebb..9a2790fdea 100644
--- a/src/lib/libcrypto/evp/m_sha1.c
+++ b/src/lib/libcrypto/evp/m_sha1.c
@@ -59,8 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61 61
62#ifndef OPENSSL_FIPS
63
64#ifndef OPENSSL_NO_SHA 62#ifndef OPENSSL_NO_SHA
65 63
66#include <openssl/evp.h> 64#include <openssl/evp.h>
@@ -70,7 +68,6 @@
70#include <openssl/rsa.h> 68#include <openssl/rsa.h>
71#endif 69#endif
72 70
73
74static int init(EVP_MD_CTX *ctx) 71static int init(EVP_MD_CTX *ctx)
75 { return SHA1_Init(ctx->md_data); } 72 { return SHA1_Init(ctx->md_data); }
76 73
@@ -205,5 +202,3 @@ static const EVP_MD sha512_md=
205const EVP_MD *EVP_sha512(void) 202const EVP_MD *EVP_sha512(void)
206 { return(&sha512_md); } 203 { return(&sha512_md); }
207#endif /* ifndef OPENSSL_NO_SHA512 */ 204#endif /* ifndef OPENSSL_NO_SHA512 */
208
209#endif
diff --git a/src/lib/libcrypto/evp/names.c b/src/lib/libcrypto/evp/names.c
index 6311ad7cfb..f2869f5c78 100644
--- a/src/lib/libcrypto/evp/names.c
+++ b/src/lib/libcrypto/evp/names.c
@@ -66,10 +66,6 @@ int EVP_add_cipher(const EVP_CIPHER *c)
66 { 66 {
67 int r; 67 int r;
68 68
69 if (c == NULL) return 0;
70
71 OPENSSL_init();
72
73 r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c); 69 r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
74 if (r == 0) return(0); 70 if (r == 0) return(0);
75 check_defer(c->nid); 71 check_defer(c->nid);
@@ -82,7 +78,6 @@ int EVP_add_digest(const EVP_MD *md)
82 { 78 {
83 int r; 79 int r;
84 const char *name; 80 const char *name;
85 OPENSSL_init();
86 81
87 name=OBJ_nid2sn(md->type); 82 name=OBJ_nid2sn(md->type);
88 r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md); 83 r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md);
diff --git a/src/lib/libcrypto/evp/openbsd_hw.c b/src/lib/libcrypto/evp/openbsd_hw.c
new file mode 100644
index 0000000000..3831a5731e
--- /dev/null
+++ b/src/lib/libcrypto/evp/openbsd_hw.c
@@ -0,0 +1,446 @@
1/* Written by Ben Laurie, 2001 */
2/*
3 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 */
49
50#include <openssl/evp.h>
51#include <openssl/objects.h>
52#include <openssl/rsa.h>
53#include "evp_locl.h"
54
55/* This stuff should now all be supported through
56 * crypto/engine/hw_openbsd_dev_crypto.c unless I botched it up */
57static void *dummy=&dummy;
58
59#if 0
60
61/* check flag after OpenSSL headers to ensure make depend works */
62#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
63
64#include <fcntl.h>
65#include <stdio.h>
66#include <errno.h>
67#include <sys/ioctl.h>
68#include <crypto/cryptodev.h>
69#include <unistd.h>
70#include <assert.h>
71
72/* longest key supported in hardware */
73#define MAX_HW_KEY 24
74#define MAX_HW_IV 8
75
76#define MD5_DIGEST_LENGTH 16
77#define MD5_CBLOCK 64
78
79static int fd;
80static int dev_failed;
81
82typedef struct session_op session_op;
83
84#define CDATA(ctx) EVP_C_DATA(session_op,ctx)
85
86static void err(const char *str)
87 {
88 fprintf(stderr,"%s: errno %d\n",str,errno);
89 }
90
91static int dev_crypto_init(session_op *ses)
92 {
93 if(dev_failed)
94 return 0;
95 if(!fd)
96 {
97 int cryptodev_fd;
98
99 if ((cryptodev_fd=open("/dev/crypto",O_RDWR,0)) < 0)
100 {
101 err("/dev/crypto");
102 dev_failed=1;
103 return 0;
104 }
105 if (ioctl(cryptodev_fd,CRIOGET,&fd) == -1)
106 {
107 err("CRIOGET failed");
108 close(cryptodev_fd);
109 dev_failed=1;
110 return 0;
111 }
112 close(cryptodev_fd);
113 }
114 assert(ses);
115 memset(ses,'\0',sizeof *ses);
116
117 return 1;
118 }
119
120static int dev_crypto_cleanup(EVP_CIPHER_CTX *ctx)
121 {
122 if(ioctl(fd,CIOCFSESSION,&CDATA(ctx)->ses) == -1)
123 err("CIOCFSESSION failed");
124
125 OPENSSL_free(CDATA(ctx)->key);
126
127 return 1;
128 }
129
130static int dev_crypto_init_key(EVP_CIPHER_CTX *ctx,int cipher,
131 const unsigned char *key,int klen)
132 {
133 if(!dev_crypto_init(CDATA(ctx)))
134 return 0;
135
136 CDATA(ctx)->key=OPENSSL_malloc(MAX_HW_KEY);
137
138 assert(ctx->cipher->iv_len <= MAX_HW_IV);
139
140 memcpy(CDATA(ctx)->key,key,klen);
141
142 CDATA(ctx)->cipher=cipher;
143 CDATA(ctx)->keylen=klen;
144
145 if (ioctl(fd,CIOCGSESSION,CDATA(ctx)) == -1)
146 {
147 err("CIOCGSESSION failed");
148 return 0;
149 }
150 return 1;
151 }
152
153static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
154 const unsigned char *in,unsigned int inl)
155 {
156 struct crypt_op cryp;
157 unsigned char lb[MAX_HW_IV];
158
159 if(!inl)
160 return 1;
161
162 assert(CDATA(ctx));
163 assert(!dev_failed);
164
165 memset(&cryp,'\0',sizeof cryp);
166 cryp.ses=CDATA(ctx)->ses;
167 cryp.op=ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
168 cryp.flags=0;
169 cryp.len=inl;
170 assert((inl&(ctx->cipher->block_size-1)) == 0);
171 cryp.src=(caddr_t)in;
172 cryp.dst=(caddr_t)out;
173 cryp.mac=0;
174 if(ctx->cipher->iv_len)
175 cryp.iv=(caddr_t)ctx->iv;
176
177 if(!ctx->encrypt)
178 memcpy(lb,&in[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len);
179
180 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
181 {
182 if(errno == EINVAL) /* buffers are misaligned */
183 {
184 unsigned int cinl=0;
185 char *cin=NULL;
186 char *cout=NULL;
187
188 /* NB: this can only make cinl != inl with stream ciphers */
189 cinl=(inl+3)/4*4;
190
191 if(((unsigned long)in&3) || cinl != inl)
192 {
193 cin=OPENSSL_malloc(cinl);
194 memcpy(cin,in,inl);
195 cryp.src=cin;
196 }
197
198 if(((unsigned long)out&3) || cinl != inl)
199 {
200 cout=OPENSSL_malloc(cinl);
201 cryp.dst=cout;
202 }
203
204 cryp.len=cinl;
205
206 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
207 {
208 err("CIOCCRYPT(2) failed");
209 printf("src=%p dst=%p\n",cryp.src,cryp.dst);
210 abort();
211 return 0;
212 }
213
214 if(cout)
215 {
216 memcpy(out,cout,inl);
217 OPENSSL_free(cout);
218 }
219 if(cin)
220 OPENSSL_free(cin);
221 }
222 else
223 {
224 err("CIOCCRYPT failed");
225 abort();
226 return 0;
227 }
228 }
229
230 if(ctx->encrypt)
231 memcpy(ctx->iv,&out[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len);
232 else
233 memcpy(ctx->iv,lb,ctx->cipher->iv_len);
234
235 return 1;
236 }
237
238static int dev_crypto_des_ede3_init_key(EVP_CIPHER_CTX *ctx,
239 const unsigned char *key,
240 const unsigned char *iv, int enc)
241 { return dev_crypto_init_key(ctx,CRYPTO_3DES_CBC,key,24); }
242
243#define dev_crypto_des_ede3_cbc_cipher dev_crypto_cipher
244
245BLOCK_CIPHER_def_cbc(dev_crypto_des_ede3, session_op, NID_des_ede3, 8, 24, 8,
246 0, dev_crypto_des_ede3_init_key,
247 dev_crypto_cleanup,
248 EVP_CIPHER_set_asn1_iv,
249 EVP_CIPHER_get_asn1_iv,
250 NULL)
251
252static int dev_crypto_rc4_init_key(EVP_CIPHER_CTX *ctx,
253 const unsigned char *key,
254 const unsigned char *iv, int enc)
255 { return dev_crypto_init_key(ctx,CRYPTO_ARC4,key,16); }
256
257static const EVP_CIPHER r4_cipher=
258 {
259 NID_rc4,
260 1,16,0, /* FIXME: key should be up to 256 bytes */
261 EVP_CIPH_VARIABLE_LENGTH,
262 dev_crypto_rc4_init_key,
263 dev_crypto_cipher,
264 dev_crypto_cleanup,
265 sizeof(session_op),
266 NULL,
267 NULL,
268 NULL
269 };
270
271const EVP_CIPHER *EVP_dev_crypto_rc4(void)
272 { return &r4_cipher; }
273
274typedef struct
275 {
276 session_op sess;
277 char *data;
278 int len;
279 unsigned char md[EVP_MAX_MD_SIZE];
280 } MD_DATA;
281
282static int dev_crypto_init_digest(MD_DATA *md_data,int mac)
283 {
284 if(!dev_crypto_init(&md_data->sess))
285 return 0;
286
287 md_data->len=0;
288 md_data->data=NULL;
289
290 md_data->sess.mac=mac;
291
292 if (ioctl(fd,CIOCGSESSION,&md_data->sess) == -1)
293 {
294 err("CIOCGSESSION failed");
295 return 0;
296 }
297 return 1;
298 }
299
300static int dev_crypto_cleanup_digest(MD_DATA *md_data)
301 {
302 if (ioctl(fd,CIOCFSESSION,&md_data->sess.ses) == -1)
303 {
304 err("CIOCFSESSION failed");
305 return 0;
306 }
307
308 return 1;
309 }
310
311/* FIXME: if device can do chained MACs, then don't accumulate */
312/* FIXME: move accumulation to the framework */
313static int dev_crypto_md5_init(EVP_MD_CTX *ctx)
314 { return dev_crypto_init_digest(ctx->md_data,CRYPTO_MD5); }
315
316static int do_digest(int ses,unsigned char *md,const void *data,int len)
317 {
318 struct crypt_op cryp;
319 static unsigned char md5zero[16]=
320 {
321 0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,
322 0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e
323 };
324
325 /* some cards can't do zero length */
326 if(!len)
327 {
328 memcpy(md,md5zero,16);
329 return 1;
330 }
331
332 memset(&cryp,'\0',sizeof cryp);
333 cryp.ses=ses;
334 cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */
335 cryp.len=len;
336 cryp.src=(caddr_t)data;
337 cryp.dst=(caddr_t)data; // FIXME!!!
338 cryp.mac=(caddr_t)md;
339
340 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
341 {
342 if(errno == EINVAL) /* buffer is misaligned */
343 {
344 char *dcopy;
345
346 dcopy=OPENSSL_malloc(len);
347 memcpy(dcopy,data,len);
348 cryp.src=dcopy;
349 cryp.dst=cryp.src; // FIXME!!!
350
351 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
352 {
353 err("CIOCCRYPT(MAC2) failed");
354 abort();
355 return 0;
356 }
357 OPENSSL_free(dcopy);
358 }
359 else
360 {
361 err("CIOCCRYPT(MAC) failed");
362 abort();
363 return 0;
364 }
365 }
366 // printf("done\n");
367
368 return 1;
369 }
370
371static int dev_crypto_md5_update(EVP_MD_CTX *ctx,const void *data,
372 unsigned long len)
373 {
374 MD_DATA *md_data=ctx->md_data;
375
376 if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
377 return do_digest(md_data->sess.ses,md_data->md,data,len);
378
379 md_data->data=OPENSSL_realloc(md_data->data,md_data->len+len);
380 memcpy(md_data->data+md_data->len,data,len);
381 md_data->len+=len;
382
383 return 1;
384 }
385
386static int dev_crypto_md5_final(EVP_MD_CTX *ctx,unsigned char *md)
387 {
388 int ret;
389 MD_DATA *md_data=ctx->md_data;
390
391 if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
392 {
393 memcpy(md,md_data->md,MD5_DIGEST_LENGTH);
394 ret=1;
395 }
396 else
397 {
398 ret=do_digest(md_data->sess.ses,md,md_data->data,md_data->len);
399 OPENSSL_free(md_data->data);
400 md_data->data=NULL;
401 md_data->len=0;
402 }
403
404 return ret;
405 }
406
407static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
408 {
409 const MD_DATA *from_md=from->md_data;
410 MD_DATA *to_md=to->md_data;
411
412 // How do we copy sessions?
413 assert(from->digest->flags&EVP_MD_FLAG_ONESHOT);
414
415 to_md->data=OPENSSL_malloc(from_md->len);
416 memcpy(to_md->data,from_md->data,from_md->len);
417
418 return 1;
419 }
420
421static int dev_crypto_md5_cleanup(EVP_MD_CTX *ctx)
422 {
423 return dev_crypto_cleanup_digest(ctx->md_data);
424 }
425
426static const EVP_MD md5_md=
427 {
428 NID_md5,
429 NID_md5WithRSAEncryption,
430 MD5_DIGEST_LENGTH,
431 EVP_MD_FLAG_ONESHOT, // XXX: set according to device info...
432 dev_crypto_md5_init,
433 dev_crypto_md5_update,
434 dev_crypto_md5_final,
435 dev_crypto_md5_copy,
436 dev_crypto_md5_cleanup,
437 EVP_PKEY_RSA_method,
438 MD5_CBLOCK,
439 sizeof(MD_DATA),
440 };
441
442const EVP_MD *EVP_dev_crypto_md5(void)
443 { return &md5_md; }
444
445#endif
446#endif
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c
index 294cc90d87..7ecfa8dad9 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -82,8 +82,6 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
82 unsigned char *salt; 82 unsigned char *salt;
83 const unsigned char *pbuf; 83 const unsigned char *pbuf;
84 int mdsize; 84 int mdsize;
85 int rv = 0;
86 EVP_MD_CTX_init(&ctx);
87 85
88 /* Extract useful info from parameter */ 86 /* Extract useful info from parameter */
89 if (param == NULL || param->type != V_ASN1_SEQUENCE || 87 if (param == NULL || param->type != V_ASN1_SEQUENCE ||
@@ -106,38 +104,29 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
106 if(!pass) passlen = 0; 104 if(!pass) passlen = 0;
107 else if(passlen == -1) passlen = strlen(pass); 105 else if(passlen == -1) passlen = strlen(pass);
108 106
109 if (!EVP_DigestInit_ex(&ctx, md, NULL)) 107 EVP_MD_CTX_init(&ctx);
110 goto err; 108 EVP_DigestInit_ex(&ctx, md, NULL);
111 if (!EVP_DigestUpdate(&ctx, pass, passlen)) 109 EVP_DigestUpdate(&ctx, pass, passlen);
112 goto err; 110 EVP_DigestUpdate(&ctx, salt, saltlen);
113 if (!EVP_DigestUpdate(&ctx, salt, saltlen))
114 goto err;
115 PBEPARAM_free(pbe); 111 PBEPARAM_free(pbe);
116 if (!EVP_DigestFinal_ex(&ctx, md_tmp, NULL)) 112 EVP_DigestFinal_ex(&ctx, md_tmp, NULL);
117 goto err;
118 mdsize = EVP_MD_size(md); 113 mdsize = EVP_MD_size(md);
119 if (mdsize < 0) 114 if (mdsize < 0)
120 return 0; 115 return 0;
121 for (i = 1; i < iter; i++) { 116 for (i = 1; i < iter; i++) {
122 if (!EVP_DigestInit_ex(&ctx, md, NULL)) 117 EVP_DigestInit_ex(&ctx, md, NULL);
123 goto err; 118 EVP_DigestUpdate(&ctx, md_tmp, mdsize);
124 if (!EVP_DigestUpdate(&ctx, md_tmp, mdsize)) 119 EVP_DigestFinal_ex (&ctx, md_tmp, NULL);
125 goto err;
126 if (!EVP_DigestFinal_ex (&ctx, md_tmp, NULL))
127 goto err;
128 } 120 }
121 EVP_MD_CTX_cleanup(&ctx);
129 OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= (int)sizeof(md_tmp)); 122 OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= (int)sizeof(md_tmp));
130 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); 123 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher));
131 OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16); 124 OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16);
132 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), 125 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)),
133 EVP_CIPHER_iv_length(cipher)); 126 EVP_CIPHER_iv_length(cipher));
134 if (!EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de)) 127 EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de);
135 goto err;
136 OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE); 128 OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE);
137 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); 129 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
138 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); 130 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH);
139 rv = 1; 131 return 1;
140 err:
141 EVP_MD_CTX_cleanup(&ctx);
142 return rv;
143} 132}
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c
index 975d004df4..334379f310 100644
--- a/src/lib/libcrypto/evp/p5_crpt2.c
+++ b/src/lib/libcrypto/evp/p5_crpt2.c
@@ -62,7 +62,6 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/hmac.h> 64#include <openssl/hmac.h>
65#include "evp_locl.h"
66 65
67/* set this to print out info about the keygen algorithm */ 66/* set this to print out info about the keygen algorithm */
68/* #define DEBUG_PKCS5V2 */ 67/* #define DEBUG_PKCS5V2 */
@@ -111,14 +110,10 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
111 itmp[1] = (unsigned char)((i >> 16) & 0xff); 110 itmp[1] = (unsigned char)((i >> 16) & 0xff);
112 itmp[2] = (unsigned char)((i >> 8) & 0xff); 111 itmp[2] = (unsigned char)((i >> 8) & 0xff);
113 itmp[3] = (unsigned char)(i & 0xff); 112 itmp[3] = (unsigned char)(i & 0xff);
114 if (!HMAC_Init_ex(&hctx, pass, passlen, digest, NULL) 113 HMAC_Init_ex(&hctx, pass, passlen, digest, NULL);
115 || !HMAC_Update(&hctx, salt, saltlen) 114 HMAC_Update(&hctx, salt, saltlen);
116 || !HMAC_Update(&hctx, itmp, 4) 115 HMAC_Update(&hctx, itmp, 4);
117 || !HMAC_Final(&hctx, digtmp, NULL)) 116 HMAC_Final(&hctx, digtmp, NULL);
118 {
119 HMAC_CTX_cleanup(&hctx);
120 return 0;
121 }
122 memcpy(p, digtmp, cplen); 117 memcpy(p, digtmp, cplen);
123 for(j = 1; j < iter; j++) 118 for(j = 1; j < iter; j++)
124 { 119 {
@@ -173,24 +168,27 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
173 ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, 168 ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md,
174 int en_de) 169 int en_de)
175{ 170{
171 unsigned char *salt, key[EVP_MAX_KEY_LENGTH];
176 const unsigned char *pbuf; 172 const unsigned char *pbuf;
177 int plen; 173 int saltlen, iter, plen;
174 unsigned int keylen;
178 PBE2PARAM *pbe2 = NULL; 175 PBE2PARAM *pbe2 = NULL;
179 const EVP_CIPHER *cipher; 176 const EVP_CIPHER *cipher;
180 177 PBKDF2PARAM *kdf = NULL;
181 int rv = 0; 178 const EVP_MD *prfmd;
179 int prf_nid, hmac_md_nid;
182 180
183 if (param == NULL || param->type != V_ASN1_SEQUENCE || 181 if (param == NULL || param->type != V_ASN1_SEQUENCE ||
184 param->value.sequence == NULL) { 182 param->value.sequence == NULL) {
185 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); 183 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
186 goto err; 184 return 0;
187 } 185 }
188 186
189 pbuf = param->value.sequence->data; 187 pbuf = param->value.sequence->data;
190 plen = param->value.sequence->length; 188 plen = param->value.sequence->length;
191 if(!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) { 189 if(!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
192 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); 190 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
193 goto err; 191 return 0;
194 } 192 }
195 193
196 /* See if we recognise the key derivation function */ 194 /* See if we recognise the key derivation function */
@@ -213,63 +211,38 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
213 } 211 }
214 212
215 /* Fixup cipher based on AlgorithmIdentifier */ 213 /* Fixup cipher based on AlgorithmIdentifier */
216 if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de)) 214 EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de);
217 goto err;
218 if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) { 215 if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) {
219 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, 216 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
220 EVP_R_CIPHER_PARAMETER_ERROR); 217 EVP_R_CIPHER_PARAMETER_ERROR);
221 goto err; 218 goto err;
222 } 219 }
223 rv = PKCS5_v2_PBKDF2_keyivgen(ctx, pass, passlen,
224 pbe2->keyfunc->parameter, c, md, en_de);
225 err:
226 PBE2PARAM_free(pbe2);
227 return rv;
228}
229
230int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
231 ASN1_TYPE *param,
232 const EVP_CIPHER *c, const EVP_MD *md, int en_de)
233{
234 unsigned char *salt, key[EVP_MAX_KEY_LENGTH];
235 const unsigned char *pbuf;
236 int saltlen, iter, plen;
237 int rv = 0;
238 unsigned int keylen = 0;
239 int prf_nid, hmac_md_nid;
240 PBKDF2PARAM *kdf = NULL;
241 const EVP_MD *prfmd;
242
243 if (EVP_CIPHER_CTX_cipher(ctx) == NULL)
244 {
245 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,EVP_R_NO_CIPHER_SET);
246 goto err;
247 }
248 keylen = EVP_CIPHER_CTX_key_length(ctx); 220 keylen = EVP_CIPHER_CTX_key_length(ctx);
249 OPENSSL_assert(keylen <= sizeof key); 221 OPENSSL_assert(keylen <= sizeof key);
250 222
251 /* Decode parameter */ 223 /* Now decode key derivation function */
252 224
253 if(!param || (param->type != V_ASN1_SEQUENCE)) 225 if(!pbe2->keyfunc->parameter ||
226 (pbe2->keyfunc->parameter->type != V_ASN1_SEQUENCE))
254 { 227 {
255 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,EVP_R_DECODE_ERROR); 228 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
256 goto err; 229 goto err;
257 } 230 }
258 231
259 pbuf = param->value.sequence->data; 232 pbuf = pbe2->keyfunc->parameter->value.sequence->data;
260 plen = param->value.sequence->length; 233 plen = pbe2->keyfunc->parameter->value.sequence->length;
261
262 if(!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) { 234 if(!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) {
263 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN,EVP_R_DECODE_ERROR); 235 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
264 goto err; 236 goto err;
265 } 237 }
266 238
267 keylen = EVP_CIPHER_CTX_key_length(ctx); 239 PBE2PARAM_free(pbe2);
240 pbe2 = NULL;
268 241
269 /* Now check the parameters of the kdf */ 242 /* Now check the parameters of the kdf */
270 243
271 if(kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != (int)keylen)){ 244 if(kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != (int)keylen)){
272 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, 245 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
273 EVP_R_UNSUPPORTED_KEYLENGTH); 246 EVP_R_UNSUPPORTED_KEYLENGTH);
274 goto err; 247 goto err;
275 } 248 }
@@ -281,19 +254,19 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
281 254
282 if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0)) 255 if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0))
283 { 256 {
284 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); 257 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
285 goto err; 258 goto err;
286 } 259 }
287 260
288 prfmd = EVP_get_digestbynid(hmac_md_nid); 261 prfmd = EVP_get_digestbynid(hmac_md_nid);
289 if (prfmd == NULL) 262 if (prfmd == NULL)
290 { 263 {
291 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); 264 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
292 goto err; 265 goto err;
293 } 266 }
294 267
295 if(kdf->salt->type != V_ASN1_OCTET_STRING) { 268 if(kdf->salt->type != V_ASN1_OCTET_STRING) {
296 EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, 269 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
297 EVP_R_UNSUPPORTED_SALT_TYPE); 270 EVP_R_UNSUPPORTED_SALT_TYPE);
298 goto err; 271 goto err;
299 } 272 }
@@ -305,11 +278,15 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
305 if(!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd, 278 if(!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd,
306 keylen, key)) 279 keylen, key))
307 goto err; 280 goto err;
308 rv = EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de); 281 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
309 err:
310 OPENSSL_cleanse(key, keylen); 282 OPENSSL_cleanse(key, keylen);
311 PBKDF2PARAM_free(kdf); 283 PBKDF2PARAM_free(kdf);
312 return rv; 284 return 1;
285
286 err:
287 PBE2PARAM_free(pbe2);
288 PBKDF2PARAM_free(kdf);
289 return 0;
313} 290}
314 291
315#ifdef DEBUG_PKCS5V2 292#ifdef DEBUG_PKCS5V2
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c
index c748fbea87..53a59a295c 100644
--- a/src/lib/libcrypto/evp/p_open.c
+++ b/src/lib/libcrypto/evp/p_open.c
@@ -115,8 +115,7 @@ int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
115 int i; 115 int i;
116 116
117 i=EVP_DecryptFinal_ex(ctx,out,outl); 117 i=EVP_DecryptFinal_ex(ctx,out,outl);
118 if (i) 118 EVP_DecryptInit_ex(ctx,NULL,NULL,NULL,NULL);
119 i = EVP_DecryptInit_ex(ctx,NULL,NULL,NULL,NULL);
120 return(i); 119 return(i);
121 } 120 }
122#else /* !OPENSSL_NO_RSA */ 121#else /* !OPENSSL_NO_RSA */
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c
index e5919b0fbf..d8324526e7 100644
--- a/src/lib/libcrypto/evp/p_seal.c
+++ b/src/lib/libcrypto/evp/p_seal.c
@@ -110,7 +110,6 @@ int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
110 { 110 {
111 int i; 111 int i;
112 i = EVP_EncryptFinal_ex(ctx,out,outl); 112 i = EVP_EncryptFinal_ex(ctx,out,outl);
113 if (i) 113 EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL);
114 i = EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL);
115 return i; 114 return i;
116 } 115 }
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c
index dfa48c157c..bb893f5bde 100644
--- a/src/lib/libcrypto/evp/p_sign.c
+++ b/src/lib/libcrypto/evp/p_sign.c
@@ -80,20 +80,18 @@ 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,ok=0,v;
84 EVP_MD_CTX tmp_ctx; 84 EVP_MD_CTX tmp_ctx;
85 EVP_PKEY_CTX *pkctx = NULL;
86 85
87 *siglen=0; 86 *siglen=0;
88 EVP_MD_CTX_init(&tmp_ctx); 87 EVP_MD_CTX_init(&tmp_ctx);
89 if (!EVP_MD_CTX_copy_ex(&tmp_ctx,ctx)) 88 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
90 goto err; 89 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
91 if (!EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len))
92 goto err;
93 EVP_MD_CTX_cleanup(&tmp_ctx); 90 EVP_MD_CTX_cleanup(&tmp_ctx);
94 91
95 if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) 92 if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
96 { 93 {
94 EVP_PKEY_CTX *pkctx = NULL;
97 size_t sltmp = (size_t)EVP_PKEY_size(pkey); 95 size_t sltmp = (size_t)EVP_PKEY_size(pkey);
98 i = 0; 96 i = 0;
99 pkctx = EVP_PKEY_CTX_new(pkey, NULL); 97 pkctx = EVP_PKEY_CTX_new(pkey, NULL);
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c
index 5f5c409f45..41d4b67130 100644
--- a/src/lib/libcrypto/evp/p_verify.c
+++ b/src/lib/libcrypto/evp/p_verify.c
@@ -67,19 +67,17 @@ 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,ok=0,v;
71 EVP_MD_CTX tmp_ctx; 71 EVP_MD_CTX tmp_ctx;
72 EVP_PKEY_CTX *pkctx = NULL;
73 72
74 EVP_MD_CTX_init(&tmp_ctx); 73 EVP_MD_CTX_init(&tmp_ctx);
75 if (!EVP_MD_CTX_copy_ex(&tmp_ctx,ctx)) 74 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
76 goto err; 75 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
77 if (!EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len))
78 goto err;
79 EVP_MD_CTX_cleanup(&tmp_ctx); 76 EVP_MD_CTX_cleanup(&tmp_ctx);
80 77
81 if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) 78 if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
82 { 79 {
80 EVP_PKEY_CTX *pkctx = NULL;
83 i = -1; 81 i = -1;
84 pkctx = EVP_PKEY_CTX_new(pkey, NULL); 82 pkctx = EVP_PKEY_CTX_new(pkey, NULL);
85 if (!pkctx) 83 if (!pkctx)