diff options
Diffstat (limited to 'src/lib/libcrypto/evp')
54 files changed, 10223 insertions, 275 deletions
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl new file mode 100644 index 0000000000..f33aebd33a --- /dev/null +++ b/src/lib/libcrypto/evp/Makefile.ssl | |||
@@ -0,0 +1,1059 @@ | |||
1 | # | ||
2 | # SSLeay/crypto/evp/Makefile | ||
3 | # | ||
4 | |||
5 | DIR= evp | ||
6 | TOP= ../.. | ||
7 | CC= cc | ||
8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
9 | CFLAG=-g | ||
10 | INSTALL_PREFIX= | ||
11 | OPENSSLDIR= /usr/local/ssl | ||
12 | INSTALLTOP=/usr/local/ssl | ||
13 | MAKE= make -f Makefile.ssl | ||
14 | MAKEDEPPROG= makedepend | ||
15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
16 | MAKEFILE= Makefile.ssl | ||
17 | AR= ar r | ||
18 | |||
19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
20 | |||
21 | GENERAL=Makefile | ||
22 | TEST=evp_test.c | ||
23 | TESTDATA=evptests.txt | ||
24 | APPS= | ||
25 | |||
26 | LIB=$(TOP)/libcrypto.a | ||
27 | LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \ | ||
28 | e_des.c e_bf.c e_idea.c e_des3.c \ | ||
29 | e_rc4.c e_aes.c names.c \ | ||
30 | e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \ | ||
31 | m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \ | ||
32 | m_dss.c m_dss1.c m_mdc2.c m_ripemd.c \ | ||
33 | p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ | ||
34 | bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ | ||
35 | c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \ | ||
36 | evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c | ||
37 | |||
38 | LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \ | ||
39 | e_des.o e_bf.o e_idea.o e_des3.o \ | ||
40 | e_rc4.o e_aes.o names.o \ | ||
41 | e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \ | ||
42 | m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \ | ||
43 | m_dss.o m_dss1.o m_mdc2.o m_ripemd.o \ | ||
44 | p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ | ||
45 | bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \ | ||
46 | c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o \ | ||
47 | evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o | ||
48 | |||
49 | SRC= $(LIBSRC) | ||
50 | |||
51 | EXHEADER= evp.h | ||
52 | HEADER= $(EXHEADER) | ||
53 | |||
54 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
55 | |||
56 | top: | ||
57 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
58 | |||
59 | all: lib | ||
60 | |||
61 | lib: $(LIBOBJ) | ||
62 | $(AR) $(LIB) $(LIBOBJ) | ||
63 | $(RANLIB) $(LIB) || echo Never mind. | ||
64 | @touch lib | ||
65 | |||
66 | files: | ||
67 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
68 | |||
69 | links: | ||
70 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
71 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
72 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
73 | cp $(TESTDATA) ../../test | ||
74 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
75 | |||
76 | install: | ||
77 | @for i in $(EXHEADER) ; \ | ||
78 | do \ | ||
79 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
80 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
81 | done; | ||
82 | |||
83 | tags: | ||
84 | ctags $(SRC) | ||
85 | |||
86 | tests: | ||
87 | |||
88 | lint: | ||
89 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
90 | |||
91 | depend: | ||
92 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC) | ||
93 | |||
94 | dclean: | ||
95 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
96 | mv -f Makefile.new $(MAKEFILE) | ||
97 | |||
98 | clean: | ||
99 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
100 | |||
101 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
102 | |||
103 | bio_b64.o: ../../e_os.h ../../include/openssl/aes.h | ||
104 | bio_b64.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
105 | bio_b64.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
106 | bio_b64.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
107 | bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
108 | bio_b64.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
109 | bio_b64.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
110 | bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
111 | bio_b64.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
112 | bio_b64.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
113 | bio_b64.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
114 | bio_b64.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
115 | bio_b64.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
116 | bio_b64.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h | ||
117 | bio_b64.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
118 | bio_b64.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
119 | bio_b64.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
120 | bio_b64.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
121 | bio_b64.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
122 | bio_b64.o: ../cryptlib.h bio_b64.c | ||
123 | bio_enc.o: ../../e_os.h ../../include/openssl/aes.h | ||
124 | bio_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
125 | bio_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
126 | bio_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
127 | bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
128 | bio_enc.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
129 | bio_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
130 | bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
131 | bio_enc.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
132 | bio_enc.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
133 | bio_enc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
134 | bio_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
135 | bio_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
136 | bio_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h | ||
137 | bio_enc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
138 | bio_enc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
139 | bio_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
140 | bio_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
141 | bio_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
142 | bio_enc.o: ../cryptlib.h bio_enc.c | ||
143 | bio_md.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
144 | bio_md.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
145 | bio_md.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
146 | bio_md.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
147 | bio_md.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
148 | bio_md.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
149 | bio_md.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
150 | bio_md.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
151 | bio_md.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
152 | bio_md.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
153 | bio_md.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
154 | bio_md.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
155 | bio_md.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
156 | bio_md.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
157 | bio_md.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
158 | bio_md.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
159 | bio_md.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
160 | bio_md.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
161 | bio_md.o: ../../include/openssl/ui_compat.h ../cryptlib.h bio_md.c | ||
162 | bio_ok.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
163 | bio_ok.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
164 | bio_ok.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
165 | bio_ok.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
166 | bio_ok.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
167 | bio_ok.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
168 | bio_ok.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
169 | bio_ok.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
170 | bio_ok.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
171 | bio_ok.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
172 | bio_ok.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
173 | bio_ok.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
174 | bio_ok.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
175 | bio_ok.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | ||
176 | bio_ok.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
177 | bio_ok.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
178 | bio_ok.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
179 | bio_ok.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
180 | bio_ok.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
181 | bio_ok.o: ../cryptlib.h bio_ok.c | ||
182 | c_all.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
183 | c_all.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
184 | c_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
185 | c_all.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
186 | c_all.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
187 | c_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
188 | c_all.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
189 | c_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
190 | c_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
191 | c_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
192 | c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
193 | c_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
194 | c_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
195 | c_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
196 | c_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
197 | c_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
198 | c_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
199 | c_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
200 | c_all.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
201 | c_all.o: ../../include/openssl/ui_compat.h ../cryptlib.h c_all.c | ||
202 | c_allc.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
203 | c_allc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
204 | c_allc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
205 | c_allc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
206 | c_allc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
207 | c_allc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
208 | c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
209 | c_allc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
210 | c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
211 | c_allc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
212 | c_allc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
213 | c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
214 | c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
215 | c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h | ||
216 | c_allc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
217 | c_allc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
218 | c_allc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
219 | c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
220 | c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
221 | c_allc.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
222 | c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_allc.c | ||
223 | c_alld.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
224 | c_alld.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
225 | c_alld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
226 | c_alld.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
227 | c_alld.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
228 | c_alld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
229 | c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
230 | c_alld.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
231 | c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
232 | c_alld.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
233 | c_alld.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
234 | c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
235 | c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
236 | c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h | ||
237 | c_alld.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
238 | c_alld.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
239 | c_alld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
240 | c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
241 | c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
242 | c_alld.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
243 | c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_alld.c | ||
244 | digest.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
245 | digest.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
246 | digest.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
247 | digest.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
248 | digest.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
249 | digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
250 | digest.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
251 | digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
252 | digest.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
253 | digest.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
254 | digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
255 | digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
256 | digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
257 | digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
258 | digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
259 | digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
260 | digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
261 | digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
262 | digest.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
263 | digest.o: ../../include/openssl/ui_compat.h ../cryptlib.h digest.c | ||
264 | e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
265 | e_aes.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
266 | e_aes.o: ../../include/openssl/bn.h ../../include/openssl/cast.h | ||
267 | e_aes.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
268 | e_aes.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
269 | e_aes.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
270 | e_aes.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
271 | e_aes.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
272 | e_aes.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
273 | e_aes.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
274 | e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
275 | e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
276 | e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h | ||
277 | e_aes.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
278 | e_aes.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
279 | e_aes.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
280 | e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
281 | e_aes.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h e_aes.c | ||
282 | e_aes.o: evp_locl.h | ||
283 | e_bf.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
284 | e_bf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
285 | e_bf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
286 | e_bf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
287 | e_bf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
288 | e_bf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
289 | e_bf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
290 | e_bf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
291 | e_bf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
292 | e_bf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
293 | e_bf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
294 | e_bf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
295 | e_bf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
296 | e_bf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
297 | e_bf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
298 | e_bf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
299 | e_bf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
300 | e_bf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
301 | e_bf.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_bf.c evp_locl.h | ||
302 | e_cast.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
303 | e_cast.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
304 | e_cast.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
305 | e_cast.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
306 | e_cast.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
307 | e_cast.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
308 | e_cast.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
309 | e_cast.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
310 | e_cast.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
311 | e_cast.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
312 | e_cast.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
313 | e_cast.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
314 | e_cast.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
315 | e_cast.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
316 | e_cast.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
317 | e_cast.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
318 | e_cast.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
319 | e_cast.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
320 | e_cast.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_cast.c evp_locl.h | ||
321 | e_des.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
322 | e_des.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
323 | e_des.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
324 | e_des.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
325 | e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
326 | e_des.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
327 | e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
328 | e_des.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
329 | e_des.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
330 | e_des.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
331 | e_des.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
332 | e_des.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
333 | e_des.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
334 | e_des.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
335 | e_des.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
336 | e_des.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
337 | e_des.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
338 | e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
339 | e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h | ||
340 | e_des3.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
341 | e_des3.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
342 | e_des3.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
343 | e_des3.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
344 | e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
345 | e_des3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
346 | e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
347 | e_des3.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
348 | e_des3.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
349 | e_des3.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
350 | e_des3.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
351 | e_des3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
352 | e_des3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
353 | e_des3.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
354 | e_des3.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
355 | e_des3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
356 | e_des3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
357 | e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
358 | e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h | ||
359 | e_idea.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
360 | e_idea.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
361 | e_idea.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
362 | e_idea.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
363 | e_idea.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
364 | e_idea.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
365 | e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
366 | e_idea.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
367 | e_idea.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
368 | e_idea.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
369 | e_idea.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
370 | e_idea.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
371 | e_idea.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
372 | e_idea.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
373 | e_idea.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
374 | e_idea.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
375 | e_idea.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
376 | e_idea.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
377 | e_idea.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_idea.c evp_locl.h | ||
378 | e_null.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
379 | e_null.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
380 | e_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
381 | e_null.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
382 | e_null.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
383 | e_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
384 | e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
385 | e_null.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
386 | e_null.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
387 | e_null.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
388 | e_null.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
389 | e_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
390 | e_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
391 | e_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
392 | e_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
393 | e_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
394 | e_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
395 | e_null.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
396 | e_null.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_null.c | ||
397 | e_rc2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
398 | e_rc2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
399 | e_rc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
400 | e_rc2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
401 | e_rc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
402 | e_rc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
403 | e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
404 | e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
405 | e_rc2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
406 | e_rc2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
407 | e_rc2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
408 | e_rc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
409 | e_rc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
410 | e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
411 | e_rc2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
412 | e_rc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
413 | e_rc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
414 | e_rc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
415 | e_rc2.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc2.c evp_locl.h | ||
416 | e_rc4.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
417 | e_rc4.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
418 | e_rc4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
419 | e_rc4.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
420 | e_rc4.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
421 | e_rc4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
422 | e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
423 | e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
424 | e_rc4.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
425 | e_rc4.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
426 | e_rc4.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
427 | e_rc4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
428 | e_rc4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
429 | e_rc4.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
430 | e_rc4.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
431 | e_rc4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
432 | e_rc4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
433 | e_rc4.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
434 | e_rc4.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc4.c | ||
435 | e_rc5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
436 | e_rc5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
437 | e_rc5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
438 | e_rc5.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
439 | e_rc5.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
440 | e_rc5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
441 | e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
442 | e_rc5.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
443 | e_rc5.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
444 | e_rc5.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
445 | e_rc5.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
446 | e_rc5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
447 | e_rc5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
448 | e_rc5.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
449 | e_rc5.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
450 | e_rc5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
451 | e_rc5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
452 | e_rc5.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
453 | e_rc5.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc5.c evp_locl.h | ||
454 | e_xcbc_d.o: ../../e_os.h ../../include/openssl/aes.h | ||
455 | e_xcbc_d.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
456 | e_xcbc_d.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
457 | e_xcbc_d.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
458 | e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
459 | e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
460 | e_xcbc_d.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
461 | e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
462 | e_xcbc_d.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
463 | e_xcbc_d.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
464 | e_xcbc_d.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
465 | e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
466 | e_xcbc_d.o: ../../include/openssl/opensslconf.h | ||
467 | e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
468 | e_xcbc_d.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
469 | e_xcbc_d.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
470 | e_xcbc_d.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
471 | e_xcbc_d.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
472 | e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
473 | e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c | ||
474 | encode.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
475 | encode.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
476 | encode.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
477 | encode.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
478 | encode.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
479 | encode.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
480 | encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
481 | encode.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
482 | encode.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
483 | encode.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
484 | encode.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
485 | encode.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
486 | encode.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
487 | encode.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
488 | encode.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
489 | encode.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
490 | encode.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
491 | encode.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
492 | encode.o: ../../include/openssl/ui_compat.h ../cryptlib.h encode.c | ||
493 | evp_acnf.o: ../../e_os.h ../../include/openssl/aes.h | ||
494 | evp_acnf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
495 | evp_acnf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
496 | evp_acnf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
497 | evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | ||
498 | evp_acnf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
499 | evp_acnf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
500 | evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
501 | evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
502 | evp_acnf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
503 | evp_acnf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
504 | evp_acnf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
505 | evp_acnf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
506 | evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
507 | evp_acnf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
508 | evp_acnf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
509 | evp_acnf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
510 | evp_acnf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
511 | evp_acnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
512 | evp_acnf.o: ../../include/openssl/ui_compat.h ../cryptlib.h evp_acnf.c | ||
513 | evp_enc.o: ../../e_os.h ../../include/openssl/aes.h | ||
514 | evp_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
515 | evp_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
516 | evp_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
517 | evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
518 | evp_enc.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
519 | evp_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
520 | evp_enc.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
521 | evp_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
522 | evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
523 | evp_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
524 | evp_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
525 | evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
526 | evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
527 | evp_enc.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | ||
528 | evp_enc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
529 | evp_enc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
530 | evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
531 | evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
532 | evp_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
533 | evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h | ||
534 | evp_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
535 | evp_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
536 | evp_err.o: ../../include/openssl/bn.h ../../include/openssl/cast.h | ||
537 | evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
538 | evp_err.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
539 | evp_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
540 | evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
541 | evp_err.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
542 | evp_err.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
543 | evp_err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
544 | evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
545 | evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
546 | evp_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h | ||
547 | evp_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
548 | evp_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
549 | evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
550 | evp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
551 | evp_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
552 | evp_err.o: evp_err.c | ||
553 | evp_key.o: ../../e_os.h ../../include/openssl/aes.h | ||
554 | evp_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
555 | evp_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
556 | evp_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
557 | evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
558 | evp_key.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
559 | evp_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
560 | evp_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
561 | evp_key.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
562 | evp_key.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
563 | evp_key.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
564 | evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
565 | evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
566 | evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
567 | evp_key.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
568 | evp_key.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
569 | evp_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
570 | evp_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
571 | evp_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
572 | evp_key.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
573 | evp_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_key.c | ||
574 | evp_lib.o: ../../e_os.h ../../include/openssl/aes.h | ||
575 | evp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
576 | evp_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
577 | evp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
578 | evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
579 | evp_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
580 | evp_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
581 | evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
582 | evp_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
583 | evp_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
584 | evp_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
585 | evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
586 | evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
587 | evp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h | ||
588 | evp_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
589 | evp_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
590 | evp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
591 | evp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
592 | evp_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
593 | evp_lib.o: ../cryptlib.h evp_lib.c | ||
594 | evp_pbe.o: ../../e_os.h ../../include/openssl/aes.h | ||
595 | evp_pbe.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
596 | evp_pbe.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
597 | evp_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
598 | evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
599 | evp_pbe.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
600 | evp_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
601 | evp_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
602 | evp_pbe.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
603 | evp_pbe.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
604 | evp_pbe.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
605 | evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
606 | evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
607 | evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
608 | evp_pbe.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
609 | evp_pbe.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
610 | evp_pbe.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
611 | evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
612 | evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
613 | evp_pbe.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
614 | evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c | ||
615 | evp_pkey.o: ../../e_os.h ../../include/openssl/aes.h | ||
616 | evp_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
617 | evp_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
618 | evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
619 | evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
620 | evp_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
621 | evp_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
622 | evp_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
623 | evp_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
624 | evp_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
625 | evp_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
626 | evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
627 | evp_pkey.o: ../../include/openssl/opensslconf.h | ||
628 | evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
629 | evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
630 | evp_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
631 | evp_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
632 | evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
633 | evp_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
634 | evp_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
635 | evp_pkey.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
636 | evp_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pkey.c | ||
637 | m_dss.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
638 | m_dss.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
639 | m_dss.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
640 | m_dss.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
641 | m_dss.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
642 | m_dss.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
643 | m_dss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
644 | m_dss.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
645 | m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
646 | m_dss.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
647 | m_dss.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
648 | m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
649 | m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
650 | m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
651 | m_dss.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
652 | m_dss.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
653 | m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
654 | m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
655 | m_dss.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
656 | m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
657 | m_dss.o: ../cryptlib.h m_dss.c | ||
658 | m_dss1.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
659 | m_dss1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
660 | m_dss1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
661 | m_dss1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
662 | m_dss1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
663 | m_dss1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
664 | m_dss1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
665 | m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
666 | m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
667 | m_dss1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
668 | m_dss1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
669 | m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
670 | m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
671 | m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
672 | m_dss1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
673 | m_dss1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
674 | m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
675 | m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
676 | m_dss1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
677 | m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
678 | m_dss1.o: ../cryptlib.h m_dss1.c | ||
679 | m_md2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
680 | m_md2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
681 | m_md2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
682 | m_md2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
683 | m_md2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
684 | m_md2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
685 | m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
686 | m_md2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
687 | m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
688 | m_md2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
689 | m_md2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
690 | m_md2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
691 | m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
692 | m_md2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
693 | m_md2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
694 | m_md2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
695 | m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
696 | m_md2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
697 | m_md2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
698 | m_md2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
699 | m_md2.o: ../cryptlib.h m_md2.c | ||
700 | m_md4.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
701 | m_md4.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
702 | m_md4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
703 | m_md4.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
704 | m_md4.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
705 | m_md4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
706 | m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
707 | m_md4.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
708 | m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
709 | m_md4.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
710 | m_md4.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
711 | m_md4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
712 | m_md4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
713 | m_md4.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
714 | m_md4.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
715 | m_md4.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
716 | m_md4.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
717 | m_md4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
718 | m_md4.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
719 | m_md4.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
720 | m_md4.o: ../cryptlib.h m_md4.c | ||
721 | m_md5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
722 | m_md5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
723 | m_md5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
724 | m_md5.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
725 | m_md5.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
726 | m_md5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
727 | m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
728 | m_md5.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
729 | m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
730 | m_md5.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
731 | m_md5.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
732 | m_md5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
733 | m_md5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
734 | m_md5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
735 | m_md5.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
736 | m_md5.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
737 | m_md5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
738 | m_md5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
739 | m_md5.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
740 | m_md5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
741 | m_md5.o: ../cryptlib.h m_md5.c | ||
742 | m_mdc2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
743 | m_mdc2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
744 | m_mdc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
745 | m_mdc2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
746 | m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
747 | m_mdc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
748 | m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
749 | m_mdc2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
750 | m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
751 | m_mdc2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
752 | m_mdc2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
753 | m_mdc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
754 | m_mdc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
755 | m_mdc2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
756 | m_mdc2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
757 | m_mdc2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
758 | m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
759 | m_mdc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
760 | m_mdc2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
761 | m_mdc2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
762 | m_mdc2.o: ../cryptlib.h m_mdc2.c | ||
763 | m_null.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
764 | m_null.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
765 | m_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
766 | m_null.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
767 | m_null.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
768 | m_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
769 | m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
770 | m_null.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
771 | m_null.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
772 | m_null.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
773 | m_null.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
774 | m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
775 | m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
776 | m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
777 | m_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
778 | m_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
779 | m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
780 | m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
781 | m_null.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
782 | m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
783 | m_null.o: ../cryptlib.h m_null.c | ||
784 | m_ripemd.o: ../../e_os.h ../../include/openssl/aes.h | ||
785 | m_ripemd.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
786 | m_ripemd.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
787 | m_ripemd.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
788 | m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
789 | m_ripemd.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
790 | m_ripemd.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
791 | m_ripemd.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
792 | m_ripemd.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
793 | m_ripemd.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
794 | m_ripemd.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
795 | m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
796 | m_ripemd.o: ../../include/openssl/opensslconf.h | ||
797 | m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
798 | m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
799 | m_ripemd.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
800 | m_ripemd.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
801 | m_ripemd.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
802 | m_ripemd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
803 | m_ripemd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
804 | m_ripemd.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
805 | m_ripemd.o: ../cryptlib.h m_ripemd.c | ||
806 | m_sha.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
807 | m_sha.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
808 | m_sha.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
809 | m_sha.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
810 | m_sha.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
811 | m_sha.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
812 | m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
813 | m_sha.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
814 | m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
815 | m_sha.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
816 | m_sha.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
817 | m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
818 | m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
819 | m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
820 | m_sha.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
821 | m_sha.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
822 | m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
823 | m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
824 | m_sha.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
825 | m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
826 | m_sha.o: ../cryptlib.h m_sha.c | ||
827 | m_sha1.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
828 | m_sha1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
829 | m_sha1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
830 | m_sha1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
831 | m_sha1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
832 | m_sha1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
833 | m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
834 | m_sha1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
835 | m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
836 | m_sha1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
837 | m_sha1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
838 | m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
839 | m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
840 | m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
841 | m_sha1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
842 | m_sha1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
843 | m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
844 | m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
845 | m_sha1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
846 | m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
847 | m_sha1.o: ../cryptlib.h m_sha1.c | ||
848 | names.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
849 | names.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
850 | names.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
851 | names.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
852 | names.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
853 | names.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
854 | names.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
855 | names.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
856 | names.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
857 | names.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
858 | names.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
859 | names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
860 | names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
861 | names.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
862 | names.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
863 | names.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
864 | names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
865 | names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
866 | names.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
867 | names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
868 | names.o: ../cryptlib.h names.c | ||
869 | p5_crpt.o: ../../e_os.h ../../include/openssl/aes.h | ||
870 | p5_crpt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
871 | p5_crpt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
872 | p5_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
873 | p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
874 | p5_crpt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
875 | p5_crpt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
876 | p5_crpt.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
877 | p5_crpt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
878 | p5_crpt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
879 | p5_crpt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
880 | p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
881 | p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
882 | p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
883 | p5_crpt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
884 | p5_crpt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
885 | p5_crpt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
886 | p5_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
887 | p5_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
888 | p5_crpt.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
889 | p5_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt.c | ||
890 | p5_crpt2.o: ../../e_os.h ../../include/openssl/aes.h | ||
891 | p5_crpt2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
892 | p5_crpt2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
893 | p5_crpt2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
894 | p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
895 | p5_crpt2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
896 | p5_crpt2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
897 | p5_crpt2.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
898 | p5_crpt2.o: ../../include/openssl/hmac.h ../../include/openssl/idea.h | ||
899 | p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
900 | p5_crpt2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
901 | p5_crpt2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
902 | p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
903 | p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
904 | p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
905 | p5_crpt2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
906 | p5_crpt2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
907 | p5_crpt2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
908 | p5_crpt2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
909 | p5_crpt2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
910 | p5_crpt2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
911 | p5_crpt2.o: ../cryptlib.h p5_crpt2.c | ||
912 | p_dec.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
913 | p_dec.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
914 | p_dec.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
915 | p_dec.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
916 | p_dec.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
917 | p_dec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
918 | p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
919 | p_dec.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
920 | p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
921 | p_dec.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
922 | p_dec.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
923 | p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
924 | p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
925 | p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
926 | p_dec.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
927 | p_dec.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
928 | p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
929 | p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
930 | p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
931 | p_dec.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
932 | p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c | ||
933 | p_enc.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
934 | p_enc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
935 | p_enc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
936 | p_enc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
937 | p_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
938 | p_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
939 | p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
940 | p_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
941 | p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
942 | p_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
943 | p_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
944 | p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
945 | p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
946 | p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
947 | p_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
948 | p_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
949 | p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
950 | p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
951 | p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
952 | p_enc.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
953 | p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c | ||
954 | p_lib.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
955 | p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h | ||
956 | p_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
957 | p_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
958 | p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
959 | p_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
960 | p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
961 | p_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
962 | p_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
963 | p_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
964 | p_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
965 | p_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
966 | p_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
967 | p_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
968 | p_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
969 | p_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
970 | p_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
971 | p_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
972 | p_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
973 | p_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
974 | p_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_lib.c | ||
975 | p_open.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
976 | p_open.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
977 | p_open.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
978 | p_open.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
979 | p_open.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
980 | p_open.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
981 | p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
982 | p_open.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
983 | p_open.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
984 | p_open.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
985 | p_open.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
986 | p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
987 | p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
988 | p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
989 | p_open.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
990 | p_open.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
991 | p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
992 | p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
993 | p_open.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
994 | p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
995 | p_open.o: ../cryptlib.h p_open.c | ||
996 | p_seal.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
997 | p_seal.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
998 | p_seal.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
999 | p_seal.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
1000 | p_seal.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
1001 | p_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
1002 | p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
1003 | p_seal.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
1004 | p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
1005 | p_seal.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
1006 | p_seal.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
1007 | p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
1008 | p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
1009 | p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
1010 | p_seal.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
1011 | p_seal.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
1012 | p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
1013 | p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
1014 | p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
1015 | p_seal.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h | ||
1016 | p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c | ||
1017 | p_sign.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h | ||
1018 | p_sign.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
1019 | p_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | ||
1020 | p_sign.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
1021 | p_sign.o: ../../include/openssl/des.h ../../include/openssl/des_old.h | ||
1022 | p_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
1023 | p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
1024 | p_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
1025 | p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
1026 | p_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
1027 | p_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
1028 | p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
1029 | p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
1030 | p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
1031 | p_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
1032 | p_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
1033 | p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
1034 | p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
1035 | p_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
1036 | p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
1037 | p_sign.o: ../cryptlib.h p_sign.c | ||
1038 | p_verify.o: ../../e_os.h ../../include/openssl/aes.h | ||
1039 | p_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
1040 | p_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
1041 | p_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
1042 | p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
1043 | p_verify.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h | ||
1044 | p_verify.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
1045 | p_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
1046 | p_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
1047 | p_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
1048 | p_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
1049 | p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
1050 | p_verify.o: ../../include/openssl/opensslconf.h | ||
1051 | p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
1052 | p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h | ||
1053 | p_verify.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
1054 | p_verify.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
1055 | p_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
1056 | p_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
1057 | p_verify.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
1058 | p_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
1059 | p_verify.o: ../cryptlib.h p_verify.c | ||
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c new file mode 100644 index 0000000000..33349c2f98 --- /dev/null +++ b/src/lib/libcrypto/evp/bio_b64.c | |||
@@ -0,0 +1,567 @@ | |||
1 | /* crypto/evp/bio_b64.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 <errno.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/buffer.h> | ||
63 | #include <openssl/evp.h> | ||
64 | |||
65 | static int b64_write(BIO *h, const char *buf, int num); | ||
66 | static int b64_read(BIO *h, char *buf, int size); | ||
67 | /*static int b64_puts(BIO *h, const char *str); */ | ||
68 | /*static int b64_gets(BIO *h, char *str, int size); */ | ||
69 | static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2); | ||
70 | static int b64_new(BIO *h); | ||
71 | static int b64_free(BIO *data); | ||
72 | static long b64_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp); | ||
73 | #define B64_BLOCK_SIZE 1024 | ||
74 | #define B64_BLOCK_SIZE2 768 | ||
75 | #define B64_NONE 0 | ||
76 | #define B64_ENCODE 1 | ||
77 | #define B64_DECODE 2 | ||
78 | |||
79 | typedef struct b64_struct | ||
80 | { | ||
81 | /*BIO *bio; moved to the BIO structure */ | ||
82 | int buf_len; | ||
83 | int buf_off; | ||
84 | int tmp_len; /* used to find the start when decoding */ | ||
85 | int tmp_nl; /* If true, scan until '\n' */ | ||
86 | int encode; | ||
87 | int start; /* have we started decoding yet? */ | ||
88 | int cont; /* <= 0 when finished */ | ||
89 | EVP_ENCODE_CTX base64; | ||
90 | char buf[EVP_ENCODE_LENGTH(B64_BLOCK_SIZE)+10]; | ||
91 | char tmp[B64_BLOCK_SIZE]; | ||
92 | } BIO_B64_CTX; | ||
93 | |||
94 | static BIO_METHOD methods_b64= | ||
95 | { | ||
96 | BIO_TYPE_BASE64,"base64 encoding", | ||
97 | b64_write, | ||
98 | b64_read, | ||
99 | NULL, /* b64_puts, */ | ||
100 | NULL, /* b64_gets, */ | ||
101 | b64_ctrl, | ||
102 | b64_new, | ||
103 | b64_free, | ||
104 | b64_callback_ctrl, | ||
105 | }; | ||
106 | |||
107 | BIO_METHOD *BIO_f_base64(void) | ||
108 | { | ||
109 | return(&methods_b64); | ||
110 | } | ||
111 | |||
112 | static int b64_new(BIO *bi) | ||
113 | { | ||
114 | BIO_B64_CTX *ctx; | ||
115 | |||
116 | ctx=(BIO_B64_CTX *)OPENSSL_malloc(sizeof(BIO_B64_CTX)); | ||
117 | if (ctx == NULL) return(0); | ||
118 | |||
119 | ctx->buf_len=0; | ||
120 | ctx->tmp_len=0; | ||
121 | ctx->tmp_nl=0; | ||
122 | ctx->buf_off=0; | ||
123 | ctx->cont=1; | ||
124 | ctx->start=1; | ||
125 | ctx->encode=0; | ||
126 | |||
127 | bi->init=1; | ||
128 | bi->ptr=(char *)ctx; | ||
129 | bi->flags=0; | ||
130 | return(1); | ||
131 | } | ||
132 | |||
133 | static int b64_free(BIO *a) | ||
134 | { | ||
135 | if (a == NULL) return(0); | ||
136 | OPENSSL_free(a->ptr); | ||
137 | a->ptr=NULL; | ||
138 | a->init=0; | ||
139 | a->flags=0; | ||
140 | return(1); | ||
141 | } | ||
142 | |||
143 | static int b64_read(BIO *b, char *out, int outl) | ||
144 | { | ||
145 | int ret=0,i,ii,j,k,x,n,num,ret_code=0; | ||
146 | BIO_B64_CTX *ctx; | ||
147 | unsigned char *p,*q; | ||
148 | |||
149 | if (out == NULL) return(0); | ||
150 | ctx=(BIO_B64_CTX *)b->ptr; | ||
151 | |||
152 | if ((ctx == NULL) || (b->next_bio == NULL)) return(0); | ||
153 | |||
154 | if (ctx->encode != B64_DECODE) | ||
155 | { | ||
156 | ctx->encode=B64_DECODE; | ||
157 | ctx->buf_len=0; | ||
158 | ctx->buf_off=0; | ||
159 | ctx->tmp_len=0; | ||
160 | EVP_DecodeInit(&(ctx->base64)); | ||
161 | } | ||
162 | |||
163 | /* First check if there are bytes decoded/encoded */ | ||
164 | if (ctx->buf_len > 0) | ||
165 | { | ||
166 | i=ctx->buf_len-ctx->buf_off; | ||
167 | if (i > outl) i=outl; | ||
168 | OPENSSL_assert(ctx->buf_off+i < sizeof ctx->buf); | ||
169 | memcpy(out,&(ctx->buf[ctx->buf_off]),i); | ||
170 | ret=i; | ||
171 | out+=i; | ||
172 | outl-=i; | ||
173 | ctx->buf_off+=i; | ||
174 | if (ctx->buf_len == ctx->buf_off) | ||
175 | { | ||
176 | ctx->buf_len=0; | ||
177 | ctx->buf_off=0; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | /* At this point, we have room of outl bytes and an empty | ||
182 | * buffer, so we should read in some more. */ | ||
183 | |||
184 | ret_code=0; | ||
185 | while (outl > 0) | ||
186 | { | ||
187 | |||
188 | if (ctx->cont <= 0) | ||
189 | break; | ||
190 | |||
191 | i=BIO_read(b->next_bio,&(ctx->tmp[ctx->tmp_len]), | ||
192 | B64_BLOCK_SIZE-ctx->tmp_len); | ||
193 | |||
194 | if (i <= 0) | ||
195 | { | ||
196 | ret_code=i; | ||
197 | |||
198 | /* Should be continue next time we are called? */ | ||
199 | if (!BIO_should_retry(b->next_bio)) | ||
200 | { | ||
201 | ctx->cont=i; | ||
202 | /* If buffer empty break */ | ||
203 | if(ctx->tmp_len == 0) | ||
204 | break; | ||
205 | /* Fall through and process what we have */ | ||
206 | else | ||
207 | i = 0; | ||
208 | } | ||
209 | /* else we retry and add more data to buffer */ | ||
210 | else | ||
211 | break; | ||
212 | } | ||
213 | i+=ctx->tmp_len; | ||
214 | ctx->tmp_len = i; | ||
215 | |||
216 | /* We need to scan, a line at a time until we | ||
217 | * have a valid line if we are starting. */ | ||
218 | if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)) | ||
219 | { | ||
220 | /* ctx->start=1; */ | ||
221 | ctx->tmp_len=0; | ||
222 | } | ||
223 | else if (ctx->start) | ||
224 | { | ||
225 | q=p=(unsigned char *)ctx->tmp; | ||
226 | for (j=0; j<i; j++) | ||
227 | { | ||
228 | if (*(q++) != '\n') continue; | ||
229 | |||
230 | /* due to a previous very long line, | ||
231 | * we need to keep on scanning for a '\n' | ||
232 | * before we even start looking for | ||
233 | * base64 encoded stuff. */ | ||
234 | if (ctx->tmp_nl) | ||
235 | { | ||
236 | p=q; | ||
237 | ctx->tmp_nl=0; | ||
238 | continue; | ||
239 | } | ||
240 | |||
241 | k=EVP_DecodeUpdate(&(ctx->base64), | ||
242 | (unsigned char *)ctx->buf, | ||
243 | &num,p,q-p); | ||
244 | if ((k <= 0) && (num == 0) && (ctx->start)) | ||
245 | EVP_DecodeInit(&ctx->base64); | ||
246 | else | ||
247 | { | ||
248 | if (p != (unsigned char *) | ||
249 | &(ctx->tmp[0])) | ||
250 | { | ||
251 | i-=(p- (unsigned char *) | ||
252 | &(ctx->tmp[0])); | ||
253 | for (x=0; x < i; x++) | ||
254 | ctx->tmp[x]=p[x]; | ||
255 | } | ||
256 | EVP_DecodeInit(&ctx->base64); | ||
257 | ctx->start=0; | ||
258 | break; | ||
259 | } | ||
260 | p=q; | ||
261 | } | ||
262 | |||
263 | /* we fell off the end without starting */ | ||
264 | if (j == i) | ||
265 | { | ||
266 | /* Is this is one long chunk?, if so, keep on | ||
267 | * reading until a new line. */ | ||
268 | if (p == (unsigned char *)&(ctx->tmp[0])) | ||
269 | { | ||
270 | /* Check buffer full */ | ||
271 | if (i == B64_BLOCK_SIZE) | ||
272 | { | ||
273 | ctx->tmp_nl=1; | ||
274 | ctx->tmp_len=0; | ||
275 | } | ||
276 | } | ||
277 | else if (p != q) /* finished on a '\n' */ | ||
278 | { | ||
279 | n=q-p; | ||
280 | for (ii=0; ii<n; ii++) | ||
281 | ctx->tmp[ii]=p[ii]; | ||
282 | ctx->tmp_len=n; | ||
283 | } | ||
284 | /* else finished on a '\n' */ | ||
285 | continue; | ||
286 | } | ||
287 | else | ||
288 | ctx->tmp_len=0; | ||
289 | } | ||
290 | /* If buffer isn't full and we can retry then | ||
291 | * restart to read in more data. | ||
292 | */ | ||
293 | else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0)) | ||
294 | continue; | ||
295 | |||
296 | if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) | ||
297 | { | ||
298 | int z,jj; | ||
299 | |||
300 | jj=(i>>2)<<2; | ||
301 | z=EVP_DecodeBlock((unsigned char *)ctx->buf, | ||
302 | (unsigned char *)ctx->tmp,jj); | ||
303 | if (jj > 2) | ||
304 | { | ||
305 | if (ctx->tmp[jj-1] == '=') | ||
306 | { | ||
307 | z--; | ||
308 | if (ctx->tmp[jj-2] == '=') | ||
309 | z--; | ||
310 | } | ||
311 | } | ||
312 | /* z is now number of output bytes and jj is the | ||
313 | * number consumed */ | ||
314 | if (jj != i) | ||
315 | { | ||
316 | memcpy((unsigned char *)ctx->tmp, | ||
317 | (unsigned char *)&(ctx->tmp[jj]),i-jj); | ||
318 | ctx->tmp_len=i-jj; | ||
319 | } | ||
320 | ctx->buf_len=0; | ||
321 | if (z > 0) | ||
322 | { | ||
323 | ctx->buf_len=z; | ||
324 | i=1; | ||
325 | } | ||
326 | else | ||
327 | i=z; | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | i=EVP_DecodeUpdate(&(ctx->base64), | ||
332 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
333 | (unsigned char *)ctx->tmp,i); | ||
334 | ctx->tmp_len = 0; | ||
335 | } | ||
336 | ctx->buf_off=0; | ||
337 | if (i < 0) | ||
338 | { | ||
339 | ret_code=0; | ||
340 | ctx->buf_len=0; | ||
341 | break; | ||
342 | } | ||
343 | |||
344 | if (ctx->buf_len <= outl) | ||
345 | i=ctx->buf_len; | ||
346 | else | ||
347 | i=outl; | ||
348 | |||
349 | memcpy(out,ctx->buf,i); | ||
350 | ret+=i; | ||
351 | ctx->buf_off=i; | ||
352 | if (ctx->buf_off == ctx->buf_len) | ||
353 | { | ||
354 | ctx->buf_len=0; | ||
355 | ctx->buf_off=0; | ||
356 | } | ||
357 | outl-=i; | ||
358 | out+=i; | ||
359 | } | ||
360 | BIO_clear_retry_flags(b); | ||
361 | BIO_copy_next_retry(b); | ||
362 | return((ret == 0)?ret_code:ret); | ||
363 | } | ||
364 | |||
365 | static int b64_write(BIO *b, const char *in, int inl) | ||
366 | { | ||
367 | int ret=inl,n,i; | ||
368 | BIO_B64_CTX *ctx; | ||
369 | |||
370 | ctx=(BIO_B64_CTX *)b->ptr; | ||
371 | BIO_clear_retry_flags(b); | ||
372 | |||
373 | if (ctx->encode != B64_ENCODE) | ||
374 | { | ||
375 | ctx->encode=B64_ENCODE; | ||
376 | ctx->buf_len=0; | ||
377 | ctx->buf_off=0; | ||
378 | ctx->tmp_len=0; | ||
379 | EVP_EncodeInit(&(ctx->base64)); | ||
380 | } | ||
381 | |||
382 | n=ctx->buf_len-ctx->buf_off; | ||
383 | while (n > 0) | ||
384 | { | ||
385 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
386 | if (i <= 0) | ||
387 | { | ||
388 | BIO_copy_next_retry(b); | ||
389 | return(i); | ||
390 | } | ||
391 | ctx->buf_off+=i; | ||
392 | n-=i; | ||
393 | } | ||
394 | /* at this point all pending data has been written */ | ||
395 | ctx->buf_off=0; | ||
396 | ctx->buf_len=0; | ||
397 | |||
398 | if ((in == NULL) || (inl <= 0)) return(0); | ||
399 | |||
400 | while (inl > 0) | ||
401 | { | ||
402 | n=(inl > B64_BLOCK_SIZE)?B64_BLOCK_SIZE:inl; | ||
403 | |||
404 | if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) | ||
405 | { | ||
406 | if (ctx->tmp_len > 0) | ||
407 | { | ||
408 | n=3-ctx->tmp_len; | ||
409 | /* There's a teoretical possibility for this */ | ||
410 | if (n > inl) | ||
411 | n=inl; | ||
412 | memcpy(&(ctx->tmp[ctx->tmp_len]),in,n); | ||
413 | ctx->tmp_len+=n; | ||
414 | if (ctx->tmp_len < 3) | ||
415 | break; | ||
416 | ctx->buf_len=EVP_EncodeBlock( | ||
417 | (unsigned char *)ctx->buf, | ||
418 | (unsigned char *)ctx->tmp, | ||
419 | ctx->tmp_len); | ||
420 | /* Since we're now done using the temporary | ||
421 | buffer, the length should be 0'd */ | ||
422 | ctx->tmp_len=0; | ||
423 | } | ||
424 | else | ||
425 | { | ||
426 | if (n < 3) | ||
427 | { | ||
428 | memcpy(&(ctx->tmp[0]),in,n); | ||
429 | ctx->tmp_len=n; | ||
430 | break; | ||
431 | } | ||
432 | n-=n%3; | ||
433 | ctx->buf_len=EVP_EncodeBlock( | ||
434 | (unsigned char *)ctx->buf, | ||
435 | (unsigned char *)in,n); | ||
436 | } | ||
437 | } | ||
438 | else | ||
439 | { | ||
440 | EVP_EncodeUpdate(&(ctx->base64), | ||
441 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
442 | (unsigned char *)in,n); | ||
443 | } | ||
444 | inl-=n; | ||
445 | in+=n; | ||
446 | |||
447 | ctx->buf_off=0; | ||
448 | n=ctx->buf_len; | ||
449 | while (n > 0) | ||
450 | { | ||
451 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
452 | if (i <= 0) | ||
453 | { | ||
454 | BIO_copy_next_retry(b); | ||
455 | return((ret == 0)?i:ret); | ||
456 | } | ||
457 | n-=i; | ||
458 | ctx->buf_off+=i; | ||
459 | } | ||
460 | ctx->buf_len=0; | ||
461 | ctx->buf_off=0; | ||
462 | } | ||
463 | return(ret); | ||
464 | } | ||
465 | |||
466 | static long b64_ctrl(BIO *b, int cmd, long num, void *ptr) | ||
467 | { | ||
468 | BIO_B64_CTX *ctx; | ||
469 | long ret=1; | ||
470 | int i; | ||
471 | |||
472 | ctx=(BIO_B64_CTX *)b->ptr; | ||
473 | |||
474 | switch (cmd) | ||
475 | { | ||
476 | case BIO_CTRL_RESET: | ||
477 | ctx->cont=1; | ||
478 | ctx->start=1; | ||
479 | ctx->encode=B64_NONE; | ||
480 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
481 | break; | ||
482 | case BIO_CTRL_EOF: /* More to read */ | ||
483 | if (ctx->cont <= 0) | ||
484 | ret=1; | ||
485 | else | ||
486 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
487 | break; | ||
488 | case BIO_CTRL_WPENDING: /* More to write in buffer */ | ||
489 | ret=ctx->buf_len-ctx->buf_off; | ||
490 | if ((ret == 0) && (ctx->encode != B64_NONE) | ||
491 | && (ctx->base64.num != 0)) | ||
492 | ret=1; | ||
493 | else if (ret <= 0) | ||
494 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
495 | break; | ||
496 | case BIO_CTRL_PENDING: /* More to read in buffer */ | ||
497 | ret=ctx->buf_len-ctx->buf_off; | ||
498 | if (ret <= 0) | ||
499 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
500 | break; | ||
501 | case BIO_CTRL_FLUSH: | ||
502 | /* do a final write */ | ||
503 | again: | ||
504 | while (ctx->buf_len != ctx->buf_off) | ||
505 | { | ||
506 | i=b64_write(b,NULL,0); | ||
507 | if (i < 0) | ||
508 | return i; | ||
509 | } | ||
510 | if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) | ||
511 | { | ||
512 | if (ctx->tmp_len != 0) | ||
513 | { | ||
514 | ctx->buf_len=EVP_EncodeBlock( | ||
515 | (unsigned char *)ctx->buf, | ||
516 | (unsigned char *)ctx->tmp, | ||
517 | ctx->tmp_len); | ||
518 | ctx->buf_off=0; | ||
519 | ctx->tmp_len=0; | ||
520 | goto again; | ||
521 | } | ||
522 | } | ||
523 | else if (ctx->encode != B64_NONE && ctx->base64.num != 0) | ||
524 | { | ||
525 | ctx->buf_off=0; | ||
526 | EVP_EncodeFinal(&(ctx->base64), | ||
527 | (unsigned char *)ctx->buf, | ||
528 | &(ctx->buf_len)); | ||
529 | /* push out the bytes */ | ||
530 | goto again; | ||
531 | } | ||
532 | /* Finally flush the underlying BIO */ | ||
533 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
534 | break; | ||
535 | |||
536 | case BIO_C_DO_STATE_MACHINE: | ||
537 | BIO_clear_retry_flags(b); | ||
538 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
539 | BIO_copy_next_retry(b); | ||
540 | break; | ||
541 | |||
542 | case BIO_CTRL_DUP: | ||
543 | break; | ||
544 | case BIO_CTRL_INFO: | ||
545 | case BIO_CTRL_GET: | ||
546 | case BIO_CTRL_SET: | ||
547 | default: | ||
548 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
549 | break; | ||
550 | } | ||
551 | return(ret); | ||
552 | } | ||
553 | |||
554 | static long b64_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | ||
555 | { | ||
556 | long ret=1; | ||
557 | |||
558 | if (b->next_bio == NULL) return(0); | ||
559 | switch (cmd) | ||
560 | { | ||
561 | default: | ||
562 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
563 | break; | ||
564 | } | ||
565 | return(ret); | ||
566 | } | ||
567 | |||
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c new file mode 100644 index 0000000000..b8cda1a9f0 --- /dev/null +++ b/src/lib/libcrypto/evp/bio_enc.c | |||
@@ -0,0 +1,426 @@ | |||
1 | /* crypto/evp/bio_enc.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 <errno.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/buffer.h> | ||
63 | #include <openssl/evp.h> | ||
64 | |||
65 | static int enc_write(BIO *h, const char *buf, int num); | ||
66 | static int enc_read(BIO *h, char *buf, int size); | ||
67 | /*static int enc_puts(BIO *h, const char *str); */ | ||
68 | /*static int enc_gets(BIO *h, char *str, int size); */ | ||
69 | static long enc_ctrl(BIO *h, int cmd, long arg1, void *arg2); | ||
70 | static int enc_new(BIO *h); | ||
71 | static int enc_free(BIO *data); | ||
72 | static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps); | ||
73 | #define ENC_BLOCK_SIZE (1024*4) | ||
74 | #define BUF_OFFSET (EVP_MAX_BLOCK_LENGTH*2) | ||
75 | |||
76 | typedef struct enc_struct | ||
77 | { | ||
78 | int buf_len; | ||
79 | int buf_off; | ||
80 | int cont; /* <= 0 when finished */ | ||
81 | int finished; | ||
82 | int ok; /* bad decrypt */ | ||
83 | EVP_CIPHER_CTX cipher; | ||
84 | /* buf is larger than ENC_BLOCK_SIZE because EVP_DecryptUpdate | ||
85 | * can return up to a block more data than is presented to it | ||
86 | */ | ||
87 | char buf[ENC_BLOCK_SIZE+BUF_OFFSET+2]; | ||
88 | } BIO_ENC_CTX; | ||
89 | |||
90 | static BIO_METHOD methods_enc= | ||
91 | { | ||
92 | BIO_TYPE_CIPHER,"cipher", | ||
93 | enc_write, | ||
94 | enc_read, | ||
95 | NULL, /* enc_puts, */ | ||
96 | NULL, /* enc_gets, */ | ||
97 | enc_ctrl, | ||
98 | enc_new, | ||
99 | enc_free, | ||
100 | enc_callback_ctrl, | ||
101 | }; | ||
102 | |||
103 | BIO_METHOD *BIO_f_cipher(void) | ||
104 | { | ||
105 | return(&methods_enc); | ||
106 | } | ||
107 | |||
108 | static int enc_new(BIO *bi) | ||
109 | { | ||
110 | BIO_ENC_CTX *ctx; | ||
111 | |||
112 | ctx=(BIO_ENC_CTX *)OPENSSL_malloc(sizeof(BIO_ENC_CTX)); | ||
113 | if (ctx == NULL) return(0); | ||
114 | EVP_CIPHER_CTX_init(&ctx->cipher); | ||
115 | |||
116 | ctx->buf_len=0; | ||
117 | ctx->buf_off=0; | ||
118 | ctx->cont=1; | ||
119 | ctx->finished=0; | ||
120 | ctx->ok=1; | ||
121 | |||
122 | bi->init=0; | ||
123 | bi->ptr=(char *)ctx; | ||
124 | bi->flags=0; | ||
125 | return(1); | ||
126 | } | ||
127 | |||
128 | static int enc_free(BIO *a) | ||
129 | { | ||
130 | BIO_ENC_CTX *b; | ||
131 | |||
132 | if (a == NULL) return(0); | ||
133 | b=(BIO_ENC_CTX *)a->ptr; | ||
134 | EVP_CIPHER_CTX_cleanup(&(b->cipher)); | ||
135 | OPENSSL_cleanse(a->ptr,sizeof(BIO_ENC_CTX)); | ||
136 | OPENSSL_free(a->ptr); | ||
137 | a->ptr=NULL; | ||
138 | a->init=0; | ||
139 | a->flags=0; | ||
140 | return(1); | ||
141 | } | ||
142 | |||
143 | static int enc_read(BIO *b, char *out, int outl) | ||
144 | { | ||
145 | int ret=0,i; | ||
146 | BIO_ENC_CTX *ctx; | ||
147 | |||
148 | if (out == NULL) return(0); | ||
149 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
150 | |||
151 | if ((ctx == NULL) || (b->next_bio == NULL)) return(0); | ||
152 | |||
153 | /* First check if there are bytes decoded/encoded */ | ||
154 | if (ctx->buf_len > 0) | ||
155 | { | ||
156 | i=ctx->buf_len-ctx->buf_off; | ||
157 | if (i > outl) i=outl; | ||
158 | memcpy(out,&(ctx->buf[ctx->buf_off]),i); | ||
159 | ret=i; | ||
160 | out+=i; | ||
161 | outl-=i; | ||
162 | ctx->buf_off+=i; | ||
163 | if (ctx->buf_len == ctx->buf_off) | ||
164 | { | ||
165 | ctx->buf_len=0; | ||
166 | ctx->buf_off=0; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | /* At this point, we have room of outl bytes and an empty | ||
171 | * buffer, so we should read in some more. */ | ||
172 | |||
173 | while (outl > 0) | ||
174 | { | ||
175 | if (ctx->cont <= 0) break; | ||
176 | |||
177 | /* read in at IV offset, read the EVP_Cipher | ||
178 | * documentation about why */ | ||
179 | i=BIO_read(b->next_bio,&(ctx->buf[BUF_OFFSET]),ENC_BLOCK_SIZE); | ||
180 | |||
181 | if (i <= 0) | ||
182 | { | ||
183 | /* Should be continue next time we are called? */ | ||
184 | if (!BIO_should_retry(b->next_bio)) | ||
185 | { | ||
186 | ctx->cont=i; | ||
187 | i=EVP_CipherFinal_ex(&(ctx->cipher), | ||
188 | (unsigned char *)ctx->buf, | ||
189 | &(ctx->buf_len)); | ||
190 | ctx->ok=i; | ||
191 | ctx->buf_off=0; | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | ret=(ret == 0)?i:ret; | ||
196 | break; | ||
197 | } | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | EVP_CipherUpdate(&(ctx->cipher), | ||
202 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
203 | (unsigned char *)&(ctx->buf[BUF_OFFSET]),i); | ||
204 | ctx->cont=1; | ||
205 | /* Note: it is possible for EVP_CipherUpdate to | ||
206 | * decrypt zero bytes because this is or looks like | ||
207 | * the final block: if this happens we should retry | ||
208 | * and either read more data or decrypt the final | ||
209 | * block | ||
210 | */ | ||
211 | if(ctx->buf_len == 0) continue; | ||
212 | } | ||
213 | |||
214 | if (ctx->buf_len <= outl) | ||
215 | i=ctx->buf_len; | ||
216 | else | ||
217 | i=outl; | ||
218 | if (i <= 0) break; | ||
219 | memcpy(out,ctx->buf,i); | ||
220 | ret+=i; | ||
221 | ctx->buf_off=i; | ||
222 | outl-=i; | ||
223 | out+=i; | ||
224 | } | ||
225 | |||
226 | BIO_clear_retry_flags(b); | ||
227 | BIO_copy_next_retry(b); | ||
228 | return((ret == 0)?ctx->cont:ret); | ||
229 | } | ||
230 | |||
231 | static int enc_write(BIO *b, const char *in, int inl) | ||
232 | { | ||
233 | int ret=0,n,i; | ||
234 | BIO_ENC_CTX *ctx; | ||
235 | |||
236 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
237 | ret=inl; | ||
238 | |||
239 | BIO_clear_retry_flags(b); | ||
240 | n=ctx->buf_len-ctx->buf_off; | ||
241 | while (n > 0) | ||
242 | { | ||
243 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
244 | if (i <= 0) | ||
245 | { | ||
246 | BIO_copy_next_retry(b); | ||
247 | return(i); | ||
248 | } | ||
249 | ctx->buf_off+=i; | ||
250 | n-=i; | ||
251 | } | ||
252 | /* at this point all pending data has been written */ | ||
253 | |||
254 | if ((in == NULL) || (inl <= 0)) return(0); | ||
255 | |||
256 | ctx->buf_off=0; | ||
257 | while (inl > 0) | ||
258 | { | ||
259 | n=(inl > ENC_BLOCK_SIZE)?ENC_BLOCK_SIZE:inl; | ||
260 | EVP_CipherUpdate(&(ctx->cipher), | ||
261 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
262 | (unsigned char *)in,n); | ||
263 | inl-=n; | ||
264 | in+=n; | ||
265 | |||
266 | ctx->buf_off=0; | ||
267 | n=ctx->buf_len; | ||
268 | while (n > 0) | ||
269 | { | ||
270 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
271 | if (i <= 0) | ||
272 | { | ||
273 | BIO_copy_next_retry(b); | ||
274 | return (ret == inl) ? i : ret - inl; | ||
275 | } | ||
276 | n-=i; | ||
277 | ctx->buf_off+=i; | ||
278 | } | ||
279 | ctx->buf_len=0; | ||
280 | ctx->buf_off=0; | ||
281 | } | ||
282 | BIO_copy_next_retry(b); | ||
283 | return(ret); | ||
284 | } | ||
285 | |||
286 | static long enc_ctrl(BIO *b, int cmd, long num, void *ptr) | ||
287 | { | ||
288 | BIO *dbio; | ||
289 | BIO_ENC_CTX *ctx,*dctx; | ||
290 | long ret=1; | ||
291 | int i; | ||
292 | EVP_CIPHER_CTX **c_ctx; | ||
293 | |||
294 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
295 | |||
296 | switch (cmd) | ||
297 | { | ||
298 | case BIO_CTRL_RESET: | ||
299 | ctx->ok=1; | ||
300 | ctx->finished=0; | ||
301 | EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL, | ||
302 | ctx->cipher.encrypt); | ||
303 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
304 | break; | ||
305 | case BIO_CTRL_EOF: /* More to read */ | ||
306 | if (ctx->cont <= 0) | ||
307 | ret=1; | ||
308 | else | ||
309 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
310 | break; | ||
311 | case BIO_CTRL_WPENDING: | ||
312 | ret=ctx->buf_len-ctx->buf_off; | ||
313 | if (ret <= 0) | ||
314 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
315 | break; | ||
316 | case BIO_CTRL_PENDING: /* More to read in buffer */ | ||
317 | ret=ctx->buf_len-ctx->buf_off; | ||
318 | if (ret <= 0) | ||
319 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
320 | break; | ||
321 | case BIO_CTRL_FLUSH: | ||
322 | /* do a final write */ | ||
323 | again: | ||
324 | while (ctx->buf_len != ctx->buf_off) | ||
325 | { | ||
326 | i=enc_write(b,NULL,0); | ||
327 | if (i < 0) | ||
328 | return i; | ||
329 | } | ||
330 | |||
331 | if (!ctx->finished) | ||
332 | { | ||
333 | ctx->finished=1; | ||
334 | ctx->buf_off=0; | ||
335 | ret=EVP_CipherFinal_ex(&(ctx->cipher), | ||
336 | (unsigned char *)ctx->buf, | ||
337 | &(ctx->buf_len)); | ||
338 | ctx->ok=(int)ret; | ||
339 | if (ret <= 0) break; | ||
340 | |||
341 | /* push out the bytes */ | ||
342 | goto again; | ||
343 | } | ||
344 | |||
345 | /* Finally flush the underlying BIO */ | ||
346 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
347 | break; | ||
348 | case BIO_C_GET_CIPHER_STATUS: | ||
349 | ret=(long)ctx->ok; | ||
350 | break; | ||
351 | case BIO_C_DO_STATE_MACHINE: | ||
352 | BIO_clear_retry_flags(b); | ||
353 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
354 | BIO_copy_next_retry(b); | ||
355 | break; | ||
356 | case BIO_C_GET_CIPHER_CTX: | ||
357 | c_ctx=(EVP_CIPHER_CTX **)ptr; | ||
358 | (*c_ctx)= &(ctx->cipher); | ||
359 | b->init=1; | ||
360 | break; | ||
361 | case BIO_CTRL_DUP: | ||
362 | dbio=(BIO *)ptr; | ||
363 | dctx=(BIO_ENC_CTX *)dbio->ptr; | ||
364 | memcpy(&(dctx->cipher),&(ctx->cipher),sizeof(ctx->cipher)); | ||
365 | dbio->init=1; | ||
366 | break; | ||
367 | default: | ||
368 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
369 | break; | ||
370 | } | ||
371 | return(ret); | ||
372 | } | ||
373 | |||
374 | static long enc_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | ||
375 | { | ||
376 | long ret=1; | ||
377 | |||
378 | if (b->next_bio == NULL) return(0); | ||
379 | switch (cmd) | ||
380 | { | ||
381 | default: | ||
382 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
383 | break; | ||
384 | } | ||
385 | return(ret); | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | void BIO_set_cipher_ctx(b,c) | ||
390 | BIO *b; | ||
391 | EVP_CIPHER_ctx *c; | ||
392 | { | ||
393 | if (b == NULL) return; | ||
394 | |||
395 | if ((b->callback != NULL) && | ||
396 | (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0)) | ||
397 | return; | ||
398 | |||
399 | b->init=1; | ||
400 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
401 | memcpy(ctx->cipher,c,sizeof(EVP_CIPHER_CTX)); | ||
402 | |||
403 | if (b->callback != NULL) | ||
404 | b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L); | ||
405 | } | ||
406 | */ | ||
407 | |||
408 | void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k, | ||
409 | unsigned char *i, int e) | ||
410 | { | ||
411 | BIO_ENC_CTX *ctx; | ||
412 | |||
413 | if (b == NULL) return; | ||
414 | |||
415 | if ((b->callback != NULL) && | ||
416 | (b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,0L) <= 0)) | ||
417 | return; | ||
418 | |||
419 | b->init=1; | ||
420 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
421 | EVP_CipherInit_ex(&(ctx->cipher),c,NULL, k,i,e); | ||
422 | |||
423 | if (b->callback != NULL) | ||
424 | b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L); | ||
425 | } | ||
426 | |||
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c new file mode 100644 index 0000000000..f4aa41ac4b --- /dev/null +++ b/src/lib/libcrypto/evp/bio_md.c | |||
@@ -0,0 +1,264 @@ | |||
1 | /* crypto/evp/bio_md.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 <errno.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/buffer.h> | ||
63 | #include <openssl/evp.h> | ||
64 | |||
65 | /* BIO_put and BIO_get both add to the digest, | ||
66 | * BIO_gets returns the digest */ | ||
67 | |||
68 | static int md_write(BIO *h, char const *buf, int num); | ||
69 | static int md_read(BIO *h, char *buf, int size); | ||
70 | /*static int md_puts(BIO *h, const char *str); */ | ||
71 | static int md_gets(BIO *h, char *str, int size); | ||
72 | static long md_ctrl(BIO *h, int cmd, long arg1, void *arg2); | ||
73 | static int md_new(BIO *h); | ||
74 | static int md_free(BIO *data); | ||
75 | static long md_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp); | ||
76 | |||
77 | static BIO_METHOD methods_md= | ||
78 | { | ||
79 | BIO_TYPE_MD,"message digest", | ||
80 | md_write, | ||
81 | md_read, | ||
82 | NULL, /* md_puts, */ | ||
83 | md_gets, | ||
84 | md_ctrl, | ||
85 | md_new, | ||
86 | md_free, | ||
87 | md_callback_ctrl, | ||
88 | }; | ||
89 | |||
90 | BIO_METHOD *BIO_f_md(void) | ||
91 | { | ||
92 | return(&methods_md); | ||
93 | } | ||
94 | |||
95 | static int md_new(BIO *bi) | ||
96 | { | ||
97 | EVP_MD_CTX *ctx; | ||
98 | |||
99 | ctx=EVP_MD_CTX_create(); | ||
100 | if (ctx == NULL) return(0); | ||
101 | |||
102 | bi->init=0; | ||
103 | bi->ptr=(char *)ctx; | ||
104 | bi->flags=0; | ||
105 | return(1); | ||
106 | } | ||
107 | |||
108 | static int md_free(BIO *a) | ||
109 | { | ||
110 | if (a == NULL) return(0); | ||
111 | EVP_MD_CTX_destroy(a->ptr); | ||
112 | a->ptr=NULL; | ||
113 | a->init=0; | ||
114 | a->flags=0; | ||
115 | return(1); | ||
116 | } | ||
117 | |||
118 | static int md_read(BIO *b, char *out, int outl) | ||
119 | { | ||
120 | int ret=0; | ||
121 | EVP_MD_CTX *ctx; | ||
122 | |||
123 | if (out == NULL) return(0); | ||
124 | ctx=b->ptr; | ||
125 | |||
126 | if ((ctx == NULL) || (b->next_bio == NULL)) return(0); | ||
127 | |||
128 | ret=BIO_read(b->next_bio,out,outl); | ||
129 | if (b->init) | ||
130 | { | ||
131 | if (ret > 0) | ||
132 | { | ||
133 | EVP_DigestUpdate(ctx,(unsigned char *)out, | ||
134 | (unsigned int)ret); | ||
135 | } | ||
136 | } | ||
137 | BIO_clear_retry_flags(b); | ||
138 | BIO_copy_next_retry(b); | ||
139 | return(ret); | ||
140 | } | ||
141 | |||
142 | static int md_write(BIO *b, const char *in, int inl) | ||
143 | { | ||
144 | int ret=0; | ||
145 | EVP_MD_CTX *ctx; | ||
146 | |||
147 | if ((in == NULL) || (inl <= 0)) return(0); | ||
148 | ctx=b->ptr; | ||
149 | |||
150 | if ((ctx != NULL) && (b->next_bio != NULL)) | ||
151 | ret=BIO_write(b->next_bio,in,inl); | ||
152 | if (b->init) | ||
153 | { | ||
154 | if (ret > 0) | ||
155 | { | ||
156 | EVP_DigestUpdate(ctx,(unsigned char *)in, | ||
157 | (unsigned int)ret); | ||
158 | } | ||
159 | } | ||
160 | BIO_clear_retry_flags(b); | ||
161 | BIO_copy_next_retry(b); | ||
162 | return(ret); | ||
163 | } | ||
164 | |||
165 | static long md_ctrl(BIO *b, int cmd, long num, void *ptr) | ||
166 | { | ||
167 | EVP_MD_CTX *ctx,*dctx,**pctx; | ||
168 | const EVP_MD **ppmd; | ||
169 | EVP_MD *md; | ||
170 | long ret=1; | ||
171 | BIO *dbio; | ||
172 | |||
173 | ctx=b->ptr; | ||
174 | |||
175 | switch (cmd) | ||
176 | { | ||
177 | case BIO_CTRL_RESET: | ||
178 | if (b->init) | ||
179 | ret = EVP_DigestInit_ex(ctx,ctx->digest, NULL); | ||
180 | else | ||
181 | ret=0; | ||
182 | if (ret > 0) | ||
183 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
184 | break; | ||
185 | case BIO_C_GET_MD: | ||
186 | if (b->init) | ||
187 | { | ||
188 | ppmd=ptr; | ||
189 | *ppmd=ctx->digest; | ||
190 | } | ||
191 | else | ||
192 | ret=0; | ||
193 | break; | ||
194 | case BIO_C_GET_MD_CTX: | ||
195 | pctx=ptr; | ||
196 | *pctx=ctx; | ||
197 | break; | ||
198 | case BIO_C_SET_MD_CTX: | ||
199 | if (b->init) | ||
200 | b->ptr=ptr; | ||
201 | else | ||
202 | ret=0; | ||
203 | break; | ||
204 | case BIO_C_DO_STATE_MACHINE: | ||
205 | BIO_clear_retry_flags(b); | ||
206 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
207 | BIO_copy_next_retry(b); | ||
208 | break; | ||
209 | |||
210 | case BIO_C_SET_MD: | ||
211 | md=ptr; | ||
212 | ret = EVP_DigestInit_ex(ctx,md, NULL); | ||
213 | if (ret > 0) | ||
214 | b->init=1; | ||
215 | break; | ||
216 | case BIO_CTRL_DUP: | ||
217 | dbio=ptr; | ||
218 | dctx=dbio->ptr; | ||
219 | EVP_MD_CTX_copy_ex(dctx,ctx); | ||
220 | b->init=1; | ||
221 | break; | ||
222 | default: | ||
223 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
224 | break; | ||
225 | } | ||
226 | return(ret); | ||
227 | } | ||
228 | |||
229 | static long md_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | ||
230 | { | ||
231 | long ret=1; | ||
232 | |||
233 | if (b->next_bio == NULL) return(0); | ||
234 | switch (cmd) | ||
235 | { | ||
236 | default: | ||
237 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
238 | break; | ||
239 | } | ||
240 | return(ret); | ||
241 | } | ||
242 | |||
243 | static int md_gets(BIO *bp, char *buf, int size) | ||
244 | { | ||
245 | EVP_MD_CTX *ctx; | ||
246 | unsigned int ret; | ||
247 | |||
248 | |||
249 | ctx=bp->ptr; | ||
250 | if (size < ctx->digest->md_size) | ||
251 | return(0); | ||
252 | EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret); | ||
253 | return((int)ret); | ||
254 | } | ||
255 | |||
256 | /* | ||
257 | static int md_puts(bp,str) | ||
258 | BIO *bp; | ||
259 | char *str; | ||
260 | { | ||
261 | return(-1); | ||
262 | } | ||
263 | */ | ||
264 | |||
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c index 98bc1ab409..4e3f10141b 100644 --- a/src/lib/libcrypto/evp/bio_ok.c +++ b/src/lib/libcrypto/evp/bio_ok.c | |||
@@ -119,7 +119,6 @@ | |||
119 | 119 | ||
120 | #include <stdio.h> | 120 | #include <stdio.h> |
121 | #include <errno.h> | 121 | #include <errno.h> |
122 | #include <assert.h> | ||
123 | #include "cryptlib.h" | 122 | #include "cryptlib.h" |
124 | #include <openssl/buffer.h> | 123 | #include <openssl/buffer.h> |
125 | #include <openssl/bio.h> | 124 | #include <openssl/bio.h> |
@@ -142,12 +141,22 @@ static void block_in(BIO* b); | |||
142 | #define IOBS (OK_BLOCK_SIZE+ OK_BLOCK_BLOCK+ 3*EVP_MAX_MD_SIZE) | 141 | #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." | 142 | #define WELLKNOWN "The quick brown fox jumped over the lazy dog's back." |
144 | 143 | ||
144 | #ifndef L_ENDIAN | ||
145 | #define swapem(x) \ | ||
146 | ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ | ||
147 | (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ | ||
148 | (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ | ||
149 | (((unsigned long int)(x) & 0xff000000U) >> 24))) | ||
150 | #else | ||
151 | #define swapem(x) (x) | ||
152 | #endif | ||
153 | |||
145 | typedef struct ok_struct | 154 | typedef struct ok_struct |
146 | { | 155 | { |
147 | size_t buf_len; | 156 | int buf_len; |
148 | size_t buf_off; | 157 | int buf_off; |
149 | size_t buf_len_save; | 158 | int buf_len_save; |
150 | size_t buf_off_save; | 159 | int buf_off_save; |
151 | int cont; /* <= 0 when finished */ | 160 | int cont; /* <= 0 when finished */ |
152 | int finished; | 161 | int finished; |
153 | EVP_MD_CTX md; | 162 | EVP_MD_CTX md; |
@@ -286,8 +295,6 @@ static int ok_write(BIO *b, const char *in, int inl) | |||
286 | int ret=0,n,i; | 295 | int ret=0,n,i; |
287 | BIO_OK_CTX *ctx; | 296 | BIO_OK_CTX *ctx; |
288 | 297 | ||
289 | if (inl <= 0) return inl; | ||
290 | |||
291 | ctx=(BIO_OK_CTX *)b->ptr; | 298 | ctx=(BIO_OK_CTX *)b->ptr; |
292 | ret=inl; | 299 | ret=inl; |
293 | 300 | ||
@@ -323,7 +330,7 @@ static int ok_write(BIO *b, const char *in, int inl) | |||
323 | if ((in == NULL) || (inl <= 0)) return(0); | 330 | if ((in == NULL) || (inl <= 0)) return(0); |
324 | 331 | ||
325 | n= (inl+ ctx->buf_len > OK_BLOCK_SIZE+ OK_BLOCK_BLOCK) ? | 332 | n= (inl+ ctx->buf_len > OK_BLOCK_SIZE+ OK_BLOCK_BLOCK) ? |
326 | (int)(OK_BLOCK_SIZE+OK_BLOCK_BLOCK-ctx->buf_len) : inl; | 333 | OK_BLOCK_SIZE+ OK_BLOCK_BLOCK- ctx->buf_len : inl; |
327 | 334 | ||
328 | memcpy((unsigned char *)(&(ctx->buf[ctx->buf_len])),(unsigned char *)in,n); | 335 | memcpy((unsigned char *)(&(ctx->buf[ctx->buf_len])),(unsigned char *)in,n); |
329 | ctx->buf_len+= n; | 336 | ctx->buf_len+= n; |
@@ -441,18 +448,16 @@ static long ok_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | |||
441 | return(ret); | 448 | return(ret); |
442 | } | 449 | } |
443 | 450 | ||
444 | static void longswap(void *_ptr, size_t len) | 451 | static void longswap(void *_ptr, int len) |
445 | { const union { long one; char little; } is_endian = {1}; | 452 | { |
446 | 453 | #ifndef L_ENDIAN | |
447 | if (is_endian.little) { | 454 | int i; |
448 | size_t i; | 455 | char *ptr=_ptr; |
449 | unsigned char *p=_ptr,c; | ||
450 | 456 | ||
451 | for(i= 0;i < len;i+= 4) { | 457 | for(i= 0;i < len;i+= 4){ |
452 | c=p[0],p[0]=p[3],p[3]=c; | 458 | *((unsigned long *)&(ptr[i]))= swapem(*((unsigned long *)&(ptr[i]))); |
453 | c=p[1],p[1]=p[2],p[2]=c; | ||
454 | } | ||
455 | } | 459 | } |
460 | #endif | ||
456 | } | 461 | } |
457 | 462 | ||
458 | static void sig_out(BIO* b) | 463 | static void sig_out(BIO* b) |
@@ -491,7 +496,7 @@ static void sig_in(BIO* b) | |||
491 | ctx=b->ptr; | 496 | ctx=b->ptr; |
492 | md=&ctx->md; | 497 | md=&ctx->md; |
493 | 498 | ||
494 | if((int)(ctx->buf_len-ctx->buf_off) < 2*md->digest->md_size) return; | 499 | if(ctx->buf_len- ctx->buf_off < 2* md->digest->md_size) return; |
495 | 500 | ||
496 | EVP_DigestInit_ex(md, md->digest, NULL); | 501 | EVP_DigestInit_ex(md, md->digest, NULL); |
497 | memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size); | 502 | memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size); |
@@ -528,10 +533,9 @@ static void block_out(BIO* b) | |||
528 | md=&ctx->md; | 533 | md=&ctx->md; |
529 | 534 | ||
530 | tl= ctx->buf_len- OK_BLOCK_BLOCK; | 535 | tl= ctx->buf_len- OK_BLOCK_BLOCK; |
531 | ctx->buf[0]=(unsigned char)(tl>>24); | 536 | tl= swapem(tl); |
532 | ctx->buf[1]=(unsigned char)(tl>>16); | 537 | memcpy(ctx->buf, &tl, OK_BLOCK_BLOCK); |
533 | ctx->buf[2]=(unsigned char)(tl>>8); | 538 | tl= swapem(tl); |
534 | ctx->buf[3]=(unsigned char)(tl); | ||
535 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); | 539 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); |
536 | EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL); | 540 | EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL); |
537 | ctx->buf_len+= md->digest->md_size; | 541 | ctx->buf_len+= md->digest->md_size; |
@@ -542,18 +546,14 @@ static void block_in(BIO* b) | |||
542 | { | 546 | { |
543 | BIO_OK_CTX *ctx; | 547 | BIO_OK_CTX *ctx; |
544 | EVP_MD_CTX *md; | 548 | EVP_MD_CTX *md; |
545 | unsigned long tl= 0; | 549 | long tl= 0; |
546 | unsigned char tmp[EVP_MAX_MD_SIZE]; | 550 | unsigned char tmp[EVP_MAX_MD_SIZE]; |
547 | 551 | ||
548 | ctx=b->ptr; | 552 | ctx=b->ptr; |
549 | md=&ctx->md; | 553 | md=&ctx->md; |
550 | 554 | ||
551 | assert(sizeof(tl)>=OK_BLOCK_BLOCK); /* always true */ | 555 | memcpy(&tl, ctx->buf, OK_BLOCK_BLOCK); |
552 | tl =ctx->buf[0]; tl<<=8; | 556 | tl= swapem(tl); |
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; | 557 | if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return; |
558 | 558 | ||
559 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); | 559 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); |
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c new file mode 100644 index 0000000000..fa60a73ead --- /dev/null +++ b/src/lib/libcrypto/evp/c_all.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* crypto/evp/c_all.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 | #ifndef OPENSSL_NO_ENGINE | ||
63 | #include <openssl/engine.h> | ||
64 | #endif | ||
65 | |||
66 | #if 0 | ||
67 | #undef OpenSSL_add_all_algorithms | ||
68 | |||
69 | void OpenSSL_add_all_algorithms(void) | ||
70 | { | ||
71 | OPENSSL_add_all_algorithms_noconf(); | ||
72 | } | ||
73 | #endif | ||
74 | |||
75 | void OPENSSL_add_all_algorithms_noconf(void) | ||
76 | { | ||
77 | OpenSSL_add_all_ciphers(); | ||
78 | OpenSSL_add_all_digests(); | ||
79 | #ifndef OPENSSL_NO_ENGINE | ||
80 | # if defined(__OpenBSD__) || defined(__FreeBSD__) | ||
81 | ENGINE_setup_bsd_cryptodev(); | ||
82 | # endif | ||
83 | #endif | ||
84 | } | ||
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c index 7054d8125d..fc96812365 100644 --- a/src/lib/libcrypto/evp/c_allc.c +++ b/src/lib/libcrypto/evp/c_allc.c | |||
@@ -107,15 +107,6 @@ void OpenSSL_add_all_ciphers(void) | |||
107 | EVP_add_cipher_alias(SN_idea_cbc,"idea"); | 107 | EVP_add_cipher_alias(SN_idea_cbc,"idea"); |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | #ifndef OPENSSL_NO_SEED | ||
111 | EVP_add_cipher(EVP_seed_ecb()); | ||
112 | EVP_add_cipher(EVP_seed_cfb()); | ||
113 | EVP_add_cipher(EVP_seed_ofb()); | ||
114 | EVP_add_cipher(EVP_seed_cbc()); | ||
115 | EVP_add_cipher_alias(SN_seed_cbc,"SEED"); | ||
116 | EVP_add_cipher_alias(SN_seed_cbc,"seed"); | ||
117 | #endif | ||
118 | |||
119 | #ifndef OPENSSL_NO_RC2 | 110 | #ifndef OPENSSL_NO_RC2 |
120 | EVP_add_cipher(EVP_rc2_ecb()); | 111 | EVP_add_cipher(EVP_rc2_ecb()); |
121 | EVP_add_cipher(EVP_rc2_cfb()); | 112 | EVP_add_cipher(EVP_rc2_cfb()); |
@@ -192,34 +183,6 @@ void OpenSSL_add_all_ciphers(void) | |||
192 | EVP_add_cipher_alias(SN_aes_256_cbc,"AES256"); | 183 | EVP_add_cipher_alias(SN_aes_256_cbc,"AES256"); |
193 | EVP_add_cipher_alias(SN_aes_256_cbc,"aes256"); | 184 | EVP_add_cipher_alias(SN_aes_256_cbc,"aes256"); |
194 | #endif | 185 | #endif |
195 | |||
196 | #ifndef OPENSSL_NO_CAMELLIA | ||
197 | EVP_add_cipher(EVP_camellia_128_ecb()); | ||
198 | EVP_add_cipher(EVP_camellia_128_cbc()); | ||
199 | EVP_add_cipher(EVP_camellia_128_cfb()); | ||
200 | EVP_add_cipher(EVP_camellia_128_cfb1()); | ||
201 | EVP_add_cipher(EVP_camellia_128_cfb8()); | ||
202 | EVP_add_cipher(EVP_camellia_128_ofb()); | ||
203 | EVP_add_cipher_alias(SN_camellia_128_cbc,"CAMELLIA128"); | ||
204 | EVP_add_cipher_alias(SN_camellia_128_cbc,"camellia128"); | ||
205 | EVP_add_cipher(EVP_camellia_192_ecb()); | ||
206 | EVP_add_cipher(EVP_camellia_192_cbc()); | ||
207 | EVP_add_cipher(EVP_camellia_192_cfb()); | ||
208 | EVP_add_cipher(EVP_camellia_192_cfb1()); | ||
209 | EVP_add_cipher(EVP_camellia_192_cfb8()); | ||
210 | EVP_add_cipher(EVP_camellia_192_ofb()); | ||
211 | EVP_add_cipher_alias(SN_camellia_192_cbc,"CAMELLIA192"); | ||
212 | EVP_add_cipher_alias(SN_camellia_192_cbc,"camellia192"); | ||
213 | EVP_add_cipher(EVP_camellia_256_ecb()); | ||
214 | EVP_add_cipher(EVP_camellia_256_cbc()); | ||
215 | EVP_add_cipher(EVP_camellia_256_cfb()); | ||
216 | EVP_add_cipher(EVP_camellia_256_cfb1()); | ||
217 | EVP_add_cipher(EVP_camellia_256_cfb8()); | ||
218 | EVP_add_cipher(EVP_camellia_256_ofb()); | ||
219 | EVP_add_cipher_alias(SN_camellia_256_cbc,"CAMELLIA256"); | ||
220 | EVP_add_cipher_alias(SN_camellia_256_cbc,"camellia256"); | ||
221 | #endif | ||
222 | |||
223 | PKCS12_PBE_add(); | 186 | PKCS12_PBE_add(); |
224 | PKCS5_PBE_add(); | 187 | PKCS5_PBE_add(); |
225 | } | 188 | } |
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c index d270b0ee03..929ea56a3e 100644 --- a/src/lib/libcrypto/evp/c_alld.c +++ b/src/lib/libcrypto/evp/c_alld.c | |||
@@ -91,9 +91,6 @@ void OpenSSL_add_all_digests(void) | |||
91 | EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); | 91 | EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); |
92 | EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); | 92 | EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); |
93 | #endif | 93 | #endif |
94 | #ifndef OPENSSL_NO_ECDSA | ||
95 | EVP_add_digest(EVP_ecdsa()); | ||
96 | #endif | ||
97 | #endif | 94 | #endif |
98 | #if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES) | 95 | #if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES) |
99 | EVP_add_digest(EVP_mdc2()); | 96 | EVP_add_digest(EVP_mdc2()); |
@@ -103,6 +100,7 @@ void OpenSSL_add_all_digests(void) | |||
103 | EVP_add_digest_alias(SN_ripemd160,"ripemd"); | 100 | EVP_add_digest_alias(SN_ripemd160,"ripemd"); |
104 | EVP_add_digest_alias(SN_ripemd160,"rmd160"); | 101 | EVP_add_digest_alias(SN_ripemd160,"rmd160"); |
105 | #endif | 102 | #endif |
103 | #ifdef OPENSSL_FIPS | ||
106 | #ifndef OPENSSL_NO_SHA256 | 104 | #ifndef OPENSSL_NO_SHA256 |
107 | EVP_add_digest(EVP_sha224()); | 105 | EVP_add_digest(EVP_sha224()); |
108 | EVP_add_digest(EVP_sha256()); | 106 | EVP_add_digest(EVP_sha256()); |
@@ -111,4 +109,5 @@ void OpenSSL_add_all_digests(void) | |||
111 | EVP_add_digest(EVP_sha384()); | 109 | EVP_add_digest(EVP_sha384()); |
112 | EVP_add_digest(EVP_sha512()); | 110 | EVP_add_digest(EVP_sha512()); |
113 | #endif | 111 | #endif |
112 | #endif | ||
114 | } | 113 | } |
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c new file mode 100644 index 0000000000..f21c63842c --- /dev/null +++ b/src/lib/libcrypto/evp/digest.c | |||
@@ -0,0 +1,379 @@ | |||
1 | /* crypto/evp/digest.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 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. | ||
60 | * | ||
61 | * Redistribution and use in source and binary forms, with or without | ||
62 | * modification, are permitted provided that the following conditions | ||
63 | * are met: | ||
64 | * | ||
65 | * 1. Redistributions of source code must retain the above copyright | ||
66 | * notice, this list of conditions and the following disclaimer. | ||
67 | * | ||
68 | * 2. Redistributions in binary form must reproduce the above copyright | ||
69 | * notice, this list of conditions and the following disclaimer in | ||
70 | * the documentation and/or other materials provided with the | ||
71 | * distribution. | ||
72 | * | ||
73 | * 3. All advertising materials mentioning features or use of this | ||
74 | * software must display the following acknowledgment: | ||
75 | * "This product includes software developed by the OpenSSL Project | ||
76 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
77 | * | ||
78 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
79 | * endorse or promote products derived from this software without | ||
80 | * prior written permission. For written permission, please contact | ||
81 | * openssl-core@openssl.org. | ||
82 | * | ||
83 | * 5. Products derived from this software may not be called "OpenSSL" | ||
84 | * nor may "OpenSSL" appear in their names without prior written | ||
85 | * permission of the OpenSSL Project. | ||
86 | * | ||
87 | * 6. Redistributions of any form whatsoever must retain the following | ||
88 | * acknowledgment: | ||
89 | * "This product includes software developed by the OpenSSL Project | ||
90 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
91 | * | ||
92 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
93 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
94 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
95 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
96 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
97 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
98 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
99 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
101 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
102 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
103 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
104 | * ==================================================================== | ||
105 | * | ||
106 | * This product includes cryptographic software written by Eric Young | ||
107 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
108 | * Hudson (tjh@cryptsoft.com). | ||
109 | * | ||
110 | */ | ||
111 | |||
112 | #include <stdio.h> | ||
113 | #include "cryptlib.h" | ||
114 | #include <openssl/objects.h> | ||
115 | #include <openssl/evp.h> | ||
116 | #ifndef OPENSSL_NO_ENGINE | ||
117 | #include <openssl/engine.h> | ||
118 | #endif | ||
119 | |||
120 | void EVP_MD_CTX_init(EVP_MD_CTX *ctx) | ||
121 | { | ||
122 | memset(ctx,'\0',sizeof *ctx); | ||
123 | } | ||
124 | |||
125 | EVP_MD_CTX *EVP_MD_CTX_create(void) | ||
126 | { | ||
127 | EVP_MD_CTX *ctx=OPENSSL_malloc(sizeof *ctx); | ||
128 | |||
129 | EVP_MD_CTX_init(ctx); | ||
130 | |||
131 | return ctx; | ||
132 | } | ||
133 | |||
134 | int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) | ||
135 | { | ||
136 | EVP_MD_CTX_init(ctx); | ||
137 | return EVP_DigestInit_ex(ctx, type, NULL); | ||
138 | } | ||
139 | |||
140 | #ifdef OPENSSL_FIPS | ||
141 | |||
142 | /* The purpose of these is to trap programs that attempt to use non FIPS | ||
143 | * algorithms in FIPS mode and ignore the errors. | ||
144 | */ | ||
145 | |||
146 | static int bad_init(EVP_MD_CTX *ctx) | ||
147 | { FIPS_ERROR_IGNORED("Digest init"); return 0;} | ||
148 | |||
149 | static int bad_update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
150 | { FIPS_ERROR_IGNORED("Digest update"); return 0;} | ||
151 | |||
152 | static int bad_final(EVP_MD_CTX *ctx,unsigned char *md) | ||
153 | { FIPS_ERROR_IGNORED("Digest Final"); return 0;} | ||
154 | |||
155 | static const EVP_MD bad_md = | ||
156 | { | ||
157 | 0, | ||
158 | 0, | ||
159 | 0, | ||
160 | 0, | ||
161 | bad_init, | ||
162 | bad_update, | ||
163 | bad_final, | ||
164 | NULL, | ||
165 | NULL, | ||
166 | NULL, | ||
167 | 0, | ||
168 | {0,0,0,0}, | ||
169 | }; | ||
170 | |||
171 | #endif | ||
172 | |||
173 | int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) | ||
174 | { | ||
175 | EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); | ||
176 | #ifndef OPENSSL_NO_ENGINE | ||
177 | /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts | ||
178 | * so this context may already have an ENGINE! Try to avoid releasing | ||
179 | * the previous handle, re-querying for an ENGINE, and having a | ||
180 | * reinitialisation, when it may all be unecessary. */ | ||
181 | if (ctx->engine && ctx->digest && (!type || | ||
182 | (type && (type->type == ctx->digest->type)))) | ||
183 | goto skip_to_init; | ||
184 | if (type) | ||
185 | { | ||
186 | /* Ensure an ENGINE left lying around from last time is cleared | ||
187 | * (the previous check attempted to avoid this if the same | ||
188 | * ENGINE and EVP_MD could be used). */ | ||
189 | if(ctx->engine) | ||
190 | ENGINE_finish(ctx->engine); | ||
191 | if(impl) | ||
192 | { | ||
193 | if (!ENGINE_init(impl)) | ||
194 | { | ||
195 | EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_INITIALIZATION_ERROR); | ||
196 | return 0; | ||
197 | } | ||
198 | } | ||
199 | else | ||
200 | /* Ask if an ENGINE is reserved for this job */ | ||
201 | impl = ENGINE_get_digest_engine(type->type); | ||
202 | if(impl) | ||
203 | { | ||
204 | /* There's an ENGINE for this job ... (apparently) */ | ||
205 | const EVP_MD *d = ENGINE_get_digest(impl, type->type); | ||
206 | if(!d) | ||
207 | { | ||
208 | /* Same comment from evp_enc.c */ | ||
209 | EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_INITIALIZATION_ERROR); | ||
210 | return 0; | ||
211 | } | ||
212 | /* We'll use the ENGINE's private digest definition */ | ||
213 | type = d; | ||
214 | /* Store the ENGINE functional reference so we know | ||
215 | * 'type' came from an ENGINE and we need to release | ||
216 | * it when done. */ | ||
217 | ctx->engine = impl; | ||
218 | } | ||
219 | else | ||
220 | ctx->engine = NULL; | ||
221 | } | ||
222 | else | ||
223 | if(!ctx->digest) | ||
224 | { | ||
225 | EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_NO_DIGEST_SET); | ||
226 | return 0; | ||
227 | } | ||
228 | #endif | ||
229 | if (ctx->digest != type) | ||
230 | { | ||
231 | #ifdef OPENSSL_FIPS | ||
232 | if (FIPS_mode()) | ||
233 | { | ||
234 | if (!(type->flags & EVP_MD_FLAG_FIPS) | ||
235 | && !(ctx->flags & EVP_MD_CTX_FLAG_NON_FIPS_ALLOW)) | ||
236 | { | ||
237 | EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_DISABLED_FOR_FIPS); | ||
238 | ctx->digest = &bad_md; | ||
239 | return 0; | ||
240 | } | ||
241 | } | ||
242 | #endif | ||
243 | if (ctx->digest && ctx->digest->ctx_size) | ||
244 | OPENSSL_free(ctx->md_data); | ||
245 | ctx->digest=type; | ||
246 | if (type->ctx_size) | ||
247 | ctx->md_data=OPENSSL_malloc(type->ctx_size); | ||
248 | } | ||
249 | #ifndef OPENSSL_NO_ENGINE | ||
250 | skip_to_init: | ||
251 | #endif | ||
252 | return ctx->digest->init(ctx); | ||
253 | } | ||
254 | |||
255 | int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, | ||
256 | unsigned int count) | ||
257 | { | ||
258 | return ctx->digest->update(ctx,data,(unsigned long)count); | ||
259 | } | ||
260 | |||
261 | /* The caller can assume that this removes any secret data from the context */ | ||
262 | int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) | ||
263 | { | ||
264 | int ret; | ||
265 | ret = EVP_DigestFinal_ex(ctx, md, size); | ||
266 | EVP_MD_CTX_cleanup(ctx); | ||
267 | return ret; | ||
268 | } | ||
269 | |||
270 | /* The caller can assume that this removes any secret data from the context */ | ||
271 | int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) | ||
272 | { | ||
273 | int ret; | ||
274 | |||
275 | OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); | ||
276 | ret=ctx->digest->final(ctx,md); | ||
277 | if (size != NULL) | ||
278 | *size=ctx->digest->md_size; | ||
279 | if (ctx->digest->cleanup) | ||
280 | { | ||
281 | ctx->digest->cleanup(ctx); | ||
282 | EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); | ||
283 | } | ||
284 | memset(ctx->md_data,0,ctx->digest->ctx_size); | ||
285 | return ret; | ||
286 | } | ||
287 | |||
288 | int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) | ||
289 | { | ||
290 | EVP_MD_CTX_init(out); | ||
291 | return EVP_MD_CTX_copy_ex(out, in); | ||
292 | } | ||
293 | |||
294 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) | ||
295 | { | ||
296 | unsigned char *tmp_buf; | ||
297 | if ((in == NULL) || (in->digest == NULL)) | ||
298 | { | ||
299 | EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); | ||
300 | return 0; | ||
301 | } | ||
302 | #ifndef OPENSSL_NO_ENGINE | ||
303 | /* Make sure it's safe to copy a digest context using an ENGINE */ | ||
304 | if (in->engine && !ENGINE_init(in->engine)) | ||
305 | { | ||
306 | EVPerr(EVP_F_EVP_MD_CTX_COPY,ERR_R_ENGINE_LIB); | ||
307 | return 0; | ||
308 | } | ||
309 | #endif | ||
310 | |||
311 | if (out->digest == in->digest) | ||
312 | { | ||
313 | tmp_buf = out->md_data; | ||
314 | EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE); | ||
315 | } | ||
316 | else tmp_buf = NULL; | ||
317 | EVP_MD_CTX_cleanup(out); | ||
318 | memcpy(out,in,sizeof *out); | ||
319 | |||
320 | if (out->digest->ctx_size) | ||
321 | { | ||
322 | if (tmp_buf) out->md_data = tmp_buf; | ||
323 | else out->md_data=OPENSSL_malloc(out->digest->ctx_size); | ||
324 | memcpy(out->md_data,in->md_data,out->digest->ctx_size); | ||
325 | } | ||
326 | |||
327 | if (out->digest->copy) | ||
328 | return out->digest->copy(out,in); | ||
329 | |||
330 | return 1; | ||
331 | } | ||
332 | |||
333 | int EVP_Digest(void *data, unsigned int count, | ||
334 | unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl) | ||
335 | { | ||
336 | EVP_MD_CTX ctx; | ||
337 | int ret; | ||
338 | |||
339 | EVP_MD_CTX_init(&ctx); | ||
340 | EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT); | ||
341 | ret=EVP_DigestInit_ex(&ctx, type, impl) | ||
342 | && EVP_DigestUpdate(&ctx, data, count) | ||
343 | && EVP_DigestFinal_ex(&ctx, md, size); | ||
344 | EVP_MD_CTX_cleanup(&ctx); | ||
345 | |||
346 | return ret; | ||
347 | } | ||
348 | |||
349 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) | ||
350 | { | ||
351 | EVP_MD_CTX_cleanup(ctx); | ||
352 | OPENSSL_free(ctx); | ||
353 | } | ||
354 | |||
355 | /* This call frees resources associated with the context */ | ||
356 | int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) | ||
357 | { | ||
358 | /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final, | ||
359 | * because sometimes only copies of the context are ever finalised. | ||
360 | */ | ||
361 | if (ctx->digest && ctx->digest->cleanup | ||
362 | && !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED)) | ||
363 | ctx->digest->cleanup(ctx); | ||
364 | if (ctx->digest && ctx->digest->ctx_size && ctx->md_data | ||
365 | && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) | ||
366 | { | ||
367 | OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); | ||
368 | OPENSSL_free(ctx->md_data); | ||
369 | } | ||
370 | #ifndef OPENSSL_NO_ENGINE | ||
371 | if(ctx->engine) | ||
372 | /* The EVP_MD we used belongs to an ENGINE, release the | ||
373 | * functional reference we held for this reason. */ | ||
374 | ENGINE_finish(ctx->engine); | ||
375 | #endif | ||
376 | memset(ctx,'\0',sizeof *ctx); | ||
377 | |||
378 | return 1; | ||
379 | } | ||
diff --git a/src/lib/libcrypto/evp/e_acss.c b/src/lib/libcrypto/evp/e_acss.c new file mode 100644 index 0000000000..a16b85c627 --- /dev/null +++ b/src/lib/libcrypto/evp/e_acss.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* $Id: e_acss.c,v 1.2 2004/02/13 10:05:44 hshoexer 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 | |||
26 | typedef struct { | ||
27 | ACSS_KEY ks; | ||
28 | } EVP_ACSS_KEY; | ||
29 | |||
30 | #define data(ctx) EVP_C_DATA(EVP_ACSS_KEY,ctx) | ||
31 | |||
32 | static int acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
33 | const unsigned char *iv, int enc); | ||
34 | static int acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
35 | const unsigned char *in, unsigned int inl); | ||
36 | static int acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); | ||
37 | static 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 | |||
51 | const | ||
52 | EVP_CIPHER *EVP_acss(void) | ||
53 | { | ||
54 | return(&acss_cipher); | ||
55 | } | ||
56 | |||
57 | static int | ||
58 | acss_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 | |||
65 | static int | ||
66 | acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, | ||
67 | unsigned int inl) | ||
68 | { | ||
69 | acss(&data(ctx)->ks,inl,in,out); | ||
70 | return 1; | ||
71 | } | ||
72 | |||
73 | static int | ||
74 | acss_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 new file mode 100644 index 0000000000..7b67984fa1 --- /dev/null +++ b/src/lib/libcrypto/evp/e_aes.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* ==================================================================== | ||
2 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in | ||
13 | * the documentation and/or other materials provided with the | ||
14 | * distribution. | ||
15 | * | ||
16 | * 3. All advertising materials mentioning features or use of this | ||
17 | * software must display the following acknowledgment: | ||
18 | * "This product includes software developed by the OpenSSL Project | ||
19 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
20 | * | ||
21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
22 | * endorse or promote products derived from this software without | ||
23 | * prior written permission. For written permission, please contact | ||
24 | * openssl-core@openssl.org. | ||
25 | * | ||
26 | * 5. Products derived from this software may not be called "OpenSSL" | ||
27 | * nor may "OpenSSL" appear in their names without prior written | ||
28 | * permission of the OpenSSL Project. | ||
29 | * | ||
30 | * 6. Redistributions of any form whatsoever must retain the following | ||
31 | * acknowledgment: | ||
32 | * "This product includes software developed by the OpenSSL Project | ||
33 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
34 | * | ||
35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
46 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
47 | * ==================================================================== | ||
48 | * | ||
49 | */ | ||
50 | |||
51 | #ifndef OPENSSL_NO_AES | ||
52 | #include <openssl/evp.h> | ||
53 | #include <openssl/err.h> | ||
54 | #include <string.h> | ||
55 | #include <openssl/aes.h> | ||
56 | #include "evp_locl.h" | ||
57 | |||
58 | static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
59 | const unsigned char *iv, int enc); | ||
60 | |||
61 | typedef struct | ||
62 | { | ||
63 | AES_KEY ks; | ||
64 | } EVP_AES_KEY; | ||
65 | |||
66 | #define data(ctx) EVP_C_DATA(EVP_AES_KEY,ctx) | ||
67 | |||
68 | IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY, | ||
69 | NID_aes_128, 16, 16, 16, 128, | ||
70 | EVP_CIPH_FLAG_FIPS, aes_init_key, NULL, | ||
71 | EVP_CIPHER_set_asn1_iv, | ||
72 | EVP_CIPHER_get_asn1_iv, | ||
73 | NULL) | ||
74 | IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY, | ||
75 | NID_aes_192, 16, 24, 16, 128, | ||
76 | EVP_CIPH_FLAG_FIPS, aes_init_key, NULL, | ||
77 | EVP_CIPHER_set_asn1_iv, | ||
78 | EVP_CIPHER_get_asn1_iv, | ||
79 | NULL) | ||
80 | IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY, | ||
81 | NID_aes_256, 16, 32, 16, 128, | ||
82 | EVP_CIPH_FLAG_FIPS, aes_init_key, NULL, | ||
83 | EVP_CIPHER_set_asn1_iv, | ||
84 | EVP_CIPHER_get_asn1_iv, | ||
85 | NULL) | ||
86 | |||
87 | #define IMPLEMENT_AES_CFBR(ksize,cbits,flags) IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16,flags) | ||
88 | |||
89 | IMPLEMENT_AES_CFBR(128,1,EVP_CIPH_FLAG_FIPS) | ||
90 | IMPLEMENT_AES_CFBR(192,1,EVP_CIPH_FLAG_FIPS) | ||
91 | IMPLEMENT_AES_CFBR(256,1,EVP_CIPH_FLAG_FIPS) | ||
92 | |||
93 | IMPLEMENT_AES_CFBR(128,8,EVP_CIPH_FLAG_FIPS) | ||
94 | IMPLEMENT_AES_CFBR(192,8,EVP_CIPH_FLAG_FIPS) | ||
95 | IMPLEMENT_AES_CFBR(256,8,EVP_CIPH_FLAG_FIPS) | ||
96 | |||
97 | static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
98 | const unsigned char *iv, int enc) | ||
99 | { | ||
100 | int ret; | ||
101 | |||
102 | if ((ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_CFB_MODE | ||
103 | || (ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_OFB_MODE | ||
104 | || enc) | ||
105 | ret=AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data); | ||
106 | else | ||
107 | ret=AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data); | ||
108 | |||
109 | if(ret < 0) | ||
110 | { | ||
111 | EVPerr(EVP_F_AES_INIT_KEY,EVP_R_AES_KEY_SETUP_FAILED); | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | return 1; | ||
116 | } | ||
117 | |||
118 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_bf.c b/src/lib/libcrypto/evp/e_bf.c new file mode 100644 index 0000000000..e74337567b --- /dev/null +++ b/src/lib/libcrypto/evp/e_bf.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* crypto/evp/e_bf.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 | #ifndef OPENSSL_NO_BF | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include "evp_locl.h" | ||
64 | #include <openssl/objects.h> | ||
65 | #include <openssl/blowfish.h> | ||
66 | |||
67 | static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
68 | const unsigned char *iv, int enc); | ||
69 | |||
70 | typedef struct | ||
71 | { | ||
72 | BF_KEY ks; | ||
73 | } EVP_BF_KEY; | ||
74 | |||
75 | #define data(ctx) EVP_C_DATA(EVP_BF_KEY,ctx) | ||
76 | |||
77 | IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64, | ||
78 | EVP_CIPH_VARIABLE_LENGTH, bf_init_key, NULL, | ||
79 | EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) | ||
80 | |||
81 | static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
82 | const unsigned char *iv, int enc) | ||
83 | { | ||
84 | BF_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),key); | ||
85 | return 1; | ||
86 | } | ||
87 | |||
88 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_cast.c b/src/lib/libcrypto/evp/e_cast.c new file mode 100644 index 0000000000..3400fef187 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cast.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* crypto/evp/e_cast.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 | #ifndef OPENSSL_NO_CAST | ||
60 | |||
61 | #include <stdio.h> | ||
62 | #include "cryptlib.h" | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/objects.h> | ||
65 | #include "evp_locl.h" | ||
66 | #include <openssl/cast.h> | ||
67 | |||
68 | static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
69 | const unsigned char *iv,int enc); | ||
70 | |||
71 | typedef struct | ||
72 | { | ||
73 | CAST_KEY ks; | ||
74 | } EVP_CAST_KEY; | ||
75 | |||
76 | #define data(ctx) EVP_C_DATA(EVP_CAST_KEY,ctx) | ||
77 | |||
78 | IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY, | ||
79 | NID_cast5, 8, CAST_KEY_LENGTH, 8, 64, | ||
80 | EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL, | ||
81 | EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) | ||
82 | |||
83 | static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
84 | const unsigned char *iv, int enc) | ||
85 | { | ||
86 | CAST_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),key); | ||
87 | return 1; | ||
88 | } | ||
89 | |||
90 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c new file mode 100644 index 0000000000..46e2899825 --- /dev/null +++ b/src/lib/libcrypto/evp/e_des.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* crypto/evp/e_des.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 | #ifndef OPENSSL_NO_DES | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/objects.h> | ||
64 | #include "evp_locl.h" | ||
65 | #include <openssl/des.h> | ||
66 | |||
67 | static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
68 | const unsigned char *iv, int enc); | ||
69 | |||
70 | /* Because of various casts and different names can't use IMPLEMENT_BLOCK_CIPHER */ | ||
71 | |||
72 | static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
73 | const unsigned char *in, unsigned int inl) | ||
74 | { | ||
75 | BLOCK_CIPHER_ecb_loop() | ||
76 | DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), ctx->cipher_data, ctx->encrypt); | ||
77 | return 1; | ||
78 | } | ||
79 | |||
80 | static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
81 | const unsigned char *in, unsigned int inl) | ||
82 | { | ||
83 | DES_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num); | ||
84 | return 1; | ||
85 | } | ||
86 | |||
87 | static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
88 | const unsigned char *in, unsigned int inl) | ||
89 | { | ||
90 | DES_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data, | ||
91 | (DES_cblock *)ctx->iv, ctx->encrypt); | ||
92 | return 1; | ||
93 | } | ||
94 | |||
95 | static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
96 | const unsigned char *in, unsigned int inl) | ||
97 | { | ||
98 | DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data, | ||
99 | (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); | ||
100 | return 1; | ||
101 | } | ||
102 | |||
103 | /* Although we have a CFB-r implementation for DES, it doesn't pack the right | ||
104 | way, so wrap it here */ | ||
105 | static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
106 | const unsigned char *in, unsigned int inl) | ||
107 | { | ||
108 | unsigned int n; | ||
109 | unsigned char c[1],d[1]; | ||
110 | |||
111 | for(n=0 ; n < inl ; ++n) | ||
112 | { | ||
113 | c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0; | ||
114 | DES_cfb_encrypt(c,d,1,1,ctx->cipher_data,(DES_cblock *)ctx->iv, | ||
115 | ctx->encrypt); | ||
116 | out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8)); | ||
117 | } | ||
118 | return 1; | ||
119 | } | ||
120 | |||
121 | static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
122 | const unsigned char *in, unsigned int inl) | ||
123 | { | ||
124 | DES_cfb_encrypt(in,out,8,inl,ctx->cipher_data,(DES_cblock *)ctx->iv, | ||
125 | ctx->encrypt); | ||
126 | return 1; | ||
127 | } | ||
128 | |||
129 | BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64, | ||
130 | EVP_CIPH_FLAG_FIPS, des_init_key, NULL, | ||
131 | EVP_CIPHER_set_asn1_iv, | ||
132 | EVP_CIPHER_get_asn1_iv, | ||
133 | NULL) | ||
134 | |||
135 | BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1, | ||
136 | EVP_CIPH_FLAG_FIPS,des_init_key,NULL, | ||
137 | EVP_CIPHER_set_asn1_iv, | ||
138 | EVP_CIPHER_get_asn1_iv,NULL) | ||
139 | |||
140 | BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8, | ||
141 | EVP_CIPH_FLAG_FIPS,des_init_key,NULL, | ||
142 | EVP_CIPHER_set_asn1_iv, | ||
143 | EVP_CIPHER_get_asn1_iv,NULL) | ||
144 | |||
145 | static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
146 | const unsigned char *iv, int enc) | ||
147 | { | ||
148 | DES_cblock *deskey = (DES_cblock *)key; | ||
149 | |||
150 | DES_set_key_unchecked(deskey,ctx->cipher_data); | ||
151 | return 1; | ||
152 | } | ||
153 | |||
154 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c new file mode 100644 index 0000000000..677322bf02 --- /dev/null +++ b/src/lib/libcrypto/evp/e_des3.c | |||
@@ -0,0 +1,232 @@ | |||
1 | /* crypto/evp/e_des3.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 | #ifndef OPENSSL_NO_DES | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/objects.h> | ||
64 | #include "evp_locl.h" | ||
65 | #include <openssl/des.h> | ||
66 | |||
67 | static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
68 | const unsigned char *iv,int enc); | ||
69 | |||
70 | static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
71 | const unsigned char *iv,int enc); | ||
72 | |||
73 | typedef struct | ||
74 | { | ||
75 | DES_key_schedule ks1;/* key schedule */ | ||
76 | DES_key_schedule ks2;/* key schedule (for ede) */ | ||
77 | DES_key_schedule ks3;/* key schedule (for ede3) */ | ||
78 | } DES_EDE_KEY; | ||
79 | |||
80 | #define data(ctx) ((DES_EDE_KEY *)(ctx)->cipher_data) | ||
81 | |||
82 | /* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */ | ||
83 | |||
84 | static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
85 | const unsigned char *in, unsigned int inl) | ||
86 | { | ||
87 | BLOCK_CIPHER_ecb_loop() | ||
88 | DES_ecb3_encrypt(in + i,out + i, | ||
89 | &data(ctx)->ks1, &data(ctx)->ks2, | ||
90 | &data(ctx)->ks3, | ||
91 | ctx->encrypt); | ||
92 | return 1; | ||
93 | } | ||
94 | |||
95 | static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
96 | const unsigned char *in, unsigned int inl) | ||
97 | { | ||
98 | DES_ede3_ofb64_encrypt(in, out, (long)inl, | ||
99 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | ||
100 | (DES_cblock *)ctx->iv, &ctx->num); | ||
101 | return 1; | ||
102 | } | ||
103 | |||
104 | static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
105 | const unsigned char *in, unsigned int inl) | ||
106 | { | ||
107 | #ifdef KSSL_DEBUG | ||
108 | { | ||
109 | int i; | ||
110 | char *cp; | ||
111 | printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->buf_len); | ||
112 | printf("\t iv= "); | ||
113 | for(i=0;i<8;i++) | ||
114 | printf("%02X",ctx->iv[i]); | ||
115 | printf("\n"); | ||
116 | } | ||
117 | #endif /* KSSL_DEBUG */ | ||
118 | DES_ede3_cbc_encrypt(in, out, (long)inl, | ||
119 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | ||
120 | (DES_cblock *)ctx->iv, ctx->encrypt); | ||
121 | return 1; | ||
122 | } | ||
123 | |||
124 | static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
125 | const unsigned char *in, unsigned int inl) | ||
126 | { | ||
127 | DES_ede3_cfb64_encrypt(in, out, (long)inl, | ||
128 | &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, | ||
129 | (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); | ||
130 | return 1; | ||
131 | } | ||
132 | |||
133 | /* Although we have a CFB-r implementation for 3-DES, it doesn't pack the right | ||
134 | way, so wrap it here */ | ||
135 | static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
136 | const unsigned char *in, unsigned int inl) | ||
137 | { | ||
138 | unsigned int n; | ||
139 | unsigned char c[1],d[1]; | ||
140 | |||
141 | for(n=0 ; n < inl ; ++n) | ||
142 | { | ||
143 | c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0; | ||
144 | DES_ede3_cfb_encrypt(c,d,1,1, | ||
145 | &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3, | ||
146 | (DES_cblock *)ctx->iv,ctx->encrypt); | ||
147 | out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8)); | ||
148 | } | ||
149 | |||
150 | return 1; | ||
151 | } | ||
152 | |||
153 | static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
154 | const unsigned char *in, unsigned int inl) | ||
155 | { | ||
156 | DES_ede3_cfb_encrypt(in,out,8,inl, | ||
157 | &data(ctx)->ks1,&data(ctx)->ks2,&data(ctx)->ks3, | ||
158 | (DES_cblock *)ctx->iv,ctx->encrypt); | ||
159 | return 1; | ||
160 | } | ||
161 | |||
162 | BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64, | ||
163 | EVP_CIPH_FLAG_FIPS, des_ede_init_key, NULL, | ||
164 | EVP_CIPHER_set_asn1_iv, | ||
165 | EVP_CIPHER_get_asn1_iv, | ||
166 | NULL) | ||
167 | |||
168 | #define des_ede3_cfb64_cipher des_ede_cfb64_cipher | ||
169 | #define des_ede3_ofb_cipher des_ede_ofb_cipher | ||
170 | #define des_ede3_cbc_cipher des_ede_cbc_cipher | ||
171 | #define des_ede3_ecb_cipher des_ede_ecb_cipher | ||
172 | |||
173 | BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64, | ||
174 | EVP_CIPH_FLAG_FIPS, des_ede3_init_key, NULL, | ||
175 | EVP_CIPHER_set_asn1_iv, | ||
176 | EVP_CIPHER_get_asn1_iv, | ||
177 | NULL) | ||
178 | |||
179 | BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1, | ||
180 | EVP_CIPH_FLAG_FIPS, des_ede3_init_key,NULL, | ||
181 | EVP_CIPHER_set_asn1_iv, | ||
182 | EVP_CIPHER_get_asn1_iv,NULL) | ||
183 | |||
184 | BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8, | ||
185 | EVP_CIPH_FLAG_FIPS, des_ede3_init_key,NULL, | ||
186 | EVP_CIPHER_set_asn1_iv, | ||
187 | EVP_CIPHER_get_asn1_iv,NULL) | ||
188 | |||
189 | static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
190 | const unsigned char *iv, int enc) | ||
191 | { | ||
192 | DES_cblock *deskey = (DES_cblock *)key; | ||
193 | |||
194 | DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1); | ||
195 | DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2); | ||
196 | memcpy(&data(ctx)->ks3,&data(ctx)->ks1, | ||
197 | sizeof(data(ctx)->ks1)); | ||
198 | return 1; | ||
199 | } | ||
200 | |||
201 | static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
202 | const unsigned char *iv, int enc) | ||
203 | { | ||
204 | DES_cblock *deskey = (DES_cblock *)key; | ||
205 | #ifdef KSSL_DEBUG | ||
206 | { | ||
207 | int i; | ||
208 | printf("des_ede3_init_key(ctx=%lx)\n", ctx); | ||
209 | printf("\tKEY= "); | ||
210 | for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n"); | ||
211 | printf("\t IV= "); | ||
212 | for(i=0;i<8;i++) printf("%02X",iv[i]); printf("\n"); | ||
213 | } | ||
214 | #endif /* KSSL_DEBUG */ | ||
215 | |||
216 | DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1); | ||
217 | DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2); | ||
218 | DES_set_key_unchecked(&deskey[2],&data(ctx)->ks3); | ||
219 | |||
220 | return 1; | ||
221 | } | ||
222 | |||
223 | const EVP_CIPHER *EVP_des_ede(void) | ||
224 | { | ||
225 | return &des_ede_ecb; | ||
226 | } | ||
227 | |||
228 | const EVP_CIPHER *EVP_des_ede3(void) | ||
229 | { | ||
230 | return &des_ede3_ecb; | ||
231 | } | ||
232 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_idea.c b/src/lib/libcrypto/evp/e_idea.c new file mode 100644 index 0000000000..b9efa75ae7 --- /dev/null +++ b/src/lib/libcrypto/evp/e_idea.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* crypto/evp/e_idea.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 | #ifndef OPENSSL_NO_IDEA | ||
60 | |||
61 | #include <stdio.h> | ||
62 | #include "cryptlib.h" | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/objects.h> | ||
65 | #include "evp_locl.h" | ||
66 | #include <openssl/idea.h> | ||
67 | |||
68 | static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
69 | const unsigned char *iv,int enc); | ||
70 | |||
71 | /* NB idea_ecb_encrypt doesn't take an 'encrypt' argument so we treat it as a special | ||
72 | * case | ||
73 | */ | ||
74 | |||
75 | static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
76 | const unsigned char *in, unsigned int inl) | ||
77 | { | ||
78 | BLOCK_CIPHER_ecb_loop() | ||
79 | idea_ecb_encrypt(in + i, out + i, ctx->cipher_data); | ||
80 | return 1; | ||
81 | } | ||
82 | |||
83 | /* Can't use IMPLEMENT_BLOCK_CIPHER because idea_ecb_encrypt is different */ | ||
84 | |||
85 | typedef struct | ||
86 | { | ||
87 | IDEA_KEY_SCHEDULE ks; | ||
88 | } EVP_IDEA_KEY; | ||
89 | |||
90 | BLOCK_CIPHER_func_cbc(idea, idea, EVP_IDEA_KEY, ks) | ||
91 | BLOCK_CIPHER_func_ofb(idea, idea, 64, EVP_IDEA_KEY, ks) | ||
92 | BLOCK_CIPHER_func_cfb(idea, idea, 64, EVP_IDEA_KEY, ks) | ||
93 | |||
94 | BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64, | ||
95 | 0, idea_init_key, NULL, | ||
96 | EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) | ||
97 | |||
98 | static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
99 | const unsigned char *iv, int enc) | ||
100 | { | ||
101 | if(!enc) { | ||
102 | if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) enc = 1; | ||
103 | else if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE) enc = 1; | ||
104 | } | ||
105 | if (enc) idea_set_encrypt_key(key,ctx->cipher_data); | ||
106 | else | ||
107 | { | ||
108 | IDEA_KEY_SCHEDULE tmp; | ||
109 | |||
110 | idea_set_encrypt_key(key,&tmp); | ||
111 | idea_set_decrypt_key(&tmp,ctx->cipher_data); | ||
112 | OPENSSL_cleanse((unsigned char *)&tmp, | ||
113 | sizeof(IDEA_KEY_SCHEDULE)); | ||
114 | } | ||
115 | return 1; | ||
116 | } | ||
117 | |||
118 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_null.c b/src/lib/libcrypto/evp/e_null.c new file mode 100644 index 0000000000..a84b0f14b1 --- /dev/null +++ b/src/lib/libcrypto/evp/e_null.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /* crypto/evp/e_null.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 | |||
64 | static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
65 | const unsigned char *iv,int enc); | ||
66 | static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
67 | const unsigned char *in, unsigned int inl); | ||
68 | static const EVP_CIPHER n_cipher= | ||
69 | { | ||
70 | NID_undef, | ||
71 | 1,0,0, | ||
72 | EVP_CIPH_FLAG_FIPS, | ||
73 | null_init_key, | ||
74 | null_cipher, | ||
75 | NULL, | ||
76 | 0, | ||
77 | NULL, | ||
78 | NULL, | ||
79 | NULL | ||
80 | }; | ||
81 | |||
82 | const EVP_CIPHER *EVP_enc_null(void) | ||
83 | { | ||
84 | return(&n_cipher); | ||
85 | } | ||
86 | |||
87 | static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
88 | const unsigned char *iv, int enc) | ||
89 | { | ||
90 | /* memset(&(ctx->c),0,sizeof(ctx->c));*/ | ||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
95 | const unsigned char *in, unsigned int inl) | ||
96 | { | ||
97 | if (in != out) | ||
98 | memcpy((char *)out,(char *)in,(int)inl); | ||
99 | return 1; | ||
100 | } | ||
101 | |||
diff --git a/src/lib/libcrypto/evp/e_old.c b/src/lib/libcrypto/evp/e_old.c new file mode 100644 index 0000000000..92dc498945 --- /dev/null +++ b/src/lib/libcrypto/evp/e_old.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* crypto/evp/e_old.c -*- mode:C; c-file-style: "eay" -*- */ | ||
2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | ||
3 | * project 2004. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2004 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 | * openssl-core@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 <openssl/evp.h> | ||
60 | |||
61 | /* Define some deprecated functions, so older programs | ||
62 | don't crash and burn too quickly. On Windows and VMS, | ||
63 | these will never be used, since functions and variables | ||
64 | in shared libraries are selected by entry point location, | ||
65 | not by name. */ | ||
66 | |||
67 | #ifndef OPENSSL_NO_BF | ||
68 | #undef EVP_bf_cfb | ||
69 | const EVP_CIPHER *EVP_bf_cfb(void) { return EVP_bf_cfb64(); } | ||
70 | #endif | ||
71 | |||
72 | #ifndef OPENSSL_NO_DES | ||
73 | #undef EVP_des_cfb | ||
74 | const EVP_CIPHER *EVP_des_cfb(void) { return EVP_des_cfb64(); } | ||
75 | #undef EVP_des_ede3_cfb | ||
76 | const EVP_CIPHER *EVP_des_ede3_cfb(void) { return EVP_des_ede3_cfb64(); } | ||
77 | #undef EVP_des_ede_cfb | ||
78 | const EVP_CIPHER *EVP_des_ede_cfb(void) { return EVP_des_ede_cfb64(); } | ||
79 | #endif | ||
80 | |||
81 | #ifndef OPENSSL_NO_IDEA | ||
82 | #undef EVP_idea_cfb | ||
83 | const EVP_CIPHER *EVP_idea_cfb(void) { return EVP_idea_cfb64(); } | ||
84 | #endif | ||
85 | |||
86 | #ifndef OPENSSL_NO_RC2 | ||
87 | #undef EVP_rc2_cfb | ||
88 | const EVP_CIPHER *EVP_rc2_cfb(void) { return EVP_rc2_cfb64(); } | ||
89 | #endif | ||
90 | |||
91 | #ifndef OPENSSL_NO_CAST | ||
92 | #undef EVP_cast5_cfb | ||
93 | const EVP_CIPHER *EVP_cast5_cfb(void) { return EVP_cast5_cfb64(); } | ||
94 | #endif | ||
95 | |||
96 | #ifndef OPENSSL_NO_RC5 | ||
97 | #undef EVP_rc5_32_12_16_cfb | ||
98 | const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void) { return EVP_rc5_32_12_16_cfb64(); } | ||
99 | #endif | ||
100 | |||
101 | #ifndef OPENSSL_NO_AES | ||
102 | #undef EVP_aes_128_cfb | ||
103 | const EVP_CIPHER *EVP_aes_128_cfb(void) { return EVP_aes_128_cfb128(); } | ||
104 | #undef EVP_aes_192_cfb | ||
105 | const EVP_CIPHER *EVP_aes_192_cfb(void) { return EVP_aes_192_cfb128(); } | ||
106 | #undef EVP_aes_256_cfb | ||
107 | const EVP_CIPHER *EVP_aes_256_cfb(void) { return EVP_aes_256_cfb128(); } | ||
108 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c new file mode 100644 index 0000000000..d42cbfd17e --- /dev/null +++ b/src/lib/libcrypto/evp/e_rc2.c | |||
@@ -0,0 +1,230 @@ | |||
1 | /* crypto/evp/e_rc2.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 | #ifndef OPENSSL_NO_RC2 | ||
60 | |||
61 | #include <stdio.h> | ||
62 | #include "cryptlib.h" | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/objects.h> | ||
65 | #include "evp_locl.h" | ||
66 | #include <openssl/rc2.h> | ||
67 | |||
68 | static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
69 | const unsigned char *iv,int enc); | ||
70 | static int rc2_meth_to_magic(EVP_CIPHER_CTX *ctx); | ||
71 | static int rc2_magic_to_meth(int i); | ||
72 | static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | ||
73 | static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | ||
74 | static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); | ||
75 | |||
76 | typedef struct | ||
77 | { | ||
78 | int key_bits; /* effective key bits */ | ||
79 | RC2_KEY ks; /* key schedule */ | ||
80 | } EVP_RC2_KEY; | ||
81 | |||
82 | #define data(ctx) ((EVP_RC2_KEY *)(ctx)->cipher_data) | ||
83 | |||
84 | IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2, | ||
85 | 8, | ||
86 | RC2_KEY_LENGTH, 8, 64, | ||
87 | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | ||
88 | rc2_init_key, NULL, | ||
89 | rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, | ||
90 | rc2_ctrl) | ||
91 | |||
92 | #define RC2_40_MAGIC 0xa0 | ||
93 | #define RC2_64_MAGIC 0x78 | ||
94 | #define RC2_128_MAGIC 0x3a | ||
95 | |||
96 | static const EVP_CIPHER r2_64_cbc_cipher= | ||
97 | { | ||
98 | NID_rc2_64_cbc, | ||
99 | 8,8 /* 64 bit */,8, | ||
100 | EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | ||
101 | rc2_init_key, | ||
102 | rc2_cbc_cipher, | ||
103 | NULL, | ||
104 | sizeof(EVP_RC2_KEY), | ||
105 | rc2_set_asn1_type_and_iv, | ||
106 | rc2_get_asn1_type_and_iv, | ||
107 | rc2_ctrl, | ||
108 | NULL | ||
109 | }; | ||
110 | |||
111 | static const EVP_CIPHER r2_40_cbc_cipher= | ||
112 | { | ||
113 | NID_rc2_40_cbc, | ||
114 | 8,5 /* 40 bit */,8, | ||
115 | EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | ||
116 | rc2_init_key, | ||
117 | rc2_cbc_cipher, | ||
118 | NULL, | ||
119 | sizeof(EVP_RC2_KEY), | ||
120 | rc2_set_asn1_type_and_iv, | ||
121 | rc2_get_asn1_type_and_iv, | ||
122 | rc2_ctrl, | ||
123 | NULL | ||
124 | }; | ||
125 | |||
126 | const EVP_CIPHER *EVP_rc2_64_cbc(void) | ||
127 | { | ||
128 | return(&r2_64_cbc_cipher); | ||
129 | } | ||
130 | |||
131 | const EVP_CIPHER *EVP_rc2_40_cbc(void) | ||
132 | { | ||
133 | return(&r2_40_cbc_cipher); | ||
134 | } | ||
135 | |||
136 | static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
137 | const unsigned char *iv, int enc) | ||
138 | { | ||
139 | RC2_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), | ||
140 | key,data(ctx)->key_bits); | ||
141 | return 1; | ||
142 | } | ||
143 | |||
144 | static int rc2_meth_to_magic(EVP_CIPHER_CTX *e) | ||
145 | { | ||
146 | int i; | ||
147 | |||
148 | EVP_CIPHER_CTX_ctrl(e, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i); | ||
149 | if (i == 128) return(RC2_128_MAGIC); | ||
150 | else if (i == 64) return(RC2_64_MAGIC); | ||
151 | else if (i == 40) return(RC2_40_MAGIC); | ||
152 | else return(0); | ||
153 | } | ||
154 | |||
155 | static int rc2_magic_to_meth(int i) | ||
156 | { | ||
157 | if (i == RC2_128_MAGIC) return 128; | ||
158 | else if (i == RC2_64_MAGIC) return 64; | ||
159 | else if (i == RC2_40_MAGIC) return 40; | ||
160 | else | ||
161 | { | ||
162 | EVPerr(EVP_F_RC2_MAGIC_TO_METH,EVP_R_UNSUPPORTED_KEY_SIZE); | ||
163 | return(0); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
168 | { | ||
169 | long num=0; | ||
170 | int i=0,l; | ||
171 | int key_bits; | ||
172 | unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
173 | |||
174 | if (type != NULL) | ||
175 | { | ||
176 | l=EVP_CIPHER_CTX_iv_length(c); | ||
177 | OPENSSL_assert(l <= sizeof iv); | ||
178 | i=ASN1_TYPE_get_int_octetstring(type,&num,iv,l); | ||
179 | if (i != l) | ||
180 | return(-1); | ||
181 | key_bits =rc2_magic_to_meth((int)num); | ||
182 | if (!key_bits) | ||
183 | return(-1); | ||
184 | if(i > 0) EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1); | ||
185 | EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); | ||
186 | EVP_CIPHER_CTX_set_key_length(c, key_bits / 8); | ||
187 | } | ||
188 | return(i); | ||
189 | } | ||
190 | |||
191 | static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
192 | { | ||
193 | long num; | ||
194 | int i=0,j; | ||
195 | |||
196 | if (type != NULL) | ||
197 | { | ||
198 | num=rc2_meth_to_magic(c); | ||
199 | j=EVP_CIPHER_CTX_iv_length(c); | ||
200 | i=ASN1_TYPE_set_int_octetstring(type,num,c->oiv,j); | ||
201 | } | ||
202 | return(i); | ||
203 | } | ||
204 | |||
205 | static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | ||
206 | { | ||
207 | switch(type) | ||
208 | { | ||
209 | case EVP_CTRL_INIT: | ||
210 | data(c)->key_bits = EVP_CIPHER_CTX_key_length(c) * 8; | ||
211 | return 1; | ||
212 | |||
213 | case EVP_CTRL_GET_RC2_KEY_BITS: | ||
214 | *(int *)ptr = data(c)->key_bits; | ||
215 | return 1; | ||
216 | |||
217 | case EVP_CTRL_SET_RC2_KEY_BITS: | ||
218 | if(arg > 0) | ||
219 | { | ||
220 | data(c)->key_bits = arg; | ||
221 | return 1; | ||
222 | } | ||
223 | return 0; | ||
224 | |||
225 | default: | ||
226 | return -1; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c new file mode 100644 index 0000000000..8aa70585b9 --- /dev/null +++ b/src/lib/libcrypto/evp/e_rc4.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* crypto/evp/e_rc4.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 | #ifndef OPENSSL_NO_RC4 | ||
60 | |||
61 | #include <stdio.h> | ||
62 | #include "cryptlib.h" | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/objects.h> | ||
65 | #include "evp_locl.h" | ||
66 | #include <openssl/rc4.h> | ||
67 | |||
68 | /* FIXME: surely this is available elsewhere? */ | ||
69 | #define EVP_RC4_KEY_SIZE 16 | ||
70 | |||
71 | typedef struct | ||
72 | { | ||
73 | RC4_KEY ks; /* working key */ | ||
74 | } EVP_RC4_KEY; | ||
75 | |||
76 | #define data(ctx) ((EVP_RC4_KEY *)(ctx)->cipher_data) | ||
77 | |||
78 | static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
79 | const unsigned char *iv,int enc); | ||
80 | static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
81 | const unsigned char *in, unsigned int inl); | ||
82 | static const EVP_CIPHER r4_cipher= | ||
83 | { | ||
84 | NID_rc4, | ||
85 | 1,EVP_RC4_KEY_SIZE,0, | ||
86 | EVP_CIPH_VARIABLE_LENGTH, | ||
87 | rc4_init_key, | ||
88 | rc4_cipher, | ||
89 | NULL, | ||
90 | sizeof(EVP_RC4_KEY), | ||
91 | NULL, | ||
92 | NULL, | ||
93 | NULL | ||
94 | }; | ||
95 | |||
96 | static const EVP_CIPHER r4_40_cipher= | ||
97 | { | ||
98 | NID_rc4_40, | ||
99 | 1,5 /* 40 bit */,0, | ||
100 | EVP_CIPH_VARIABLE_LENGTH, | ||
101 | rc4_init_key, | ||
102 | rc4_cipher, | ||
103 | NULL, | ||
104 | sizeof(EVP_RC4_KEY), | ||
105 | NULL, | ||
106 | NULL, | ||
107 | NULL | ||
108 | }; | ||
109 | |||
110 | const EVP_CIPHER *EVP_rc4(void) | ||
111 | { | ||
112 | return(&r4_cipher); | ||
113 | } | ||
114 | |||
115 | const EVP_CIPHER *EVP_rc4_40(void) | ||
116 | { | ||
117 | return(&r4_40_cipher); | ||
118 | } | ||
119 | |||
120 | static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
121 | const unsigned char *iv, int enc) | ||
122 | { | ||
123 | RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), | ||
124 | key); | ||
125 | return 1; | ||
126 | } | ||
127 | |||
128 | static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
129 | const unsigned char *in, unsigned int inl) | ||
130 | { | ||
131 | RC4(&data(ctx)->ks,inl,in,out); | ||
132 | return 1; | ||
133 | } | ||
134 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_rc5.c b/src/lib/libcrypto/evp/e_rc5.c index 19a10c6402..3c7713b181 100644 --- a/src/lib/libcrypto/evp/e_rc5.c +++ b/src/lib/libcrypto/evp/e_rc5.c | |||
@@ -56,11 +56,10 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <stdio.h> | ||
60 | #include "cryptlib.h" | ||
61 | |||
62 | #ifndef OPENSSL_NO_RC5 | 59 | #ifndef OPENSSL_NO_RC5 |
63 | 60 | ||
61 | #include <stdio.h> | ||
62 | #include "cryptlib.h" | ||
64 | #include <openssl/evp.h> | 63 | #include <openssl/evp.h> |
65 | #include <openssl/objects.h> | 64 | #include <openssl/objects.h> |
66 | #include "evp_locl.h" | 65 | #include "evp_locl.h" |
diff --git a/src/lib/libcrypto/evp/e_seed.c b/src/lib/libcrypto/evp/e_seed.c new file mode 100644 index 0000000000..8c1ec0d43a --- /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 | #include <openssl/evp.h> | ||
58 | #include <openssl/err.h> | ||
59 | #include <string.h> | ||
60 | #include <assert.h> | ||
61 | #ifndef OPENSSL_NO_SEED | ||
62 | #include <openssl/seed.h> | ||
63 | #include "evp_locl.h" | ||
64 | |||
65 | static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); | ||
66 | |||
67 | typedef struct | ||
68 | { | ||
69 | SEED_KEY_SCHEDULE ks; | ||
70 | } EVP_SEED_KEY; | ||
71 | |||
72 | IMPLEMENT_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 | |||
76 | static 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/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c new file mode 100644 index 0000000000..a6f849e93d --- /dev/null +++ b/src/lib/libcrypto/evp/e_xcbc_d.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* crypto/evp/e_xcbc_d.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 | #ifndef OPENSSL_NO_DES | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/objects.h> | ||
64 | #include <openssl/des.h> | ||
65 | |||
66 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
67 | const unsigned char *iv,int enc); | ||
68 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
69 | const unsigned char *in, unsigned int inl); | ||
70 | |||
71 | |||
72 | typedef struct | ||
73 | { | ||
74 | DES_key_schedule ks;/* key schedule */ | ||
75 | DES_cblock inw; | ||
76 | DES_cblock outw; | ||
77 | } DESX_CBC_KEY; | ||
78 | |||
79 | #define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data) | ||
80 | |||
81 | static const EVP_CIPHER d_xcbc_cipher= | ||
82 | { | ||
83 | NID_desx_cbc, | ||
84 | 8,24,8, | ||
85 | EVP_CIPH_CBC_MODE, | ||
86 | desx_cbc_init_key, | ||
87 | desx_cbc_cipher, | ||
88 | NULL, | ||
89 | sizeof(DESX_CBC_KEY), | ||
90 | EVP_CIPHER_set_asn1_iv, | ||
91 | EVP_CIPHER_get_asn1_iv, | ||
92 | NULL | ||
93 | }; | ||
94 | |||
95 | const EVP_CIPHER *EVP_desx_cbc(void) | ||
96 | { | ||
97 | return(&d_xcbc_cipher); | ||
98 | } | ||
99 | |||
100 | static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
101 | const unsigned char *iv, int enc) | ||
102 | { | ||
103 | DES_cblock *deskey = (DES_cblock *)key; | ||
104 | |||
105 | DES_set_key_unchecked(deskey,&data(ctx)->ks); | ||
106 | memcpy(&data(ctx)->inw[0],&key[8],8); | ||
107 | memcpy(&data(ctx)->outw[0],&key[16],8); | ||
108 | |||
109 | return 1; | ||
110 | } | ||
111 | |||
112 | static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
113 | const unsigned char *in, unsigned int inl) | ||
114 | { | ||
115 | DES_xcbc_encrypt(in,out,inl,&data(ctx)->ks, | ||
116 | (DES_cblock *)&(ctx->iv[0]), | ||
117 | &data(ctx)->inw, | ||
118 | &data(ctx)->outw, | ||
119 | ctx->encrypt); | ||
120 | return 1; | ||
121 | } | ||
122 | #endif | ||
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c new file mode 100644 index 0000000000..33e540087d --- /dev/null +++ b/src/lib/libcrypto/evp/encode.c | |||
@@ -0,0 +1,446 @@ | |||
1 | /* crypto/evp/encode.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 | |||
63 | #ifndef CHARSET_EBCDIC | ||
64 | #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) | ||
65 | #define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f]) | ||
66 | #else | ||
67 | /* We assume that PEM encoded files are EBCDIC files | ||
68 | * (i.e., printable text files). Convert them here while decoding. | ||
69 | * When encoding, output is EBCDIC (text) format again. | ||
70 | * (No need for conversion in the conv_bin2ascii macro, as the | ||
71 | * underlying textstring data_bin2ascii[] is already EBCDIC) | ||
72 | */ | ||
73 | #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) | ||
74 | #define conv_ascii2bin(a) (data_ascii2bin[os_toascii[a]&0x7f]) | ||
75 | #endif | ||
76 | |||
77 | /* 64 char lines | ||
78 | * pad input with 0 | ||
79 | * left over chars are set to = | ||
80 | * 1 byte => xx== | ||
81 | * 2 bytes => xxx= | ||
82 | * 3 bytes => xxxx | ||
83 | */ | ||
84 | #define BIN_PER_LINE (64/4*3) | ||
85 | #define CHUNKS_PER_LINE (64/4) | ||
86 | #define CHAR_PER_LINE (64+1) | ||
87 | |||
88 | static unsigned char data_bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZ\ | ||
89 | abcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
90 | |||
91 | /* 0xF0 is a EOLN | ||
92 | * 0xF1 is ignore but next needs to be 0xF0 (for \r\n processing). | ||
93 | * 0xF2 is EOF | ||
94 | * 0xE0 is ignore at start of line. | ||
95 | * 0xFF is error | ||
96 | */ | ||
97 | |||
98 | #define B64_EOLN 0xF0 | ||
99 | #define B64_CR 0xF1 | ||
100 | #define B64_EOF 0xF2 | ||
101 | #define B64_WS 0xE0 | ||
102 | #define B64_ERROR 0xFF | ||
103 | #define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3) | ||
104 | |||
105 | static unsigned char data_ascii2bin[128]={ | ||
106 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
107 | 0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF, | ||
108 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
109 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
110 | 0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
111 | 0xFF,0xFF,0xFF,0x3E,0xFF,0xF2,0xFF,0x3F, | ||
112 | 0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B, | ||
113 | 0x3C,0x3D,0xFF,0xFF,0xFF,0x00,0xFF,0xFF, | ||
114 | 0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06, | ||
115 | 0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E, | ||
116 | 0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16, | ||
117 | 0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
118 | 0xFF,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20, | ||
119 | 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, | ||
120 | 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30, | ||
121 | 0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
122 | }; | ||
123 | |||
124 | void EVP_EncodeInit(EVP_ENCODE_CTX *ctx) | ||
125 | { | ||
126 | ctx->length=48; | ||
127 | ctx->num=0; | ||
128 | ctx->line_num=0; | ||
129 | } | ||
130 | |||
131 | void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | ||
132 | unsigned char *in, int inl) | ||
133 | { | ||
134 | int i,j; | ||
135 | unsigned int total=0; | ||
136 | |||
137 | *outl=0; | ||
138 | if (inl == 0) return; | ||
139 | OPENSSL_assert(ctx->length <= sizeof ctx->enc_data); | ||
140 | if ((ctx->num+inl) < ctx->length) | ||
141 | { | ||
142 | memcpy(&(ctx->enc_data[ctx->num]),in,inl); | ||
143 | ctx->num+=inl; | ||
144 | return; | ||
145 | } | ||
146 | if (ctx->num != 0) | ||
147 | { | ||
148 | i=ctx->length-ctx->num; | ||
149 | memcpy(&(ctx->enc_data[ctx->num]),in,i); | ||
150 | in+=i; | ||
151 | inl-=i; | ||
152 | j=EVP_EncodeBlock(out,ctx->enc_data,ctx->length); | ||
153 | ctx->num=0; | ||
154 | out+=j; | ||
155 | *(out++)='\n'; | ||
156 | *out='\0'; | ||
157 | total=j+1; | ||
158 | } | ||
159 | while (inl >= ctx->length) | ||
160 | { | ||
161 | j=EVP_EncodeBlock(out,in,ctx->length); | ||
162 | in+=ctx->length; | ||
163 | inl-=ctx->length; | ||
164 | out+=j; | ||
165 | *(out++)='\n'; | ||
166 | *out='\0'; | ||
167 | total+=j+1; | ||
168 | } | ||
169 | if (inl != 0) | ||
170 | memcpy(&(ctx->enc_data[0]),in,inl); | ||
171 | ctx->num=inl; | ||
172 | *outl=total; | ||
173 | } | ||
174 | |||
175 | void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) | ||
176 | { | ||
177 | unsigned int ret=0; | ||
178 | |||
179 | if (ctx->num != 0) | ||
180 | { | ||
181 | ret=EVP_EncodeBlock(out,ctx->enc_data,ctx->num); | ||
182 | out[ret++]='\n'; | ||
183 | out[ret]='\0'; | ||
184 | ctx->num=0; | ||
185 | } | ||
186 | *outl=ret; | ||
187 | } | ||
188 | |||
189 | int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int dlen) | ||
190 | { | ||
191 | int i,ret=0; | ||
192 | unsigned long l; | ||
193 | |||
194 | for (i=dlen; i > 0; i-=3) | ||
195 | { | ||
196 | if (i >= 3) | ||
197 | { | ||
198 | l= (((unsigned long)f[0])<<16L)| | ||
199 | (((unsigned long)f[1])<< 8L)|f[2]; | ||
200 | *(t++)=conv_bin2ascii(l>>18L); | ||
201 | *(t++)=conv_bin2ascii(l>>12L); | ||
202 | *(t++)=conv_bin2ascii(l>> 6L); | ||
203 | *(t++)=conv_bin2ascii(l ); | ||
204 | } | ||
205 | else | ||
206 | { | ||
207 | l=((unsigned long)f[0])<<16L; | ||
208 | if (i == 2) l|=((unsigned long)f[1]<<8L); | ||
209 | |||
210 | *(t++)=conv_bin2ascii(l>>18L); | ||
211 | *(t++)=conv_bin2ascii(l>>12L); | ||
212 | *(t++)=(i == 1)?'=':conv_bin2ascii(l>> 6L); | ||
213 | *(t++)='='; | ||
214 | } | ||
215 | ret+=4; | ||
216 | f+=3; | ||
217 | } | ||
218 | |||
219 | *t='\0'; | ||
220 | return(ret); | ||
221 | } | ||
222 | |||
223 | void EVP_DecodeInit(EVP_ENCODE_CTX *ctx) | ||
224 | { | ||
225 | ctx->length=30; | ||
226 | ctx->num=0; | ||
227 | ctx->line_num=0; | ||
228 | ctx->expect_nl=0; | ||
229 | } | ||
230 | |||
231 | /* -1 for error | ||
232 | * 0 for last line | ||
233 | * 1 for full line | ||
234 | */ | ||
235 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | ||
236 | unsigned char *in, int inl) | ||
237 | { | ||
238 | int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl; | ||
239 | unsigned char *d; | ||
240 | |||
241 | n=ctx->num; | ||
242 | d=ctx->enc_data; | ||
243 | ln=ctx->line_num; | ||
244 | exp_nl=ctx->expect_nl; | ||
245 | |||
246 | /* last line of input. */ | ||
247 | if ((inl == 0) || ((n == 0) && (conv_ascii2bin(in[0]) == B64_EOF))) | ||
248 | { rv=0; goto end; } | ||
249 | |||
250 | /* We parse the input data */ | ||
251 | for (i=0; i<inl; i++) | ||
252 | { | ||
253 | /* If the current line is > 80 characters, scream alot */ | ||
254 | if (ln >= 80) { rv= -1; goto end; } | ||
255 | |||
256 | /* Get char and put it into the buffer */ | ||
257 | tmp= *(in++); | ||
258 | v=conv_ascii2bin(tmp); | ||
259 | /* only save the good data :-) */ | ||
260 | if (!B64_NOT_BASE64(v)) | ||
261 | { | ||
262 | OPENSSL_assert(n < sizeof ctx->enc_data); | ||
263 | d[n++]=tmp; | ||
264 | ln++; | ||
265 | } | ||
266 | else if (v == B64_ERROR) | ||
267 | { | ||
268 | rv= -1; | ||
269 | goto end; | ||
270 | } | ||
271 | |||
272 | /* have we seen a '=' which is 'definitly' the last | ||
273 | * input line. seof will point to the character that | ||
274 | * holds it. and eof will hold how many characters to | ||
275 | * chop off. */ | ||
276 | if (tmp == '=') | ||
277 | { | ||
278 | if (seof == -1) seof=n; | ||
279 | eof++; | ||
280 | } | ||
281 | |||
282 | if (v == B64_CR) | ||
283 | { | ||
284 | ln = 0; | ||
285 | if (exp_nl) | ||
286 | continue; | ||
287 | } | ||
288 | |||
289 | /* eoln */ | ||
290 | if (v == B64_EOLN) | ||
291 | { | ||
292 | ln=0; | ||
293 | if (exp_nl) | ||
294 | { | ||
295 | exp_nl=0; | ||
296 | continue; | ||
297 | } | ||
298 | } | ||
299 | exp_nl=0; | ||
300 | |||
301 | /* If we are at the end of input and it looks like a | ||
302 | * line, process it. */ | ||
303 | if (((i+1) == inl) && (((n&3) == 0) || eof)) | ||
304 | { | ||
305 | v=B64_EOF; | ||
306 | /* In case things were given us in really small | ||
307 | records (so two '=' were given in separate | ||
308 | updates), eof may contain the incorrect number | ||
309 | of ending bytes to skip, so let's redo the count */ | ||
310 | eof = 0; | ||
311 | if (d[n-1] == '=') eof++; | ||
312 | if (d[n-2] == '=') eof++; | ||
313 | /* There will never be more than two '=' */ | ||
314 | } | ||
315 | |||
316 | if ((v == B64_EOF && (n&3) == 0) || (n >= 64)) | ||
317 | { | ||
318 | /* This is needed to work correctly on 64 byte input | ||
319 | * lines. We process the line and then need to | ||
320 | * accept the '\n' */ | ||
321 | if ((v != B64_EOF) && (n >= 64)) exp_nl=1; | ||
322 | tmp2=v; | ||
323 | if (n > 0) | ||
324 | { | ||
325 | v=EVP_DecodeBlock(out,d,n); | ||
326 | if (v < 0) { rv=0; goto end; } | ||
327 | n=0; | ||
328 | ret+=(v-eof); | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | eof=1; | ||
333 | v=0; | ||
334 | } | ||
335 | |||
336 | /* This is the case where we have had a short | ||
337 | * but valid input line */ | ||
338 | if ((v < ctx->length) && eof) | ||
339 | { | ||
340 | rv=0; | ||
341 | goto end; | ||
342 | } | ||
343 | else | ||
344 | ctx->length=v; | ||
345 | |||
346 | if (seof >= 0) { rv=0; goto end; } | ||
347 | out+=v; | ||
348 | } | ||
349 | } | ||
350 | rv=1; | ||
351 | end: | ||
352 | *outl=ret; | ||
353 | ctx->num=n; | ||
354 | ctx->line_num=ln; | ||
355 | ctx->expect_nl=exp_nl; | ||
356 | return(rv); | ||
357 | } | ||
358 | |||
359 | int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n) | ||
360 | { | ||
361 | int i,ret=0,a,b,c,d; | ||
362 | unsigned long l; | ||
363 | |||
364 | /* trim white space from the start of the line. */ | ||
365 | while ((conv_ascii2bin(*f) == B64_WS) && (n > 0)) | ||
366 | { | ||
367 | f++; | ||
368 | n--; | ||
369 | } | ||
370 | |||
371 | /* strip off stuff at the end of the line | ||
372 | * ascii2bin values B64_WS, B64_EOLN, B64_EOLN and B64_EOF */ | ||
373 | while ((n > 3) && (B64_NOT_BASE64(conv_ascii2bin(f[n-1])))) | ||
374 | n--; | ||
375 | |||
376 | if (n%4 != 0) return(-1); | ||
377 | |||
378 | for (i=0; i<n; i+=4) | ||
379 | { | ||
380 | a=conv_ascii2bin(*(f++)); | ||
381 | b=conv_ascii2bin(*(f++)); | ||
382 | c=conv_ascii2bin(*(f++)); | ||
383 | d=conv_ascii2bin(*(f++)); | ||
384 | if ( (a & 0x80) || (b & 0x80) || | ||
385 | (c & 0x80) || (d & 0x80)) | ||
386 | return(-1); | ||
387 | l=( (((unsigned long)a)<<18L)| | ||
388 | (((unsigned long)b)<<12L)| | ||
389 | (((unsigned long)c)<< 6L)| | ||
390 | (((unsigned long)d) )); | ||
391 | *(t++)=(unsigned char)(l>>16L)&0xff; | ||
392 | *(t++)=(unsigned char)(l>> 8L)&0xff; | ||
393 | *(t++)=(unsigned char)(l )&0xff; | ||
394 | ret+=3; | ||
395 | } | ||
396 | return(ret); | ||
397 | } | ||
398 | |||
399 | int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) | ||
400 | { | ||
401 | int i; | ||
402 | |||
403 | *outl=0; | ||
404 | if (ctx->num != 0) | ||
405 | { | ||
406 | i=EVP_DecodeBlock(out,ctx->enc_data,ctx->num); | ||
407 | if (i < 0) return(-1); | ||
408 | ctx->num=0; | ||
409 | *outl=i; | ||
410 | return(1); | ||
411 | } | ||
412 | else | ||
413 | return(1); | ||
414 | } | ||
415 | |||
416 | #ifdef undef | ||
417 | int EVP_DecodeValid(unsigned char *buf, int len) | ||
418 | { | ||
419 | int i,num=0,bad=0; | ||
420 | |||
421 | if (len == 0) return(-1); | ||
422 | while (conv_ascii2bin(*buf) == B64_WS) | ||
423 | { | ||
424 | buf++; | ||
425 | len--; | ||
426 | if (len == 0) return(-1); | ||
427 | } | ||
428 | |||
429 | for (i=len; i >= 4; i-=4) | ||
430 | { | ||
431 | if ( (conv_ascii2bin(buf[0]) >= 0x40) || | ||
432 | (conv_ascii2bin(buf[1]) >= 0x40) || | ||
433 | (conv_ascii2bin(buf[2]) >= 0x40) || | ||
434 | (conv_ascii2bin(buf[3]) >= 0x40)) | ||
435 | return(-1); | ||
436 | buf+=4; | ||
437 | num+=1+(buf[2] != '=')+(buf[3] != '='); | ||
438 | } | ||
439 | if ((i == 1) && (conv_ascii2bin(buf[0]) == B64_EOLN)) | ||
440 | return(num); | ||
441 | if ((i == 2) && (conv_ascii2bin(buf[0]) == B64_EOLN) && | ||
442 | (conv_ascii2bin(buf[0]) == B64_EOLN)) | ||
443 | return(num); | ||
444 | return(1); | ||
445 | } | ||
446 | #endif | ||
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h new file mode 100644 index 0000000000..f29e0ba8f0 --- /dev/null +++ b/src/lib/libcrypto/evp/evp.h | |||
@@ -0,0 +1,910 @@ | |||
1 | /* crypto/evp/evp.h */ | ||
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 | #ifndef HEADER_ENVELOPE_H | ||
60 | #define HEADER_ENVELOPE_H | ||
61 | |||
62 | #ifdef OPENSSL_ALGORITHM_DEFINES | ||
63 | # include <openssl/opensslconf.h> | ||
64 | #else | ||
65 | # define OPENSSL_ALGORITHM_DEFINES | ||
66 | # include <openssl/opensslconf.h> | ||
67 | # undef OPENSSL_ALGORITHM_DEFINES | ||
68 | #endif | ||
69 | |||
70 | #include <openssl/ossl_typ.h> | ||
71 | |||
72 | #include <openssl/symhacks.h> | ||
73 | |||
74 | #ifndef OPENSSL_NO_BIO | ||
75 | #include <openssl/bio.h> | ||
76 | #endif | ||
77 | |||
78 | #ifdef OPENSSL_FIPS | ||
79 | #include <openssl/fips.h> | ||
80 | #endif | ||
81 | |||
82 | /* | ||
83 | #define EVP_RC2_KEY_SIZE 16 | ||
84 | #define EVP_RC4_KEY_SIZE 16 | ||
85 | #define EVP_BLOWFISH_KEY_SIZE 16 | ||
86 | #define EVP_CAST5_KEY_SIZE 16 | ||
87 | #define EVP_RC5_32_12_16_KEY_SIZE 16 | ||
88 | */ | ||
89 | #define EVP_MAX_MD_SIZE 64 /* longest known SHA512 */ | ||
90 | #define EVP_MAX_KEY_LENGTH 32 | ||
91 | #define EVP_MAX_IV_LENGTH 16 | ||
92 | #define EVP_MAX_BLOCK_LENGTH 32 | ||
93 | |||
94 | #define PKCS5_SALT_LEN 8 | ||
95 | /* Default PKCS#5 iteration count */ | ||
96 | #define PKCS5_DEFAULT_ITER 2048 | ||
97 | |||
98 | #include <openssl/objects.h> | ||
99 | |||
100 | #define EVP_PK_RSA 0x0001 | ||
101 | #define EVP_PK_DSA 0x0002 | ||
102 | #define EVP_PK_DH 0x0004 | ||
103 | #define EVP_PKT_SIGN 0x0010 | ||
104 | #define EVP_PKT_ENC 0x0020 | ||
105 | #define EVP_PKT_EXCH 0x0040 | ||
106 | #define EVP_PKS_RSA 0x0100 | ||
107 | #define EVP_PKS_DSA 0x0200 | ||
108 | #define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ | ||
109 | |||
110 | #define EVP_PKEY_NONE NID_undef | ||
111 | #define EVP_PKEY_RSA NID_rsaEncryption | ||
112 | #define EVP_PKEY_RSA2 NID_rsa | ||
113 | #define EVP_PKEY_DSA NID_dsa | ||
114 | #define EVP_PKEY_DSA1 NID_dsa_2 | ||
115 | #define EVP_PKEY_DSA2 NID_dsaWithSHA | ||
116 | #define EVP_PKEY_DSA3 NID_dsaWithSHA1 | ||
117 | #define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 | ||
118 | #define EVP_PKEY_DH NID_dhKeyAgreement | ||
119 | |||
120 | #ifdef __cplusplus | ||
121 | extern "C" { | ||
122 | #endif | ||
123 | |||
124 | /* Type needs to be a bit field | ||
125 | * Sub-type needs to be for variations on the method, as in, can it do | ||
126 | * arbitrary encryption.... */ | ||
127 | struct evp_pkey_st | ||
128 | { | ||
129 | int type; | ||
130 | int save_type; | ||
131 | int references; | ||
132 | union { | ||
133 | char *ptr; | ||
134 | #ifndef OPENSSL_NO_RSA | ||
135 | struct rsa_st *rsa; /* RSA */ | ||
136 | #endif | ||
137 | #ifndef OPENSSL_NO_DSA | ||
138 | struct dsa_st *dsa; /* DSA */ | ||
139 | #endif | ||
140 | #ifndef OPENSSL_NO_DH | ||
141 | struct dh_st *dh; /* DH */ | ||
142 | #endif | ||
143 | } pkey; | ||
144 | int save_parameters; | ||
145 | STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ | ||
146 | } /* EVP_PKEY */; | ||
147 | |||
148 | #define EVP_PKEY_MO_SIGN 0x0001 | ||
149 | #define EVP_PKEY_MO_VERIFY 0x0002 | ||
150 | #define EVP_PKEY_MO_ENCRYPT 0x0004 | ||
151 | #define EVP_PKEY_MO_DECRYPT 0x0008 | ||
152 | |||
153 | #if 0 | ||
154 | /* This structure is required to tie the message digest and signing together. | ||
155 | * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or | ||
156 | * oid, md and pkey. | ||
157 | * This is required because for various smart-card perform the digest and | ||
158 | * signing/verification on-board. To handle this case, the specific | ||
159 | * EVP_MD and EVP_PKEY_METHODs need to be closely associated. | ||
160 | * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. | ||
161 | * This can either be software or a token to provide the required low level | ||
162 | * routines. | ||
163 | */ | ||
164 | typedef struct evp_pkey_md_st | ||
165 | { | ||
166 | int oid; | ||
167 | EVP_MD *md; | ||
168 | EVP_PKEY_METHOD *pkey; | ||
169 | } EVP_PKEY_MD; | ||
170 | |||
171 | #define EVP_rsa_md2() \ | ||
172 | EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ | ||
173 | EVP_rsa_pkcs1(),EVP_md2()) | ||
174 | #define EVP_rsa_md5() \ | ||
175 | EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ | ||
176 | EVP_rsa_pkcs1(),EVP_md5()) | ||
177 | #define EVP_rsa_sha0() \ | ||
178 | EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ | ||
179 | EVP_rsa_pkcs1(),EVP_sha()) | ||
180 | #define EVP_rsa_sha1() \ | ||
181 | EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ | ||
182 | EVP_rsa_pkcs1(),EVP_sha1()) | ||
183 | #define EVP_rsa_ripemd160() \ | ||
184 | EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ | ||
185 | EVP_rsa_pkcs1(),EVP_ripemd160()) | ||
186 | #define EVP_rsa_mdc2() \ | ||
187 | EVP_PKEY_MD_add(NID_mdc2WithRSA,\ | ||
188 | EVP_rsa_octet_string(),EVP_mdc2()) | ||
189 | #define EVP_dsa_sha() \ | ||
190 | EVP_PKEY_MD_add(NID_dsaWithSHA,\ | ||
191 | EVP_dsa(),EVP_sha()) | ||
192 | #define EVP_dsa_sha1() \ | ||
193 | EVP_PKEY_MD_add(NID_dsaWithSHA1,\ | ||
194 | EVP_dsa(),EVP_sha1()) | ||
195 | |||
196 | typedef struct evp_pkey_method_st | ||
197 | { | ||
198 | char *name; | ||
199 | int flags; | ||
200 | int type; /* RSA, DSA, an SSLeay specific constant */ | ||
201 | int oid; /* For the pub-key type */ | ||
202 | int encrypt_oid; /* pub/priv key encryption */ | ||
203 | |||
204 | int (*sign)(); | ||
205 | int (*verify)(); | ||
206 | struct { | ||
207 | int (*set)(); /* get and/or set the underlying type */ | ||
208 | int (*get)(); | ||
209 | int (*encrypt)(); | ||
210 | int (*decrypt)(); | ||
211 | int (*i2d)(); | ||
212 | int (*d2i)(); | ||
213 | int (*dup)(); | ||
214 | } pub,priv; | ||
215 | int (*set_asn1_parameters)(); | ||
216 | int (*get_asn1_parameters)(); | ||
217 | } EVP_PKEY_METHOD; | ||
218 | #endif | ||
219 | |||
220 | #ifndef EVP_MD | ||
221 | struct env_md_st | ||
222 | { | ||
223 | int type; | ||
224 | int pkey_type; | ||
225 | int md_size; | ||
226 | unsigned long flags; | ||
227 | int (*init)(EVP_MD_CTX *ctx); | ||
228 | int (*update)(EVP_MD_CTX *ctx,const void *data,unsigned long count); | ||
229 | int (*final)(EVP_MD_CTX *ctx,unsigned char *md); | ||
230 | int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); | ||
231 | int (*cleanup)(EVP_MD_CTX *ctx); | ||
232 | |||
233 | /* FIXME: prototype these some day */ | ||
234 | int (*sign)(); | ||
235 | int (*verify)(); | ||
236 | int required_pkey_type[5]; /*EVP_PKEY_xxx */ | ||
237 | int block_size; | ||
238 | int ctx_size; /* how big does the ctx->md_data need to be */ | ||
239 | } /* EVP_MD */; | ||
240 | |||
241 | #define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single | ||
242 | * block */ | ||
243 | #define EVP_MD_FLAG_FIPS 0x0400 /* Note if suitable for use in FIPS mode */ | ||
244 | |||
245 | #define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} | ||
246 | |||
247 | #ifndef OPENSSL_NO_DSA | ||
248 | #define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \ | ||
249 | {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ | ||
250 | EVP_PKEY_DSA4,0} | ||
251 | #else | ||
252 | #define EVP_PKEY_DSA_method EVP_PKEY_NULL_method | ||
253 | #endif | ||
254 | |||
255 | #ifndef OPENSSL_NO_RSA | ||
256 | #define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \ | ||
257 | {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} | ||
258 | #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ | ||
259 | RSA_sign_ASN1_OCTET_STRING, \ | ||
260 | RSA_verify_ASN1_OCTET_STRING, \ | ||
261 | {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} | ||
262 | #else | ||
263 | #define EVP_PKEY_RSA_method EVP_PKEY_NULL_method | ||
264 | #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method | ||
265 | #endif | ||
266 | |||
267 | #endif /* !EVP_MD */ | ||
268 | |||
269 | struct env_md_ctx_st | ||
270 | { | ||
271 | const EVP_MD *digest; | ||
272 | ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ | ||
273 | unsigned long flags; | ||
274 | void *md_data; | ||
275 | } /* EVP_MD_CTX */; | ||
276 | |||
277 | /* values for EVP_MD_CTX flags */ | ||
278 | |||
279 | #define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called | ||
280 | * once only */ | ||
281 | #define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been | ||
282 | * cleaned */ | ||
283 | #define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data | ||
284 | * in EVP_MD_CTX_cleanup */ | ||
285 | |||
286 | #define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest | ||
287 | * in FIPS mode */ | ||
288 | |||
289 | struct evp_cipher_st | ||
290 | { | ||
291 | int nid; | ||
292 | int block_size; | ||
293 | int key_len; /* Default value for variable length ciphers */ | ||
294 | int iv_len; | ||
295 | unsigned long flags; /* Various flags */ | ||
296 | int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
297 | const unsigned char *iv, int enc); /* init key */ | ||
298 | int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
299 | const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ | ||
300 | int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ | ||
301 | int ctx_size; /* how big ctx->cipher_data needs to be */ | ||
302 | int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ | ||
303 | int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ | ||
304 | int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ | ||
305 | void *app_data; /* Application data */ | ||
306 | } /* EVP_CIPHER */; | ||
307 | |||
308 | /* Values for cipher flags */ | ||
309 | |||
310 | /* Modes for ciphers */ | ||
311 | |||
312 | #define EVP_CIPH_STREAM_CIPHER 0x0 | ||
313 | #define EVP_CIPH_ECB_MODE 0x1 | ||
314 | #define EVP_CIPH_CBC_MODE 0x2 | ||
315 | #define EVP_CIPH_CFB_MODE 0x3 | ||
316 | #define EVP_CIPH_OFB_MODE 0x4 | ||
317 | #define EVP_CIPH_MODE 0x7 | ||
318 | /* Set if variable length cipher */ | ||
319 | #define EVP_CIPH_VARIABLE_LENGTH 0x8 | ||
320 | /* Set if the iv handling should be done by the cipher itself */ | ||
321 | #define EVP_CIPH_CUSTOM_IV 0x10 | ||
322 | /* Set if the cipher's init() function should be called if key is NULL */ | ||
323 | #define EVP_CIPH_ALWAYS_CALL_INIT 0x20 | ||
324 | /* Call ctrl() to init cipher parameters */ | ||
325 | #define EVP_CIPH_CTRL_INIT 0x40 | ||
326 | /* Don't use standard key length function */ | ||
327 | #define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 | ||
328 | /* Don't use standard block padding */ | ||
329 | #define EVP_CIPH_NO_PADDING 0x100 | ||
330 | /* Note if suitable for use in FIPS mode */ | ||
331 | #define EVP_CIPH_FLAG_FIPS 0x400 | ||
332 | /* Allow non FIPS cipher in FIPS mode */ | ||
333 | #define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x800 | ||
334 | |||
335 | /* ctrl() values */ | ||
336 | |||
337 | #define EVP_CTRL_INIT 0x0 | ||
338 | #define EVP_CTRL_SET_KEY_LENGTH 0x1 | ||
339 | #define EVP_CTRL_GET_RC2_KEY_BITS 0x2 | ||
340 | #define EVP_CTRL_SET_RC2_KEY_BITS 0x3 | ||
341 | #define EVP_CTRL_GET_RC5_ROUNDS 0x4 | ||
342 | #define EVP_CTRL_SET_RC5_ROUNDS 0x5 | ||
343 | #define EVP_CTRL_SET_ACSS_MODE 0x6 | ||
344 | |||
345 | typedef struct evp_cipher_info_st | ||
346 | { | ||
347 | const EVP_CIPHER *cipher; | ||
348 | unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
349 | } EVP_CIPHER_INFO; | ||
350 | |||
351 | struct evp_cipher_ctx_st | ||
352 | { | ||
353 | const EVP_CIPHER *cipher; | ||
354 | ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ | ||
355 | int encrypt; /* encrypt or decrypt */ | ||
356 | int buf_len; /* number we have left */ | ||
357 | |||
358 | unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ | ||
359 | unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ | ||
360 | unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ | ||
361 | int num; /* used by cfb/ofb mode */ | ||
362 | |||
363 | void *app_data; /* application stuff */ | ||
364 | int key_len; /* May change for variable length cipher */ | ||
365 | unsigned long flags; /* Various flags */ | ||
366 | void *cipher_data; /* per EVP data */ | ||
367 | int final_used; | ||
368 | int block_mask; | ||
369 | unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ | ||
370 | } /* EVP_CIPHER_CTX */; | ||
371 | |||
372 | typedef struct evp_Encode_Ctx_st | ||
373 | { | ||
374 | int num; /* number saved in a partial encode/decode */ | ||
375 | int length; /* The length is either the output line length | ||
376 | * (in input bytes) or the shortest input line | ||
377 | * length that is ok. Once decoding begins, | ||
378 | * the length is adjusted up each time a longer | ||
379 | * line is decoded */ | ||
380 | unsigned char enc_data[80]; /* data to encode */ | ||
381 | int line_num; /* number read on current line */ | ||
382 | int expect_nl; | ||
383 | } EVP_ENCODE_CTX; | ||
384 | |||
385 | /* Password based encryption function */ | ||
386 | typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
387 | ASN1_TYPE *param, const EVP_CIPHER *cipher, | ||
388 | const EVP_MD *md, int en_de); | ||
389 | |||
390 | #ifndef OPENSSL_NO_RSA | ||
391 | #define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ | ||
392 | (char *)(rsa)) | ||
393 | #endif | ||
394 | |||
395 | #ifndef OPENSSL_NO_DSA | ||
396 | #define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ | ||
397 | (char *)(dsa)) | ||
398 | #endif | ||
399 | |||
400 | #ifndef OPENSSL_NO_DH | ||
401 | #define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ | ||
402 | (char *)(dh)) | ||
403 | #endif | ||
404 | |||
405 | /* Add some extra combinations */ | ||
406 | #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) | ||
407 | #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) | ||
408 | #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) | ||
409 | #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) | ||
410 | |||
411 | #define EVP_MD_type(e) ((e)->type) | ||
412 | #define EVP_MD_nid(e) EVP_MD_type(e) | ||
413 | #define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) | ||
414 | #define EVP_MD_pkey_type(e) ((e)->pkey_type) | ||
415 | #define EVP_MD_size(e) ((e)->md_size) | ||
416 | #define EVP_MD_block_size(e) ((e)->block_size) | ||
417 | |||
418 | #define EVP_MD_CTX_md(e) ((e)->digest) | ||
419 | #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) | ||
420 | #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) | ||
421 | #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) | ||
422 | |||
423 | #define EVP_CIPHER_nid(e) ((e)->nid) | ||
424 | #define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) | ||
425 | #define EVP_CIPHER_block_size(e) ((e)->block_size) | ||
426 | #define EVP_CIPHER_key_length(e) ((e)->key_len) | ||
427 | #define EVP_CIPHER_iv_length(e) ((e)->iv_len) | ||
428 | #define EVP_CIPHER_flags(e) ((e)->flags) | ||
429 | #define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE) | ||
430 | |||
431 | #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) | ||
432 | #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) | ||
433 | #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) | ||
434 | #define EVP_CIPHER_CTX_key_length(e) ((e)->key_len) | ||
435 | #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) | ||
436 | #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) | ||
437 | #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) | ||
438 | #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) | ||
439 | #define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags) | ||
440 | #define EVP_CIPHER_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs)) | ||
441 | #define EVP_CIPHER_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs)) | ||
442 | #define EVP_CIPHER_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs)) | ||
443 | #define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE) | ||
444 | |||
445 | #define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) | ||
446 | #define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) | ||
447 | |||
448 | #define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) | ||
449 | #define EVP_SignInit(a,b) EVP_DigestInit(a,b) | ||
450 | #define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) | ||
451 | #define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) | ||
452 | #define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) | ||
453 | #define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) | ||
454 | #define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) | ||
455 | #define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) | ||
456 | |||
457 | #ifdef CONST_STRICT | ||
458 | void BIO_set_md(BIO *,const EVP_MD *md); | ||
459 | #else | ||
460 | # define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) | ||
461 | #endif | ||
462 | #define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) | ||
463 | #define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) | ||
464 | #define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp) | ||
465 | #define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) | ||
466 | #define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) | ||
467 | |||
468 | #define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l)) | ||
469 | |||
470 | #define EVP_add_cipher_alias(n,alias) \ | ||
471 | OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) | ||
472 | #define EVP_add_digest_alias(n,alias) \ | ||
473 | OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) | ||
474 | #define EVP_delete_cipher_alias(alias) \ | ||
475 | OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); | ||
476 | #define EVP_delete_digest_alias(alias) \ | ||
477 | OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); | ||
478 | |||
479 | void EVP_MD_CTX_init(EVP_MD_CTX *ctx); | ||
480 | int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); | ||
481 | EVP_MD_CTX *EVP_MD_CTX_create(void); | ||
482 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); | ||
483 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); | ||
484 | #define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs)) | ||
485 | #define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs)) | ||
486 | #define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs)) | ||
487 | int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); | ||
488 | int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, | ||
489 | unsigned int cnt); | ||
490 | int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); | ||
491 | int EVP_Digest(void *data, unsigned int count, | ||
492 | unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); | ||
493 | |||
494 | int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); | ||
495 | int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); | ||
496 | int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); | ||
497 | |||
498 | int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); | ||
499 | void EVP_set_pw_prompt(char *prompt); | ||
500 | char * EVP_get_pw_prompt(void); | ||
501 | |||
502 | int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, | ||
503 | const unsigned char *salt, const unsigned char *data, | ||
504 | int datal, int count, unsigned char *key,unsigned char *iv); | ||
505 | |||
506 | int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, | ||
507 | const unsigned char *key, const unsigned char *iv); | ||
508 | int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, | ||
509 | const unsigned char *key, const unsigned char *iv); | ||
510 | int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
511 | int *outl, const unsigned char *in, int inl); | ||
512 | int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); | ||
513 | int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); | ||
514 | |||
515 | int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, | ||
516 | const unsigned char *key, const unsigned char *iv); | ||
517 | int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, | ||
518 | const unsigned char *key, const unsigned char *iv); | ||
519 | int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
520 | int *outl, const unsigned char *in, int inl); | ||
521 | int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); | ||
522 | int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); | ||
523 | |||
524 | int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, | ||
525 | const unsigned char *key,const unsigned char *iv, | ||
526 | int enc); | ||
527 | int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, | ||
528 | const unsigned char *key,const unsigned char *iv, | ||
529 | int enc); | ||
530 | int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
531 | int *outl, const unsigned char *in, int inl); | ||
532 | int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); | ||
533 | int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); | ||
534 | |||
535 | int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, | ||
536 | EVP_PKEY *pkey); | ||
537 | |||
538 | int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, | ||
539 | unsigned int siglen,EVP_PKEY *pkey); | ||
540 | |||
541 | int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,unsigned char *ek, | ||
542 | int ekl,unsigned char *iv,EVP_PKEY *priv); | ||
543 | int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); | ||
544 | |||
545 | int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, | ||
546 | int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk); | ||
547 | int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); | ||
548 | |||
549 | void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); | ||
550 | void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, | ||
551 | int *outl,unsigned char *in,int inl); | ||
552 | void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); | ||
553 | int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); | ||
554 | |||
555 | void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); | ||
556 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, | ||
557 | unsigned char *in, int inl); | ||
558 | int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned | ||
559 | char *out, int *outl); | ||
560 | int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); | ||
561 | |||
562 | void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); | ||
563 | int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); | ||
564 | int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); | ||
565 | int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); | ||
566 | int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); | ||
567 | |||
568 | #ifndef OPENSSL_NO_BIO | ||
569 | BIO_METHOD *BIO_f_md(void); | ||
570 | BIO_METHOD *BIO_f_base64(void); | ||
571 | BIO_METHOD *BIO_f_cipher(void); | ||
572 | BIO_METHOD *BIO_f_reliable(void); | ||
573 | void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,unsigned char *k, | ||
574 | unsigned char *i, int enc); | ||
575 | #endif | ||
576 | |||
577 | const EVP_MD *EVP_md_null(void); | ||
578 | #ifndef OPENSSL_NO_MD2 | ||
579 | const EVP_MD *EVP_md2(void); | ||
580 | #endif | ||
581 | #ifndef OPENSSL_NO_MD4 | ||
582 | const EVP_MD *EVP_md4(void); | ||
583 | #endif | ||
584 | #ifndef OPENSSL_NO_MD5 | ||
585 | const EVP_MD *EVP_md5(void); | ||
586 | #endif | ||
587 | #ifndef OPENSSL_NO_SHA | ||
588 | const EVP_MD *EVP_sha(void); | ||
589 | const EVP_MD *EVP_sha1(void); | ||
590 | const EVP_MD *EVP_dss(void); | ||
591 | const EVP_MD *EVP_dss1(void); | ||
592 | #ifdef OPENSSL_FIPS | ||
593 | #ifndef OPENSSL_NO_SHA256 | ||
594 | const EVP_MD *EVP_sha224(void); | ||
595 | const EVP_MD *EVP_sha256(void); | ||
596 | #endif | ||
597 | #ifndef OPENSSL_NO_SHA512 | ||
598 | const EVP_MD *EVP_sha384(void); | ||
599 | const EVP_MD *EVP_sha512(void); | ||
600 | #endif | ||
601 | #endif | ||
602 | #endif | ||
603 | #ifndef OPENSSL_NO_MDC2 | ||
604 | const EVP_MD *EVP_mdc2(void); | ||
605 | #endif | ||
606 | #ifndef OPENSSL_NO_RIPEMD | ||
607 | const EVP_MD *EVP_ripemd160(void); | ||
608 | #endif | ||
609 | const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ | ||
610 | #ifndef OPENSSL_NO_DES | ||
611 | const EVP_CIPHER *EVP_des_ecb(void); | ||
612 | const EVP_CIPHER *EVP_des_ede(void); | ||
613 | const EVP_CIPHER *EVP_des_ede3(void); | ||
614 | const EVP_CIPHER *EVP_des_ede_ecb(void); | ||
615 | const EVP_CIPHER *EVP_des_ede3_ecb(void); | ||
616 | const EVP_CIPHER *EVP_des_cfb64(void); | ||
617 | # define EVP_des_cfb EVP_des_cfb64 | ||
618 | const EVP_CIPHER *EVP_des_cfb1(void); | ||
619 | const EVP_CIPHER *EVP_des_cfb8(void); | ||
620 | const EVP_CIPHER *EVP_des_ede_cfb64(void); | ||
621 | # define EVP_des_ede_cfb EVP_des_ede_cfb64 | ||
622 | #if 0 | ||
623 | const EVP_CIPHER *EVP_des_ede_cfb1(void); | ||
624 | const EVP_CIPHER *EVP_des_ede_cfb8(void); | ||
625 | #endif | ||
626 | const EVP_CIPHER *EVP_des_ede3_cfb64(void); | ||
627 | # define EVP_des_ede3_cfb EVP_des_ede3_cfb64 | ||
628 | const EVP_CIPHER *EVP_des_ede3_cfb1(void); | ||
629 | const EVP_CIPHER *EVP_des_ede3_cfb8(void); | ||
630 | const EVP_CIPHER *EVP_des_ofb(void); | ||
631 | const EVP_CIPHER *EVP_des_ede_ofb(void); | ||
632 | const EVP_CIPHER *EVP_des_ede3_ofb(void); | ||
633 | const EVP_CIPHER *EVP_des_cbc(void); | ||
634 | const EVP_CIPHER *EVP_des_ede_cbc(void); | ||
635 | const EVP_CIPHER *EVP_des_ede3_cbc(void); | ||
636 | const EVP_CIPHER *EVP_desx_cbc(void); | ||
637 | /* This should now be supported through the dev_crypto ENGINE. But also, why are | ||
638 | * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ | ||
639 | #if 0 | ||
640 | # ifdef OPENSSL_OPENBSD_DEV_CRYPTO | ||
641 | const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); | ||
642 | const EVP_CIPHER *EVP_dev_crypto_rc4(void); | ||
643 | const EVP_MD *EVP_dev_crypto_md5(void); | ||
644 | # endif | ||
645 | #endif | ||
646 | #endif | ||
647 | #ifndef OPENSSL_NO_RC4 | ||
648 | const EVP_CIPHER *EVP_rc4(void); | ||
649 | const EVP_CIPHER *EVP_rc4_40(void); | ||
650 | #endif | ||
651 | #ifndef OPENSSL_NO_IDEA | ||
652 | const EVP_CIPHER *EVP_idea_ecb(void); | ||
653 | const EVP_CIPHER *EVP_idea_cfb64(void); | ||
654 | # define EVP_idea_cfb EVP_idea_cfb64 | ||
655 | const EVP_CIPHER *EVP_idea_ofb(void); | ||
656 | const EVP_CIPHER *EVP_idea_cbc(void); | ||
657 | #endif | ||
658 | #ifndef OPENSSL_NO_RC2 | ||
659 | const EVP_CIPHER *EVP_rc2_ecb(void); | ||
660 | const EVP_CIPHER *EVP_rc2_cbc(void); | ||
661 | const EVP_CIPHER *EVP_rc2_40_cbc(void); | ||
662 | const EVP_CIPHER *EVP_rc2_64_cbc(void); | ||
663 | const EVP_CIPHER *EVP_rc2_cfb64(void); | ||
664 | # define EVP_rc2_cfb EVP_rc2_cfb64 | ||
665 | const EVP_CIPHER *EVP_rc2_ofb(void); | ||
666 | #endif | ||
667 | #ifndef OPENSSL_NO_BF | ||
668 | const EVP_CIPHER *EVP_bf_ecb(void); | ||
669 | const EVP_CIPHER *EVP_bf_cbc(void); | ||
670 | const EVP_CIPHER *EVP_bf_cfb64(void); | ||
671 | # define EVP_bf_cfb EVP_bf_cfb64 | ||
672 | const EVP_CIPHER *EVP_bf_ofb(void); | ||
673 | #endif | ||
674 | #ifndef OPENSSL_NO_CAST | ||
675 | const EVP_CIPHER *EVP_cast5_ecb(void); | ||
676 | const EVP_CIPHER *EVP_cast5_cbc(void); | ||
677 | const EVP_CIPHER *EVP_cast5_cfb64(void); | ||
678 | # define EVP_cast5_cfb EVP_cast5_cfb64 | ||
679 | const EVP_CIPHER *EVP_cast5_ofb(void); | ||
680 | #endif | ||
681 | #ifndef OPENSSL_NO_RC5 | ||
682 | const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); | ||
683 | const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); | ||
684 | const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); | ||
685 | # define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 | ||
686 | const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); | ||
687 | #endif | ||
688 | #ifndef OPENSSL_NO_AES | ||
689 | const EVP_CIPHER *EVP_aes_128_ecb(void); | ||
690 | const EVP_CIPHER *EVP_aes_128_cbc(void); | ||
691 | const EVP_CIPHER *EVP_aes_128_cfb1(void); | ||
692 | const EVP_CIPHER *EVP_aes_128_cfb8(void); | ||
693 | const EVP_CIPHER *EVP_aes_128_cfb128(void); | ||
694 | # define EVP_aes_128_cfb EVP_aes_128_cfb128 | ||
695 | const EVP_CIPHER *EVP_aes_128_ofb(void); | ||
696 | #if 0 | ||
697 | const EVP_CIPHER *EVP_aes_128_ctr(void); | ||
698 | #endif | ||
699 | const EVP_CIPHER *EVP_aes_192_ecb(void); | ||
700 | const EVP_CIPHER *EVP_aes_192_cbc(void); | ||
701 | const EVP_CIPHER *EVP_aes_192_cfb1(void); | ||
702 | const EVP_CIPHER *EVP_aes_192_cfb8(void); | ||
703 | const EVP_CIPHER *EVP_aes_192_cfb128(void); | ||
704 | # define EVP_aes_192_cfb EVP_aes_192_cfb128 | ||
705 | const EVP_CIPHER *EVP_aes_192_ofb(void); | ||
706 | #if 0 | ||
707 | const EVP_CIPHER *EVP_aes_192_ctr(void); | ||
708 | #endif | ||
709 | const EVP_CIPHER *EVP_aes_256_ecb(void); | ||
710 | const EVP_CIPHER *EVP_aes_256_cbc(void); | ||
711 | const EVP_CIPHER *EVP_aes_256_cfb1(void); | ||
712 | const EVP_CIPHER *EVP_aes_256_cfb8(void); | ||
713 | const EVP_CIPHER *EVP_aes_256_cfb128(void); | ||
714 | # define EVP_aes_256_cfb EVP_aes_256_cfb128 | ||
715 | const EVP_CIPHER *EVP_aes_256_ofb(void); | ||
716 | #if 0 | ||
717 | const EVP_CIPHER *EVP_aes_256_ctr(void); | ||
718 | #endif | ||
719 | #endif | ||
720 | #ifndef OPENSSL_NO_ACSS | ||
721 | const EVP_CIPHER *EVP_acss(void); | ||
722 | #endif | ||
723 | |||
724 | void OPENSSL_add_all_algorithms_noconf(void); | ||
725 | void OPENSSL_add_all_algorithms_conf(void); | ||
726 | |||
727 | #ifdef OPENSSL_LOAD_CONF | ||
728 | #define OpenSSL_add_all_algorithms() \ | ||
729 | OPENSSL_add_all_algorithms_conf() | ||
730 | #else | ||
731 | #define OpenSSL_add_all_algorithms() \ | ||
732 | OPENSSL_add_all_algorithms_noconf() | ||
733 | #endif | ||
734 | |||
735 | void OpenSSL_add_all_ciphers(void); | ||
736 | void OpenSSL_add_all_digests(void); | ||
737 | #define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() | ||
738 | #define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() | ||
739 | #define SSLeay_add_all_digests() OpenSSL_add_all_digests() | ||
740 | |||
741 | int EVP_add_cipher(const EVP_CIPHER *cipher); | ||
742 | int EVP_add_digest(const EVP_MD *digest); | ||
743 | |||
744 | const EVP_CIPHER *EVP_get_cipherbyname(const char *name); | ||
745 | const EVP_MD *EVP_get_digestbyname(const char *name); | ||
746 | void EVP_cleanup(void); | ||
747 | |||
748 | int EVP_PKEY_decrypt(unsigned char *dec_key,unsigned char *enc_key, | ||
749 | int enc_key_len,EVP_PKEY *private_key); | ||
750 | int EVP_PKEY_encrypt(unsigned char *enc_key, | ||
751 | unsigned char *key,int key_len,EVP_PKEY *pub_key); | ||
752 | int EVP_PKEY_type(int type); | ||
753 | int EVP_PKEY_bits(EVP_PKEY *pkey); | ||
754 | int EVP_PKEY_size(EVP_PKEY *pkey); | ||
755 | int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); | ||
756 | |||
757 | #ifndef OPENSSL_NO_RSA | ||
758 | struct rsa_st; | ||
759 | int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key); | ||
760 | struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); | ||
761 | #endif | ||
762 | #ifndef OPENSSL_NO_DSA | ||
763 | struct dsa_st; | ||
764 | int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key); | ||
765 | struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); | ||
766 | #endif | ||
767 | #ifndef OPENSSL_NO_DH | ||
768 | struct dh_st; | ||
769 | int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); | ||
770 | struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); | ||
771 | #endif | ||
772 | |||
773 | |||
774 | EVP_PKEY * EVP_PKEY_new(void); | ||
775 | void EVP_PKEY_free(EVP_PKEY *pkey); | ||
776 | EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, | ||
777 | long length); | ||
778 | int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); | ||
779 | |||
780 | EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp, | ||
781 | long length); | ||
782 | EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp, | ||
783 | long length); | ||
784 | int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); | ||
785 | |||
786 | int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from); | ||
787 | int EVP_PKEY_missing_parameters(EVP_PKEY *pkey); | ||
788 | int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); | ||
789 | int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b); | ||
790 | |||
791 | int EVP_CIPHER_type(const EVP_CIPHER *ctx); | ||
792 | |||
793 | /* calls methods */ | ||
794 | int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | ||
795 | int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | ||
796 | |||
797 | /* These are used by EVP_CIPHER methods */ | ||
798 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); | ||
799 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); | ||
800 | |||
801 | /* PKCS5 password based encryption */ | ||
802 | int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
803 | ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, | ||
804 | int en_de); | ||
805 | int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, | ||
806 | unsigned char *salt, int saltlen, int iter, | ||
807 | int keylen, unsigned char *out); | ||
808 | int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
809 | ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, | ||
810 | int en_de); | ||
811 | |||
812 | void PKCS5_PBE_add(void); | ||
813 | |||
814 | int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, | ||
815 | ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); | ||
816 | int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, | ||
817 | EVP_PBE_KEYGEN *keygen); | ||
818 | void EVP_PBE_cleanup(void); | ||
819 | |||
820 | /* BEGIN ERROR CODES */ | ||
821 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
822 | * made after this point may be overwritten when the script is next run. | ||
823 | */ | ||
824 | void ERR_load_EVP_strings(void); | ||
825 | |||
826 | /* Error codes for the EVP functions. */ | ||
827 | |||
828 | /* Function codes. */ | ||
829 | #define EVP_F_AES_INIT_KEY 129 | ||
830 | #define EVP_F_D2I_PKEY 100 | ||
831 | #define EVP_F_EVP_ADD_CIPHER 130 | ||
832 | #define EVP_F_EVP_ADD_DIGEST 131 | ||
833 | #define EVP_F_EVP_CIPHERINIT 123 | ||
834 | #define EVP_F_EVP_CIPHER_CTX_CTRL 124 | ||
835 | #define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 | ||
836 | #define EVP_F_EVP_DECRYPTFINAL 101 | ||
837 | #define EVP_F_EVP_DIGESTINIT 128 | ||
838 | #define EVP_F_EVP_ENCRYPTFINAL 127 | ||
839 | #define EVP_F_EVP_GET_CIPHERBYNAME 132 | ||
840 | #define EVP_F_EVP_GET_DIGESTBYNAME 133 | ||
841 | #define EVP_F_EVP_MD_CTX_COPY 110 | ||
842 | #define EVP_F_EVP_OPENINIT 102 | ||
843 | #define EVP_F_EVP_PBE_ALG_ADD 115 | ||
844 | #define EVP_F_EVP_PBE_CIPHERINIT 116 | ||
845 | #define EVP_F_EVP_PKCS82PKEY 111 | ||
846 | #define EVP_F_EVP_PKCS8_SET_BROKEN 112 | ||
847 | #define EVP_F_EVP_PKEY2PKCS8 113 | ||
848 | #define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 | ||
849 | #define EVP_F_EVP_PKEY_DECRYPT 104 | ||
850 | #define EVP_F_EVP_PKEY_ENCRYPT 105 | ||
851 | #define EVP_F_EVP_PKEY_GET1_DH 119 | ||
852 | #define EVP_F_EVP_PKEY_GET1_DSA 120 | ||
853 | #define EVP_F_EVP_PKEY_GET1_RSA 121 | ||
854 | #define EVP_F_EVP_PKEY_NEW 106 | ||
855 | #define EVP_F_EVP_RIJNDAEL 126 | ||
856 | #define EVP_F_EVP_SIGNFINAL 107 | ||
857 | #define EVP_F_EVP_VERIFYFINAL 108 | ||
858 | #define EVP_F_PKCS5_PBE_KEYIVGEN 117 | ||
859 | #define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 | ||
860 | #define EVP_F_RC2_MAGIC_TO_METH 109 | ||
861 | #define EVP_F_RC5_CTRL 125 | ||
862 | |||
863 | /* Reason codes. */ | ||
864 | #define EVP_R_AES_KEY_SETUP_FAILED 140 | ||
865 | #define EVP_R_BAD_BLOCK_LENGTH 136 | ||
866 | #define EVP_R_BAD_DECRYPT 100 | ||
867 | #define EVP_R_BAD_KEY_LENGTH 137 | ||
868 | #define EVP_R_BN_DECODE_ERROR 112 | ||
869 | #define EVP_R_BN_PUBKEY_ERROR 113 | ||
870 | #define EVP_R_CIPHER_PARAMETER_ERROR 122 | ||
871 | #define EVP_R_CTRL_NOT_IMPLEMENTED 132 | ||
872 | #define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 | ||
873 | #define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 | ||
874 | #define EVP_R_DECODE_ERROR 114 | ||
875 | #define EVP_R_DIFFERENT_KEY_TYPES 101 | ||
876 | #define EVP_R_DISABLED_FOR_FIPS 141 | ||
877 | #define EVP_R_ENCODE_ERROR 115 | ||
878 | #define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 | ||
879 | #define EVP_R_EXPECTING_AN_RSA_KEY 127 | ||
880 | #define EVP_R_EXPECTING_A_DH_KEY 128 | ||
881 | #define EVP_R_EXPECTING_A_DSA_KEY 129 | ||
882 | #define EVP_R_INITIALIZATION_ERROR 134 | ||
883 | #define EVP_R_INPUT_NOT_INITIALIZED 111 | ||
884 | #define EVP_R_INVALID_KEY_LENGTH 130 | ||
885 | #define EVP_R_IV_TOO_LARGE 102 | ||
886 | #define EVP_R_KEYGEN_FAILURE 120 | ||
887 | #define EVP_R_MISSING_PARAMETERS 103 | ||
888 | #define EVP_R_NO_CIPHER_SET 131 | ||
889 | #define EVP_R_NO_DIGEST_SET 139 | ||
890 | #define EVP_R_NO_DSA_PARAMETERS 116 | ||
891 | #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 | ||
892 | #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 | ||
893 | #define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 | ||
894 | #define EVP_R_PUBLIC_KEY_NOT_RSA 106 | ||
895 | #define EVP_R_UNKNOWN_PBE_ALGORITHM 121 | ||
896 | #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 | ||
897 | #define EVP_R_UNSUPPORTED_CIPHER 107 | ||
898 | #define EVP_R_UNSUPPORTED_KEYLENGTH 123 | ||
899 | #define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 | ||
900 | #define EVP_R_UNSUPPORTED_KEY_SIZE 108 | ||
901 | #define EVP_R_UNSUPPORTED_PRF 125 | ||
902 | #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 | ||
903 | #define EVP_R_UNSUPPORTED_SALT_TYPE 126 | ||
904 | #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 | ||
905 | #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 | ||
906 | |||
907 | #ifdef __cplusplus | ||
908 | } | ||
909 | #endif | ||
910 | #endif | ||
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c new file mode 100644 index 0000000000..f549eeb437 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_enc.c | |||
@@ -0,0 +1,592 @@ | |||
1 | /* crypto/evp/evp_enc.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/err.h> | ||
63 | #ifndef OPENSSL_NO_ENGINE | ||
64 | #include <openssl/engine.h> | ||
65 | #endif | ||
66 | #include "evp_locl.h" | ||
67 | |||
68 | const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT; | ||
69 | |||
70 | void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) | ||
71 | { | ||
72 | memset(ctx,0,sizeof(EVP_CIPHER_CTX)); | ||
73 | /* ctx->cipher=NULL; */ | ||
74 | } | ||
75 | |||
76 | |||
77 | int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
78 | const unsigned char *key, const unsigned char *iv, int enc) | ||
79 | { | ||
80 | if (cipher) | ||
81 | EVP_CIPHER_CTX_init(ctx); | ||
82 | return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc); | ||
83 | } | ||
84 | |||
85 | #ifdef OPENSSL_FIPS | ||
86 | |||
87 | /* The purpose of these is to trap programs that attempt to use non FIPS | ||
88 | * algorithms in FIPS mode and ignore the errors. | ||
89 | */ | ||
90 | |||
91 | int bad_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
92 | const unsigned char *iv, int enc) | ||
93 | { FIPS_ERROR_IGNORED("Cipher init"); return 0;} | ||
94 | |||
95 | int bad_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
96 | const unsigned char *in, unsigned int inl) | ||
97 | { FIPS_ERROR_IGNORED("Cipher update"); return 0;} | ||
98 | |||
99 | /* NB: no cleanup because it is allowed after failed init */ | ||
100 | |||
101 | int bad_set_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ) | ||
102 | { FIPS_ERROR_IGNORED("Cipher set_asn1"); return 0;} | ||
103 | int bad_get_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ) | ||
104 | { FIPS_ERROR_IGNORED("Cipher get_asn1"); return 0;} | ||
105 | int bad_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) | ||
106 | { FIPS_ERROR_IGNORED("Cipher ctrl"); return 0;} | ||
107 | |||
108 | static const EVP_CIPHER bad_cipher = | ||
109 | { | ||
110 | 0, | ||
111 | 0, | ||
112 | 0, | ||
113 | 0, | ||
114 | 0, | ||
115 | bad_init, | ||
116 | bad_do_cipher, | ||
117 | NULL, | ||
118 | 0, | ||
119 | bad_set_asn1, | ||
120 | bad_get_asn1, | ||
121 | bad_ctrl, | ||
122 | NULL | ||
123 | }; | ||
124 | |||
125 | #endif | ||
126 | |||
127 | int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | ||
128 | const unsigned char *key, const unsigned char *iv, int enc) | ||
129 | { | ||
130 | if (enc == -1) | ||
131 | enc = ctx->encrypt; | ||
132 | else | ||
133 | { | ||
134 | if (enc) | ||
135 | enc = 1; | ||
136 | ctx->encrypt = enc; | ||
137 | } | ||
138 | #ifndef OPENSSL_NO_ENGINE | ||
139 | /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts | ||
140 | * so this context may already have an ENGINE! Try to avoid releasing | ||
141 | * the previous handle, re-querying for an ENGINE, and having a | ||
142 | * reinitialisation, when it may all be unecessary. */ | ||
143 | if (ctx->engine && ctx->cipher && (!cipher || | ||
144 | (cipher && (cipher->nid == ctx->cipher->nid)))) | ||
145 | goto skip_to_init; | ||
146 | #endif | ||
147 | if (cipher) | ||
148 | { | ||
149 | /* Ensure a context left lying around from last time is cleared | ||
150 | * (the previous check attempted to avoid this if the same | ||
151 | * ENGINE and EVP_CIPHER could be used). */ | ||
152 | EVP_CIPHER_CTX_cleanup(ctx); | ||
153 | |||
154 | /* Restore encrypt field: it is zeroed by cleanup */ | ||
155 | ctx->encrypt = enc; | ||
156 | #ifndef OPENSSL_NO_ENGINE | ||
157 | if(impl) | ||
158 | { | ||
159 | if (!ENGINE_init(impl)) | ||
160 | { | ||
161 | EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR); | ||
162 | return 0; | ||
163 | } | ||
164 | } | ||
165 | else | ||
166 | /* Ask if an ENGINE is reserved for this job */ | ||
167 | impl = ENGINE_get_cipher_engine(cipher->nid); | ||
168 | if(impl) | ||
169 | { | ||
170 | /* There's an ENGINE for this job ... (apparently) */ | ||
171 | const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid); | ||
172 | if(!c) | ||
173 | { | ||
174 | /* One positive side-effect of US's export | ||
175 | * control history, is that we should at least | ||
176 | * be able to avoid using US mispellings of | ||
177 | * "initialisation"? */ | ||
178 | EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR); | ||
179 | return 0; | ||
180 | } | ||
181 | /* We'll use the ENGINE's private cipher definition */ | ||
182 | cipher = c; | ||
183 | /* Store the ENGINE functional reference so we know | ||
184 | * 'cipher' came from an ENGINE and we need to release | ||
185 | * it when done. */ | ||
186 | ctx->engine = impl; | ||
187 | } | ||
188 | else | ||
189 | ctx->engine = NULL; | ||
190 | #endif | ||
191 | ctx->cipher=cipher; | ||
192 | if (ctx->cipher->ctx_size) | ||
193 | { | ||
194 | ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size); | ||
195 | if (!ctx->cipher_data) | ||
196 | { | ||
197 | EVPerr(EVP_F_EVP_CIPHERINIT, ERR_R_MALLOC_FAILURE); | ||
198 | return 0; | ||
199 | } | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | ctx->cipher_data = NULL; | ||
204 | } | ||
205 | ctx->key_len = cipher->key_len; | ||
206 | ctx->flags = 0; | ||
207 | if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT) | ||
208 | { | ||
209 | if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) | ||
210 | { | ||
211 | EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR); | ||
212 | return 0; | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | else if(!ctx->cipher) | ||
217 | { | ||
218 | EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET); | ||
219 | return 0; | ||
220 | } | ||
221 | #ifndef OPENSSL_NO_ENGINE | ||
222 | skip_to_init: | ||
223 | #endif | ||
224 | /* we assume block size is a power of 2 in *cryptUpdate */ | ||
225 | OPENSSL_assert(ctx->cipher->block_size == 1 | ||
226 | || ctx->cipher->block_size == 8 | ||
227 | || ctx->cipher->block_size == 16); | ||
228 | |||
229 | if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { | ||
230 | switch(EVP_CIPHER_CTX_mode(ctx)) { | ||
231 | |||
232 | case EVP_CIPH_STREAM_CIPHER: | ||
233 | case EVP_CIPH_ECB_MODE: | ||
234 | break; | ||
235 | |||
236 | case EVP_CIPH_CFB_MODE: | ||
237 | case EVP_CIPH_OFB_MODE: | ||
238 | |||
239 | ctx->num = 0; | ||
240 | |||
241 | case EVP_CIPH_CBC_MODE: | ||
242 | |||
243 | OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof ctx->iv); | ||
244 | if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); | ||
245 | memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); | ||
246 | break; | ||
247 | |||
248 | default: | ||
249 | return 0; | ||
250 | break; | ||
251 | } | ||
252 | } | ||
253 | |||
254 | #ifdef OPENSSL_FIPS | ||
255 | /* After 'key' is set no further parameters changes are permissible. | ||
256 | * So only check for non FIPS enabling at this point. | ||
257 | */ | ||
258 | if (key && FIPS_mode()) | ||
259 | { | ||
260 | if (!(ctx->cipher->flags & EVP_CIPH_FLAG_FIPS) | ||
261 | & !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW)) | ||
262 | { | ||
263 | EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_DISABLED_FOR_FIPS); | ||
264 | ERR_add_error_data(2, "cipher=", | ||
265 | EVP_CIPHER_name(ctx->cipher)); | ||
266 | ctx->cipher = &bad_cipher; | ||
267 | return 0; | ||
268 | } | ||
269 | } | ||
270 | #endif | ||
271 | |||
272 | if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) { | ||
273 | if(!ctx->cipher->init(ctx,key,iv,enc)) return 0; | ||
274 | } | ||
275 | ctx->buf_len=0; | ||
276 | ctx->final_used=0; | ||
277 | ctx->block_mask=ctx->cipher->block_size-1; | ||
278 | return 1; | ||
279 | } | ||
280 | |||
281 | int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | ||
282 | const unsigned char *in, int inl) | ||
283 | { | ||
284 | if (ctx->encrypt) | ||
285 | return EVP_EncryptUpdate(ctx,out,outl,in,inl); | ||
286 | else return EVP_DecryptUpdate(ctx,out,outl,in,inl); | ||
287 | } | ||
288 | |||
289 | int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
290 | { | ||
291 | if (ctx->encrypt) | ||
292 | return EVP_EncryptFinal_ex(ctx,out,outl); | ||
293 | else return EVP_DecryptFinal_ex(ctx,out,outl); | ||
294 | } | ||
295 | |||
296 | int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
297 | { | ||
298 | if (ctx->encrypt) | ||
299 | return EVP_EncryptFinal(ctx,out,outl); | ||
300 | else return EVP_DecryptFinal(ctx,out,outl); | ||
301 | } | ||
302 | |||
303 | int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
304 | const unsigned char *key, const unsigned char *iv) | ||
305 | { | ||
306 | return EVP_CipherInit(ctx, cipher, key, iv, 1); | ||
307 | } | ||
308 | |||
309 | int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, | ||
310 | const unsigned char *key, const unsigned char *iv) | ||
311 | { | ||
312 | return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1); | ||
313 | } | ||
314 | |||
315 | int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
316 | const unsigned char *key, const unsigned char *iv) | ||
317 | { | ||
318 | return EVP_CipherInit(ctx, cipher, key, iv, 0); | ||
319 | } | ||
320 | |||
321 | int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | ||
322 | const unsigned char *key, const unsigned char *iv) | ||
323 | { | ||
324 | return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0); | ||
325 | } | ||
326 | |||
327 | int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | ||
328 | const unsigned char *in, int inl) | ||
329 | { | ||
330 | int i,j,bl; | ||
331 | |||
332 | OPENSSL_assert(inl > 0); | ||
333 | if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) | ||
334 | { | ||
335 | if(ctx->cipher->do_cipher(ctx,out,in,inl)) | ||
336 | { | ||
337 | *outl=inl; | ||
338 | return 1; | ||
339 | } | ||
340 | else | ||
341 | { | ||
342 | *outl=0; | ||
343 | return 0; | ||
344 | } | ||
345 | } | ||
346 | i=ctx->buf_len; | ||
347 | bl=ctx->cipher->block_size; | ||
348 | OPENSSL_assert(bl <= sizeof ctx->buf); | ||
349 | if (i != 0) | ||
350 | { | ||
351 | if (i+inl < bl) | ||
352 | { | ||
353 | memcpy(&(ctx->buf[i]),in,inl); | ||
354 | ctx->buf_len+=inl; | ||
355 | *outl=0; | ||
356 | return 1; | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | j=bl-i; | ||
361 | memcpy(&(ctx->buf[i]),in,j); | ||
362 | if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0; | ||
363 | inl-=j; | ||
364 | in+=j; | ||
365 | out+=bl; | ||
366 | *outl=bl; | ||
367 | } | ||
368 | } | ||
369 | else | ||
370 | *outl = 0; | ||
371 | i=inl&(bl-1); | ||
372 | inl-=i; | ||
373 | if (inl > 0) | ||
374 | { | ||
375 | if(!ctx->cipher->do_cipher(ctx,out,in,inl)) return 0; | ||
376 | *outl+=inl; | ||
377 | } | ||
378 | |||
379 | if (i != 0) | ||
380 | memcpy(ctx->buf,&(in[inl]),i); | ||
381 | ctx->buf_len=i; | ||
382 | return 1; | ||
383 | } | ||
384 | |||
385 | int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
386 | { | ||
387 | int ret; | ||
388 | ret = EVP_EncryptFinal_ex(ctx, out, outl); | ||
389 | return ret; | ||
390 | } | ||
391 | |||
392 | int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
393 | { | ||
394 | int i,n,b,bl,ret; | ||
395 | |||
396 | b=ctx->cipher->block_size; | ||
397 | OPENSSL_assert(b <= sizeof ctx->buf); | ||
398 | if (b == 1) | ||
399 | { | ||
400 | *outl=0; | ||
401 | return 1; | ||
402 | } | ||
403 | bl=ctx->buf_len; | ||
404 | if (ctx->flags & EVP_CIPH_NO_PADDING) | ||
405 | { | ||
406 | if(bl) | ||
407 | { | ||
408 | EVPerr(EVP_F_EVP_ENCRYPTFINAL,EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH); | ||
409 | return 0; | ||
410 | } | ||
411 | *outl = 0; | ||
412 | return 1; | ||
413 | } | ||
414 | |||
415 | n=b-bl; | ||
416 | for (i=bl; i<b; i++) | ||
417 | ctx->buf[i]=n; | ||
418 | ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b); | ||
419 | |||
420 | |||
421 | if(ret) | ||
422 | *outl=b; | ||
423 | |||
424 | return ret; | ||
425 | } | ||
426 | |||
427 | int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | ||
428 | const unsigned char *in, int inl) | ||
429 | { | ||
430 | int b, fix_len; | ||
431 | |||
432 | if (inl == 0) | ||
433 | { | ||
434 | *outl=0; | ||
435 | return 1; | ||
436 | } | ||
437 | |||
438 | if (ctx->flags & EVP_CIPH_NO_PADDING) | ||
439 | return EVP_EncryptUpdate(ctx, out, outl, in, inl); | ||
440 | |||
441 | b=ctx->cipher->block_size; | ||
442 | OPENSSL_assert(b <= sizeof ctx->final); | ||
443 | |||
444 | if(ctx->final_used) | ||
445 | { | ||
446 | memcpy(out,ctx->final,b); | ||
447 | out+=b; | ||
448 | fix_len = 1; | ||
449 | } | ||
450 | else | ||
451 | fix_len = 0; | ||
452 | |||
453 | |||
454 | if(!EVP_EncryptUpdate(ctx,out,outl,in,inl)) | ||
455 | return 0; | ||
456 | |||
457 | /* if we have 'decrypted' a multiple of block size, make sure | ||
458 | * we have a copy of this last block */ | ||
459 | if (b > 1 && !ctx->buf_len) | ||
460 | { | ||
461 | *outl-=b; | ||
462 | ctx->final_used=1; | ||
463 | memcpy(ctx->final,&out[*outl],b); | ||
464 | } | ||
465 | else | ||
466 | ctx->final_used = 0; | ||
467 | |||
468 | if (fix_len) | ||
469 | *outl += b; | ||
470 | |||
471 | return 1; | ||
472 | } | ||
473 | |||
474 | int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
475 | { | ||
476 | int ret; | ||
477 | ret = EVP_DecryptFinal_ex(ctx, out, outl); | ||
478 | return ret; | ||
479 | } | ||
480 | |||
481 | int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
482 | { | ||
483 | int i,b; | ||
484 | int n; | ||
485 | |||
486 | *outl=0; | ||
487 | b=ctx->cipher->block_size; | ||
488 | if (ctx->flags & EVP_CIPH_NO_PADDING) | ||
489 | { | ||
490 | if(ctx->buf_len) | ||
491 | { | ||
492 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH); | ||
493 | return 0; | ||
494 | } | ||
495 | *outl = 0; | ||
496 | return 1; | ||
497 | } | ||
498 | if (b > 1) | ||
499 | { | ||
500 | if (ctx->buf_len || !ctx->final_used) | ||
501 | { | ||
502 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH); | ||
503 | return(0); | ||
504 | } | ||
505 | OPENSSL_assert(b <= sizeof ctx->final); | ||
506 | n=ctx->final[b-1]; | ||
507 | if (n > b) | ||
508 | { | ||
509 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT); | ||
510 | return(0); | ||
511 | } | ||
512 | for (i=0; i<n; i++) | ||
513 | { | ||
514 | if (ctx->final[--b] != n) | ||
515 | { | ||
516 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT); | ||
517 | return(0); | ||
518 | } | ||
519 | } | ||
520 | n=ctx->cipher->block_size-n; | ||
521 | for (i=0; i<n; i++) | ||
522 | out[i]=ctx->final[i]; | ||
523 | *outl=n; | ||
524 | } | ||
525 | else | ||
526 | *outl=0; | ||
527 | return(1); | ||
528 | } | ||
529 | |||
530 | int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) | ||
531 | { | ||
532 | if (c->cipher != NULL) | ||
533 | { | ||
534 | if(c->cipher->cleanup && !c->cipher->cleanup(c)) | ||
535 | return 0; | ||
536 | /* Cleanse cipher context data */ | ||
537 | if (c->cipher_data) | ||
538 | OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size); | ||
539 | } | ||
540 | if (c->cipher_data) | ||
541 | OPENSSL_free(c->cipher_data); | ||
542 | #ifndef OPENSSL_NO_ENGINE | ||
543 | if (c->engine) | ||
544 | /* The EVP_CIPHER we used belongs to an ENGINE, release the | ||
545 | * functional reference we held for this reason. */ | ||
546 | ENGINE_finish(c->engine); | ||
547 | #endif | ||
548 | memset(c,0,sizeof(EVP_CIPHER_CTX)); | ||
549 | return 1; | ||
550 | } | ||
551 | |||
552 | int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) | ||
553 | { | ||
554 | if(c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) | ||
555 | return EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_KEY_LENGTH, keylen, NULL); | ||
556 | if(c->key_len == keylen) return 1; | ||
557 | if((keylen > 0) && (c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) | ||
558 | { | ||
559 | c->key_len = keylen; | ||
560 | return 1; | ||
561 | } | ||
562 | EVPerr(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH,EVP_R_INVALID_KEY_LENGTH); | ||
563 | return 0; | ||
564 | } | ||
565 | |||
566 | int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad) | ||
567 | { | ||
568 | if (pad) ctx->flags &= ~EVP_CIPH_NO_PADDING; | ||
569 | else ctx->flags |= EVP_CIPH_NO_PADDING; | ||
570 | return 1; | ||
571 | } | ||
572 | |||
573 | int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) | ||
574 | { | ||
575 | int ret; | ||
576 | if(!ctx->cipher) { | ||
577 | EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET); | ||
578 | return 0; | ||
579 | } | ||
580 | |||
581 | if(!ctx->cipher->ctrl) { | ||
582 | EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED); | ||
583 | return 0; | ||
584 | } | ||
585 | |||
586 | ret = ctx->cipher->ctrl(ctx, type, arg, ptr); | ||
587 | if(ret == -1) { | ||
588 | EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED); | ||
589 | return 0; | ||
590 | } | ||
591 | return ret; | ||
592 | } | ||
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c new file mode 100644 index 0000000000..77eee070d3 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_err.c | |||
@@ -0,0 +1,171 @@ | |||
1 | /* crypto/evp/evp_err.c */ | ||
2 | /* ==================================================================== | ||
3 | * Copyright (c) 1999-2005 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 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
57 | * made to it will be overwritten when the script next updates this file, | ||
58 | * only reason strings will be preserved. | ||
59 | */ | ||
60 | |||
61 | #include <stdio.h> | ||
62 | #include <openssl/err.h> | ||
63 | #include <openssl/evp.h> | ||
64 | |||
65 | /* BEGIN ERROR CODES */ | ||
66 | #ifndef OPENSSL_NO_ERR | ||
67 | |||
68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_EVP,func,0) | ||
69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_EVP,0,reason) | ||
70 | |||
71 | static ERR_STRING_DATA EVP_str_functs[]= | ||
72 | { | ||
73 | {ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, | ||
74 | {ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, | ||
75 | {ERR_FUNC(EVP_F_EVP_ADD_CIPHER), "EVP_add_cipher"}, | ||
76 | {ERR_FUNC(EVP_F_EVP_ADD_DIGEST), "EVP_add_digest"}, | ||
77 | {ERR_FUNC(EVP_F_EVP_CIPHERINIT), "EVP_CipherInit"}, | ||
78 | {ERR_FUNC(EVP_F_EVP_CIPHER_CTX_CTRL), "EVP_CIPHER_CTX_ctrl"}, | ||
79 | {ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH), "EVP_CIPHER_CTX_set_key_length"}, | ||
80 | {ERR_FUNC(EVP_F_EVP_DECRYPTFINAL), "EVP_DecryptFinal"}, | ||
81 | {ERR_FUNC(EVP_F_EVP_DIGESTINIT), "EVP_DigestInit"}, | ||
82 | {ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL), "EVP_EncryptFinal"}, | ||
83 | {ERR_FUNC(EVP_F_EVP_GET_CIPHERBYNAME), "EVP_get_cipherbyname"}, | ||
84 | {ERR_FUNC(EVP_F_EVP_GET_DIGESTBYNAME), "EVP_get_digestbyname"}, | ||
85 | {ERR_FUNC(EVP_F_EVP_MD_CTX_COPY), "EVP_MD_CTX_copy"}, | ||
86 | {ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"}, | ||
87 | {ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD), "EVP_PBE_alg_add"}, | ||
88 | {ERR_FUNC(EVP_F_EVP_PBE_CIPHERINIT), "EVP_PBE_CipherInit"}, | ||
89 | {ERR_FUNC(EVP_F_EVP_PKCS82PKEY), "EVP_PKCS82PKEY"}, | ||
90 | {ERR_FUNC(EVP_F_EVP_PKCS8_SET_BROKEN), "EVP_PKCS8_SET_BROKEN"}, | ||
91 | {ERR_FUNC(EVP_F_EVP_PKEY2PKCS8), "EVP_PKEY2PKCS8"}, | ||
92 | {ERR_FUNC(EVP_F_EVP_PKEY_COPY_PARAMETERS), "EVP_PKEY_copy_parameters"}, | ||
93 | {ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT), "EVP_PKEY_decrypt"}, | ||
94 | {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT), "EVP_PKEY_encrypt"}, | ||
95 | {ERR_FUNC(EVP_F_EVP_PKEY_GET1_DH), "EVP_PKEY_get1_DH"}, | ||
96 | {ERR_FUNC(EVP_F_EVP_PKEY_GET1_DSA), "EVP_PKEY_get1_DSA"}, | ||
97 | {ERR_FUNC(EVP_F_EVP_PKEY_GET1_RSA), "EVP_PKEY_get1_RSA"}, | ||
98 | {ERR_FUNC(EVP_F_EVP_PKEY_NEW), "EVP_PKEY_new"}, | ||
99 | {ERR_FUNC(EVP_F_EVP_RIJNDAEL), "EVP_RIJNDAEL"}, | ||
100 | {ERR_FUNC(EVP_F_EVP_SIGNFINAL), "EVP_SignFinal"}, | ||
101 | {ERR_FUNC(EVP_F_EVP_VERIFYFINAL), "EVP_VerifyFinal"}, | ||
102 | {ERR_FUNC(EVP_F_PKCS5_PBE_KEYIVGEN), "PKCS5_PBE_keyivgen"}, | ||
103 | {ERR_FUNC(EVP_F_PKCS5_V2_PBE_KEYIVGEN), "PKCS5_v2_PBE_keyivgen"}, | ||
104 | {ERR_FUNC(EVP_F_RC2_MAGIC_TO_METH), "RC2_MAGIC_TO_METH"}, | ||
105 | {ERR_FUNC(EVP_F_RC5_CTRL), "RC5_CTRL"}, | ||
106 | {0,NULL} | ||
107 | }; | ||
108 | |||
109 | static ERR_STRING_DATA EVP_str_reasons[]= | ||
110 | { | ||
111 | {ERR_REASON(EVP_R_AES_KEY_SETUP_FAILED) ,"aes key setup failed"}, | ||
112 | {ERR_REASON(EVP_R_BAD_BLOCK_LENGTH) ,"bad block length"}, | ||
113 | {ERR_REASON(EVP_R_BAD_DECRYPT) ,"bad decrypt"}, | ||
114 | {ERR_REASON(EVP_R_BAD_KEY_LENGTH) ,"bad key length"}, | ||
115 | {ERR_REASON(EVP_R_BN_DECODE_ERROR) ,"bn decode error"}, | ||
116 | {ERR_REASON(EVP_R_BN_PUBKEY_ERROR) ,"bn pubkey error"}, | ||
117 | {ERR_REASON(EVP_R_CIPHER_PARAMETER_ERROR),"cipher parameter error"}, | ||
118 | {ERR_REASON(EVP_R_CTRL_NOT_IMPLEMENTED) ,"ctrl not implemented"}, | ||
119 | {ERR_REASON(EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED),"ctrl operation not implemented"}, | ||
120 | {ERR_REASON(EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH),"data not multiple of block length"}, | ||
121 | {ERR_REASON(EVP_R_DECODE_ERROR) ,"decode error"}, | ||
122 | {ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) ,"different key types"}, | ||
123 | {ERR_REASON(EVP_R_DISABLED_FOR_FIPS) ,"disabled for fips"}, | ||
124 | {ERR_REASON(EVP_R_ENCODE_ERROR) ,"encode error"}, | ||
125 | {ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR),"evp pbe cipherinit error"}, | ||
126 | {ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) ,"expecting an rsa key"}, | ||
127 | {ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) ,"expecting a dh key"}, | ||
128 | {ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) ,"expecting a dsa key"}, | ||
129 | {ERR_REASON(EVP_R_INITIALIZATION_ERROR) ,"initialization error"}, | ||
130 | {ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) ,"input not initialized"}, | ||
131 | {ERR_REASON(EVP_R_INVALID_KEY_LENGTH) ,"invalid key length"}, | ||
132 | {ERR_REASON(EVP_R_IV_TOO_LARGE) ,"iv too large"}, | ||
133 | {ERR_REASON(EVP_R_KEYGEN_FAILURE) ,"keygen failure"}, | ||
134 | {ERR_REASON(EVP_R_MISSING_PARAMETERS) ,"missing parameters"}, | ||
135 | {ERR_REASON(EVP_R_NO_CIPHER_SET) ,"no cipher set"}, | ||
136 | {ERR_REASON(EVP_R_NO_DIGEST_SET) ,"no digest set"}, | ||
137 | {ERR_REASON(EVP_R_NO_DSA_PARAMETERS) ,"no dsa parameters"}, | ||
138 | {ERR_REASON(EVP_R_NO_SIGN_FUNCTION_CONFIGURED),"no sign function configured"}, | ||
139 | {ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED),"no verify function configured"}, | ||
140 | {ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE),"pkcs8 unknown broken type"}, | ||
141 | {ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) ,"public key not rsa"}, | ||
142 | {ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) ,"unknown pbe algorithm"}, | ||
143 | {ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS),"unsuported number of rounds"}, | ||
144 | {ERR_REASON(EVP_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, | ||
145 | {ERR_REASON(EVP_R_UNSUPPORTED_KEYLENGTH) ,"unsupported keylength"}, | ||
146 | {ERR_REASON(EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION),"unsupported key derivation function"}, | ||
147 | {ERR_REASON(EVP_R_UNSUPPORTED_KEY_SIZE) ,"unsupported key size"}, | ||
148 | {ERR_REASON(EVP_R_UNSUPPORTED_PRF) ,"unsupported prf"}, | ||
149 | {ERR_REASON(EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM),"unsupported private key algorithm"}, | ||
150 | {ERR_REASON(EVP_R_UNSUPPORTED_SALT_TYPE) ,"unsupported salt type"}, | ||
151 | {ERR_REASON(EVP_R_WRONG_FINAL_BLOCK_LENGTH),"wrong final block length"}, | ||
152 | {ERR_REASON(EVP_R_WRONG_PUBLIC_KEY_TYPE) ,"wrong public key type"}, | ||
153 | {0,NULL} | ||
154 | }; | ||
155 | |||
156 | #endif | ||
157 | |||
158 | void ERR_load_EVP_strings(void) | ||
159 | { | ||
160 | static int init=1; | ||
161 | |||
162 | if (init) | ||
163 | { | ||
164 | init=0; | ||
165 | #ifndef OPENSSL_NO_ERR | ||
166 | ERR_load_strings(0,EVP_str_functs); | ||
167 | ERR_load_strings(0,EVP_str_reasons); | ||
168 | #endif | ||
169 | |||
170 | } | ||
171 | } | ||
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c new file mode 100644 index 0000000000..f8650d5df6 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_key.c | |||
@@ -0,0 +1,175 @@ | |||
1 | /* crypto/evp/evp_key.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/x509.h> | ||
62 | #include <openssl/objects.h> | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/ui.h> | ||
65 | |||
66 | /* should be init to zeros. */ | ||
67 | static char prompt_string[80]; | ||
68 | |||
69 | void EVP_set_pw_prompt(char *prompt) | ||
70 | { | ||
71 | if (prompt == NULL) | ||
72 | prompt_string[0]='\0'; | ||
73 | else | ||
74 | { | ||
75 | strncpy(prompt_string,prompt,79); | ||
76 | prompt_string[79]='\0'; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | char *EVP_get_pw_prompt(void) | ||
81 | { | ||
82 | if (prompt_string[0] == '\0') | ||
83 | return(NULL); | ||
84 | else | ||
85 | return(prompt_string); | ||
86 | } | ||
87 | |||
88 | /* For historical reasons, the standard function for reading passwords is | ||
89 | * in the DES library -- if someone ever wants to disable DES, | ||
90 | * this function will fail */ | ||
91 | int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) | ||
92 | { | ||
93 | int ret; | ||
94 | char buff[BUFSIZ]; | ||
95 | UI *ui; | ||
96 | |||
97 | if ((prompt == NULL) && (prompt_string[0] != '\0')) | ||
98 | prompt=prompt_string; | ||
99 | ui = UI_new(); | ||
100 | UI_add_input_string(ui,prompt,0,buf,0,(len>=BUFSIZ)?BUFSIZ-1:len); | ||
101 | if (verify) | ||
102 | UI_add_verify_string(ui,prompt,0, | ||
103 | buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf); | ||
104 | ret = UI_process(ui); | ||
105 | UI_free(ui); | ||
106 | OPENSSL_cleanse(buff,BUFSIZ); | ||
107 | return ret; | ||
108 | } | ||
109 | |||
110 | int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, | ||
111 | const unsigned char *salt, const unsigned char *data, int datal, | ||
112 | int count, unsigned char *key, unsigned char *iv) | ||
113 | { | ||
114 | EVP_MD_CTX c; | ||
115 | unsigned char md_buf[EVP_MAX_MD_SIZE]; | ||
116 | int niv,nkey,addmd=0; | ||
117 | unsigned int mds=0,i; | ||
118 | |||
119 | nkey=type->key_len; | ||
120 | niv=type->iv_len; | ||
121 | OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH); | ||
122 | OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH); | ||
123 | |||
124 | if (data == NULL) return(nkey); | ||
125 | |||
126 | EVP_MD_CTX_init(&c); | ||
127 | for (;;) | ||
128 | { | ||
129 | if (!EVP_DigestInit_ex(&c,md, NULL)) | ||
130 | return 0; | ||
131 | if (addmd++) | ||
132 | EVP_DigestUpdate(&c,&(md_buf[0]),mds); | ||
133 | EVP_DigestUpdate(&c,data,datal); | ||
134 | if (salt != NULL) | ||
135 | EVP_DigestUpdate(&c,salt,PKCS5_SALT_LEN); | ||
136 | EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds); | ||
137 | |||
138 | for (i=1; i<(unsigned int)count; i++) | ||
139 | { | ||
140 | EVP_DigestInit_ex(&c,md, NULL); | ||
141 | EVP_DigestUpdate(&c,&(md_buf[0]),mds); | ||
142 | EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds); | ||
143 | } | ||
144 | i=0; | ||
145 | if (nkey) | ||
146 | { | ||
147 | for (;;) | ||
148 | { | ||
149 | if (nkey == 0) break; | ||
150 | if (i == mds) break; | ||
151 | if (key != NULL) | ||
152 | *(key++)=md_buf[i]; | ||
153 | nkey--; | ||
154 | i++; | ||
155 | } | ||
156 | } | ||
157 | if (niv && (i != mds)) | ||
158 | { | ||
159 | for (;;) | ||
160 | { | ||
161 | if (niv == 0) break; | ||
162 | if (i == mds) break; | ||
163 | if (iv != NULL) | ||
164 | *(iv++)=md_buf[i]; | ||
165 | niv--; | ||
166 | i++; | ||
167 | } | ||
168 | } | ||
169 | if ((nkey == 0) && (niv == 0)) break; | ||
170 | } | ||
171 | EVP_MD_CTX_cleanup(&c); | ||
172 | OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE); | ||
173 | return(type->key_len); | ||
174 | } | ||
175 | |||
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c new file mode 100644 index 0000000000..a63ba19317 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_lib.c | |||
@@ -0,0 +1,168 @@ | |||
1 | /* crypto/evp/evp_lib.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 | |||
64 | int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
65 | { | ||
66 | int ret; | ||
67 | |||
68 | if (c->cipher->set_asn1_parameters != NULL) | ||
69 | ret=c->cipher->set_asn1_parameters(c,type); | ||
70 | else | ||
71 | return -1; | ||
72 | return(ret); | ||
73 | } | ||
74 | |||
75 | int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
76 | { | ||
77 | int ret; | ||
78 | |||
79 | if (c->cipher->get_asn1_parameters != NULL) | ||
80 | ret=c->cipher->get_asn1_parameters(c,type); | ||
81 | else | ||
82 | return -1; | ||
83 | return(ret); | ||
84 | } | ||
85 | |||
86 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
87 | { | ||
88 | int i=0,l; | ||
89 | |||
90 | if (type != NULL) | ||
91 | { | ||
92 | l=EVP_CIPHER_CTX_iv_length(c); | ||
93 | OPENSSL_assert(l <= sizeof c->iv); | ||
94 | i=ASN1_TYPE_get_octetstring(type,c->oiv,l); | ||
95 | if (i != l) | ||
96 | return(-1); | ||
97 | else if (i > 0) | ||
98 | memcpy(c->iv,c->oiv,l); | ||
99 | } | ||
100 | return(i); | ||
101 | } | ||
102 | |||
103 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
104 | { | ||
105 | int i=0,j; | ||
106 | |||
107 | if (type != NULL) | ||
108 | { | ||
109 | j=EVP_CIPHER_CTX_iv_length(c); | ||
110 | OPENSSL_assert(j <= sizeof c->iv); | ||
111 | i=ASN1_TYPE_set_octetstring(type,c->oiv,j); | ||
112 | } | ||
113 | return(i); | ||
114 | } | ||
115 | |||
116 | /* Convert the various cipher NIDs and dummies to a proper OID NID */ | ||
117 | int EVP_CIPHER_type(const EVP_CIPHER *ctx) | ||
118 | { | ||
119 | int nid; | ||
120 | ASN1_OBJECT *otmp; | ||
121 | nid = EVP_CIPHER_nid(ctx); | ||
122 | |||
123 | switch(nid) { | ||
124 | |||
125 | case NID_rc2_cbc: | ||
126 | case NID_rc2_64_cbc: | ||
127 | case NID_rc2_40_cbc: | ||
128 | |||
129 | return NID_rc2_cbc; | ||
130 | |||
131 | case NID_rc4: | ||
132 | case NID_rc4_40: | ||
133 | |||
134 | return NID_rc4; | ||
135 | |||
136 | case NID_aes_128_cfb128: | ||
137 | case NID_aes_128_cfb8: | ||
138 | case NID_aes_128_cfb1: | ||
139 | |||
140 | return NID_aes_128_cfb128; | ||
141 | |||
142 | case NID_aes_192_cfb128: | ||
143 | case NID_aes_192_cfb8: | ||
144 | case NID_aes_192_cfb1: | ||
145 | |||
146 | return NID_aes_192_cfb128; | ||
147 | |||
148 | case NID_aes_256_cfb128: | ||
149 | case NID_aes_256_cfb8: | ||
150 | case NID_aes_256_cfb1: | ||
151 | |||
152 | return NID_aes_256_cfb128; | ||
153 | |||
154 | case NID_des_cfb64: | ||
155 | case NID_des_cfb8: | ||
156 | case NID_des_cfb1: | ||
157 | |||
158 | return NID_des_cfb64; | ||
159 | |||
160 | default: | ||
161 | /* Check it has an OID and it is valid */ | ||
162 | otmp = OBJ_nid2obj(nid); | ||
163 | if(!otmp || !otmp->data) nid = NID_undef; | ||
164 | ASN1_OBJECT_free(otmp); | ||
165 | return nid; | ||
166 | } | ||
167 | } | ||
168 | |||
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h new file mode 100644 index 0000000000..f8c5343620 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_locl.h | |||
@@ -0,0 +1,252 @@ | |||
1 | /* evp_locl.h */ | ||
2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 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 | /* Macros to code block cipher wrappers */ | ||
60 | |||
61 | /* Wrapper functions for each cipher mode */ | ||
62 | |||
63 | #define BLOCK_CIPHER_ecb_loop() \ | ||
64 | unsigned int i, bl; \ | ||
65 | bl = ctx->cipher->block_size;\ | ||
66 | if(inl < bl) return 1;\ | ||
67 | inl -= bl; \ | ||
68 | for(i=0; i <= inl; i+=bl) \ | ||
69 | |||
70 | #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ | ||
71 | static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ | ||
72 | {\ | ||
73 | BLOCK_CIPHER_ecb_loop() \ | ||
74 | cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\ | ||
75 | return 1;\ | ||
76 | } | ||
77 | |||
78 | #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ | ||
79 | static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ | ||
80 | {\ | ||
81 | cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ | ||
82 | return 1;\ | ||
83 | } | ||
84 | |||
85 | #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ | ||
86 | static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ | ||
87 | {\ | ||
88 | cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ | ||
89 | return 1;\ | ||
90 | } | ||
91 | |||
92 | #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ | ||
93 | static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ | ||
94 | {\ | ||
95 | cprefix##_cfb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ | ||
96 | return 1;\ | ||
97 | } | ||
98 | |||
99 | #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ | ||
100 | BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ | ||
101 | BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ | ||
102 | BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ | ||
103 | BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) | ||
104 | |||
105 | #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ | ||
106 | key_len, iv_len, flags, init_key, cleanup, \ | ||
107 | set_asn1, get_asn1, ctrl) \ | ||
108 | static const EVP_CIPHER cname##_##mode = { \ | ||
109 | nid##_##nmode, block_size, key_len, iv_len, \ | ||
110 | flags | EVP_CIPH_##MODE##_MODE, \ | ||
111 | init_key, \ | ||
112 | cname##_##mode##_cipher, \ | ||
113 | cleanup, \ | ||
114 | sizeof(kstruct), \ | ||
115 | set_asn1, get_asn1,\ | ||
116 | ctrl, \ | ||
117 | NULL \ | ||
118 | }; \ | ||
119 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } | ||
120 | |||
121 | #define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \ | ||
122 | iv_len, flags, init_key, cleanup, set_asn1, \ | ||
123 | get_asn1, ctrl) \ | ||
124 | BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ | ||
125 | iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) | ||
126 | |||
127 | #define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \ | ||
128 | iv_len, cbits, flags, init_key, cleanup, \ | ||
129 | set_asn1, get_asn1, ctrl) \ | ||
130 | BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ | ||
131 | key_len, iv_len, flags, init_key, cleanup, set_asn1, \ | ||
132 | get_asn1, ctrl) | ||
133 | |||
134 | #define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \ | ||
135 | iv_len, cbits, flags, init_key, cleanup, \ | ||
136 | set_asn1, get_asn1, ctrl) \ | ||
137 | BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \ | ||
138 | key_len, iv_len, flags, init_key, cleanup, set_asn1, \ | ||
139 | get_asn1, ctrl) | ||
140 | |||
141 | #define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ | ||
142 | iv_len, flags, init_key, cleanup, set_asn1, \ | ||
143 | get_asn1, ctrl) \ | ||
144 | BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ | ||
145 | iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) | ||
146 | |||
147 | #define BLOCK_CIPHER_defs(cname, kstruct, \ | ||
148 | nid, block_size, key_len, iv_len, cbits, flags, \ | ||
149 | init_key, cleanup, set_asn1, get_asn1, ctrl) \ | ||
150 | BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ | ||
151 | init_key, cleanup, set_asn1, get_asn1, ctrl) \ | ||
152 | BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \ | ||
153 | flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ | ||
154 | BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ | ||
155 | flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ | ||
156 | BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ | ||
157 | init_key, cleanup, set_asn1, get_asn1, ctrl) | ||
158 | |||
159 | |||
160 | /* | ||
161 | #define BLOCK_CIPHER_defs(cname, kstruct, \ | ||
162 | nid, block_size, key_len, iv_len, flags,\ | ||
163 | init_key, cleanup, set_asn1, get_asn1, ctrl)\ | ||
164 | static const EVP_CIPHER cname##_cbc = {\ | ||
165 | nid##_cbc, block_size, key_len, iv_len, \ | ||
166 | flags | EVP_CIPH_CBC_MODE,\ | ||
167 | init_key,\ | ||
168 | cname##_cbc_cipher,\ | ||
169 | cleanup,\ | ||
170 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ | ||
171 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ | ||
172 | set_asn1, get_asn1,\ | ||
173 | ctrl, \ | ||
174 | NULL \ | ||
175 | };\ | ||
176 | const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ | ||
177 | static const EVP_CIPHER cname##_cfb = {\ | ||
178 | nid##_cfb64, 1, key_len, iv_len, \ | ||
179 | flags | EVP_CIPH_CFB_MODE,\ | ||
180 | init_key,\ | ||
181 | cname##_cfb_cipher,\ | ||
182 | cleanup,\ | ||
183 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ | ||
184 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ | ||
185 | set_asn1, get_asn1,\ | ||
186 | ctrl,\ | ||
187 | NULL \ | ||
188 | };\ | ||
189 | const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ | ||
190 | static const EVP_CIPHER cname##_ofb = {\ | ||
191 | nid##_ofb64, 1, key_len, iv_len, \ | ||
192 | flags | EVP_CIPH_OFB_MODE,\ | ||
193 | init_key,\ | ||
194 | cname##_ofb_cipher,\ | ||
195 | cleanup,\ | ||
196 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ | ||
197 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ | ||
198 | set_asn1, get_asn1,\ | ||
199 | ctrl,\ | ||
200 | NULL \ | ||
201 | };\ | ||
202 | const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ | ||
203 | static const EVP_CIPHER cname##_ecb = {\ | ||
204 | nid##_ecb, block_size, key_len, iv_len, \ | ||
205 | flags | EVP_CIPH_ECB_MODE,\ | ||
206 | init_key,\ | ||
207 | cname##_ecb_cipher,\ | ||
208 | cleanup,\ | ||
209 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ | ||
210 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ | ||
211 | set_asn1, get_asn1,\ | ||
212 | ctrl,\ | ||
213 | NULL \ | ||
214 | };\ | ||
215 | const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } | ||
216 | */ | ||
217 | |||
218 | #define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ | ||
219 | block_size, key_len, iv_len, cbits, \ | ||
220 | flags, init_key, \ | ||
221 | cleanup, set_asn1, get_asn1, ctrl) \ | ||
222 | BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ | ||
223 | BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ | ||
224 | cbits, flags, init_key, cleanup, set_asn1, \ | ||
225 | get_asn1, ctrl) | ||
226 | |||
227 | #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) | ||
228 | |||
229 | #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,flags) \ | ||
230 | BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ | ||
231 | BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ | ||
232 | NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ | ||
233 | flags, cipher##_init_key, NULL, \ | ||
234 | EVP_CIPHER_set_asn1_iv, \ | ||
235 | EVP_CIPHER_get_asn1_iv, \ | ||
236 | NULL) | ||
237 | |||
238 | #ifdef OPENSSL_FIPS | ||
239 | #define RC2_set_key private_RC2_set_key | ||
240 | #define RC4_set_key private_RC4_set_key | ||
241 | #define CAST_set_key private_CAST_set_key | ||
242 | #define RC5_32_set_key private_RC5_32_set_key | ||
243 | #define BF_set_key private_BF_set_key | ||
244 | #define idea_set_encrypt_key private_idea_set_encrypt_key | ||
245 | |||
246 | #define MD5_Init private_MD5_Init | ||
247 | #define MD4_Init private_MD4_Init | ||
248 | #define MD2_Init private_MD2_Init | ||
249 | #define MDC2_Init private_MDC2_Init | ||
250 | #define SHA_Init private_SHA_Init | ||
251 | |||
252 | #endif | ||
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c new file mode 100644 index 0000000000..91e545a141 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_pbe.c | |||
@@ -0,0 +1,136 @@ | |||
1 | /* evp_pbe.c */ | ||
2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
3 | * project 1999. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 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 <stdio.h> | ||
60 | #include "cryptlib.h" | ||
61 | #include <openssl/evp.h> | ||
62 | #include <openssl/x509.h> | ||
63 | |||
64 | /* Password based encryption (PBE) functions */ | ||
65 | |||
66 | static STACK *pbe_algs; | ||
67 | |||
68 | /* Setup a cipher context from a PBE algorithm */ | ||
69 | |||
70 | typedef struct { | ||
71 | int pbe_nid; | ||
72 | const EVP_CIPHER *cipher; | ||
73 | const EVP_MD *md; | ||
74 | EVP_PBE_KEYGEN *keygen; | ||
75 | } EVP_PBE_CTL; | ||
76 | |||
77 | int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, | ||
78 | ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de) | ||
79 | { | ||
80 | |||
81 | EVP_PBE_CTL *pbetmp, pbelu; | ||
82 | int i; | ||
83 | pbelu.pbe_nid = OBJ_obj2nid(pbe_obj); | ||
84 | if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu); | ||
85 | else i = -1; | ||
86 | |||
87 | if (i == -1) { | ||
88 | char obj_tmp[80]; | ||
89 | EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM); | ||
90 | if (!pbe_obj) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp); | ||
91 | else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj); | ||
92 | ERR_add_error_data(2, "TYPE=", obj_tmp); | ||
93 | return 0; | ||
94 | } | ||
95 | if(!pass) passlen = 0; | ||
96 | else if (passlen == -1) passlen = strlen(pass); | ||
97 | pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i); | ||
98 | i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher, | ||
99 | pbetmp->md, en_de); | ||
100 | if (!i) { | ||
101 | EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_KEYGEN_FAILURE); | ||
102 | return 0; | ||
103 | } | ||
104 | return 1; | ||
105 | } | ||
106 | |||
107 | static int pbe_cmp(const char * const *a, const char * const *b) | ||
108 | { | ||
109 | EVP_PBE_CTL **pbe1 = (EVP_PBE_CTL **) a, **pbe2 = (EVP_PBE_CTL **)b; | ||
110 | return ((*pbe1)->pbe_nid - (*pbe2)->pbe_nid); | ||
111 | } | ||
112 | |||
113 | /* Add a PBE algorithm */ | ||
114 | |||
115 | int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, | ||
116 | EVP_PBE_KEYGEN *keygen) | ||
117 | { | ||
118 | EVP_PBE_CTL *pbe_tmp; | ||
119 | if (!pbe_algs) pbe_algs = sk_new(pbe_cmp); | ||
120 | if (!(pbe_tmp = (EVP_PBE_CTL*) OPENSSL_malloc (sizeof(EVP_PBE_CTL)))) { | ||
121 | EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE); | ||
122 | return 0; | ||
123 | } | ||
124 | pbe_tmp->pbe_nid = nid; | ||
125 | pbe_tmp->cipher = cipher; | ||
126 | pbe_tmp->md = md; | ||
127 | pbe_tmp->keygen = keygen; | ||
128 | sk_push (pbe_algs, (char *)pbe_tmp); | ||
129 | return 1; | ||
130 | } | ||
131 | |||
132 | void EVP_PBE_cleanup(void) | ||
133 | { | ||
134 | sk_pop_free(pbe_algs, OPENSSL_freeFunc); | ||
135 | pbe_algs = NULL; | ||
136 | } | ||
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c new file mode 100644 index 0000000000..47a69932a5 --- /dev/null +++ b/src/lib/libcrypto/evp/evp_pkey.c | |||
@@ -0,0 +1,468 @@ | |||
1 | /* evp_pkey.c */ | ||
2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
3 | * project 1999. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 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 <stdio.h> | ||
60 | #include <stdlib.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/x509.h> | ||
63 | #include <openssl/rand.h> | ||
64 | |||
65 | #ifndef OPENSSL_NO_DSA | ||
66 | static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey); | ||
67 | #endif | ||
68 | |||
69 | /* Extract a private key from a PKCS8 structure */ | ||
70 | |||
71 | EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) | ||
72 | { | ||
73 | EVP_PKEY *pkey = NULL; | ||
74 | #ifndef OPENSSL_NO_RSA | ||
75 | RSA *rsa = NULL; | ||
76 | #endif | ||
77 | #ifndef OPENSSL_NO_DSA | ||
78 | DSA *dsa = NULL; | ||
79 | ASN1_INTEGER *privkey; | ||
80 | ASN1_TYPE *t1, *t2, *param = NULL; | ||
81 | STACK_OF(ASN1_TYPE) *ndsa = NULL; | ||
82 | BN_CTX *ctx = NULL; | ||
83 | int plen; | ||
84 | #endif | ||
85 | X509_ALGOR *a; | ||
86 | unsigned char *p; | ||
87 | const unsigned char *cp; | ||
88 | int pkeylen; | ||
89 | char obj_tmp[80]; | ||
90 | |||
91 | if(p8->pkey->type == V_ASN1_OCTET_STRING) { | ||
92 | p8->broken = PKCS8_OK; | ||
93 | p = p8->pkey->value.octet_string->data; | ||
94 | pkeylen = p8->pkey->value.octet_string->length; | ||
95 | } else { | ||
96 | p8->broken = PKCS8_NO_OCTET; | ||
97 | p = p8->pkey->value.sequence->data; | ||
98 | pkeylen = p8->pkey->value.sequence->length; | ||
99 | } | ||
100 | if (!(pkey = EVP_PKEY_new())) { | ||
101 | EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); | ||
102 | return NULL; | ||
103 | } | ||
104 | a = p8->pkeyalg; | ||
105 | switch (OBJ_obj2nid(a->algorithm)) | ||
106 | { | ||
107 | #ifndef OPENSSL_NO_RSA | ||
108 | case NID_rsaEncryption: | ||
109 | cp = p; | ||
110 | if (!(rsa = d2i_RSAPrivateKey (NULL,&cp, pkeylen))) { | ||
111 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
112 | return NULL; | ||
113 | } | ||
114 | EVP_PKEY_assign_RSA (pkey, rsa); | ||
115 | break; | ||
116 | #endif | ||
117 | #ifndef OPENSSL_NO_DSA | ||
118 | case NID_dsa: | ||
119 | /* PKCS#8 DSA is weird: you just get a private key integer | ||
120 | * and parameters in the AlgorithmIdentifier the pubkey must | ||
121 | * be recalculated. | ||
122 | */ | ||
123 | |||
124 | /* Check for broken DSA PKCS#8, UGH! */ | ||
125 | if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { | ||
126 | if(!(ndsa = ASN1_seq_unpack_ASN1_TYPE(p, pkeylen, | ||
127 | d2i_ASN1_TYPE, | ||
128 | ASN1_TYPE_free))) { | ||
129 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
130 | goto dsaerr; | ||
131 | } | ||
132 | if(sk_ASN1_TYPE_num(ndsa) != 2 ) { | ||
133 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
134 | goto dsaerr; | ||
135 | } | ||
136 | /* Handle Two broken types: | ||
137 | * SEQUENCE {parameters, priv_key} | ||
138 | * SEQUENCE {pub_key, priv_key} | ||
139 | */ | ||
140 | |||
141 | t1 = sk_ASN1_TYPE_value(ndsa, 0); | ||
142 | t2 = sk_ASN1_TYPE_value(ndsa, 1); | ||
143 | if(t1->type == V_ASN1_SEQUENCE) { | ||
144 | p8->broken = PKCS8_EMBEDDED_PARAM; | ||
145 | param = t1; | ||
146 | } else if(a->parameter->type == V_ASN1_SEQUENCE) { | ||
147 | p8->broken = PKCS8_NS_DB; | ||
148 | param = a->parameter; | ||
149 | } else { | ||
150 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
151 | goto dsaerr; | ||
152 | } | ||
153 | |||
154 | if(t2->type != V_ASN1_INTEGER) { | ||
155 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
156 | goto dsaerr; | ||
157 | } | ||
158 | privkey = t2->value.integer; | ||
159 | } else { | ||
160 | if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) { | ||
161 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
162 | goto dsaerr; | ||
163 | } | ||
164 | param = p8->pkeyalg->parameter; | ||
165 | } | ||
166 | if (!param || (param->type != V_ASN1_SEQUENCE)) { | ||
167 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
168 | goto dsaerr; | ||
169 | } | ||
170 | cp = p = param->value.sequence->data; | ||
171 | plen = param->value.sequence->length; | ||
172 | if (!(dsa = d2i_DSAparams (NULL, &cp, plen))) { | ||
173 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
174 | goto dsaerr; | ||
175 | } | ||
176 | /* We have parameters now set private key */ | ||
177 | if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { | ||
178 | EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR); | ||
179 | goto dsaerr; | ||
180 | } | ||
181 | /* Calculate public key (ouch!) */ | ||
182 | if (!(dsa->pub_key = BN_new())) { | ||
183 | EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); | ||
184 | goto dsaerr; | ||
185 | } | ||
186 | if (!(ctx = BN_CTX_new())) { | ||
187 | EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); | ||
188 | goto dsaerr; | ||
189 | } | ||
190 | |||
191 | if (!BN_mod_exp(dsa->pub_key, dsa->g, | ||
192 | dsa->priv_key, dsa->p, ctx)) { | ||
193 | |||
194 | EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR); | ||
195 | goto dsaerr; | ||
196 | } | ||
197 | |||
198 | EVP_PKEY_assign_DSA(pkey, dsa); | ||
199 | BN_CTX_free (ctx); | ||
200 | if(ndsa) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | ||
201 | else ASN1_INTEGER_free(privkey); | ||
202 | break; | ||
203 | dsaerr: | ||
204 | BN_CTX_free (ctx); | ||
205 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | ||
206 | DSA_free(dsa); | ||
207 | EVP_PKEY_free(pkey); | ||
208 | return NULL; | ||
209 | break; | ||
210 | #endif | ||
211 | default: | ||
212 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); | ||
213 | if (!a->algorithm) BUF_strlcpy (obj_tmp, "NULL", sizeof obj_tmp); | ||
214 | else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm); | ||
215 | ERR_add_error_data(2, "TYPE=", obj_tmp); | ||
216 | EVP_PKEY_free (pkey); | ||
217 | return NULL; | ||
218 | } | ||
219 | return pkey; | ||
220 | } | ||
221 | |||
222 | PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey) | ||
223 | { | ||
224 | return EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK); | ||
225 | } | ||
226 | |||
227 | /* Turn a private key into a PKCS8 structure */ | ||
228 | |||
229 | PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken) | ||
230 | { | ||
231 | PKCS8_PRIV_KEY_INFO *p8; | ||
232 | |||
233 | if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) { | ||
234 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
235 | return NULL; | ||
236 | } | ||
237 | p8->broken = broken; | ||
238 | if (!ASN1_INTEGER_set(p8->version, 0)) { | ||
239 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
240 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
241 | return NULL; | ||
242 | } | ||
243 | if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) { | ||
244 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
245 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
246 | return NULL; | ||
247 | } | ||
248 | p8->pkey->type = V_ASN1_OCTET_STRING; | ||
249 | switch (EVP_PKEY_type(pkey->type)) { | ||
250 | #ifndef OPENSSL_NO_RSA | ||
251 | case EVP_PKEY_RSA: | ||
252 | |||
253 | if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE; | ||
254 | |||
255 | p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption); | ||
256 | p8->pkeyalg->parameter->type = V_ASN1_NULL; | ||
257 | if (!ASN1_pack_string ((char *)pkey, i2d_PrivateKey, | ||
258 | &p8->pkey->value.octet_string)) { | ||
259 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
260 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
261 | return NULL; | ||
262 | } | ||
263 | break; | ||
264 | #endif | ||
265 | #ifndef OPENSSL_NO_DSA | ||
266 | case EVP_PKEY_DSA: | ||
267 | if(!dsa_pkey2pkcs8(p8, pkey)) { | ||
268 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
269 | return NULL; | ||
270 | } | ||
271 | |||
272 | break; | ||
273 | #endif | ||
274 | default: | ||
275 | EVPerr(EVP_F_EVP_PKEY2PKCS8, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); | ||
276 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
277 | return NULL; | ||
278 | } | ||
279 | RAND_add(p8->pkey->value.octet_string->data, | ||
280 | p8->pkey->value.octet_string->length, 0); | ||
281 | return p8; | ||
282 | } | ||
283 | |||
284 | PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken) | ||
285 | { | ||
286 | switch (broken) { | ||
287 | |||
288 | case PKCS8_OK: | ||
289 | p8->broken = PKCS8_OK; | ||
290 | return p8; | ||
291 | break; | ||
292 | |||
293 | case PKCS8_NO_OCTET: | ||
294 | p8->broken = PKCS8_NO_OCTET; | ||
295 | p8->pkey->type = V_ASN1_SEQUENCE; | ||
296 | return p8; | ||
297 | break; | ||
298 | |||
299 | default: | ||
300 | EVPerr(EVP_F_EVP_PKCS8_SET_BROKEN,EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE); | ||
301 | return NULL; | ||
302 | break; | ||
303 | |||
304 | } | ||
305 | } | ||
306 | |||
307 | #ifndef OPENSSL_NO_DSA | ||
308 | static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey) | ||
309 | { | ||
310 | ASN1_STRING *params = NULL; | ||
311 | ASN1_INTEGER *prkey = NULL; | ||
312 | ASN1_TYPE *ttmp = NULL; | ||
313 | STACK_OF(ASN1_TYPE) *ndsa = NULL; | ||
314 | unsigned char *p = NULL, *q; | ||
315 | int len; | ||
316 | |||
317 | p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa); | ||
318 | len = i2d_DSAparams (pkey->pkey.dsa, NULL); | ||
319 | if (!(p = OPENSSL_malloc(len))) { | ||
320 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
321 | goto err; | ||
322 | } | ||
323 | q = p; | ||
324 | i2d_DSAparams (pkey->pkey.dsa, &q); | ||
325 | if (!(params = ASN1_STRING_new())) { | ||
326 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
327 | goto err; | ||
328 | } | ||
329 | if (!ASN1_STRING_set(params, p, len)) { | ||
330 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
331 | goto err; | ||
332 | } | ||
333 | OPENSSL_free(p); | ||
334 | p = NULL; | ||
335 | /* Get private key into integer */ | ||
336 | if (!(prkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) { | ||
337 | EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR); | ||
338 | goto err; | ||
339 | } | ||
340 | |||
341 | switch(p8->broken) { | ||
342 | |||
343 | case PKCS8_OK: | ||
344 | case PKCS8_NO_OCTET: | ||
345 | |||
346 | if (!ASN1_pack_string((char *)prkey, i2d_ASN1_INTEGER, | ||
347 | &p8->pkey->value.octet_string)) { | ||
348 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
349 | goto err; | ||
350 | } | ||
351 | |||
352 | M_ASN1_INTEGER_free (prkey); | ||
353 | prkey = NULL; | ||
354 | p8->pkeyalg->parameter->value.sequence = params; | ||
355 | params = NULL; | ||
356 | p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE; | ||
357 | |||
358 | break; | ||
359 | |||
360 | case PKCS8_NS_DB: | ||
361 | |||
362 | p8->pkeyalg->parameter->value.sequence = params; | ||
363 | params = NULL; | ||
364 | p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE; | ||
365 | if (!(ndsa = sk_ASN1_TYPE_new_null())) { | ||
366 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
367 | goto err; | ||
368 | } | ||
369 | if (!(ttmp = ASN1_TYPE_new())) { | ||
370 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
371 | goto err; | ||
372 | } | ||
373 | if (!(ttmp->value.integer = | ||
374 | BN_to_ASN1_INTEGER(pkey->pkey.dsa->pub_key, NULL))) { | ||
375 | EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR); | ||
376 | goto err; | ||
377 | } | ||
378 | ttmp->type = V_ASN1_INTEGER; | ||
379 | if (!sk_ASN1_TYPE_push(ndsa, ttmp)) { | ||
380 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
381 | goto err; | ||
382 | } | ||
383 | |||
384 | if (!(ttmp = ASN1_TYPE_new())) { | ||
385 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
386 | goto err; | ||
387 | } | ||
388 | ttmp->value.integer = prkey; | ||
389 | prkey = NULL; | ||
390 | ttmp->type = V_ASN1_INTEGER; | ||
391 | if (!sk_ASN1_TYPE_push(ndsa, ttmp)) { | ||
392 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
393 | goto err; | ||
394 | } | ||
395 | ttmp = NULL; | ||
396 | |||
397 | if (!(p8->pkey->value.octet_string = ASN1_OCTET_STRING_new())) { | ||
398 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
399 | goto err; | ||
400 | } | ||
401 | |||
402 | if (!ASN1_seq_pack_ASN1_TYPE(ndsa, i2d_ASN1_TYPE, | ||
403 | &p8->pkey->value.octet_string->data, | ||
404 | &p8->pkey->value.octet_string->length)) { | ||
405 | |||
406 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
407 | goto err; | ||
408 | } | ||
409 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | ||
410 | break; | ||
411 | |||
412 | case PKCS8_EMBEDDED_PARAM: | ||
413 | |||
414 | p8->pkeyalg->parameter->type = V_ASN1_NULL; | ||
415 | if (!(ndsa = sk_ASN1_TYPE_new_null())) { | ||
416 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
417 | goto err; | ||
418 | } | ||
419 | if (!(ttmp = ASN1_TYPE_new())) { | ||
420 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
421 | goto err; | ||
422 | } | ||
423 | ttmp->value.sequence = params; | ||
424 | params = NULL; | ||
425 | ttmp->type = V_ASN1_SEQUENCE; | ||
426 | if (!sk_ASN1_TYPE_push(ndsa, ttmp)) { | ||
427 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
428 | goto err; | ||
429 | } | ||
430 | |||
431 | if (!(ttmp = ASN1_TYPE_new())) { | ||
432 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
433 | goto err; | ||
434 | } | ||
435 | ttmp->value.integer = prkey; | ||
436 | prkey = NULL; | ||
437 | ttmp->type = V_ASN1_INTEGER; | ||
438 | if (!sk_ASN1_TYPE_push(ndsa, ttmp)) { | ||
439 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
440 | goto err; | ||
441 | } | ||
442 | ttmp = NULL; | ||
443 | |||
444 | if (!(p8->pkey->value.octet_string = ASN1_OCTET_STRING_new())) { | ||
445 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
446 | goto err; | ||
447 | } | ||
448 | |||
449 | if (!ASN1_seq_pack_ASN1_TYPE(ndsa, i2d_ASN1_TYPE, | ||
450 | &p8->pkey->value.octet_string->data, | ||
451 | &p8->pkey->value.octet_string->length)) { | ||
452 | |||
453 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
454 | goto err; | ||
455 | } | ||
456 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | ||
457 | break; | ||
458 | } | ||
459 | return 1; | ||
460 | err: | ||
461 | if (p != NULL) OPENSSL_free(p); | ||
462 | if (params != NULL) ASN1_STRING_free(params); | ||
463 | if (prkey != NULL) M_ASN1_INTEGER_free(prkey); | ||
464 | if (ttmp != NULL) ASN1_TYPE_free(ttmp); | ||
465 | if (ndsa != NULL) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | ||
466 | return 0; | ||
467 | } | ||
468 | #endif | ||
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c index bb6f02c2e9..a624cfd248 100644 --- a/src/lib/libcrypto/evp/evp_test.c +++ b/src/lib/libcrypto/evp/evp_test.c | |||
@@ -52,7 +52,6 @@ | |||
52 | 52 | ||
53 | #include "../e_os.h" | 53 | #include "../e_os.h" |
54 | 54 | ||
55 | #include <openssl/opensslconf.h> | ||
56 | #include <openssl/evp.h> | 55 | #include <openssl/evp.h> |
57 | #ifndef OPENSSL_NO_ENGINE | 56 | #ifndef OPENSSL_NO_ENGINE |
58 | #include <openssl/engine.h> | 57 | #include <openssl/engine.h> |
@@ -137,7 +136,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
137 | const unsigned char *iv,int in, | 136 | const unsigned char *iv,int in, |
138 | const unsigned char *plaintext,int pn, | 137 | const unsigned char *plaintext,int pn, |
139 | const unsigned char *ciphertext,int cn, | 138 | const unsigned char *ciphertext,int cn, |
140 | int encdec) | 139 | int encdec,int multiplier) |
141 | { | 140 | { |
142 | EVP_CIPHER_CTX ctx; | 141 | EVP_CIPHER_CTX ctx; |
143 | unsigned char out[4096]; | 142 | unsigned char out[4096]; |
@@ -168,7 +167,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
168 | } | 167 | } |
169 | EVP_CIPHER_CTX_set_padding(&ctx,0); | 168 | EVP_CIPHER_CTX_set_padding(&ctx,0); |
170 | 169 | ||
171 | if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) | 170 | if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn*multiplier)) |
172 | { | 171 | { |
173 | fprintf(stderr,"Encrypt failed\n"); | 172 | fprintf(stderr,"Encrypt failed\n"); |
174 | ERR_print_errors_fp(stderr); | 173 | ERR_print_errors_fp(stderr); |
@@ -181,7 +180,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
181 | test1_exit(7); | 180 | test1_exit(7); |
182 | } | 181 | } |
183 | 182 | ||
184 | if(outl+outl2 != cn) | 183 | if(outl+outl2 != cn*multiplier) |
185 | { | 184 | { |
186 | fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", | 185 | fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", |
187 | outl+outl2,cn); | 186 | outl+outl2,cn); |
@@ -207,7 +206,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
207 | } | 206 | } |
208 | EVP_CIPHER_CTX_set_padding(&ctx,0); | 207 | EVP_CIPHER_CTX_set_padding(&ctx,0); |
209 | 208 | ||
210 | if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn)) | 209 | if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn*multiplier)) |
211 | { | 210 | { |
212 | fprintf(stderr,"Decrypt failed\n"); | 211 | fprintf(stderr,"Decrypt failed\n"); |
213 | ERR_print_errors_fp(stderr); | 212 | ERR_print_errors_fp(stderr); |
@@ -220,7 +219,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
220 | test1_exit(7); | 219 | test1_exit(7); |
221 | } | 220 | } |
222 | 221 | ||
223 | if(outl+outl2 != cn) | 222 | if(outl+outl2 != cn*multiplier) |
224 | { | 223 | { |
225 | fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", | 224 | fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", |
226 | outl+outl2,cn); | 225 | outl+outl2,cn); |
@@ -245,7 +244,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, | |||
245 | const unsigned char *iv,int in, | 244 | const unsigned char *iv,int in, |
246 | const unsigned char *plaintext,int pn, | 245 | const unsigned char *plaintext,int pn, |
247 | const unsigned char *ciphertext,int cn, | 246 | const unsigned char *ciphertext,int cn, |
248 | int encdec) | 247 | int encdec,int multiplier) |
249 | { | 248 | { |
250 | const EVP_CIPHER *c; | 249 | const EVP_CIPHER *c; |
251 | 250 | ||
@@ -253,7 +252,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, | |||
253 | if(!c) | 252 | if(!c) |
254 | return 0; | 253 | return 0; |
255 | 254 | ||
256 | test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec); | 255 | test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec,multiplier); |
257 | 256 | ||
258 | return 1; | 257 | return 1; |
259 | } | 258 | } |
@@ -369,6 +368,7 @@ int main(int argc,char **argv) | |||
369 | unsigned char *iv,*key,*plaintext,*ciphertext; | 368 | unsigned char *iv,*key,*plaintext,*ciphertext; |
370 | int encdec; | 369 | int encdec; |
371 | int kn,in,pn,cn; | 370 | int kn,in,pn,cn; |
371 | int multiplier=1; | ||
372 | 372 | ||
373 | if(!fgets((char *)line,sizeof line,f)) | 373 | if(!fgets((char *)line,sizeof line,f)) |
374 | break; | 374 | break; |
@@ -393,44 +393,17 @@ int main(int argc,char **argv) | |||
393 | pn=convert(plaintext); | 393 | pn=convert(plaintext); |
394 | cn=convert(ciphertext); | 394 | cn=convert(ciphertext); |
395 | 395 | ||
396 | if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec) | 396 | if(strchr(cipher,'*')) |
397 | { | ||
398 | p=cipher; | ||
399 | sstrsep(&p,"*"); | ||
400 | multiplier=atoi(sstrsep(&p,"*")); | ||
401 | } | ||
402 | |||
403 | if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec, | ||
404 | multiplier) | ||
397 | && !test_digest(cipher,plaintext,pn,ciphertext,cn)) | 405 | && !test_digest(cipher,plaintext,pn,ciphertext,cn)) |
398 | { | 406 | { |
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); | 407 | fprintf(stderr,"Can't find %s\n",cipher); |
435 | EXIT(3); | 408 | EXIT(3); |
436 | } | 409 | } |
diff --git a/src/lib/libcrypto/evp/evptests.txt b/src/lib/libcrypto/evp/evptests.txt index beb12144b6..dfe91a5bc0 100644 --- a/src/lib/libcrypto/evp/evptests.txt +++ b/src/lib/libcrypto/evp/evptests.txt | |||
@@ -92,7 +92,102 @@ AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000 | |||
92 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D | 92 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D |
93 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461 | 93 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461 |
94 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B | 94 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B |
95 | # We don't support CFB{1,8}-AESxxx.{En,De}crypt | 95 | |
96 | # CFB1-AES128.Encrypt | ||
97 | |||
98 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:00:00:1 | ||
99 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00020406080a0c0e10121416181a1c1e:80:80:1 | ||
100 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0004080c1014181c2024282c3034383d:80:80:1 | ||
101 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0008101820283038404850586068707b:00:00:1 | ||
102 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00102030405060708090a0b0c0d0e0f6:80:80:1 | ||
103 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0020406080a0c0e10121416181a1c1ed:00:00:1 | ||
104 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:004080c1014181c2024282c3034383da:80:00:1 | ||
105 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:008101820283038404850586068707b4:80:00:1 | ||
106 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f68:80:80:1 | ||
107 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:020406080a0c0e10121416181a1c1ed1:80:00:1 | ||
108 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:04080c1014181c2024282c3034383da2:00:80:1 | ||
109 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:08101820283038404850586068707b45:00:80:1 | ||
110 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:102030405060708090a0b0c0d0e0f68b:00:00:1 | ||
111 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:20406080a0c0e10121416181a1c1ed16:00:00:1 | ||
112 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:4080c1014181c2024282c3034383da2c:00:80:1 | ||
113 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:8101820283038404850586068707b459:80:80:1 | ||
114 | # all of the above packed into one... | ||
115 | # in: 0110 1011 1100 0001 = 6bc1 | ||
116 | # out: 0110 1000 1011 0011 = 68b3 | ||
117 | AES-128-CFB1*8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1:68b3:1 | ||
118 | |||
119 | # CFB1-AES128.Decrypt | ||
120 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:00:00:0 | ||
121 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00020406080a0c0e10121416181a1c1e:80:80:0 | ||
122 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0004080c1014181c2024282c3034383d:80:80:0 | ||
123 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0008101820283038404850586068707b:00:00:0 | ||
124 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:00102030405060708090a0b0c0d0e0f6:80:80:0 | ||
125 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0020406080a0c0e10121416181a1c1ed:00:00:0 | ||
126 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:004080c1014181c2024282c3034383da:80:00:0 | ||
127 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:008101820283038404850586068707b4:80:00:0 | ||
128 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f68:80:80:0 | ||
129 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:020406080a0c0e10121416181a1c1ed1:80:00:0 | ||
130 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:04080c1014181c2024282c3034383da2:00:80:0 | ||
131 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:08101820283038404850586068707b45:00:80:0 | ||
132 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:102030405060708090a0b0c0d0e0f68b:00:00:0 | ||
133 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:20406080a0c0e10121416181a1c1ed16:00:00:0 | ||
134 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:4080c1014181c2024282c3034383da2c:00:80:0 | ||
135 | AES-128-CFB1:2b7e151628aed2a6abf7158809cf4f3c:8101820283038404850586068707b459:80:80:0 | ||
136 | # all of the above packed into one... | ||
137 | # in: 0110 1000 1011 0011 = 68b3 | ||
138 | # out: 0110 1011 1100 0001 = 6bc1 | ||
139 | AES-128-CFB1*8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1:68b3:0 | ||
140 | |||
141 | # TODO: CFB1-AES192 and 256 | ||
142 | |||
143 | # CFB8-AES128.Encrypt | ||
144 | |||
145 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6b:3b:1 | ||
146 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f3b:c1:79:1 | ||
147 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:02030405060708090a0b0c0d0e0f3b79:be:42:1 | ||
148 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:030405060708090a0b0c0d0e0f3b7942:e2:4c:1 | ||
149 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0405060708090a0b0c0d0e0f3b79424c:2e:9c:1 | ||
150 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:05060708090a0b0c0d0e0f3b79424c9c:40:0d:1 | ||
151 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:060708090a0b0c0d0e0f3b79424c9c0d:9f:d4:1 | ||
152 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0708090a0b0c0d0e0f3b79424c9c0dd4:96:36:1 | ||
153 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:08090a0b0c0d0e0f3b79424c9c0dd436:e9:ba:1 | ||
154 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:090a0b0c0d0e0f3b79424c9c0dd436ba:3d:ce:1 | ||
155 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0a0b0c0d0e0f3b79424c9c0dd436bace:7e:9e:1 | ||
156 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0b0c0d0e0f3b79424c9c0dd436bace9e:11:0e:1 | ||
157 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0c0d0e0f3b79424c9c0dd436bace9e0e:73:d4:1 | ||
158 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0d0e0f3b79424c9c0dd436bace9e0ed4:93:58:1 | ||
159 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0e0f3b79424c9c0dd436bace9e0ed458:17:6a:1 | ||
160 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0f3b79424c9c0dd436bace9e0ed4586a:2a:4f:1 | ||
161 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:3b79424c9c0dd436bace9e0ed4586a4f:ae:32:1 | ||
162 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:79424c9c0dd436bace9e0ed4586a4f32:2d:b9:1 | ||
163 | # all of the above packed into one | ||
164 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1bee22e409f96e93d7e117393172aae2d:3b79424c9c0dd436bace9e0ed4586a4f32b9:1 | ||
165 | |||
166 | # CFB8-AES128.Decrypt | ||
167 | |||
168 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6b:3b:0 | ||
169 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f3b:c1:79:0 | ||
170 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:02030405060708090a0b0c0d0e0f3b79:be:42:0 | ||
171 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:030405060708090a0b0c0d0e0f3b7942:e2:4c:0 | ||
172 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0405060708090a0b0c0d0e0f3b79424c:2e:9c:0 | ||
173 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:05060708090a0b0c0d0e0f3b79424c9c:40:0d:0 | ||
174 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:060708090a0b0c0d0e0f3b79424c9c0d:9f:d4:0 | ||
175 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0708090a0b0c0d0e0f3b79424c9c0dd4:96:36:0 | ||
176 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:08090a0b0c0d0e0f3b79424c9c0dd436:e9:ba:0 | ||
177 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:090a0b0c0d0e0f3b79424c9c0dd436ba:3d:ce:0 | ||
178 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0a0b0c0d0e0f3b79424c9c0dd436bace:7e:9e:0 | ||
179 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0b0c0d0e0f3b79424c9c0dd436bace9e:11:0e:0 | ||
180 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0c0d0e0f3b79424c9c0dd436bace9e0e:73:d4:0 | ||
181 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0d0e0f3b79424c9c0dd436bace9e0ed4:93:58:0 | ||
182 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0e0f3b79424c9c0dd436bace9e0ed458:17:6a:0 | ||
183 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0f3b79424c9c0dd436bace9e0ed4586a:2a:4f:0 | ||
184 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:3b79424c9c0dd436bace9e0ed4586a4f:ae:32:0 | ||
185 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:79424c9c0dd436bace9e0ed4586a4f32:2d:b9:0 | ||
186 | # all of the above packed into one | ||
187 | AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1bee22e409f96e93d7e117393172aae2d:3b79424c9c0dd436bace9e0ed4586a4f32b9:0 | ||
188 | |||
189 | # TODO: 192 and 256 bit keys | ||
190 | |||
96 | # For all CFB128 encrypts and decrypts, the transformed sequence is | 191 | # For all CFB128 encrypts and decrypts, the transformed sequence is |
97 | # AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec | 192 | # AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec |
98 | # CFB128-AES128.Encrypt | 193 | # CFB128-AES128.Encrypt |
@@ -174,6 +269,16 @@ DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363 | |||
174 | # DES EDE3 CBC tests (from destest) | 269 | # DES EDE3 CBC tests (from destest) |
175 | DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675 | 270 | DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675 |
176 | 271 | ||
272 | # DES CFB1 from FIPS 81 | ||
273 | # plaintext: 0100 1110 0110 1111 0111 0111 = 4e6f77 | ||
274 | # ciphertext: 1100 1101 0001 1110 1100 1001 = cd1ec9 | ||
275 | |||
276 | DES-CFB1*8:0123456789abcdef:1234567890abcdef:4e6f77:cd1ec9 | ||
277 | |||
278 | # DES CFB8 from FIPS 81 | ||
279 | |||
280 | DES-CFB8:0123456789abcdef:1234567890abcdef:4e6f7720697320746865:f31fda07011462ee187f | ||
281 | |||
177 | # RC4 tests (from rc4test) | 282 | # RC4 tests (from rc4test) |
178 | RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596 | 283 | RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596 |
179 | RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879 | 284 | RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879 |
@@ -181,141 +286,3 @@ RC4:00000000000000000000000000000000::0000000000000000:de188941a3375d3a | |||
181 | RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858 | 286 | RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858 |
182 | RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf | 287 | RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf |
183 | RC4:ef012345ef012345ef012345ef012345::00000000000000000000:d6a141a7ec3c38dfbd61 | 288 | RC4: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 | ||
189 | CAMELLIA-128-ECB:0123456789abcdeffedcba9876543210::0123456789abcdeffedcba9876543210:67673138549669730857065648eabe43 | ||
190 | CAMELLIA-192-ECB:0123456789abcdeffedcba98765432100011223344556677::0123456789abcdeffedcba9876543210:b4993401b3e996f84ee5cee7d79b09b9 | ||
191 | CAMELLIA-256-ECB:0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff::0123456789abcdeffedcba9876543210:9acc237dff16d76c20ef7c919e3a7509 | ||
192 | |||
193 | # ECB-CAMELLIA128.Encrypt | ||
194 | CAMELLIA-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:77CF412067AF8270613529149919546F:1 | ||
195 | CAMELLIA-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:B22F3C36B72D31329EEE8ADDC2906C68:1 | ||
196 | CAMELLIA-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:2EDF1F3418D53B88841FC8985FB1ECF2:1 | ||
197 | |||
198 | # ECB-CAMELLIA128.Encrypt and ECB-CAMELLIA128.Decrypt | ||
199 | CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:432FC5DCD628115B7C388D770B270C96 | ||
200 | CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:0BE1F14023782A22E8384C5ABB7FAB2B | ||
201 | CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:A0A1ABCD1893AB6FE0FE5B65DF5F8636 | ||
202 | CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:E61925E0D5DFAA9BB29F815B3076E51A | ||
203 | |||
204 | # ECB-CAMELLIA192.Encrypt and ECB-CAMELLIA192.Decrypt | ||
205 | CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:CCCC6C4E138B45848514D48D0D3439D3 | ||
206 | CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:5713C62C14B2EC0F8393B6AFD6F5785A | ||
207 | CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:B40ED2B60EB54D09D030CF511FEEF366 | ||
208 | CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:909DBD95799096748CB27357E73E1D26 | ||
209 | |||
210 | # ECB-CAMELLIA256.Encrypt and ECB-CAMELLIA256.Decrypt | ||
211 | CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:BEFD219B112FA00098919CD101C9CCFA | ||
212 | CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:C91D3A8F1AEA08A9386CF4B66C0169EA | ||
213 | CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:A623D711DC5F25A51BB8A80D56397D28 | ||
214 | CAMELLIA-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 | ||
219 | CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:1607CF494B36BBF00DAEB0B503C831AB | ||
220 | CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:1607CF494B36BBF00DAEB0B503C831AB:AE2D8A571E03AC9C9EB76FAC45AF8E51:A2F2CF671629EF7840C5A5DFB5074887 | ||
221 | CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:A2F2CF671629EF7840C5A5DFB5074887:30C81C46A35CE411E5FBC1191A0A52EF:0F06165008CF8B8B5A63586362543E54 | ||
222 | CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:36A84CDAFD5F9A85ADA0F0A993D6D577:F69F2445DF4F9B17AD2B417BE66C3710:74C64268CDB8B8FAF5B34E8AF3732980 | ||
223 | |||
224 | # CBC-CAMELLIA192.Encrypt and CBC-CAMELLIA192.Decrypt | ||
225 | CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:2A4830AB5AC4A1A2405955FD2195CF93 | ||
226 | CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2A4830AB5AC4A1A2405955FD2195CF93:AE2D8A571E03AC9C9EB76FAC45AF8E51:5D5A869BD14CE54264F892A6DD2EC3D5 | ||
227 | CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:5D5A869BD14CE54264F892A6DD2EC3D5:30C81C46A35CE411E5FBC1191A0A52EF:37D359C3349836D884E310ADDF68C449 | ||
228 | CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:37D359C3349836D884E310ADDF68C449:F69F2445DF4F9B17AD2B417BE66C3710:01FAAA930B4AB9916E9668E1428C6B08 | ||
229 | |||
230 | # CBC-CAMELLIA256.Encrypt and CBC-CAMELLIA256.Decrypt | ||
231 | CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:E6CFA35FC02B134A4D2C0B6737AC3EDA | ||
232 | CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E6CFA35FC02B134A4D2C0B6737AC3EDA:AE2D8A571E03AC9C9EB76FAC45AF8E51:36CBEB73BD504B4070B1B7DE2B21EB50 | ||
233 | CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:36CBEB73BD504B4070B1B7DE2B21EB50:30C81C46A35CE411E5FBC1191A0A52EF:E31A6055297D96CA3330CDF1B1860A83 | ||
234 | CAMELLIA-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 | ||
240 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:1 | ||
241 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:14F7646187817EB586599146B82BD719:AE2D8A571E03AC9C9EB76FAC45AF8E51:A53D28BB82DF741103EA4F921A44880B:1 | ||
242 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:A53D28BB82DF741103EA4F921A44880B:30C81C46A35CE411E5FBC1191A0A52EF:9C2157A664626D1DEF9EA420FDE69B96:1 | ||
243 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:9C2157A664626D1DEF9EA420FDE69B96:F69F2445DF4F9B17AD2B417BE66C3710:742A25F0542340C7BAEF24CA8482BB09:1 | ||
244 | |||
245 | # CFB128-CAMELLIA128.Decrypt | ||
246 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:0 | ||
247 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:14F7646187817EB586599146B82BD719:AE2D8A571E03AC9C9EB76FAC45AF8E51:A53D28BB82DF741103EA4F921A44880B:0 | ||
248 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:A53D28BB82DF741103EA4F921A44880B:30C81C46A35CE411E5FBC1191A0A52EF:9C2157A664626D1DEF9EA420FDE69B96:0 | ||
249 | CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:9C2157A664626D1DEF9EA420FDE69B96:F69F2445DF4F9B17AD2B417BE66C3710:742A25F0542340C7BAEF24CA8482BB09:0 | ||
250 | |||
251 | # CFB128-CAMELLIA192.Encrypt | ||
252 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:1 | ||
253 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:C832BB9780677DAA82D9B6860DCD565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:86F8491627906D780C7A6D46EA331F98:1 | ||
254 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:86F8491627906D780C7A6D46EA331F98:30C81C46A35CE411E5FBC1191A0A52EF:69511CCE594CF710CB98BB63D7221F01:1 | ||
255 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:69511CCE594CF710CB98BB63D7221F01:F69F2445DF4F9B17AD2B417BE66C3710:D5B5378A3ABED55803F25565D8907B84:1 | ||
256 | |||
257 | # CFB128-CAMELLIA192.Decrypt | ||
258 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:0 | ||
259 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:C832BB9780677DAA82D9B6860DCD565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:86F8491627906D780C7A6D46EA331F98:0 | ||
260 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:86F8491627906D780C7A6D46EA331F98:30C81C46A35CE411E5FBC1191A0A52EF:69511CCE594CF710CB98BB63D7221F01:0 | ||
261 | CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:69511CCE594CF710CB98BB63D7221F01:F69F2445DF4F9B17AD2B417BE66C3710:D5B5378A3ABED55803F25565D8907B84:0 | ||
262 | |||
263 | # CFB128-CAMELLIA256.Encrypt | ||
264 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:1 | ||
265 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:CF6107BB0CEA7D7FB1BD31F5E7B06C93:AE2D8A571E03AC9C9EB76FAC45AF8E51:89BEDB4CCDD864EA11BA4CBE849B5E2B:1 | ||
266 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:89BEDB4CCDD864EA11BA4CBE849B5E2B:30C81C46A35CE411E5FBC1191A0A52EF:555FC3F34BDD2D54C62D9E3BF338C1C4:1 | ||
267 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:555FC3F34BDD2D54C62D9E3BF338C1C4:F69F2445DF4F9B17AD2B417BE66C3710:5953ADCE14DB8C7F39F1BD39F359BFFA:1 | ||
268 | |||
269 | # CFB128-CAMELLIA256.Decrypt | ||
270 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:0 | ||
271 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:CF6107BB0CEA7D7FB1BD31F5E7B06C93:AE2D8A571E03AC9C9EB76FAC45AF8E51:89BEDB4CCDD864EA11BA4CBE849B5E2B:0 | ||
272 | CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:89BEDB4CCDD864EA11BA4CBE849B5E2B:30C81C46A35CE411E5FBC1191A0A52EF:555FC3F34BDD2D54C62D9E3BF338C1C4:0 | ||
273 | CAMELLIA-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 | ||
278 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:1 | ||
279 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:25623DB569CA51E01482649977E28D84:1 | ||
280 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:C776634A60729DC657D12B9FCA801E98:1 | ||
281 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:D776379BE0E50825E681DA1A4C980E8E:1 | ||
282 | |||
283 | # OFB-CAMELLIA128.Decrypt | ||
284 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:0 | ||
285 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:25623DB569CA51E01482649977E28D84:0 | ||
286 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:C776634A60729DC657D12B9FCA801E98:0 | ||
287 | CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:D776379BE0E50825E681DA1A4C980E8E:0 | ||
288 | |||
289 | # OFB-CAMELLIA192.Encrypt | ||
290 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:1 | ||
291 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:8ECEB7D0350D72C7F78562AEBDF99339:1 | ||
292 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:BDD62DBBB9700846C53B507F544696F0:1 | ||
293 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:E28014E046B802F385C4C2E13EAD4A72:1 | ||
294 | |||
295 | # OFB-CAMELLIA192.Decrypt | ||
296 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:0 | ||
297 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:8ECEB7D0350D72C7F78562AEBDF99339:0 | ||
298 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:BDD62DBBB9700846C53B507F544696F0:0 | ||
299 | CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:E28014E046B802F385C4C2E13EAD4A72:0 | ||
300 | |||
301 | # OFB-CAMELLIA256.Encrypt | ||
302 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:1 | ||
303 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:127AD97E8E3994E4820027D7BA109368:1 | ||
304 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:6BFF6265A6A6B7A535BC65A80B17214E:1 | ||
305 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0A4A0404E26AA78A27CB271E8BF3CF20:1 | ||
306 | |||
307 | # OFB-CAMELLIA256.Decrypt | ||
308 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:0 | ||
309 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:127AD97E8E3994E4820027D7BA109368:0 | ||
310 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:6BFF6265A6A6B7A535BC65A80B17214E:0 | ||
311 | CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0A4A0404E26AA78A27CB271E8BF3CF20:0 | ||
312 | |||
313 | # SEED test vectors from RFC4269 | ||
314 | SEED-ECB:00000000000000000000000000000000::000102030405060708090A0B0C0D0E0F:5EBAC6E0054E166819AFF1CC6D346CDB:0 | ||
315 | SEED-ECB:000102030405060708090A0B0C0D0E0F::00000000000000000000000000000000:C11F22F20140505084483597E4370F43:0 | ||
316 | SEED-ECB:4706480851E61BE85D74BFB3FD956185::83A2F8A288641FB9A4E9A5CC2F131C7D:EE54D13EBCAE706D226BC3142CD40D4A:0 | ||
317 | SEED-ECB:28DBC3BC49FFD87DCFA509B11D422BE7::B41E6BE2EBA84A148E2EED84593C5EC7:9B9B7BFCD1813CB95D0B3618F40F5122:0 | ||
318 | SEED-ECB:00000000000000000000000000000000::000102030405060708090A0B0C0D0E0F:5EBAC6E0054E166819AFF1CC6D346CDB:1 | ||
319 | SEED-ECB:000102030405060708090A0B0C0D0E0F::00000000000000000000000000000000:C11F22F20140505084483597E4370F43:1 | ||
320 | SEED-ECB:4706480851E61BE85D74BFB3FD956185::83A2F8A288641FB9A4E9A5CC2F131C7D:EE54D13EBCAE706D226BC3142CD40D4A:1 | ||
321 | SEED-ECB:28DBC3BC49FFD87DCFA509B11D422BE7::B41E6BE2EBA84A148E2EED84593C5EC7:9B9B7BFCD1813CB95D0B3618F40F5122:1 | ||
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c new file mode 100644 index 0000000000..d393eb3400 --- /dev/null +++ b/src/lib/libcrypto/evp/m_dss.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* crypto/evp/m_dss.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 | |||
65 | #ifndef OPENSSL_NO_SHA | ||
66 | static int init(EVP_MD_CTX *ctx) | ||
67 | { return SHA1_Init(ctx->md_data); } | ||
68 | |||
69 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
70 | { return SHA1_Update(ctx->md_data,data,count); } | ||
71 | |||
72 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
73 | { return SHA1_Final(md,ctx->md_data); } | ||
74 | |||
75 | static const EVP_MD dsa_md= | ||
76 | { | ||
77 | NID_dsaWithSHA, | ||
78 | NID_dsaWithSHA, | ||
79 | SHA_DIGEST_LENGTH, | ||
80 | EVP_MD_FLAG_FIPS, | ||
81 | init, | ||
82 | update, | ||
83 | final, | ||
84 | NULL, | ||
85 | NULL, | ||
86 | EVP_PKEY_DSA_method, | ||
87 | SHA_CBLOCK, | ||
88 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
89 | }; | ||
90 | |||
91 | const EVP_MD *EVP_dss(void) | ||
92 | { | ||
93 | return(&dsa_md); | ||
94 | } | ||
95 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c new file mode 100644 index 0000000000..23b90d0538 --- /dev/null +++ b/src/lib/libcrypto/evp/m_dss1.c | |||
@@ -0,0 +1,102 @@ | |||
1 | /* crypto/evp/m_dss1.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 | #ifndef OPENSSL_NO_SHA | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/objects.h> | ||
64 | #include <openssl/x509.h> | ||
65 | |||
66 | static int init(EVP_MD_CTX *ctx) | ||
67 | { return SHA1_Init(ctx->md_data); } | ||
68 | |||
69 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
70 | #ifndef OPENSSL_FIPS | ||
71 | { return SHA1_Update(ctx->md_data,data,count); } | ||
72 | #else | ||
73 | { | ||
74 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
75 | return SHA1_Update(ctx->md_data,data,count); | ||
76 | } | ||
77 | #endif | ||
78 | |||
79 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
80 | { return SHA1_Final(md,ctx->md_data); } | ||
81 | |||
82 | static const EVP_MD dss1_md= | ||
83 | { | ||
84 | NID_dsa, | ||
85 | NID_dsaWithSHA1, | ||
86 | SHA_DIGEST_LENGTH, | ||
87 | EVP_MD_FLAG_FIPS, | ||
88 | init, | ||
89 | update, | ||
90 | final, | ||
91 | NULL, | ||
92 | NULL, | ||
93 | EVP_PKEY_DSA_method, | ||
94 | SHA_CBLOCK, | ||
95 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
96 | }; | ||
97 | |||
98 | const EVP_MD *EVP_dss1(void) | ||
99 | { | ||
100 | return(&dss1_md); | ||
101 | } | ||
102 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c index 5ce849f161..0df48e5199 100644 --- a/src/lib/libcrypto/evp/m_md2.c +++ b/src/lib/libcrypto/evp/m_md2.c | |||
@@ -56,23 +56,19 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_MD2 | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | |||
62 | #ifndef OPENSSL_NO_MD2 | ||
63 | |||
64 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
63 | #include "evp_locl.h" | ||
65 | #include <openssl/objects.h> | 64 | #include <openssl/objects.h> |
66 | #include <openssl/x509.h> | 65 | #include <openssl/x509.h> |
67 | #include <openssl/md2.h> | 66 | #include <openssl/md2.h> |
68 | #ifndef OPENSSL_NO_RSA | ||
69 | #include <openssl/rsa.h> | ||
70 | #endif | ||
71 | 67 | ||
72 | static int init(EVP_MD_CTX *ctx) | 68 | static int init(EVP_MD_CTX *ctx) |
73 | { return MD2_Init(ctx->md_data); } | 69 | { return MD2_Init(ctx->md_data); } |
74 | 70 | ||
75 | static int update(EVP_MD_CTX *ctx,const void *data,size_t count) | 71 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) |
76 | { return MD2_Update(ctx->md_data,data,count); } | 72 | { return MD2_Update(ctx->md_data,data,count); } |
77 | 73 | ||
78 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | 74 | static int final(EVP_MD_CTX *ctx,unsigned char *md) |
diff --git a/src/lib/libcrypto/evp/m_md4.c b/src/lib/libcrypto/evp/m_md4.c new file mode 100644 index 0000000000..0605e4b707 --- /dev/null +++ b/src/lib/libcrypto/evp/m_md4.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* crypto/evp/m_md4.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 | #ifndef OPENSSL_NO_MD4 | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include "evp_locl.h" | ||
64 | #include <openssl/objects.h> | ||
65 | #include <openssl/x509.h> | ||
66 | #include <openssl/md4.h> | ||
67 | |||
68 | static int init(EVP_MD_CTX *ctx) | ||
69 | { return MD4_Init(ctx->md_data); } | ||
70 | |||
71 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
72 | { return MD4_Update(ctx->md_data,data,count); } | ||
73 | |||
74 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
75 | { return MD4_Final(md,ctx->md_data); } | ||
76 | |||
77 | static const EVP_MD md4_md= | ||
78 | { | ||
79 | NID_md4, | ||
80 | NID_md4WithRSAEncryption, | ||
81 | MD4_DIGEST_LENGTH, | ||
82 | 0, | ||
83 | init, | ||
84 | update, | ||
85 | final, | ||
86 | NULL, | ||
87 | NULL, | ||
88 | EVP_PKEY_RSA_method, | ||
89 | MD4_CBLOCK, | ||
90 | sizeof(EVP_MD *)+sizeof(MD4_CTX), | ||
91 | }; | ||
92 | |||
93 | const EVP_MD *EVP_md4(void) | ||
94 | { | ||
95 | return(&md4_md); | ||
96 | } | ||
97 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c new file mode 100644 index 0000000000..752615d473 --- /dev/null +++ b/src/lib/libcrypto/evp/m_md5.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* crypto/evp/m_md5.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 | #ifndef OPENSSL_NO_MD5 | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include "evp_locl.h" | ||
64 | #include <openssl/objects.h> | ||
65 | #include <openssl/x509.h> | ||
66 | #include <openssl/md5.h> | ||
67 | |||
68 | static int init(EVP_MD_CTX *ctx) | ||
69 | { return MD5_Init(ctx->md_data); } | ||
70 | |||
71 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
72 | { return MD5_Update(ctx->md_data,data,count); } | ||
73 | |||
74 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
75 | { return MD5_Final(md,ctx->md_data); } | ||
76 | |||
77 | static const EVP_MD md5_md= | ||
78 | { | ||
79 | NID_md5, | ||
80 | NID_md5WithRSAEncryption, | ||
81 | MD5_DIGEST_LENGTH, | ||
82 | 0, | ||
83 | init, | ||
84 | update, | ||
85 | final, | ||
86 | NULL, | ||
87 | NULL, | ||
88 | EVP_PKEY_RSA_method, | ||
89 | MD5_CBLOCK, | ||
90 | sizeof(EVP_MD *)+sizeof(MD5_CTX), | ||
91 | }; | ||
92 | |||
93 | const EVP_MD *EVP_md5(void) | ||
94 | { | ||
95 | return(&md5_md); | ||
96 | } | ||
97 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c index 36c4e9b134..62de1336b8 100644 --- a/src/lib/libcrypto/evp/m_mdc2.c +++ b/src/lib/libcrypto/evp/m_mdc2.c | |||
@@ -56,21 +56,19 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_MDC2 | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | |||
62 | #ifndef OPENSSL_NO_MDC2 | ||
63 | |||
64 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
63 | #include "evp_locl.h" | ||
65 | #include <openssl/objects.h> | 64 | #include <openssl/objects.h> |
66 | #include <openssl/x509.h> | 65 | #include <openssl/x509.h> |
67 | #include <openssl/mdc2.h> | 66 | #include <openssl/mdc2.h> |
68 | #include <openssl/rsa.h> | ||
69 | 67 | ||
70 | static int init(EVP_MD_CTX *ctx) | 68 | static int init(EVP_MD_CTX *ctx) |
71 | { return MDC2_Init(ctx->md_data); } | 69 | { return MDC2_Init(ctx->md_data); } |
72 | 70 | ||
73 | static int update(EVP_MD_CTX *ctx,const void *data,size_t count) | 71 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) |
74 | { return MDC2_Update(ctx->md_data,data,count); } | 72 | { return MDC2_Update(ctx->md_data,data,count); } |
75 | 73 | ||
76 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | 74 | static int final(EVP_MD_CTX *ctx,unsigned char *md) |
diff --git a/src/lib/libcrypto/evp/m_null.c b/src/lib/libcrypto/evp/m_null.c new file mode 100644 index 0000000000..f6f0a1d2c0 --- /dev/null +++ b/src/lib/libcrypto/evp/m_null.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* crypto/evp/m_null.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 | |||
65 | static int init(EVP_MD_CTX *ctx) | ||
66 | { return 1; } | ||
67 | |||
68 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
69 | { return 1; } | ||
70 | |||
71 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
72 | { return 1; } | ||
73 | |||
74 | static const EVP_MD null_md= | ||
75 | { | ||
76 | NID_undef, | ||
77 | NID_undef, | ||
78 | 0, | ||
79 | 0, | ||
80 | init, | ||
81 | update, | ||
82 | final, | ||
83 | NULL, | ||
84 | NULL, | ||
85 | EVP_PKEY_NULL_method, | ||
86 | 0, | ||
87 | sizeof(EVP_MD *), | ||
88 | }; | ||
89 | |||
90 | const EVP_MD *EVP_md_null(void) | ||
91 | { | ||
92 | return(&null_md); | ||
93 | } | ||
94 | |||
95 | |||
diff --git a/src/lib/libcrypto/evp/m_ripemd.c b/src/lib/libcrypto/evp/m_ripemd.c new file mode 100644 index 0000000000..64725528dc --- /dev/null +++ b/src/lib/libcrypto/evp/m_ripemd.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* crypto/evp/m_ripemd.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 | #ifndef OPENSSL_NO_RIPEMD | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/ripemd.h> | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/objects.h> | ||
65 | #include <openssl/x509.h> | ||
66 | |||
67 | static int init(EVP_MD_CTX *ctx) | ||
68 | { return RIPEMD160_Init(ctx->md_data); } | ||
69 | |||
70 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
71 | { return RIPEMD160_Update(ctx->md_data,data,count); } | ||
72 | |||
73 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
74 | { return RIPEMD160_Final(md,ctx->md_data); } | ||
75 | |||
76 | static const EVP_MD ripemd160_md= | ||
77 | { | ||
78 | NID_ripemd160, | ||
79 | NID_ripemd160WithRSA, | ||
80 | RIPEMD160_DIGEST_LENGTH, | ||
81 | 0, | ||
82 | init, | ||
83 | update, | ||
84 | final, | ||
85 | NULL, | ||
86 | NULL, | ||
87 | EVP_PKEY_RSA_method, | ||
88 | RIPEMD160_CBLOCK, | ||
89 | sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX), | ||
90 | }; | ||
91 | |||
92 | const EVP_MD *EVP_ripemd160(void) | ||
93 | { | ||
94 | return(&ripemd160_md); | ||
95 | } | ||
96 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c index acccc8f92d..ed54909b16 100644 --- a/src/lib/libcrypto/evp/m_sha.c +++ b/src/lib/libcrypto/evp/m_sha.c | |||
@@ -56,22 +56,21 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0) | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | 62 | /* Including sha.h prior evp.h masks FIPS SHA declarations, but that's | |
62 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0) | 63 | * exactly what we want to achieve here... */ |
63 | 64 | #include <openssl/sha.h> | |
64 | #include <openssl/evp.h> | 65 | #include <openssl/evp.h> |
66 | #include "evp_locl.h" | ||
65 | #include <openssl/objects.h> | 67 | #include <openssl/objects.h> |
66 | #include <openssl/x509.h> | 68 | #include <openssl/x509.h> |
67 | #ifndef OPENSSL_NO_RSA | ||
68 | #include <openssl/rsa.h> | ||
69 | #endif | ||
70 | 69 | ||
71 | static int init(EVP_MD_CTX *ctx) | 70 | static int init(EVP_MD_CTX *ctx) |
72 | { return SHA_Init(ctx->md_data); } | 71 | { return SHA_Init(ctx->md_data); } |
73 | 72 | ||
74 | static int update(EVP_MD_CTX *ctx,const void *data,size_t count) | 73 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) |
75 | { return SHA_Update(ctx->md_data,data,count); } | 74 | { return SHA_Update(ctx->md_data,data,count); } |
76 | 75 | ||
77 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | 76 | static int final(EVP_MD_CTX *ctx,unsigned char *md) |
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c new file mode 100644 index 0000000000..60da93873c --- /dev/null +++ b/src/lib/libcrypto/evp/m_sha1.c | |||
@@ -0,0 +1,214 @@ | |||
1 | /* crypto/evp/m_sha1.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 | #ifndef OPENSSL_NO_SHA | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/objects.h> | ||
64 | #include <openssl/x509.h> | ||
65 | |||
66 | static int init(EVP_MD_CTX *ctx) | ||
67 | { return SHA1_Init(ctx->md_data); } | ||
68 | |||
69 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
70 | #ifndef OPENSSL_FIPS | ||
71 | { return SHA1_Update(ctx->md_data,data,count); } | ||
72 | #else | ||
73 | { | ||
74 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
75 | return SHA1_Update(ctx->md_data,data,count); | ||
76 | } | ||
77 | #endif | ||
78 | |||
79 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
80 | { return SHA1_Final(md,ctx->md_data); } | ||
81 | |||
82 | static const EVP_MD sha1_md= | ||
83 | { | ||
84 | NID_sha1, | ||
85 | NID_sha1WithRSAEncryption, | ||
86 | SHA_DIGEST_LENGTH, | ||
87 | EVP_MD_FLAG_FIPS, | ||
88 | init, | ||
89 | update, | ||
90 | final, | ||
91 | NULL, | ||
92 | NULL, | ||
93 | EVP_PKEY_RSA_method, | ||
94 | SHA_CBLOCK, | ||
95 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
96 | }; | ||
97 | |||
98 | const EVP_MD *EVP_sha1(void) | ||
99 | { | ||
100 | return(&sha1_md); | ||
101 | } | ||
102 | #endif | ||
103 | |||
104 | #ifdef OPENSSL_FIPS | ||
105 | #ifndef OPENSSL_NO_SHA256 | ||
106 | static int init224(EVP_MD_CTX *ctx) | ||
107 | { return SHA224_Init(ctx->md_data); } | ||
108 | static int init256(EVP_MD_CTX *ctx) | ||
109 | { return SHA256_Init(ctx->md_data); } | ||
110 | /* | ||
111 | * Even though there're separate SHA224_[Update|Final], we call | ||
112 | * SHA256 functions even in SHA224 context. This is what happens | ||
113 | * there anyway, so we can spare few CPU cycles:-) | ||
114 | */ | ||
115 | static int update256(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
116 | { | ||
117 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
118 | return SHA256_Update(ctx->md_data,data,count); | ||
119 | } | ||
120 | static int final256(EVP_MD_CTX *ctx,unsigned char *md) | ||
121 | { return SHA256_Final(md,ctx->md_data); } | ||
122 | |||
123 | static const EVP_MD sha224_md= | ||
124 | { | ||
125 | NID_sha224, | ||
126 | NID_sha224WithRSAEncryption, | ||
127 | SHA224_DIGEST_LENGTH, | ||
128 | EVP_MD_FLAG_FIPS, | ||
129 | init224, | ||
130 | update256, | ||
131 | final256, | ||
132 | NULL, | ||
133 | NULL, | ||
134 | EVP_PKEY_RSA_method, | ||
135 | SHA256_CBLOCK, | ||
136 | sizeof(EVP_MD *)+sizeof(SHA256_CTX), | ||
137 | }; | ||
138 | |||
139 | const EVP_MD *EVP_sha224(void) | ||
140 | { return(&sha224_md); } | ||
141 | |||
142 | static const EVP_MD sha256_md= | ||
143 | { | ||
144 | NID_sha256, | ||
145 | NID_sha256WithRSAEncryption, | ||
146 | SHA256_DIGEST_LENGTH, | ||
147 | EVP_MD_FLAG_FIPS, | ||
148 | init256, | ||
149 | update256, | ||
150 | final256, | ||
151 | NULL, | ||
152 | NULL, | ||
153 | EVP_PKEY_RSA_method, | ||
154 | SHA256_CBLOCK, | ||
155 | sizeof(EVP_MD *)+sizeof(SHA256_CTX), | ||
156 | }; | ||
157 | |||
158 | const EVP_MD *EVP_sha256(void) | ||
159 | { return(&sha256_md); } | ||
160 | #endif /* ifndef OPENSSL_NO_SHA256 */ | ||
161 | |||
162 | #ifndef OPENSSL_NO_SHA512 | ||
163 | static int init384(EVP_MD_CTX *ctx) | ||
164 | { return SHA384_Init(ctx->md_data); } | ||
165 | static int init512(EVP_MD_CTX *ctx) | ||
166 | { return SHA512_Init(ctx->md_data); } | ||
167 | /* See comment in SHA224/256 section */ | ||
168 | static int update512(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
169 | { | ||
170 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
171 | return SHA512_Update(ctx->md_data,data,count); | ||
172 | } | ||
173 | static int final512(EVP_MD_CTX *ctx,unsigned char *md) | ||
174 | { return SHA512_Final(md,ctx->md_data); } | ||
175 | |||
176 | static const EVP_MD sha384_md= | ||
177 | { | ||
178 | NID_sha384, | ||
179 | NID_sha384WithRSAEncryption, | ||
180 | SHA384_DIGEST_LENGTH, | ||
181 | EVP_MD_FLAG_FIPS, | ||
182 | init384, | ||
183 | update512, | ||
184 | final512, | ||
185 | NULL, | ||
186 | NULL, | ||
187 | EVP_PKEY_RSA_method, | ||
188 | SHA512_CBLOCK, | ||
189 | sizeof(EVP_MD *)+sizeof(SHA512_CTX), | ||
190 | }; | ||
191 | |||
192 | const EVP_MD *EVP_sha384(void) | ||
193 | { return(&sha384_md); } | ||
194 | |||
195 | static const EVP_MD sha512_md= | ||
196 | { | ||
197 | NID_sha512, | ||
198 | NID_sha512WithRSAEncryption, | ||
199 | SHA512_DIGEST_LENGTH, | ||
200 | EVP_MD_FLAG_FIPS, | ||
201 | init512, | ||
202 | update512, | ||
203 | final512, | ||
204 | NULL, | ||
205 | NULL, | ||
206 | EVP_PKEY_RSA_method, | ||
207 | SHA512_CBLOCK, | ||
208 | sizeof(EVP_MD *)+sizeof(SHA512_CTX), | ||
209 | }; | ||
210 | |||
211 | const EVP_MD *EVP_sha512(void) | ||
212 | { return(&sha512_md); } | ||
213 | #endif /* ifndef OPENSSL_NO_SHA512 */ | ||
214 | #endif /* ifdef OPENSSL_FIPS */ | ||
diff --git a/src/lib/libcrypto/evp/names.c b/src/lib/libcrypto/evp/names.c new file mode 100644 index 0000000000..7712453046 --- /dev/null +++ b/src/lib/libcrypto/evp/names.c | |||
@@ -0,0 +1,126 @@ | |||
1 | /* crypto/evp/names.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 | #ifdef OPENSSL_FIPS | ||
65 | #include <openssl/fips.h> | ||
66 | #endif | ||
67 | |||
68 | int EVP_add_cipher(const EVP_CIPHER *c) | ||
69 | { | ||
70 | int r; | ||
71 | |||
72 | r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(char *)c); | ||
73 | if (r == 0) return(0); | ||
74 | r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(char *)c); | ||
75 | return(r); | ||
76 | } | ||
77 | |||
78 | int EVP_add_digest(const EVP_MD *md) | ||
79 | { | ||
80 | int r; | ||
81 | const char *name; | ||
82 | |||
83 | name=OBJ_nid2sn(md->type); | ||
84 | r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(char *)md); | ||
85 | if (r == 0) return(0); | ||
86 | r=OBJ_NAME_add(OBJ_nid2ln(md->type),OBJ_NAME_TYPE_MD_METH,(char *)md); | ||
87 | if (r == 0) return(0); | ||
88 | |||
89 | if (md->type != md->pkey_type) | ||
90 | { | ||
91 | r=OBJ_NAME_add(OBJ_nid2sn(md->pkey_type), | ||
92 | OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name); | ||
93 | if (r == 0) return(0); | ||
94 | r=OBJ_NAME_add(OBJ_nid2ln(md->pkey_type), | ||
95 | OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name); | ||
96 | } | ||
97 | return(r); | ||
98 | } | ||
99 | |||
100 | const EVP_CIPHER *EVP_get_cipherbyname(const char *name) | ||
101 | { | ||
102 | const EVP_CIPHER *cp; | ||
103 | |||
104 | cp=(const EVP_CIPHER *)OBJ_NAME_get(name,OBJ_NAME_TYPE_CIPHER_METH); | ||
105 | return(cp); | ||
106 | } | ||
107 | |||
108 | const EVP_MD *EVP_get_digestbyname(const char *name) | ||
109 | { | ||
110 | const EVP_MD *cp; | ||
111 | |||
112 | cp=(const EVP_MD *)OBJ_NAME_get(name,OBJ_NAME_TYPE_MD_METH); | ||
113 | return(cp); | ||
114 | } | ||
115 | |||
116 | void EVP_cleanup(void) | ||
117 | { | ||
118 | OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH); | ||
119 | OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH); | ||
120 | /* The above calls will only clean out the contents of the name | ||
121 | hash table, but not the hash table itself. The following line | ||
122 | does that part. -- Richard Levitte */ | ||
123 | OBJ_NAME_cleanup(-1); | ||
124 | |||
125 | EVP_PBE_cleanup(); | ||
126 | } | ||
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c new file mode 100644 index 0000000000..a1874e83b2 --- /dev/null +++ b/src/lib/libcrypto/evp/p5_crpt.c | |||
@@ -0,0 +1,153 @@ | |||
1 | /* p5_crpt.c */ | ||
2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
3 | * project 1999. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 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 <stdio.h> | ||
60 | #include <stdlib.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/x509.h> | ||
63 | #include <openssl/evp.h> | ||
64 | |||
65 | /* PKCS#5 v1.5 compatible PBE functions: see PKCS#5 v2.0 for more info. | ||
66 | */ | ||
67 | |||
68 | void PKCS5_PBE_add(void) | ||
69 | { | ||
70 | #ifndef OPENSSL_NO_DES | ||
71 | # ifndef OPENSSL_NO_MD5 | ||
72 | EVP_PBE_alg_add(NID_pbeWithMD5AndDES_CBC, EVP_des_cbc(), EVP_md5(), | ||
73 | PKCS5_PBE_keyivgen); | ||
74 | # endif | ||
75 | # ifndef OPENSSL_NO_MD2 | ||
76 | EVP_PBE_alg_add(NID_pbeWithMD2AndDES_CBC, EVP_des_cbc(), EVP_md2(), | ||
77 | PKCS5_PBE_keyivgen); | ||
78 | # endif | ||
79 | # ifndef OPENSSL_NO_SHA | ||
80 | EVP_PBE_alg_add(NID_pbeWithSHA1AndDES_CBC, EVP_des_cbc(), EVP_sha1(), | ||
81 | PKCS5_PBE_keyivgen); | ||
82 | # endif | ||
83 | #endif | ||
84 | #ifndef OPENSSL_NO_RC2 | ||
85 | # ifndef OPENSSL_NO_MD5 | ||
86 | EVP_PBE_alg_add(NID_pbeWithMD5AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md5(), | ||
87 | PKCS5_PBE_keyivgen); | ||
88 | # endif | ||
89 | # ifndef OPENSSL_NO_MD2 | ||
90 | EVP_PBE_alg_add(NID_pbeWithMD2AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md2(), | ||
91 | PKCS5_PBE_keyivgen); | ||
92 | # endif | ||
93 | # ifndef OPENSSL_NO_SHA | ||
94 | EVP_PBE_alg_add(NID_pbeWithSHA1AndRC2_CBC, EVP_rc2_64_cbc(), EVP_sha1(), | ||
95 | PKCS5_PBE_keyivgen); | ||
96 | # endif | ||
97 | #endif | ||
98 | #ifndef OPENSSL_NO_HMAC | ||
99 | EVP_PBE_alg_add(NID_pbes2, NULL, NULL, PKCS5_v2_PBE_keyivgen); | ||
100 | #endif | ||
101 | } | ||
102 | |||
103 | int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, | ||
104 | ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, | ||
105 | int en_de) | ||
106 | { | ||
107 | EVP_MD_CTX ctx; | ||
108 | unsigned char md_tmp[EVP_MAX_MD_SIZE]; | ||
109 | unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; | ||
110 | int i; | ||
111 | PBEPARAM *pbe; | ||
112 | int saltlen, iter; | ||
113 | unsigned char *salt, *pbuf; | ||
114 | |||
115 | /* Extract useful info from parameter */ | ||
116 | pbuf = param->value.sequence->data; | ||
117 | if (!param || (param->type != V_ASN1_SEQUENCE) || | ||
118 | !(pbe = d2i_PBEPARAM (NULL, &pbuf, param->value.sequence->length))) { | ||
119 | EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | if (!pbe->iter) iter = 1; | ||
124 | else iter = ASN1_INTEGER_get (pbe->iter); | ||
125 | salt = pbe->salt->data; | ||
126 | saltlen = pbe->salt->length; | ||
127 | |||
128 | if(!pass) passlen = 0; | ||
129 | else if(passlen == -1) passlen = strlen(pass); | ||
130 | |||
131 | EVP_MD_CTX_init(&ctx); | ||
132 | EVP_DigestInit_ex(&ctx, md, NULL); | ||
133 | EVP_DigestUpdate(&ctx, pass, passlen); | ||
134 | EVP_DigestUpdate(&ctx, salt, saltlen); | ||
135 | PBEPARAM_free(pbe); | ||
136 | EVP_DigestFinal_ex(&ctx, md_tmp, NULL); | ||
137 | for (i = 1; i < iter; i++) { | ||
138 | EVP_DigestInit_ex(&ctx, md, NULL); | ||
139 | EVP_DigestUpdate(&ctx, md_tmp, EVP_MD_size(md)); | ||
140 | EVP_DigestFinal_ex (&ctx, md_tmp, NULL); | ||
141 | } | ||
142 | EVP_MD_CTX_cleanup(&ctx); | ||
143 | OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= sizeof md_tmp); | ||
144 | memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); | ||
145 | OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16); | ||
146 | memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), | ||
147 | EVP_CIPHER_iv_length(cipher)); | ||
148 | EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de); | ||
149 | OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE); | ||
150 | OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); | ||
151 | OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); | ||
152 | return 1; | ||
153 | } | ||
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c new file mode 100644 index 0000000000..1d5fabc4b2 --- /dev/null +++ b/src/lib/libcrypto/evp/p5_crpt2.c | |||
@@ -0,0 +1,256 @@ | |||
1 | /* p5_crpt2.c */ | ||
2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
3 | * project 1999. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 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 | #if !defined(OPENSSL_NO_HMAC) && !defined(OPENSSL_NO_SHA) | ||
59 | #include <stdio.h> | ||
60 | #include <stdlib.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/x509.h> | ||
63 | #include <openssl/evp.h> | ||
64 | #include <openssl/hmac.h> | ||
65 | |||
66 | /* set this to print out info about the keygen algorithm */ | ||
67 | /* #define DEBUG_PKCS5V2 */ | ||
68 | |||
69 | #ifdef DEBUG_PKCS5V2 | ||
70 | static void h__dump (const unsigned char *p, int len); | ||
71 | #endif | ||
72 | |||
73 | /* This is an implementation of PKCS#5 v2.0 password based encryption key | ||
74 | * derivation function PBKDF2 using the only currently defined function HMAC | ||
75 | * with SHA1. Verified against test vectors posted by Peter Gutmann | ||
76 | * <pgut001@cs.auckland.ac.nz> to the PKCS-TNG <pkcs-tng@rsa.com> mailing list. | ||
77 | */ | ||
78 | |||
79 | int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, | ||
80 | unsigned char *salt, int saltlen, int iter, | ||
81 | int keylen, unsigned char *out) | ||
82 | { | ||
83 | unsigned char digtmp[SHA_DIGEST_LENGTH], *p, itmp[4]; | ||
84 | int cplen, j, k, tkeylen; | ||
85 | unsigned long i = 1; | ||
86 | HMAC_CTX hctx; | ||
87 | |||
88 | HMAC_CTX_init(&hctx); | ||
89 | p = out; | ||
90 | tkeylen = keylen; | ||
91 | if(!pass) passlen = 0; | ||
92 | else if(passlen == -1) passlen = strlen(pass); | ||
93 | while(tkeylen) { | ||
94 | if(tkeylen > SHA_DIGEST_LENGTH) cplen = SHA_DIGEST_LENGTH; | ||
95 | else cplen = tkeylen; | ||
96 | /* We are unlikely to ever use more than 256 blocks (5120 bits!) | ||
97 | * but just in case... | ||
98 | */ | ||
99 | itmp[0] = (unsigned char)((i >> 24) & 0xff); | ||
100 | itmp[1] = (unsigned char)((i >> 16) & 0xff); | ||
101 | itmp[2] = (unsigned char)((i >> 8) & 0xff); | ||
102 | itmp[3] = (unsigned char)(i & 0xff); | ||
103 | HMAC_Init_ex(&hctx, pass, passlen, EVP_sha1(), NULL); | ||
104 | HMAC_Update(&hctx, salt, saltlen); | ||
105 | HMAC_Update(&hctx, itmp, 4); | ||
106 | HMAC_Final(&hctx, digtmp, NULL); | ||
107 | memcpy(p, digtmp, cplen); | ||
108 | for(j = 1; j < iter; j++) { | ||
109 | HMAC(EVP_sha1(), pass, passlen, | ||
110 | digtmp, SHA_DIGEST_LENGTH, digtmp, NULL); | ||
111 | for(k = 0; k < cplen; k++) p[k] ^= digtmp[k]; | ||
112 | } | ||
113 | tkeylen-= cplen; | ||
114 | i++; | ||
115 | p+= cplen; | ||
116 | } | ||
117 | HMAC_CTX_cleanup(&hctx); | ||
118 | #ifdef DEBUG_PKCS5V2 | ||
119 | fprintf(stderr, "Password:\n"); | ||
120 | h__dump (pass, passlen); | ||
121 | fprintf(stderr, "Salt:\n"); | ||
122 | h__dump (salt, saltlen); | ||
123 | fprintf(stderr, "Iteration count %d\n", iter); | ||
124 | fprintf(stderr, "Key:\n"); | ||
125 | h__dump (out, keylen); | ||
126 | #endif | ||
127 | return 1; | ||
128 | } | ||
129 | |||
130 | #ifdef DO_TEST | ||
131 | main() | ||
132 | { | ||
133 | unsigned char out[4]; | ||
134 | unsigned char salt[] = {0x12, 0x34, 0x56, 0x78}; | ||
135 | PKCS5_PBKDF2_HMAC_SHA1("password", -1, salt, 4, 5, 4, out); | ||
136 | fprintf(stderr, "Out %02X %02X %02X %02X\n", | ||
137 | out[0], out[1], out[2], out[3]); | ||
138 | } | ||
139 | |||
140 | #endif | ||
141 | |||
142 | /* Now the key derivation function itself. This is a bit evil because | ||
143 | * it has to check the ASN1 parameters are valid: and there are quite a | ||
144 | * few of them... | ||
145 | */ | ||
146 | |||
147 | int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
148 | ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, | ||
149 | int en_de) | ||
150 | { | ||
151 | unsigned char *pbuf, *salt, key[EVP_MAX_KEY_LENGTH]; | ||
152 | int saltlen, keylen, iter, plen; | ||
153 | PBE2PARAM *pbe2 = NULL; | ||
154 | const EVP_CIPHER *cipher; | ||
155 | PBKDF2PARAM *kdf = NULL; | ||
156 | |||
157 | pbuf = param->value.sequence->data; | ||
158 | plen = param->value.sequence->length; | ||
159 | if(!param || (param->type != V_ASN1_SEQUENCE) || | ||
160 | !(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) { | ||
161 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | /* See if we recognise the key derivation function */ | ||
166 | |||
167 | if(OBJ_obj2nid(pbe2->keyfunc->algorithm) != NID_id_pbkdf2) { | ||
168 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
169 | EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION); | ||
170 | goto err; | ||
171 | } | ||
172 | |||
173 | /* lets see if we recognise the encryption algorithm. | ||
174 | */ | ||
175 | |||
176 | cipher = EVP_get_cipherbyname( | ||
177 | OBJ_nid2sn(OBJ_obj2nid(pbe2->encryption->algorithm))); | ||
178 | |||
179 | if(!cipher) { | ||
180 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
181 | EVP_R_UNSUPPORTED_CIPHER); | ||
182 | goto err; | ||
183 | } | ||
184 | |||
185 | /* Fixup cipher based on AlgorithmIdentifier */ | ||
186 | EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de); | ||
187 | if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) { | ||
188 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
189 | EVP_R_CIPHER_PARAMETER_ERROR); | ||
190 | goto err; | ||
191 | } | ||
192 | keylen = EVP_CIPHER_CTX_key_length(ctx); | ||
193 | OPENSSL_assert(keylen <= sizeof key); | ||
194 | |||
195 | /* Now decode key derivation function */ | ||
196 | |||
197 | if(!pbe2->keyfunc->parameter || | ||
198 | (pbe2->keyfunc->parameter->type != V_ASN1_SEQUENCE)) | ||
199 | { | ||
200 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
201 | goto err; | ||
202 | } | ||
203 | |||
204 | pbuf = pbe2->keyfunc->parameter->value.sequence->data; | ||
205 | plen = pbe2->keyfunc->parameter->value.sequence->length; | ||
206 | if(!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) { | ||
207 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
208 | goto err; | ||
209 | } | ||
210 | |||
211 | PBE2PARAM_free(pbe2); | ||
212 | pbe2 = NULL; | ||
213 | |||
214 | /* Now check the parameters of the kdf */ | ||
215 | |||
216 | if(kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != keylen)){ | ||
217 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
218 | EVP_R_UNSUPPORTED_KEYLENGTH); | ||
219 | goto err; | ||
220 | } | ||
221 | |||
222 | if(kdf->prf && (OBJ_obj2nid(kdf->prf->algorithm) != NID_hmacWithSHA1)) { | ||
223 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); | ||
224 | goto err; | ||
225 | } | ||
226 | |||
227 | if(kdf->salt->type != V_ASN1_OCTET_STRING) { | ||
228 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
229 | EVP_R_UNSUPPORTED_SALT_TYPE); | ||
230 | goto err; | ||
231 | } | ||
232 | |||
233 | /* it seems that its all OK */ | ||
234 | salt = kdf->salt->value.octet_string->data; | ||
235 | saltlen = kdf->salt->value.octet_string->length; | ||
236 | iter = ASN1_INTEGER_get(kdf->iter); | ||
237 | PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key); | ||
238 | EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de); | ||
239 | OPENSSL_cleanse(key, keylen); | ||
240 | PBKDF2PARAM_free(kdf); | ||
241 | return 1; | ||
242 | |||
243 | err: | ||
244 | PBE2PARAM_free(pbe2); | ||
245 | PBKDF2PARAM_free(kdf); | ||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | #ifdef DEBUG_PKCS5V2 | ||
250 | static void h__dump (const unsigned char *p, int len) | ||
251 | { | ||
252 | for (; len --; p++) fprintf(stderr, "%02X ", *p); | ||
253 | fprintf(stderr, "\n"); | ||
254 | } | ||
255 | #endif | ||
256 | #endif | ||
diff --git a/src/lib/libcrypto/evp/p_dec.c b/src/lib/libcrypto/evp/p_dec.c new file mode 100644 index 0000000000..8af620400e --- /dev/null +++ b/src/lib/libcrypto/evp/p_dec.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /* crypto/evp/p_dec.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/rand.h> | ||
62 | #ifndef OPENSSL_NO_RSA | ||
63 | #include <openssl/rsa.h> | ||
64 | #endif | ||
65 | #include <openssl/evp.h> | ||
66 | #include <openssl/objects.h> | ||
67 | #include <openssl/x509.h> | ||
68 | |||
69 | int EVP_PKEY_decrypt(unsigned char *key, unsigned char *ek, int ekl, | ||
70 | EVP_PKEY *priv) | ||
71 | { | ||
72 | int ret= -1; | ||
73 | |||
74 | #ifndef OPENSSL_NO_RSA | ||
75 | if (priv->type != EVP_PKEY_RSA) | ||
76 | { | ||
77 | #endif | ||
78 | EVPerr(EVP_F_EVP_PKEY_DECRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); | ||
79 | #ifndef OPENSSL_NO_RSA | ||
80 | goto err; | ||
81 | } | ||
82 | |||
83 | ret=RSA_private_decrypt(ekl,ek,key,priv->pkey.rsa,RSA_PKCS1_PADDING); | ||
84 | err: | ||
85 | #endif | ||
86 | return(ret); | ||
87 | } | ||
diff --git a/src/lib/libcrypto/evp/p_enc.c b/src/lib/libcrypto/evp/p_enc.c new file mode 100644 index 0000000000..656883b996 --- /dev/null +++ b/src/lib/libcrypto/evp/p_enc.c | |||
@@ -0,0 +1,86 @@ | |||
1 | /* crypto/evp/p_enc.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/rand.h> | ||
62 | #ifndef OPENSSL_NO_RSA | ||
63 | #include <openssl/rsa.h> | ||
64 | #endif | ||
65 | #include <openssl/evp.h> | ||
66 | #include <openssl/objects.h> | ||
67 | #include <openssl/x509.h> | ||
68 | |||
69 | int EVP_PKEY_encrypt(unsigned char *ek, unsigned char *key, int key_len, | ||
70 | EVP_PKEY *pubk) | ||
71 | { | ||
72 | int ret=0; | ||
73 | |||
74 | #ifndef OPENSSL_NO_RSA | ||
75 | if (pubk->type != EVP_PKEY_RSA) | ||
76 | { | ||
77 | #endif | ||
78 | EVPerr(EVP_F_EVP_PKEY_ENCRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); | ||
79 | #ifndef OPENSSL_NO_RSA | ||
80 | goto err; | ||
81 | } | ||
82 | ret=RSA_public_encrypt(key_len,key,ek,pubk->pkey.rsa,RSA_PKCS1_PADDING); | ||
83 | err: | ||
84 | #endif | ||
85 | return(ret); | ||
86 | } | ||
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c new file mode 100644 index 0000000000..215b94292a --- /dev/null +++ b/src/lib/libcrypto/evp/p_lib.c | |||
@@ -0,0 +1,337 @@ | |||
1 | /* crypto/evp/p_lib.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/objects.h> | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/asn1_mac.h> | ||
64 | #include <openssl/x509.h> | ||
65 | |||
66 | static void EVP_PKEY_free_it(EVP_PKEY *x); | ||
67 | |||
68 | int EVP_PKEY_bits(EVP_PKEY *pkey) | ||
69 | { | ||
70 | #ifndef OPENSSL_NO_RSA | ||
71 | if (pkey->type == EVP_PKEY_RSA) | ||
72 | return(BN_num_bits(pkey->pkey.rsa->n)); | ||
73 | else | ||
74 | #endif | ||
75 | #ifndef OPENSSL_NO_DSA | ||
76 | if (pkey->type == EVP_PKEY_DSA) | ||
77 | return(BN_num_bits(pkey->pkey.dsa->p)); | ||
78 | #endif | ||
79 | return(0); | ||
80 | } | ||
81 | |||
82 | int EVP_PKEY_size(EVP_PKEY *pkey) | ||
83 | { | ||
84 | if (pkey == NULL) | ||
85 | return(0); | ||
86 | #ifndef OPENSSL_NO_RSA | ||
87 | if (pkey->type == EVP_PKEY_RSA) | ||
88 | return(RSA_size(pkey->pkey.rsa)); | ||
89 | else | ||
90 | #endif | ||
91 | #ifndef OPENSSL_NO_DSA | ||
92 | if (pkey->type == EVP_PKEY_DSA) | ||
93 | return(DSA_size(pkey->pkey.dsa)); | ||
94 | #endif | ||
95 | return(0); | ||
96 | } | ||
97 | |||
98 | int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode) | ||
99 | { | ||
100 | #ifndef OPENSSL_NO_DSA | ||
101 | if (pkey->type == EVP_PKEY_DSA) | ||
102 | { | ||
103 | int ret=pkey->save_parameters; | ||
104 | |||
105 | if (mode >= 0) | ||
106 | pkey->save_parameters=mode; | ||
107 | return(ret); | ||
108 | } | ||
109 | #endif | ||
110 | return(0); | ||
111 | } | ||
112 | |||
113 | int EVP_PKEY_copy_parameters(EVP_PKEY *to, EVP_PKEY *from) | ||
114 | { | ||
115 | if (to->type != from->type) | ||
116 | { | ||
117 | EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES); | ||
118 | goto err; | ||
119 | } | ||
120 | |||
121 | if (EVP_PKEY_missing_parameters(from)) | ||
122 | { | ||
123 | EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS); | ||
124 | goto err; | ||
125 | } | ||
126 | #ifndef OPENSSL_NO_DSA | ||
127 | if (to->type == EVP_PKEY_DSA) | ||
128 | { | ||
129 | BIGNUM *a; | ||
130 | |||
131 | if ((a=BN_dup(from->pkey.dsa->p)) == NULL) goto err; | ||
132 | if (to->pkey.dsa->p != NULL) BN_free(to->pkey.dsa->p); | ||
133 | to->pkey.dsa->p=a; | ||
134 | |||
135 | if ((a=BN_dup(from->pkey.dsa->q)) == NULL) goto err; | ||
136 | if (to->pkey.dsa->q != NULL) BN_free(to->pkey.dsa->q); | ||
137 | to->pkey.dsa->q=a; | ||
138 | |||
139 | if ((a=BN_dup(from->pkey.dsa->g)) == NULL) goto err; | ||
140 | if (to->pkey.dsa->g != NULL) BN_free(to->pkey.dsa->g); | ||
141 | to->pkey.dsa->g=a; | ||
142 | } | ||
143 | #endif | ||
144 | return(1); | ||
145 | err: | ||
146 | return(0); | ||
147 | } | ||
148 | |||
149 | int EVP_PKEY_missing_parameters(EVP_PKEY *pkey) | ||
150 | { | ||
151 | #ifndef OPENSSL_NO_DSA | ||
152 | if (pkey->type == EVP_PKEY_DSA) | ||
153 | { | ||
154 | DSA *dsa; | ||
155 | |||
156 | dsa=pkey->pkey.dsa; | ||
157 | if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) | ||
158 | return(1); | ||
159 | } | ||
160 | #endif | ||
161 | return(0); | ||
162 | } | ||
163 | |||
164 | int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b) | ||
165 | { | ||
166 | #ifndef OPENSSL_NO_DSA | ||
167 | if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA)) | ||
168 | { | ||
169 | if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) || | ||
170 | BN_cmp(a->pkey.dsa->q,b->pkey.dsa->q) || | ||
171 | BN_cmp(a->pkey.dsa->g,b->pkey.dsa->g)) | ||
172 | return(0); | ||
173 | else | ||
174 | return(1); | ||
175 | } | ||
176 | #endif | ||
177 | return(-1); | ||
178 | } | ||
179 | |||
180 | EVP_PKEY *EVP_PKEY_new(void) | ||
181 | { | ||
182 | EVP_PKEY *ret; | ||
183 | |||
184 | ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY)); | ||
185 | if (ret == NULL) | ||
186 | { | ||
187 | EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE); | ||
188 | return(NULL); | ||
189 | } | ||
190 | ret->type=EVP_PKEY_NONE; | ||
191 | ret->references=1; | ||
192 | ret->pkey.ptr=NULL; | ||
193 | ret->attributes=NULL; | ||
194 | ret->save_parameters=1; | ||
195 | return(ret); | ||
196 | } | ||
197 | |||
198 | int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key) | ||
199 | { | ||
200 | if (pkey == NULL) return(0); | ||
201 | if (pkey->pkey.ptr != NULL) | ||
202 | EVP_PKEY_free_it(pkey); | ||
203 | pkey->type=EVP_PKEY_type(type); | ||
204 | pkey->save_type=type; | ||
205 | pkey->pkey.ptr=key; | ||
206 | return(key != NULL); | ||
207 | } | ||
208 | |||
209 | #ifndef OPENSSL_NO_RSA | ||
210 | int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) | ||
211 | { | ||
212 | int ret = EVP_PKEY_assign_RSA(pkey, key); | ||
213 | if(ret) | ||
214 | RSA_up_ref(key); | ||
215 | return ret; | ||
216 | } | ||
217 | |||
218 | RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey) | ||
219 | { | ||
220 | if(pkey->type != EVP_PKEY_RSA) { | ||
221 | EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY); | ||
222 | return NULL; | ||
223 | } | ||
224 | RSA_up_ref(pkey->pkey.rsa); | ||
225 | return pkey->pkey.rsa; | ||
226 | } | ||
227 | #endif | ||
228 | |||
229 | #ifndef OPENSSL_NO_DSA | ||
230 | int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) | ||
231 | { | ||
232 | int ret = EVP_PKEY_assign_DSA(pkey, key); | ||
233 | if(ret) | ||
234 | DSA_up_ref(key); | ||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey) | ||
239 | { | ||
240 | if(pkey->type != EVP_PKEY_DSA) { | ||
241 | EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY); | ||
242 | return NULL; | ||
243 | } | ||
244 | DSA_up_ref(pkey->pkey.dsa); | ||
245 | return pkey->pkey.dsa; | ||
246 | } | ||
247 | #endif | ||
248 | |||
249 | #ifndef OPENSSL_NO_DH | ||
250 | |||
251 | int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) | ||
252 | { | ||
253 | int ret = EVP_PKEY_assign_DH(pkey, key); | ||
254 | if(ret) | ||
255 | DH_up_ref(key); | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey) | ||
260 | { | ||
261 | if(pkey->type != EVP_PKEY_DH) { | ||
262 | EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY); | ||
263 | return NULL; | ||
264 | } | ||
265 | DH_up_ref(pkey->pkey.dh); | ||
266 | return pkey->pkey.dh; | ||
267 | } | ||
268 | #endif | ||
269 | |||
270 | int EVP_PKEY_type(int type) | ||
271 | { | ||
272 | switch (type) | ||
273 | { | ||
274 | case EVP_PKEY_RSA: | ||
275 | case EVP_PKEY_RSA2: | ||
276 | return(EVP_PKEY_RSA); | ||
277 | case EVP_PKEY_DSA: | ||
278 | case EVP_PKEY_DSA1: | ||
279 | case EVP_PKEY_DSA2: | ||
280 | case EVP_PKEY_DSA3: | ||
281 | case EVP_PKEY_DSA4: | ||
282 | return(EVP_PKEY_DSA); | ||
283 | case EVP_PKEY_DH: | ||
284 | return(EVP_PKEY_DH); | ||
285 | default: | ||
286 | return(NID_undef); | ||
287 | } | ||
288 | } | ||
289 | |||
290 | void EVP_PKEY_free(EVP_PKEY *x) | ||
291 | { | ||
292 | int i; | ||
293 | |||
294 | if (x == NULL) return; | ||
295 | |||
296 | i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY); | ||
297 | #ifdef REF_PRINT | ||
298 | REF_PRINT("EVP_PKEY",x); | ||
299 | #endif | ||
300 | if (i > 0) return; | ||
301 | #ifdef REF_CHECK | ||
302 | if (i < 0) | ||
303 | { | ||
304 | fprintf(stderr,"EVP_PKEY_free, bad reference count\n"); | ||
305 | abort(); | ||
306 | } | ||
307 | #endif | ||
308 | EVP_PKEY_free_it(x); | ||
309 | OPENSSL_free(x); | ||
310 | } | ||
311 | |||
312 | static void EVP_PKEY_free_it(EVP_PKEY *x) | ||
313 | { | ||
314 | switch (x->type) | ||
315 | { | ||
316 | #ifndef OPENSSL_NO_RSA | ||
317 | case EVP_PKEY_RSA: | ||
318 | case EVP_PKEY_RSA2: | ||
319 | RSA_free(x->pkey.rsa); | ||
320 | break; | ||
321 | #endif | ||
322 | #ifndef OPENSSL_NO_DSA | ||
323 | case EVP_PKEY_DSA: | ||
324 | case EVP_PKEY_DSA2: | ||
325 | case EVP_PKEY_DSA3: | ||
326 | case EVP_PKEY_DSA4: | ||
327 | DSA_free(x->pkey.dsa); | ||
328 | break; | ||
329 | #endif | ||
330 | #ifndef OPENSSL_NO_DH | ||
331 | case EVP_PKEY_DH: | ||
332 | DH_free(x->pkey.dh); | ||
333 | break; | ||
334 | #endif | ||
335 | } | ||
336 | } | ||
337 | |||
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c new file mode 100644 index 0000000000..5a933d1cda --- /dev/null +++ b/src/lib/libcrypto/evp/p_open.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* crypto/evp/p_open.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 | #ifndef OPENSSL_NO_RSA | ||
60 | #include <stdio.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/objects.h> | ||
64 | #include <openssl/x509.h> | ||
65 | |||
66 | int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek, | ||
67 | int ekl, unsigned char *iv, EVP_PKEY *priv) | ||
68 | { | ||
69 | unsigned char *key=NULL; | ||
70 | int i,size=0,ret=0; | ||
71 | |||
72 | if(type) { | ||
73 | EVP_CIPHER_CTX_init(ctx); | ||
74 | if(!EVP_DecryptInit_ex(ctx,type,NULL, NULL,NULL)) return 0; | ||
75 | } | ||
76 | |||
77 | if(!priv) return 1; | ||
78 | |||
79 | if (priv->type != EVP_PKEY_RSA) | ||
80 | { | ||
81 | EVPerr(EVP_F_EVP_OPENINIT,EVP_R_PUBLIC_KEY_NOT_RSA); | ||
82 | goto err; | ||
83 | } | ||
84 | |||
85 | size=RSA_size(priv->pkey.rsa); | ||
86 | key=(unsigned char *)OPENSSL_malloc(size+2); | ||
87 | if (key == NULL) | ||
88 | { | ||
89 | /* ERROR */ | ||
90 | EVPerr(EVP_F_EVP_OPENINIT,ERR_R_MALLOC_FAILURE); | ||
91 | goto err; | ||
92 | } | ||
93 | |||
94 | i=EVP_PKEY_decrypt(key,ek,ekl,priv); | ||
95 | if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i)) | ||
96 | { | ||
97 | /* ERROR */ | ||
98 | goto err; | ||
99 | } | ||
100 | if(!EVP_DecryptInit_ex(ctx,NULL,NULL,key,iv)) goto err; | ||
101 | |||
102 | ret=1; | ||
103 | err: | ||
104 | if (key != NULL) OPENSSL_cleanse(key,size); | ||
105 | OPENSSL_free(key); | ||
106 | return(ret); | ||
107 | } | ||
108 | |||
109 | int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
110 | { | ||
111 | int i; | ||
112 | |||
113 | i=EVP_DecryptFinal_ex(ctx,out,outl); | ||
114 | EVP_DecryptInit_ex(ctx,NULL,NULL,NULL,NULL); | ||
115 | return(i); | ||
116 | } | ||
117 | #else /* !OPENSSL_NO_RSA */ | ||
118 | |||
119 | # ifdef PEDANTIC | ||
120 | static void *dummy=&dummy; | ||
121 | # endif | ||
122 | |||
123 | #endif | ||
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c new file mode 100644 index 0000000000..37e547fe72 --- /dev/null +++ b/src/lib/libcrypto/evp/p_seal.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* crypto/evp/p_seal.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/rand.h> | ||
62 | #ifndef OPENSSL_NO_RSA | ||
63 | #include <openssl/rsa.h> | ||
64 | #endif | ||
65 | #include <openssl/evp.h> | ||
66 | #include <openssl/objects.h> | ||
67 | #include <openssl/x509.h> | ||
68 | |||
69 | int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, | ||
70 | int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) | ||
71 | { | ||
72 | unsigned char key[EVP_MAX_KEY_LENGTH]; | ||
73 | int i; | ||
74 | |||
75 | if(type) { | ||
76 | EVP_CIPHER_CTX_init(ctx); | ||
77 | if(!EVP_EncryptInit_ex(ctx,type,NULL,NULL,NULL)) return 0; | ||
78 | } | ||
79 | if ((npubk <= 0) || !pubk) | ||
80 | return 1; | ||
81 | if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0) | ||
82 | return 0; | ||
83 | if (EVP_CIPHER_CTX_iv_length(ctx)) | ||
84 | RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx)); | ||
85 | |||
86 | if(!EVP_EncryptInit_ex(ctx,NULL,NULL,key,iv)) return 0; | ||
87 | |||
88 | for (i=0; i<npubk; i++) | ||
89 | { | ||
90 | ekl[i]=EVP_PKEY_encrypt(ek[i],key,EVP_CIPHER_CTX_key_length(ctx), | ||
91 | pubk[i]); | ||
92 | if (ekl[i] <= 0) return(-1); | ||
93 | } | ||
94 | return(npubk); | ||
95 | } | ||
96 | |||
97 | /* MACRO | ||
98 | void EVP_SealUpdate(ctx,out,outl,in,inl) | ||
99 | EVP_CIPHER_CTX *ctx; | ||
100 | unsigned char *out; | ||
101 | int *outl; | ||
102 | unsigned char *in; | ||
103 | int inl; | ||
104 | { | ||
105 | EVP_EncryptUpdate(ctx,out,outl,in,inl); | ||
106 | } | ||
107 | */ | ||
108 | |||
109 | int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
110 | { | ||
111 | int i; | ||
112 | i = EVP_EncryptFinal_ex(ctx,out,outl); | ||
113 | EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL); | ||
114 | return i; | ||
115 | } | ||
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c new file mode 100644 index 0000000000..e4ae5906f5 --- /dev/null +++ b/src/lib/libcrypto/evp/p_sign.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* crypto/evp/p_sign.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 | |||
65 | #ifdef undef | ||
66 | void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) | ||
67 | { | ||
68 | EVP_DigestInit_ex(ctx,type); | ||
69 | } | ||
70 | |||
71 | void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, | ||
72 | unsigned int count) | ||
73 | { | ||
74 | EVP_DigestUpdate(ctx,data,count); | ||
75 | } | ||
76 | #endif | ||
77 | |||
78 | int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | ||
79 | EVP_PKEY *pkey) | ||
80 | { | ||
81 | unsigned char m[EVP_MAX_MD_SIZE]; | ||
82 | unsigned int m_len; | ||
83 | int i,ok=0,v; | ||
84 | MS_STATIC EVP_MD_CTX tmp_ctx; | ||
85 | |||
86 | *siglen=0; | ||
87 | EVP_MD_CTX_init(&tmp_ctx); | ||
88 | EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); | ||
89 | EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len); | ||
90 | EVP_MD_CTX_cleanup(&tmp_ctx); | ||
91 | for (i=0; i<4; i++) | ||
92 | { | ||
93 | v=ctx->digest->required_pkey_type[i]; | ||
94 | if (v == 0) break; | ||
95 | if (pkey->type == v) | ||
96 | { | ||
97 | ok=1; | ||
98 | break; | ||
99 | } | ||
100 | } | ||
101 | if (!ok) | ||
102 | { | ||
103 | EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); | ||
104 | return(0); | ||
105 | } | ||
106 | if (ctx->digest->sign == NULL) | ||
107 | { | ||
108 | EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED); | ||
109 | return(0); | ||
110 | } | ||
111 | return(ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen, | ||
112 | pkey->pkey.ptr)); | ||
113 | } | ||
114 | |||
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c new file mode 100644 index 0000000000..d854d743a5 --- /dev/null +++ b/src/lib/libcrypto/evp/p_verify.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /* crypto/evp/p_verify.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 | |||
65 | int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, | ||
66 | unsigned int siglen, EVP_PKEY *pkey) | ||
67 | { | ||
68 | unsigned char m[EVP_MAX_MD_SIZE]; | ||
69 | unsigned int m_len; | ||
70 | int i,ok=0,v; | ||
71 | MS_STATIC EVP_MD_CTX tmp_ctx; | ||
72 | |||
73 | for (i=0; i<4; i++) | ||
74 | { | ||
75 | v=ctx->digest->required_pkey_type[i]; | ||
76 | if (v == 0) break; | ||
77 | if (pkey->type == v) | ||
78 | { | ||
79 | ok=1; | ||
80 | break; | ||
81 | } | ||
82 | } | ||
83 | if (!ok) | ||
84 | { | ||
85 | EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); | ||
86 | return(-1); | ||
87 | } | ||
88 | EVP_MD_CTX_init(&tmp_ctx); | ||
89 | EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); | ||
90 | EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len); | ||
91 | EVP_MD_CTX_cleanup(&tmp_ctx); | ||
92 | if (ctx->digest->verify == NULL) | ||
93 | { | ||
94 | EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); | ||
95 | return(0); | ||
96 | } | ||
97 | |||
98 | return(ctx->digest->verify(ctx->digest->type,m,m_len, | ||
99 | sigbuf,siglen,pkey->pkey.ptr)); | ||
100 | } | ||
101 | |||