summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/crypto.c
diff options
context:
space:
mode:
authorryker <>1998-10-05 20:13:16 +0000
committerryker <>1998-10-05 20:13:16 +0000
commit9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4 (patch)
tree51ff319f3510104698e541954d10ad98f9125f36 /src/lib/libcrypto/crypto.c
parent9e77c62555877f9a64805c49d0dcd7dbfbb40f4e (diff)
downloadopenbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.tar.gz
openbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.tar.bz2
openbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.zip
Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD build
functionality for shared libs. Note that routines such as sslv2_init and friends that use RSA will not work due to lack of RSA in this library. Needs documentation and help from ports for easy upgrade to full functionality where legally possible.
Diffstat (limited to 'src/lib/libcrypto/crypto.c')
-rw-r--r--src/lib/libcrypto/crypto.c575
1 files changed, 575 insertions, 0 deletions
diff --git a/src/lib/libcrypto/crypto.c b/src/lib/libcrypto/crypto.c
new file mode 100644
index 0000000000..366e25c939
--- /dev/null
+++ b/src/lib/libcrypto/crypto.c
@@ -0,0 +1,575 @@
1/* crypto/crypto.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/* If you are happy to use the assmbler version of bn/bn_mulw.c, define
60 * BN_ASM */
61#ifndef BN_ASM
62#undef BN_ASM
63#define X86_ASM
64#endif
65
66#ifndef DES_ASM
67#undef DES_ASM
68#endif
69
70#ifndef BF_ASM
71#undef BF_ASM
72#endif
73
74/* The following defines are only to break the compiles into chunks.
75 * If you wish to not compile some sections, use the 'NO_XXX' macros
76 */
77#ifndef CRYPTO_SUBSET
78/* Define all subset symbols. */
79#define CRYPTO_LIB_SUBSET
80#define CRYPTO_ASN1_SUBSET
81#define CRYPTO_BN_SUBSET
82#define CRYPTO_BUFFER_SUBSET
83#define CRYPTO_BIO_SUBSET
84#define CRYPTO_CONF_SUBSET
85#define CRYPTO_DES_SUBSET
86#define CRYPTO_DH_SUBSET
87#define CRYPTO_DSA_SUBSET
88#define CRYPTO_ERROR_SUBSET
89#define CRYPTO_EVP_SUBSET
90#define CRYPTO_IDEA_SUBSET
91#define CRYPTO_LHASH_SUBSET
92#define CRYPTO_MD_SUBSET
93#define CRYPTO_MDC2_SUBSET
94#define CRYPTO_METH_SUBSET
95#define CRYPTO_OBJECTS_SUBSET
96#define CRYPTO_PEM_SUBSET
97#define CRYPTO_RAND_SUBSET
98#define CRYPTO_RC_SUBSET
99#define CRYPTO_BLOWFISH_SUBSET
100#define CRYPTO_CAST_SUBSET
101#define CRYPTO_RSA_SUBSET
102#define CRYPTO_SHA_SUBSET
103#define CRYPTO_HMAC_SUBSET
104#define CRYPTO_SHA1_SUBSET
105#define CRYPTO_STACK_SUBSET
106#define CRYPTO_TXT_DB_SUBSET
107#define CRYPTO_X509_SUBSET
108#define CRYPTO_PKCS7_SUBSET
109#endif
110
111#include <stdio.h>
112#include <stdlib.h>
113#include <string.h>
114
115#define USE_SOCKETS
116#include "../e_os.h"
117
118#include "buffer.h"
119#include "bio.h"
120#include "stack.h"
121#include "lhash.h"
122
123#include "err.h"
124
125#include "bn.h"
126#include "evp.h"
127
128#include "rand.h"
129#include "conf.h"
130#include "txt_db.h"
131
132#include "x509.h"
133#include "pkcs7.h"
134#include "pem.h"
135#include "asn1.h"
136#include "objects.h"
137
138#ifdef CRYPTO_LIB_SUBSET
139#include "cryptlib.c"
140#include "mem.c"
141#include "cversion.c"
142#endif
143
144#ifdef CRYPTO_ASN1_SUBSET
145#include "asn1/a_meth.c"
146#include "asn1/a_bitstr.c"
147#include "asn1/a_d2i_fp.c"
148#include "asn1/a_dup.c"
149#include "asn1/a_hdr.c"
150#include "asn1/a_i2d_fp.c"
151#include "asn1/a_int.c"
152#include "asn1/a_bool.c"
153#include "asn1/a_bytes.c"
154#include "asn1/a_object.c"
155#include "asn1/a_octet.c"
156#include "asn1/a_print.c"
157#include "asn1/a_set.c"
158#include "asn1/a_sign.c"
159#include "asn1/a_type.c"
160#include "asn1/a_utctm.c"
161#include "asn1/a_verify.c"
162#include "asn1/a_digest.c"
163#include "asn1/asn1_err.c"
164#include "asn1/asn1_lib.c"
165#include "asn1/asn1_par.c"
166#ifndef NO_DH
167#include "asn1/d2i_dhp.c"
168#include "asn1/i2d_dhp.c"
169#endif
170#ifndef NO_DSA
171#include "asn1/d2i_dsap.c"
172#include "asn1/i2d_dsap.c"
173#include "asn1/d2i_s_pr.c"
174#include "asn1/i2d_s_pr.c"
175#include "asn1/d2i_s_pu.c"
176#include "asn1/i2d_s_pu.c"
177#endif
178#ifndef NO_RSA
179#include "asn1/d2i_r_pr.c"
180#include "asn1/i2d_r_pr.c"
181#include "asn1/d2i_r_pu.c"
182#include "asn1/i2d_r_pu.c"
183#include "asn1/n_pkey.c"
184#endif
185#include "asn1/d2i_pr.c"
186#include "asn1/d2i_pu.c"
187#include "asn1/i2d_pr.c"
188#include "asn1/i2d_pu.c"
189#include "asn1/f_int.c"
190#include "asn1/f_string.c"
191#include "asn1/p7_dgst.c"
192#include "asn1/p7_enc.c"
193#include "asn1/p7_enc_c.c"
194#include "asn1/p7_evp.c"
195#include "asn1/p7_i_s.c"
196#include "asn1/p7_lib.c"
197#include "asn1/p7_recip.c"
198#include "asn1/p7_s_e.c"
199#include "asn1/p7_signd.c"
200#include "asn1/p7_signi.c"
201#include "asn1/t_pkey.c"
202#include "asn1/t_req.c"
203#include "asn1/t_x509.c"
204#include "asn1/x_algor.c"
205#include "asn1/x_attrib.c"
206#include "asn1/x_exten.c"
207#include "asn1/x_cinf.c"
208#include "asn1/x_crl.c"
209#include "asn1/x_info.c"
210#include "asn1/x_name.c"
211#include "asn1/x_pkey.c"
212#include "asn1/x_pubkey.c"
213#include "asn1/x_req.c"
214#include "asn1/x_sig.c"
215#include "asn1/x_spki.c"
216#include "asn1/x_val.c"
217#include "asn1/x_x509.c"
218#endif
219
220#ifdef CRYPTO_BN_SUBSET
221#include "bn/bn_add.c"
222#include "bn/bn_div.c"
223#include "bn/bn_exp.c"
224#include "bn/bn_mont.c"
225#include "bn/bn_recp.c"
226#include "bn/bn_gcd.c"
227#include "bn/bn_lib.c"
228#include "bn/bn_mod.c"
229#include "bn/bn_mul.c"
230#ifndef BN_ASM
231#include "bn/bn_mulw.c"
232#endif
233#include "bn/bn_prime.c"
234#include "bn/bn_rand.c"
235#include "bn/bn_shift.c"
236#include "bn/bn_sqr.c"
237#include "bn/bn_sub.c"
238#include "bn/bn_word.c"
239#include "bn/bn_print.c"
240#include "bn/bn_err.c"
241#include "bn/bn_blind.c"
242#endif
243
244#ifdef CRYPTO_BIO_SUBSET
245#include "bio/bf_buff.c"
246#include "bio/bf_null.c"
247#include "bio/bf_nbio.c"
248#include "bio/bio_cb.c"
249#include "bio/bio_lib.c"
250#include "bio/bss_fd.c"
251#include "bio/bss_file.c"
252#include "bio/bss_mem.c"
253#include "bio/bss_null.c"
254#ifdef VMS
255#include "bio/bss_rtcp.c"
256#endif
257#include "bio/bss_sock.c"
258#include "bio/bss_conn.c"
259#include "bio/bss_acpt.c"
260#include "bio/b_sock.c"
261#include "bio/b_print.c"
262#include "bio/b_dump.c"
263#include "bio/bio_err.c"
264#endif
265
266#ifdef CRYPTO_BUFFER_SUBSET
267#include "buffer/buf_err.c"
268#include "buffer/buffer.c"
269#endif
270
271#ifdef CRYPTO_CONF_SUBSET
272#include "conf/conf.c"
273#include "conf/conf_err.c"
274#endif
275
276#ifdef CRYPTO_DES_SUBSET
277#include "des/read_pwd.c"
278#ifndef NO_DES
279#ifndef DES_ASM
280#include "des/fcrypt_b.c"
281#include "des/des_enc.c"
282#endif
283#include "des/cbc_cksm.c"
284#include "des/xcbc_enc.c"
285#include "des/cbc_enc.c"
286#include "des/cfb64ede.c"
287#include "des/cfb64enc.c"
288#include "des/cfb_enc.c"
289#include "des/ecb3_enc.c"
290#include "des/ecb_enc.c"
291#include "des/enc_read.c"
292#include "des/enc_writ.c"
293#include "des/fcrypt.c"
294#include "des/ofb64ede.c"
295#include "des/ofb64enc.c"
296#include "des/ofb_enc.c"
297#include "des/pcbc_enc.c"
298#include "des/qud_cksm.c"
299#include "des/rand_key.c"
300#include "des/read2pwd.c"
301#include "des/rpc_enc.c"
302#include "des/set_key.c"
303#include "des/str2key.c"
304#include "des/supp.c"
305#endif
306#endif
307
308#ifdef CRYPTO_DH_SUBSET
309#ifndef NO_DH
310#include "dh/dh_check.c"
311#include "dh/dh_err.c"
312#include "dh/dh_gen.c"
313#include "dh/dh_key.c"
314#include "dh/dh_lib.c"
315#endif
316#endif
317
318#ifdef CRYPTO_DSA_SUBSET
319#ifndef NO_DSA
320#include "dsa/dsa_gen.c"
321#include "dsa/dsa_key.c"
322#include "dsa/dsa_lib.c"
323#include "dsa/dsa_sign.c"
324#include "dsa/dsa_vrf.c"
325#include "dsa/dsa_err.c"
326#endif
327#endif
328
329#ifdef CRYPTO_ERROR_SUBSET
330#include "err/err.c"
331#include "err/err_all.c"
332#include "err/err_prn.c"
333#endif
334
335#ifdef CRYPTO_EVP_SUBSET
336#include "evp/bio_md.c"
337#include "evp/bio_b64.c"
338#include "evp/bio_enc.c"
339#include "evp/c_all.c"
340#include "evp/digest.c"
341#ifndef NO_DES
342#include "evp/e_cbc_3d.c"
343#include "evp/e_cfb_3d.c"
344#include "evp/e_ecb_3d.c"
345#include "evp/e_ofb_3d.c"
346#include "evp/e_cbc_d.c"
347#include "evp/e_cfb_d.c"
348#include "evp/e_xcbc_d.c"
349#include "evp/e_ecb_d.c"
350#include "evp/e_ofb_d.c"
351#endif
352#ifndef NO_IDEA
353#include "evp/e_cbc_i.c"
354#include "evp/e_cfb_i.c"
355#include "evp/e_ecb_i.c"
356#include "evp/e_ofb_i.c"
357#endif
358#ifndef NO_RC2
359#include "evp/e_cbc_r2.c"
360#include "evp/e_cfb_r2.c"
361#include "evp/e_ecb_r2.c"
362#include "evp/e_ofb_r2.c"
363#endif
364#ifndef NO_BLOWFISH
365#include "evp/e_cbc_bf.c"
366#include "evp/e_cfb_bf.c"
367#include "evp/e_ecb_bf.c"
368#include "evp/e_ofb_bf.c"
369#endif
370#ifndef NO_CAST
371#include "evp/e_cbc_c.c"
372#include "evp/e_cfb_c.c"
373#include "evp/e_ecb_c.c"
374#include "evp/e_ofb_c.c"
375#endif
376#ifndef NO_RC4
377#include "evp/e_rc4.c"
378#endif
379#include "rc5/rc5_enc.c"
380#include "rc5/rc5cfb64.c"
381#include "rc5/rc5_ecb.c"
382#include "rc5/rc5_skey.c"
383#include "rc5/rc5ofb64.c"
384#include "ripemd/rmd160.c"
385#include "ripemd/rmd_dgst.c"
386#include "ripemd/rmd_one.c"
387#include "evp/evp_lib.c"
388
389#include "evp/names.c"
390#include "evp/e_null.c"
391#include "evp/encode.c"
392#include "evp/evp_enc.c"
393#include "evp/evp_err.c"
394#include "evp/evp_key.c"
395#include "evp/m_null.c"
396#include "evp/p_lib.c"
397#ifndef NO_RSA
398#include "evp/p_open.c"
399#include "evp/p_seal.c"
400#endif
401#include "evp/p_sign.c"
402#include "evp/p_verify.c"
403#endif
404
405#ifdef CRYPTO_IDEA_SUBSET
406#ifndef NO_IDEA
407#include "idea/i_cbc.c"
408#include "idea/i_cfb64.c"
409#include "idea/i_ecb.c"
410#include "idea/i_ofb64.c"
411#include "idea/i_skey.c"
412#endif
413#endif
414
415#ifdef CRYPTO_BLOWFISH_SUBSET
416#ifndef NO_BLOWFISH
417#include "bf/bf_cfb64.c"
418#include "bf/bf_ecb.c"
419#ifndef BF_ASM
420#include "bf/bf_enc.c"
421#endif
422#include "bf/bf_ofb64.c"
423#include "bf/bf_skey.c"
424#endif
425#endif
426
427#ifdef CRYPTO_CAST_SUBSET
428#ifndef NO_CAST
429#include "cast/c_cfb64.c"
430#include "cast/c_ecb.c"
431#ifndef CAST_ASM
432#include "cast/c_enc.c"
433#endif
434#include "cast/c_ofb64.c"
435#include "cast/c_skey.c"
436#endif
437#endif
438
439#ifdef CRYPTO_LHASH_SUBSET
440#include "lhash/lh_stats.c"
441#include "lhash/lhash.c"
442#endif
443
444#ifdef CRYPTO_MD_SUBSET
445#ifndef NO_MD2
446#include "md2/md2_dgst.c"
447#include "md2/md2_one.c"
448#include "evp/m_md2.c"
449#endif
450#ifndef NO_MD5
451#include "md5/md5_dgst.c"
452#include "md5/md5_one.c"
453#include "evp/m_md5.c"
454#endif
455#endif
456
457#ifdef CRYPTO_MDC2_SUBSET
458#ifndef NO_MDC2
459#include "mdc2/mdc2dgst.c"
460#include "mdc2/mdc2_one.c"
461#include "evp/m_mdc2.c"
462#endif
463#endif
464
465#ifdef CRYPTO_OBJECTS_SUBSET
466#include "objects/obj_dat.c"
467#include "objects/obj_err.c"
468#include "objects/obj_lib.c"
469#endif
470
471#ifdef CRYPTO_PEM_SUBSET
472#include "pem/pem_err.c"
473#include "pem/pem_info.c"
474#include "pem/pem_lib.c"
475#include "pem/pem_all.c"
476#ifndef NO_RSA
477#include "pem/pem_seal.c"
478#include "pem/pem_sign.c"
479#endif
480#endif
481
482#ifdef CRYPTO_RAND_SUBSET
483#include "rand/md_rand.c"
484#include "rand/randfile.c"
485#endif
486
487#ifdef CRYPTO_RC_SUBSET
488#ifndef NO_RC2
489#include "rc2/rc2_cbc.c"
490#include "rc2/rc2_ecb.c"
491#include "rc2/rc2_skey.c"
492#include "rc2/rc2cfb64.c"
493#include "rc2/rc2ofb64.c"
494#endif
495#ifndef NO_RC4
496#include "rc4/rc4_skey.c"
497#ifndef RC4_ASM
498#include "rc4/rc4_enc.c"
499#endif
500#endif
501#endif
502
503#ifdef CRYPTO_HMAC_SUBSET
504#include "hmac/hmac.c"
505#endif
506
507#ifdef CRYPTO_RSA_SUBSET
508#ifndef NO_RSA
509#include "rsa/rsa_eay.c"
510#include "rsa/rsa_err.c"
511#include "rsa/rsa_gen.c"
512#include "rsa/rsa_lib.c"
513#include "rsa/rsa_sign.c"
514#include "rsa/rsa_saos.c"
515#endif
516#endif
517
518#ifdef CRYPTO_SHA1_SUBSET
519#ifndef NO_SHA1
520#include "sha/sha1_one.c"
521#include "sha/sha1dgst.c"
522#include "evp/m_dss1.c"
523#include "evp/m_sha1.c"
524#endif
525#endif
526
527#ifdef CRYPTO_SHA_SUBSET
528#ifndef NO_SHA
529#include "evp/m_dss.c"
530#include "sha/sha_dgst.c"
531#include "sha/sha_one.c"
532#include "evp/m_sha.c"
533#endif
534#endif
535
536#ifdef CRYPTO_STACK_SUBSET
537#include "stack/stack.c"
538#endif
539
540#ifdef CRYPTO_TXT_DB_SUBSET
541#include "txt_db/txt_db.c"
542#endif
543
544#ifdef CRYPTO_X509_SUBSET
545#include "x509/x509_cmp.c"
546#include "x509/x509_d2.c"
547#include "x509/x509_def.c"
548#include "x509/x509_err.c"
549#include "x509/x509_ext.c"
550#include "x509/x509_lu.c"
551#include "x509/x509_obj.c"
552#include "x509/x509_r2x.c"
553#include "x509/x509_req.c"
554#include "x509/x509_set.c"
555#include "x509/x509_v3.c"
556#include "x509/x509_vfy.c"
557#include "x509/x509name.c"
558#include "x509/x509pack.c"
559#include "x509/x509rset.c"
560#include "x509/x509type.c"
561#include "x509/x_all.c"
562#include "x509/x509_txt.c"
563#include "x509/by_dir.c"
564#include "x509/by_file.c"
565#include "x509/v3_net.c"
566#include "x509/v3_x509.c"
567#endif
568
569
570#ifdef CRYPTO_PKCS7_SUBSET /* I have an explicit removal of 7 lines */
571#include "pkcs7/pk7_lib.c"
572#include "pkcs7/pkcs7err.c"
573#include "pkcs7/pk7_doit.c"
574#endif /* CRYPTO_PKCS7_SUBSET */
575