From e82f18fab47b698d93971f576f962a3068132912 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 5 Oct 1998 20:13:17 +0000 Subject: This commit was manufactured by cvs2git to create tag 'SSLeay_0_9_0b'. --- src/lib/libcrypto/Makefile.ssl | 161 ++ src/lib/libcrypto/asn1/Makefile.ssl | 120 + src/lib/libcrypto/asn1/a_bmp.c | 90 + src/lib/libcrypto/asn1/asn1.err | 182 ++ src/lib/libcrypto/asn1/d2i_dhp.c | 108 + src/lib/libcrypto/asn1/d2i_dsap.c | 101 + src/lib/libcrypto/asn1/d2i_r_pr.c | 129 + src/lib/libcrypto/asn1/d2i_r_pu.c | 100 + src/lib/libcrypto/asn1/d2i_s_pr.c | 113 + src/lib/libcrypto/asn1/d2i_s_pu.c | 124 + src/lib/libcrypto/asn1/f.c | 80 + src/lib/libcrypto/asn1/i2d_dhp.c | 128 + src/lib/libcrypto/asn1/i2d_dsap.c | 121 + src/lib/libcrypto/asn1/i2d_r_pr.c | 132 + src/lib/libcrypto/asn1/i2d_r_pu.c | 118 + src/lib/libcrypto/asn1/i2d_s_pr.c | 128 + src/lib/libcrypto/asn1/i2d_s_pu.c | 133 + src/lib/libcrypto/asn1/p7_dgst.c | 130 + src/lib/libcrypto/asn1/p7_enc.c | 120 + src/lib/libcrypto/asn1/p7_enc_c.c | 127 + src/lib/libcrypto/asn1/p7_evp.c | 125 + src/lib/libcrypto/asn1/p7_i_s.c | 120 + src/lib/libcrypto/asn1/p7_lib.c | 299 ++ src/lib/libcrypto/asn1/p7_recip.c | 132 + src/lib/libcrypto/asn1/p7_s_e.c | 146 + src/lib/libcrypto/asn1/p7_signd.c | 140 + src/lib/libcrypto/asn1/p7_signi.c | 149 + src/lib/libcrypto/asn1/pkcs8.c | 142 + src/lib/libcrypto/asn1/x_cinf.c | 197 ++ src/lib/libcrypto/bf/Makefile.ssl | 107 + src/lib/libcrypto/bf/Makefile.uni | 169 ++ src/lib/libcrypto/bf/asm/b-win32.asm | 906 ++++++ src/lib/libcrypto/bf/asm/bx86unix.cpp | 976 +++++++ src/lib/libcrypto/bf/bf_locl.org | 242 ++ src/lib/libcrypto/bio/Makefile.ssl | 92 + src/lib/libcrypto/bio/bio.err | 46 + src/lib/libcrypto/bn/Makefile.ssl | 133 + src/lib/libcrypto/bn/asm/bn-win32.asm | 689 +++++ src/lib/libcrypto/bn/asm/bn86unix.cpp | 752 +++++ src/lib/libcrypto/bn/asm/sparc.s | 462 +++ src/lib/libcrypto/bn/asm/x86w16.asm | 297 ++ src/lib/libcrypto/bn/asm/x86w32.asm | 362 +++ src/lib/libcrypto/bn/bn.err | 27 + src/lib/libcrypto/bn/bn.org | 502 ++++ src/lib/libcrypto/bn/bn_m.c | 169 ++ src/lib/libcrypto/bn/bn_mulw.c | 366 +++ src/lib/libcrypto/bn/bn_sub.c | 180 ++ src/lib/libcrypto/buffer/Makefile.ssl | 84 + src/lib/libcrypto/buffer/buffer.err | 9 + src/lib/libcrypto/cast/Makefile.ssl | 109 + src/lib/libcrypto/cast/Makefile.uni | 123 + src/lib/libcrypto/cast/asm/c-win32.asm | 940 ++++++ src/lib/libcrypto/cast/asm/cx86unix.cpp | 1010 +++++++ src/lib/libcrypto/conf/Makefile.ssl | 85 + src/lib/libcrypto/conf/conf.c | 727 +++++ src/lib/libcrypto/conf/conf.err | 12 + src/lib/libcrypto/conf/conf_lcl.h | 102 + src/lib/libcrypto/cryptall.h | 110 + src/lib/libcrypto/crypto.c | 575 ++++ src/lib/libcrypto/crypto.err | 8 + src/lib/libcrypto/date.h | 1 + src/lib/libcrypto/des/DES.pod | 16 + src/lib/libcrypto/des/FILES | 96 + src/lib/libcrypto/des/MODES.DES | 84 + src/lib/libcrypto/des/Makefile.PL | 14 + src/lib/libcrypto/des/Makefile.lit | 250 ++ src/lib/libcrypto/des/Makefile.ssl | 140 + src/lib/libcrypto/des/Makefile.uni | 263 ++ src/lib/libcrypto/des/PC1 | 28 + src/lib/libcrypto/des/PC2 | 57 + src/lib/libcrypto/des/asm/d-win32.asm | 3132 ++++++++++++++++++++ src/lib/libcrypto/des/asm/dx86unix.cpp | 3202 +++++++++++++++++++++ src/lib/libcrypto/des/asm/y-win32.asm | 929 ++++++ src/lib/libcrypto/des/asm/yx86unix.cpp | 976 +++++++ src/lib/libcrypto/des/des.man | 186 ++ src/lib/libcrypto/des/des.org | 301 ++ src/lib/libcrypto/des/des.pl | 552 ++++ src/lib/libcrypto/des/des_crypt.man | 508 ++++ src/lib/libcrypto/des/des_locl.org | 516 ++++ src/lib/libcrypto/des/doIP | 46 + src/lib/libcrypto/des/doPC1 | 110 + src/lib/libcrypto/des/doPC2 | 94 + src/lib/libcrypto/des/ede_enc.c | 190 ++ src/lib/libcrypto/des/podd.h | 75 + src/lib/libcrypto/des/ranlib.sh | 23 + src/lib/libcrypto/des/shifts.pl | 198 ++ src/lib/libcrypto/des/sk.h | 204 ++ src/lib/libcrypto/des/supp.c | 109 + src/lib/libcrypto/des/testdes.pl | 167 ++ src/lib/libcrypto/des/vms.com | 90 + src/lib/libcrypto/dh/Makefile.ssl | 84 + src/lib/libcrypto/dh/dh.err | 12 + src/lib/libcrypto/dsa/Makefile.ssl | 84 + src/lib/libcrypto/dsa/dsa.err | 15 + src/lib/libcrypto/err/Makefile.ssl | 80 + src/lib/libcrypto/err/err_code.pl | 105 + src/lib/libcrypto/err/err_genc.pl | 198 ++ src/lib/libcrypto/err/error.err | 13 + src/lib/libcrypto/err/ssleay.ec | 57 + src/lib/libcrypto/evp/Makefile.ssl | 111 + src/lib/libcrypto/evp/e_cbc_3d.c | 163 ++ src/lib/libcrypto/evp/e_cbc_bf.c | 119 + src/lib/libcrypto/evp/e_cbc_c.c | 119 + src/lib/libcrypto/evp/e_cbc_d.c | 116 + src/lib/libcrypto/evp/e_cbc_i.c | 131 + src/lib/libcrypto/evp/e_cbc_r2.c | 136 + src/lib/libcrypto/evp/e_cbc_r5.c | 120 + src/lib/libcrypto/evp/e_cfb_3d.c | 166 ++ src/lib/libcrypto/evp/e_cfb_bf.c | 121 + src/lib/libcrypto/evp/e_cfb_c.c | 121 + src/lib/libcrypto/evp/e_cfb_d.c | 118 + src/lib/libcrypto/evp/e_cfb_i.c | 121 + src/lib/libcrypto/evp/e_cfb_r2.c | 122 + src/lib/libcrypto/evp/e_cfb_r5.c | 122 + src/lib/libcrypto/evp/e_ecb_3d.c | 161 ++ src/lib/libcrypto/evp/e_ecb_bf.c | 122 + src/lib/libcrypto/evp/e_ecb_c.c | 122 + src/lib/libcrypto/evp/e_ecb_d.c | 118 + src/lib/libcrypto/evp/e_ecb_i.c | 133 + src/lib/libcrypto/evp/e_ecb_r2.c | 123 + src/lib/libcrypto/evp/e_ecb_r5.c | 123 + src/lib/libcrypto/evp/e_ofb_3d.c | 165 ++ src/lib/libcrypto/evp/e_ofb_bf.c | 122 + src/lib/libcrypto/evp/e_ofb_c.c | 122 + src/lib/libcrypto/evp/e_ofb_d.c | 118 + src/lib/libcrypto/evp/e_ofb_i.c | 121 + src/lib/libcrypto/evp/e_ofb_r2.c | 123 + src/lib/libcrypto/evp/e_ofb_r5.c | 123 + src/lib/libcrypto/evp/evp.err | 24 + src/lib/libcrypto/evp/pk_lib.c | 82 + src/lib/libcrypto/hmac/Makefile.ssl | 80 + src/lib/libcrypto/idea/Makefile.ssl | 80 + src/lib/libcrypto/lhash/Makefile.ssl | 80 + src/lib/libcrypto/libvms.com | 31 + src/lib/libcrypto/md2/Makefile.ssl | 80 + src/lib/libcrypto/md2/md2.org | 106 + src/lib/libcrypto/md5/Makefile.ssl | 104 + src/lib/libcrypto/md5/Makefile.uni | 109 + src/lib/libcrypto/md5/asm/m5-win32.asm | 686 +++++ src/lib/libcrypto/md5/asm/mx86unix.cpp | 730 +++++ src/lib/libcrypto/mdc2/Makefile.ssl | 80 + src/lib/libcrypto/objects/Makefile.ssl | 87 + src/lib/libcrypto/objects/objects.err | 12 + src/lib/libcrypto/pem/Makefile.ssl | 96 + src/lib/libcrypto/pem/ctx_size.c | 122 + src/lib/libcrypto/pem/pem.err | 38 + src/lib/libcrypto/pem/pem.org | 562 ++++ src/lib/libcrypto/pkcs7/Makefile.ssl | 86 + src/lib/libcrypto/pkcs7/README | 5 + src/lib/libcrypto/pkcs7/mf.p7 | 18 + src/lib/libcrypto/pkcs7/p7.tst | 33 + src/lib/libcrypto/pkcs7/pkcs7.err | 26 + src/lib/libcrypto/rand/Makefile.ssl | 80 + src/lib/libcrypto/ranlib.sh | 23 + src/lib/libcrypto/rc2/Makefile.ssl | 80 + src/lib/libcrypto/rc2/Makefile.uni | 72 + src/lib/libcrypto/rc2/rc2.org | 118 + src/lib/libcrypto/rc4/Makefile.ssl | 108 + src/lib/libcrypto/rc4/Makefile.uni | 102 + src/lib/libcrypto/rc4/asm/r4-win32.asm | 314 ++ src/lib/libcrypto/rc4/asm/rx86unix.cpp | 358 +++ src/lib/libcrypto/rc4/rc4.org | 103 + src/lib/libcrypto/rc4/rc4_locl.org | 70 + src/lib/libcrypto/rc5/Makefile.ssl | 107 + src/lib/libcrypto/rc5/Makefile.uni | 72 + src/lib/libcrypto/rc5/asm/r5-win32.asm | 574 ++++ src/lib/libcrypto/rc5/asm/r586unix.cpp | 628 ++++ src/lib/libcrypto/rc5/asm/rc5-586.pl | 109 + src/lib/libcrypto/ripemd/Makefile.ssl | 104 + src/lib/libcrypto/ripemd/Makefile.uni | 109 + src/lib/libcrypto/ripemd/asm/rm-win32.asm | 1972 +++++++++++++ src/lib/libcrypto/ripemd/asm/rm86unix.cpp | 2016 +++++++++++++ src/lib/libcrypto/rsa/Makefile.ssl | 86 + src/lib/libcrypto/rsa/rsa.err | 45 + src/lib/libcrypto/sha/Makefile.ssl | 103 + src/lib/libcrypto/sha/Makefile.uni | 122 + src/lib/libcrypto/sha/asm/s1-win32.asm | 1664 +++++++++++ src/lib/libcrypto/sha/asm/sx86unix.cpp | 1948 +++++++++++++ src/lib/libcrypto/sha/sha_sgst.c | 246 ++ src/lib/libcrypto/stack/Makefile.ssl | 80 + src/lib/libcrypto/txt_db/Makefile.ssl | 80 + src/lib/libcrypto/util/mklink.sh | 35 + src/lib/libcrypto/util/ranlib.sh | 23 + src/lib/libcrypto/util/sep_lib.sh | 37 + src/lib/libcrypto/util/ssldir.pl | 52 + src/lib/libcrypto/util/up_ver.pl | 79 + src/lib/libcrypto/x509/Makefile.ssl | 96 + src/lib/libcrypto/x509/attrib | 38 + src/lib/libcrypto/x509/v3_net.c | 87 + src/lib/libcrypto/x509/v3_x509.c | 253 ++ src/lib/libcrypto/x509/x509.doc | 27 + src/lib/libcrypto/x509/x509.err | 46 + src/lib/libcrypto/x509/x509pack.c | 157 + src/lib/libcrypto/x509/x509v3.doc | 24 + src/lib/libcrypto/x509v3/format | 92 + src/lib/libcrypto/x509v3/header | 6 + src/lib/libcrypto/x509v3/v3_ku.c | 318 ++ src/lib/libssl/Makefile | 12 + src/lib/libssl/Makefile.bsd-wrapper | 82 + src/lib/libssl/README.OPENBSD | 66 + src/lib/libssl/crypto-patent/Makefile | 170 ++ src/lib/libssl/crypto-patent/shlib_version | 2 + src/lib/libssl/crypto/Makefile | 170 ++ src/lib/libssl/crypto/shlib_version | 2 + src/lib/libssl/src/COPYRIGHT | 65 + src/lib/libssl/src/HISTORY | 316 ++ src/lib/libssl/src/HISTORY.066 | 443 +++ src/lib/libssl/src/MICROSOFT | 146 + src/lib/libssl/src/MINFO | 968 +++++++ src/lib/libssl/src/Makefile.ssl | 331 +++ src/lib/libssl/src/PATENTS | 9 + src/lib/libssl/src/README.066 | 27 + src/lib/libssl/src/README.080 | 147 + src/lib/libssl/src/README.090 | 71 + src/lib/libssl/src/TODO | 28 + src/lib/libssl/src/VERSION | 24 + src/lib/libssl/src/apps/Makefile.ssl | 144 + src/lib/libssl/src/apps/der_chop | 305 ++ src/lib/libssl/src/apps/eay.c | 130 + src/lib/libssl/src/apps/ext.v3 | 2 + src/lib/libssl/src/apps/g_ssleay.pl | 114 + src/lib/libssl/src/apps/mklinks | 7 + src/lib/libssl/src/apps/pem_mail.c | 170 ++ src/lib/libssl/src/apps/rmlinks | 6 + src/lib/libssl/src/apps/ssleay.c | 342 +++ src/lib/libssl/src/apps/ssleay.cnf | 116 + src/lib/libssl/src/apps/tkca | 66 + src/lib/libssl/src/certs/ICE-CA.pem | 59 + src/lib/libssl/src/certs/ICE-root.pem | 48 + src/lib/libssl/src/certs/ICE-user.pem | 63 + src/lib/libssl/src/certs/ICE.crl | 9 + src/lib/libssl/src/certs/ca-cert.pem | 31 + src/lib/libssl/src/certs/dsa-ca.pem | 43 + src/lib/libssl/src/certs/dsa-pca.pem | 49 + src/lib/libssl/src/certs/factory.pem | 15 + src/lib/libssl/src/certs/nortelCA.pem | 16 + src/lib/libssl/src/certs/pca-cert.pem | 31 + src/lib/libssl/src/certs/rsa-cca.pem | 19 + src/lib/libssl/src/certs/rsa-ssca.pem | 19 + src/lib/libssl/src/certs/timCA.pem | 16 + src/lib/libssl/src/certs/tjhCA.pem | 15 + src/lib/libssl/src/certs/vsign2.pem | 31 + src/lib/libssl/src/certs/vsign4.pem | 16 + src/lib/libssl/src/crypto/Makefile.ssl | 161 ++ src/lib/libssl/src/crypto/asn1/Makefile.ssl | 120 + src/lib/libssl/src/crypto/asn1/a_bmp.c | 90 + src/lib/libssl/src/crypto/asn1/asn1.err | 182 ++ src/lib/libssl/src/crypto/asn1/d2i_dhp.c | 108 + src/lib/libssl/src/crypto/asn1/d2i_dsap.c | 101 + src/lib/libssl/src/crypto/asn1/d2i_r_pr.c | 129 + src/lib/libssl/src/crypto/asn1/d2i_r_pu.c | 100 + src/lib/libssl/src/crypto/asn1/d2i_s_pr.c | 113 + src/lib/libssl/src/crypto/asn1/d2i_s_pu.c | 124 + src/lib/libssl/src/crypto/asn1/f.c | 80 + src/lib/libssl/src/crypto/asn1/i2d_dhp.c | 128 + src/lib/libssl/src/crypto/asn1/i2d_dsap.c | 121 + src/lib/libssl/src/crypto/asn1/i2d_r_pr.c | 132 + src/lib/libssl/src/crypto/asn1/i2d_r_pu.c | 118 + src/lib/libssl/src/crypto/asn1/i2d_s_pr.c | 128 + src/lib/libssl/src/crypto/asn1/i2d_s_pu.c | 133 + src/lib/libssl/src/crypto/asn1/p7_dgst.c | 130 + src/lib/libssl/src/crypto/asn1/p7_enc.c | 120 + src/lib/libssl/src/crypto/asn1/p7_enc_c.c | 127 + src/lib/libssl/src/crypto/asn1/p7_evp.c | 125 + src/lib/libssl/src/crypto/asn1/p7_i_s.c | 120 + src/lib/libssl/src/crypto/asn1/p7_lib.c | 299 ++ src/lib/libssl/src/crypto/asn1/p7_recip.c | 132 + src/lib/libssl/src/crypto/asn1/p7_s_e.c | 146 + src/lib/libssl/src/crypto/asn1/p7_signd.c | 140 + src/lib/libssl/src/crypto/asn1/p7_signi.c | 149 + src/lib/libssl/src/crypto/asn1/pkcs8.c | 142 + src/lib/libssl/src/crypto/asn1/x_cinf.c | 197 ++ src/lib/libssl/src/crypto/bf/Makefile.ssl | 107 + src/lib/libssl/src/crypto/bf/Makefile.uni | 169 ++ src/lib/libssl/src/crypto/bf/asm/b-win32.asm | 906 ++++++ src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp | 976 +++++++ src/lib/libssl/src/crypto/bf/bf_locl.org | 242 ++ src/lib/libssl/src/crypto/bio/Makefile.ssl | 92 + src/lib/libssl/src/crypto/bio/bio.err | 46 + src/lib/libssl/src/crypto/bn/Makefile.ssl | 133 + src/lib/libssl/src/crypto/bn/asm/bn-win32.asm | 689 +++++ src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp | 752 +++++ src/lib/libssl/src/crypto/bn/asm/sparc.s | 462 +++ src/lib/libssl/src/crypto/bn/asm/x86w16.asm | 297 ++ src/lib/libssl/src/crypto/bn/asm/x86w32.asm | 362 +++ src/lib/libssl/src/crypto/bn/bn.err | 27 + src/lib/libssl/src/crypto/bn/bn.org | 502 ++++ src/lib/libssl/src/crypto/bn/bn_m.c | 169 ++ src/lib/libssl/src/crypto/bn/bn_mulw.c | 366 +++ src/lib/libssl/src/crypto/bn/bn_sub.c | 180 ++ src/lib/libssl/src/crypto/buffer/Makefile.ssl | 84 + src/lib/libssl/src/crypto/buffer/buffer.err | 9 + src/lib/libssl/src/crypto/cast/Makefile.ssl | 109 + src/lib/libssl/src/crypto/cast/Makefile.uni | 123 + src/lib/libssl/src/crypto/cast/asm/c-win32.asm | 940 ++++++ src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp | 1010 +++++++ src/lib/libssl/src/crypto/conf/Makefile.ssl | 85 + src/lib/libssl/src/crypto/conf/conf.c | 727 +++++ src/lib/libssl/src/crypto/conf/conf.err | 12 + src/lib/libssl/src/crypto/conf/conf_lcl.h | 102 + src/lib/libssl/src/crypto/cryptall.h | 110 + src/lib/libssl/src/crypto/crypto.c | 575 ++++ src/lib/libssl/src/crypto/crypto.err | 8 + src/lib/libssl/src/crypto/date.h | 1 + src/lib/libssl/src/crypto/des/DES.pod | 16 + src/lib/libssl/src/crypto/des/FILES | 96 + src/lib/libssl/src/crypto/des/MODES.DES | 84 + src/lib/libssl/src/crypto/des/Makefile.PL | 14 + src/lib/libssl/src/crypto/des/Makefile.lit | 250 ++ src/lib/libssl/src/crypto/des/Makefile.ssl | 140 + src/lib/libssl/src/crypto/des/Makefile.uni | 263 ++ src/lib/libssl/src/crypto/des/PC1 | 28 + src/lib/libssl/src/crypto/des/PC2 | 57 + src/lib/libssl/src/crypto/des/asm/d-win32.asm | 3132 ++++++++++++++++++++ src/lib/libssl/src/crypto/des/asm/dx86unix.cpp | 3202 +++++++++++++++++++++ src/lib/libssl/src/crypto/des/asm/y-win32.asm | 929 ++++++ src/lib/libssl/src/crypto/des/asm/yx86unix.cpp | 976 +++++++ src/lib/libssl/src/crypto/des/des.man | 186 ++ src/lib/libssl/src/crypto/des/des.org | 301 ++ src/lib/libssl/src/crypto/des/des.pl | 552 ++++ src/lib/libssl/src/crypto/des/des_crypt.man | 508 ++++ src/lib/libssl/src/crypto/des/des_locl.org | 516 ++++ src/lib/libssl/src/crypto/des/doIP | 46 + src/lib/libssl/src/crypto/des/doPC1 | 110 + src/lib/libssl/src/crypto/des/doPC2 | 94 + src/lib/libssl/src/crypto/des/ede_enc.c | 190 ++ src/lib/libssl/src/crypto/des/podd.h | 75 + src/lib/libssl/src/crypto/des/ranlib.sh | 23 + src/lib/libssl/src/crypto/des/shifts.pl | 198 ++ src/lib/libssl/src/crypto/des/sk.h | 204 ++ src/lib/libssl/src/crypto/des/supp.c | 109 + src/lib/libssl/src/crypto/des/testdes.pl | 167 ++ src/lib/libssl/src/crypto/des/vms.com | 90 + src/lib/libssl/src/crypto/dh/Makefile.ssl | 84 + src/lib/libssl/src/crypto/dh/dh.err | 12 + src/lib/libssl/src/crypto/dsa/Makefile.ssl | 84 + src/lib/libssl/src/crypto/dsa/dsa.err | 15 + src/lib/libssl/src/crypto/err/Makefile.ssl | 80 + src/lib/libssl/src/crypto/err/err_code.pl | 105 + src/lib/libssl/src/crypto/err/err_genc.pl | 198 ++ src/lib/libssl/src/crypto/err/error.err | 13 + src/lib/libssl/src/crypto/err/ssleay.ec | 57 + src/lib/libssl/src/crypto/evp/Makefile.ssl | 111 + src/lib/libssl/src/crypto/evp/e_cbc_3d.c | 163 ++ src/lib/libssl/src/crypto/evp/e_cbc_bf.c | 119 + src/lib/libssl/src/crypto/evp/e_cbc_c.c | 119 + src/lib/libssl/src/crypto/evp/e_cbc_d.c | 116 + src/lib/libssl/src/crypto/evp/e_cbc_i.c | 131 + src/lib/libssl/src/crypto/evp/e_cbc_r2.c | 136 + src/lib/libssl/src/crypto/evp/e_cbc_r5.c | 120 + src/lib/libssl/src/crypto/evp/e_cfb_3d.c | 166 ++ src/lib/libssl/src/crypto/evp/e_cfb_bf.c | 121 + src/lib/libssl/src/crypto/evp/e_cfb_c.c | 121 + src/lib/libssl/src/crypto/evp/e_cfb_d.c | 118 + src/lib/libssl/src/crypto/evp/e_cfb_i.c | 121 + src/lib/libssl/src/crypto/evp/e_cfb_r2.c | 122 + src/lib/libssl/src/crypto/evp/e_cfb_r5.c | 122 + src/lib/libssl/src/crypto/evp/e_ecb_3d.c | 161 ++ src/lib/libssl/src/crypto/evp/e_ecb_bf.c | 122 + src/lib/libssl/src/crypto/evp/e_ecb_c.c | 122 + src/lib/libssl/src/crypto/evp/e_ecb_d.c | 118 + src/lib/libssl/src/crypto/evp/e_ecb_i.c | 133 + src/lib/libssl/src/crypto/evp/e_ecb_r2.c | 123 + src/lib/libssl/src/crypto/evp/e_ecb_r5.c | 123 + src/lib/libssl/src/crypto/evp/e_ofb_3d.c | 165 ++ src/lib/libssl/src/crypto/evp/e_ofb_bf.c | 122 + src/lib/libssl/src/crypto/evp/e_ofb_c.c | 122 + src/lib/libssl/src/crypto/evp/e_ofb_d.c | 118 + src/lib/libssl/src/crypto/evp/e_ofb_i.c | 121 + src/lib/libssl/src/crypto/evp/e_ofb_r2.c | 123 + src/lib/libssl/src/crypto/evp/e_ofb_r5.c | 123 + src/lib/libssl/src/crypto/evp/evp.err | 24 + src/lib/libssl/src/crypto/evp/pk_lib.c | 82 + src/lib/libssl/src/crypto/hmac/Makefile.ssl | 80 + src/lib/libssl/src/crypto/idea/Makefile.ssl | 80 + src/lib/libssl/src/crypto/lhash/Makefile.ssl | 80 + src/lib/libssl/src/crypto/libvms.com | 31 + src/lib/libssl/src/crypto/md2/Makefile.ssl | 80 + src/lib/libssl/src/crypto/md2/md2.org | 106 + src/lib/libssl/src/crypto/md5/Makefile.ssl | 104 + src/lib/libssl/src/crypto/md5/Makefile.uni | 109 + src/lib/libssl/src/crypto/md5/asm/m5-win32.asm | 686 +++++ src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp | 730 +++++ src/lib/libssl/src/crypto/mdc2/Makefile.ssl | 80 + src/lib/libssl/src/crypto/objects/Makefile.ssl | 87 + src/lib/libssl/src/crypto/objects/objects.err | 12 + src/lib/libssl/src/crypto/pem/Makefile.ssl | 96 + src/lib/libssl/src/crypto/pem/ctx_size.c | 122 + src/lib/libssl/src/crypto/pem/pem.err | 38 + src/lib/libssl/src/crypto/pem/pem.org | 562 ++++ src/lib/libssl/src/crypto/pkcs7/Makefile.ssl | 86 + src/lib/libssl/src/crypto/pkcs7/README | 5 + src/lib/libssl/src/crypto/pkcs7/mf.p7 | 18 + src/lib/libssl/src/crypto/pkcs7/p7.tst | 33 + src/lib/libssl/src/crypto/pkcs7/pkcs7.err | 26 + src/lib/libssl/src/crypto/rand/Makefile.ssl | 80 + src/lib/libssl/src/crypto/ranlib.sh | 23 + src/lib/libssl/src/crypto/rc2/Makefile.ssl | 80 + src/lib/libssl/src/crypto/rc2/Makefile.uni | 72 + src/lib/libssl/src/crypto/rc2/rc2.org | 118 + src/lib/libssl/src/crypto/rc4/Makefile.ssl | 108 + src/lib/libssl/src/crypto/rc4/Makefile.uni | 102 + src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm | 314 ++ src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp | 358 +++ src/lib/libssl/src/crypto/rc4/rc4.org | 103 + src/lib/libssl/src/crypto/rc4/rc4_locl.org | 70 + src/lib/libssl/src/crypto/rc5/Makefile.ssl | 107 + src/lib/libssl/src/crypto/rc5/Makefile.uni | 72 + src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm | 574 ++++ src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp | 628 ++++ src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl | 109 + src/lib/libssl/src/crypto/ripemd/Makefile.ssl | 104 + src/lib/libssl/src/crypto/ripemd/Makefile.uni | 109 + src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm | 1972 +++++++++++++ src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp | 2016 +++++++++++++ src/lib/libssl/src/crypto/rsa/Makefile.ssl | 86 + src/lib/libssl/src/crypto/rsa/rsa.err | 45 + src/lib/libssl/src/crypto/sha/Makefile.ssl | 103 + src/lib/libssl/src/crypto/sha/Makefile.uni | 122 + src/lib/libssl/src/crypto/sha/asm/s1-win32.asm | 1664 +++++++++++ src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp | 1948 +++++++++++++ src/lib/libssl/src/crypto/sha/sha_sgst.c | 246 ++ src/lib/libssl/src/crypto/stack/Makefile.ssl | 80 + src/lib/libssl/src/crypto/txt_db/Makefile.ssl | 80 + src/lib/libssl/src/crypto/x509/Makefile.ssl | 96 + src/lib/libssl/src/crypto/x509/attrib | 38 + src/lib/libssl/src/crypto/x509/v3_net.c | 87 + src/lib/libssl/src/crypto/x509/v3_x509.c | 253 ++ src/lib/libssl/src/crypto/x509/x509.doc | 27 + src/lib/libssl/src/crypto/x509/x509.err | 46 + src/lib/libssl/src/crypto/x509/x509pack.c | 157 + src/lib/libssl/src/crypto/x509/x509v3.doc | 24 + src/lib/libssl/src/crypto/x509v3/format | 92 + src/lib/libssl/src/crypto/x509v3/header | 6 + src/lib/libssl/src/crypto/x509v3/v3_ku.c | 318 ++ src/lib/libssl/src/dep/crypto.txt | 1043 +++++++ src/lib/libssl/src/dep/files | 574 ++++ src/lib/libssl/src/dep/gen.pl | 113 + src/lib/libssl/src/dep/ssl.txt | 156 + src/lib/libssl/src/doc/API.doc | 24 + src/lib/libssl/src/doc/a_verify.doc | 85 + src/lib/libssl/src/doc/apps.doc | 53 + src/lib/libssl/src/doc/asn1.doc | 401 +++ src/lib/libssl/src/doc/bio.doc | 423 +++ src/lib/libssl/src/doc/blowfish.doc | 146 + src/lib/libssl/src/doc/bn.doc | 381 +++ src/lib/libssl/src/doc/ca.1 | 121 + src/lib/libssl/src/doc/callback.doc | 240 ++ src/lib/libssl/src/doc/cipher.doc | 345 +++ src/lib/libssl/src/doc/cipher.m | 128 + src/lib/libssl/src/doc/conf.doc | 89 + src/lib/libssl/src/doc/des.doc | 505 ++++ src/lib/libssl/src/doc/digest.doc | 94 + src/lib/libssl/src/doc/encode.doc | 15 + src/lib/libssl/src/doc/envelope.doc | 67 + src/lib/libssl/src/doc/error.doc | 115 + src/lib/libssl/src/doc/legal.doc | 117 + src/lib/libssl/src/doc/lhash.doc | 151 + src/lib/libssl/src/doc/md2.doc | 49 + src/lib/libssl/src/doc/md5.doc | 50 + src/lib/libssl/src/doc/memory.doc | 27 + src/lib/libssl/src/doc/ms3-ca.doc | 398 +++ src/lib/libssl/src/doc/ns-ca.doc | 154 + src/lib/libssl/src/doc/obj.doc | 69 + src/lib/libssl/src/doc/rand.doc | 141 + src/lib/libssl/src/doc/rc2.doc | 165 ++ src/lib/libssl/src/doc/rc4.doc | 44 + src/lib/libssl/src/doc/readme | 6 + src/lib/libssl/src/doc/ref.doc | 48 + src/lib/libssl/src/doc/req.1 | 137 + src/lib/libssl/src/doc/rsa.doc | 135 + src/lib/libssl/src/doc/rsaref.doc | 35 + src/lib/libssl/src/doc/s_mult.doc | 17 + src/lib/libssl/src/doc/session.doc | 297 ++ src/lib/libssl/src/doc/sha.doc | 52 + src/lib/libssl/src/doc/speed.doc | 96 + src/lib/libssl/src/doc/ssl-ciph.doc | 84 + src/lib/libssl/src/doc/ssl.doc | 172 ++ src/lib/libssl/src/doc/ssl_ctx.doc | 68 + src/lib/libssl/src/doc/ssleay.doc | 213 ++ src/lib/libssl/src/doc/ssluse.doc | 45 + src/lib/libssl/src/doc/stack.doc | 96 + src/lib/libssl/src/doc/threads.doc | 90 + src/lib/libssl/src/doc/txt_db.doc | 4 + src/lib/libssl/src/doc/verify | 22 + src/lib/libssl/src/doc/why.doc | 79 + src/lib/libssl/src/makefile.one | 1781 ++++++++++++ src/lib/libssl/src/ms/cipher.out | 93 + src/lib/libssl/src/ms/clear.out | 93 + src/lib/libssl/src/ms/libeay16.def | 987 +++++++ src/lib/libssl/src/ms/libeay32.def | 1035 +++++++ src/lib/libssl/src/ms/ntdll.mak | 1853 ++++++++++++ src/lib/libssl/src/ms/ssleay16.def | 171 ++ src/lib/libssl/src/ms/ssleay32.def | 164 ++ src/lib/libssl/src/ms/w31dll.mak | 2295 +++++++++++++++ src/lib/libssl/src/mt/README | 14 + src/lib/libssl/src/mt/mttest.c | 1115 +++++++ src/lib/libssl/src/mt/profile.sh | 4 + src/lib/libssl/src/mt/ptest.bat | 4 + src/lib/libssl/src/mt/pthread.sh | 9 + src/lib/libssl/src/mt/purify.sh | 4 + src/lib/libssl/src/mt/solaris.sh | 4 + src/lib/libssl/src/mt/win32.bat | 4 + src/lib/libssl/src/perl/MANIFEST | 17 + src/lib/libssl/src/perl/Makefile.PL | 25 + src/lib/libssl/src/perl/SSLeay.pm | 78 + src/lib/libssl/src/perl/SSLeay.xs | 63 + src/lib/libssl/src/perl/b.pl | 21 + src/lib/libssl/src/perl/bio.pl | 28 + src/lib/libssl/src/perl/bio.txt | 36 + src/lib/libssl/src/perl/bio.xs | 448 +++ src/lib/libssl/src/perl/bn.pl | 23 + src/lib/libssl/src/perl/bn.txt | 38 + src/lib/libssl/src/perl/bn.xs | 589 ++++ src/lib/libssl/src/perl/callback.c | 103 + src/lib/libssl/src/perl/cipher.pl | 39 + src/lib/libssl/src/perl/cipher.txt | 10 + src/lib/libssl/src/perl/cipher.xs | 152 + src/lib/libssl/src/perl/dh.pl | 40 + src/lib/libssl/src/perl/digest.txt | 7 + src/lib/libssl/src/perl/digest.xs | 83 + src/lib/libssl/src/perl/err.txt | 2 + src/lib/libssl/src/perl/err.xs | 46 + src/lib/libssl/src/perl/f.pl | 25 + src/lib/libssl/src/perl/g.pl | 18 + src/lib/libssl/src/perl/gen_rsa.pl | 49 + src/lib/libssl/src/perl/mul.pl | 56 + src/lib/libssl/src/perl/p5SSLeay.h | 96 + src/lib/libssl/src/perl/r.pl | 56 + src/lib/libssl/src/perl/s.pl | 72 + src/lib/libssl/src/perl/s2.pl | 49 + src/lib/libssl/src/perl/server.pem | 369 +++ src/lib/libssl/src/perl/ss.pl | 64 + src/lib/libssl/src/perl/ssl.pl | 71 + src/lib/libssl/src/perl/ssl.txt | 43 + src/lib/libssl/src/perl/ssl.xs | 474 +++ src/lib/libssl/src/perl/ssl_srvr.pl | 35 + src/lib/libssl/src/perl/sslbio.pl | 40 + src/lib/libssl/src/perl/t.pl | 12 + src/lib/libssl/src/perl/test | 32 + src/lib/libssl/src/perl/test.pl | 30 + src/lib/libssl/src/perl/test.txt | 36 + src/lib/libssl/src/perl/test2.pl | 28 + src/lib/libssl/src/perl/test3.pl | 19 + src/lib/libssl/src/perl/test8.pl | 19 + src/lib/libssl/src/perl/test9.pl | 38 + src/lib/libssl/src/perl/testbn.pl | 23 + src/lib/libssl/src/perl/testdec.pl | 14 + src/lib/libssl/src/perl/testmd.pl | 26 + src/lib/libssl/src/perl/tt.pl | 15 + src/lib/libssl/src/perl/typemap | 96 + src/lib/libssl/src/perl/x509.txt | 6 + src/lib/libssl/src/perl/x509.xs | 74 + src/lib/libssl/src/perl/xstmp.c | 102 + src/lib/libssl/src/perl/y.pl | 7 + src/lib/libssl/src/perl/yy.pl | 19 + src/lib/libssl/src/perl/z.pl | 32 + src/lib/libssl/src/perl/zz.pl | 22 + src/lib/libssl/src/shlib/linux.sh | 76 + src/lib/libssl/src/ssl/Makefile.ssl | 100 + src/lib/libssl/src/ssl/readme | 277 ++ src/lib/libssl/src/ssl/ssl.c | 172 ++ src/lib/libssl/src/ssl/ssl.err | 290 ++ src/lib/libssl/src/test/.rnd | Bin 0 -> 1024 bytes src/lib/libssl/src/test/Makefile.ssl | 294 ++ src/lib/libssl/src/test/certCA.srl | 1 + src/lib/libssl/src/test/demoCA/index.txt | 0 src/lib/libssl/src/test/demoCA/private/cakey.pem | 2 + src/lib/libssl/src/test/demoCA/serial | 1 + src/lib/libssl/src/test/dsa-ca.pem | 43 + src/lib/libssl/src/test/dsa-pca.pem | 49 + src/lib/libssl/src/test/p | 294 ++ src/lib/libssl/src/test/riptest | Bin 0 -> 13325 bytes src/lib/libssl/src/test/test.txt | 31 + src/lib/libssl/src/test/testkey.pem | 2 + src/lib/libssl/src/test/testreq.pem | 9 + src/lib/libssl/src/tools/Makefile.ssl | 54 + src/lib/libssl/src/util/mklink.sh | 35 + src/lib/libssl/src/util/ranlib.sh | 23 + src/lib/libssl/src/util/sep_lib.sh | 37 + src/lib/libssl/src/util/ssldir.pl | 52 + src/lib/libssl/src/util/up_ver.pl | 79 + src/lib/libssl/ssl-patent/Makefile | 45 + src/lib/libssl/ssl-patent/shlib_version | 2 + src/lib/libssl/ssl/Makefile | 45 + src/lib/libssl/ssl/shlib_version | 2 + src/lib/libssl/ssleay/Makefile | 38 + src/lib/libssl/test/.rnd | Bin 0 -> 1024 bytes src/lib/libssl/test/Makefile.ssl | 294 ++ src/lib/libssl/test/certCA.srl | 1 + src/lib/libssl/test/demoCA/index.txt | 0 src/lib/libssl/test/demoCA/private/cakey.pem | 2 + src/lib/libssl/test/demoCA/serial | 1 + src/lib/libssl/test/dsa-ca.pem | 43 + src/lib/libssl/test/dsa-pca.pem | 49 + src/lib/libssl/test/p | 294 ++ src/lib/libssl/test/riptest | Bin 0 -> 13325 bytes src/lib/libssl/test/test.txt | 31 + src/lib/libssl/test/testkey.pem | 2 + src/lib/libssl/test/testreq.pem | 9 + 600 files changed, 124124 insertions(+) create mode 100644 src/lib/libcrypto/Makefile.ssl create mode 100644 src/lib/libcrypto/asn1/Makefile.ssl create mode 100644 src/lib/libcrypto/asn1/a_bmp.c create mode 100644 src/lib/libcrypto/asn1/asn1.err create mode 100644 src/lib/libcrypto/asn1/d2i_dhp.c create mode 100644 src/lib/libcrypto/asn1/d2i_dsap.c create mode 100644 src/lib/libcrypto/asn1/d2i_r_pr.c create mode 100644 src/lib/libcrypto/asn1/d2i_r_pu.c create mode 100644 src/lib/libcrypto/asn1/d2i_s_pr.c create mode 100644 src/lib/libcrypto/asn1/d2i_s_pu.c create mode 100644 src/lib/libcrypto/asn1/f.c create mode 100644 src/lib/libcrypto/asn1/i2d_dhp.c create mode 100644 src/lib/libcrypto/asn1/i2d_dsap.c create mode 100644 src/lib/libcrypto/asn1/i2d_r_pr.c create mode 100644 src/lib/libcrypto/asn1/i2d_r_pu.c create mode 100644 src/lib/libcrypto/asn1/i2d_s_pr.c create mode 100644 src/lib/libcrypto/asn1/i2d_s_pu.c create mode 100644 src/lib/libcrypto/asn1/p7_dgst.c create mode 100644 src/lib/libcrypto/asn1/p7_enc.c create mode 100644 src/lib/libcrypto/asn1/p7_enc_c.c create mode 100644 src/lib/libcrypto/asn1/p7_evp.c create mode 100644 src/lib/libcrypto/asn1/p7_i_s.c create mode 100644 src/lib/libcrypto/asn1/p7_lib.c create mode 100644 src/lib/libcrypto/asn1/p7_recip.c create mode 100644 src/lib/libcrypto/asn1/p7_s_e.c create mode 100644 src/lib/libcrypto/asn1/p7_signd.c create mode 100644 src/lib/libcrypto/asn1/p7_signi.c create mode 100644 src/lib/libcrypto/asn1/pkcs8.c create mode 100644 src/lib/libcrypto/asn1/x_cinf.c create mode 100644 src/lib/libcrypto/bf/Makefile.ssl create mode 100644 src/lib/libcrypto/bf/Makefile.uni create mode 100644 src/lib/libcrypto/bf/asm/b-win32.asm create mode 100644 src/lib/libcrypto/bf/asm/bx86unix.cpp create mode 100644 src/lib/libcrypto/bf/bf_locl.org create mode 100644 src/lib/libcrypto/bio/Makefile.ssl create mode 100644 src/lib/libcrypto/bio/bio.err create mode 100644 src/lib/libcrypto/bn/Makefile.ssl create mode 100644 src/lib/libcrypto/bn/asm/bn-win32.asm create mode 100644 src/lib/libcrypto/bn/asm/bn86unix.cpp create mode 100644 src/lib/libcrypto/bn/asm/sparc.s create mode 100644 src/lib/libcrypto/bn/asm/x86w16.asm create mode 100644 src/lib/libcrypto/bn/asm/x86w32.asm create mode 100644 src/lib/libcrypto/bn/bn.err create mode 100644 src/lib/libcrypto/bn/bn.org create mode 100644 src/lib/libcrypto/bn/bn_m.c create mode 100644 src/lib/libcrypto/bn/bn_mulw.c create mode 100644 src/lib/libcrypto/bn/bn_sub.c create mode 100644 src/lib/libcrypto/buffer/Makefile.ssl create mode 100644 src/lib/libcrypto/buffer/buffer.err create mode 100644 src/lib/libcrypto/cast/Makefile.ssl create mode 100644 src/lib/libcrypto/cast/Makefile.uni create mode 100644 src/lib/libcrypto/cast/asm/c-win32.asm create mode 100644 src/lib/libcrypto/cast/asm/cx86unix.cpp create mode 100644 src/lib/libcrypto/conf/Makefile.ssl create mode 100644 src/lib/libcrypto/conf/conf.c create mode 100644 src/lib/libcrypto/conf/conf.err create mode 100644 src/lib/libcrypto/conf/conf_lcl.h create mode 100644 src/lib/libcrypto/cryptall.h create mode 100644 src/lib/libcrypto/crypto.c create mode 100644 src/lib/libcrypto/crypto.err create mode 100644 src/lib/libcrypto/date.h create mode 100644 src/lib/libcrypto/des/DES.pod create mode 100644 src/lib/libcrypto/des/FILES create mode 100644 src/lib/libcrypto/des/MODES.DES create mode 100644 src/lib/libcrypto/des/Makefile.PL create mode 100644 src/lib/libcrypto/des/Makefile.lit create mode 100644 src/lib/libcrypto/des/Makefile.ssl create mode 100644 src/lib/libcrypto/des/Makefile.uni create mode 100644 src/lib/libcrypto/des/PC1 create mode 100644 src/lib/libcrypto/des/PC2 create mode 100644 src/lib/libcrypto/des/asm/d-win32.asm create mode 100644 src/lib/libcrypto/des/asm/dx86unix.cpp create mode 100644 src/lib/libcrypto/des/asm/y-win32.asm create mode 100644 src/lib/libcrypto/des/asm/yx86unix.cpp create mode 100644 src/lib/libcrypto/des/des.man create mode 100644 src/lib/libcrypto/des/des.org create mode 100644 src/lib/libcrypto/des/des.pl create mode 100644 src/lib/libcrypto/des/des_crypt.man create mode 100644 src/lib/libcrypto/des/des_locl.org create mode 100644 src/lib/libcrypto/des/doIP create mode 100644 src/lib/libcrypto/des/doPC1 create mode 100644 src/lib/libcrypto/des/doPC2 create mode 100644 src/lib/libcrypto/des/ede_enc.c create mode 100644 src/lib/libcrypto/des/podd.h create mode 100644 src/lib/libcrypto/des/ranlib.sh create mode 100644 src/lib/libcrypto/des/shifts.pl create mode 100644 src/lib/libcrypto/des/sk.h create mode 100644 src/lib/libcrypto/des/supp.c create mode 100644 src/lib/libcrypto/des/testdes.pl create mode 100644 src/lib/libcrypto/des/vms.com create mode 100644 src/lib/libcrypto/dh/Makefile.ssl create mode 100644 src/lib/libcrypto/dh/dh.err create mode 100644 src/lib/libcrypto/dsa/Makefile.ssl create mode 100644 src/lib/libcrypto/dsa/dsa.err create mode 100644 src/lib/libcrypto/err/Makefile.ssl create mode 100644 src/lib/libcrypto/err/err_code.pl create mode 100644 src/lib/libcrypto/err/err_genc.pl create mode 100644 src/lib/libcrypto/err/error.err create mode 100644 src/lib/libcrypto/err/ssleay.ec create mode 100644 src/lib/libcrypto/evp/Makefile.ssl create mode 100644 src/lib/libcrypto/evp/e_cbc_3d.c create mode 100644 src/lib/libcrypto/evp/e_cbc_bf.c create mode 100644 src/lib/libcrypto/evp/e_cbc_c.c create mode 100644 src/lib/libcrypto/evp/e_cbc_d.c create mode 100644 src/lib/libcrypto/evp/e_cbc_i.c create mode 100644 src/lib/libcrypto/evp/e_cbc_r2.c create mode 100644 src/lib/libcrypto/evp/e_cbc_r5.c create mode 100644 src/lib/libcrypto/evp/e_cfb_3d.c create mode 100644 src/lib/libcrypto/evp/e_cfb_bf.c create mode 100644 src/lib/libcrypto/evp/e_cfb_c.c create mode 100644 src/lib/libcrypto/evp/e_cfb_d.c create mode 100644 src/lib/libcrypto/evp/e_cfb_i.c create mode 100644 src/lib/libcrypto/evp/e_cfb_r2.c create mode 100644 src/lib/libcrypto/evp/e_cfb_r5.c create mode 100644 src/lib/libcrypto/evp/e_ecb_3d.c create mode 100644 src/lib/libcrypto/evp/e_ecb_bf.c create mode 100644 src/lib/libcrypto/evp/e_ecb_c.c create mode 100644 src/lib/libcrypto/evp/e_ecb_d.c create mode 100644 src/lib/libcrypto/evp/e_ecb_i.c create mode 100644 src/lib/libcrypto/evp/e_ecb_r2.c create mode 100644 src/lib/libcrypto/evp/e_ecb_r5.c create mode 100644 src/lib/libcrypto/evp/e_ofb_3d.c create mode 100644 src/lib/libcrypto/evp/e_ofb_bf.c create mode 100644 src/lib/libcrypto/evp/e_ofb_c.c create mode 100644 src/lib/libcrypto/evp/e_ofb_d.c create mode 100644 src/lib/libcrypto/evp/e_ofb_i.c create mode 100644 src/lib/libcrypto/evp/e_ofb_r2.c create mode 100644 src/lib/libcrypto/evp/e_ofb_r5.c create mode 100644 src/lib/libcrypto/evp/evp.err create mode 100644 src/lib/libcrypto/evp/pk_lib.c create mode 100644 src/lib/libcrypto/hmac/Makefile.ssl create mode 100644 src/lib/libcrypto/idea/Makefile.ssl create mode 100644 src/lib/libcrypto/lhash/Makefile.ssl create mode 100644 src/lib/libcrypto/libvms.com create mode 100644 src/lib/libcrypto/md2/Makefile.ssl create mode 100644 src/lib/libcrypto/md2/md2.org create mode 100644 src/lib/libcrypto/md5/Makefile.ssl create mode 100644 src/lib/libcrypto/md5/Makefile.uni create mode 100644 src/lib/libcrypto/md5/asm/m5-win32.asm create mode 100644 src/lib/libcrypto/md5/asm/mx86unix.cpp create mode 100644 src/lib/libcrypto/mdc2/Makefile.ssl create mode 100644 src/lib/libcrypto/objects/Makefile.ssl create mode 100644 src/lib/libcrypto/objects/objects.err create mode 100644 src/lib/libcrypto/pem/Makefile.ssl create mode 100644 src/lib/libcrypto/pem/ctx_size.c create mode 100644 src/lib/libcrypto/pem/pem.err create mode 100644 src/lib/libcrypto/pem/pem.org create mode 100644 src/lib/libcrypto/pkcs7/Makefile.ssl create mode 100644 src/lib/libcrypto/pkcs7/README create mode 100644 src/lib/libcrypto/pkcs7/mf.p7 create mode 100644 src/lib/libcrypto/pkcs7/p7.tst create mode 100644 src/lib/libcrypto/pkcs7/pkcs7.err create mode 100644 src/lib/libcrypto/rand/Makefile.ssl create mode 100644 src/lib/libcrypto/ranlib.sh create mode 100644 src/lib/libcrypto/rc2/Makefile.ssl create mode 100644 src/lib/libcrypto/rc2/Makefile.uni create mode 100644 src/lib/libcrypto/rc2/rc2.org create mode 100644 src/lib/libcrypto/rc4/Makefile.ssl create mode 100644 src/lib/libcrypto/rc4/Makefile.uni create mode 100644 src/lib/libcrypto/rc4/asm/r4-win32.asm create mode 100644 src/lib/libcrypto/rc4/asm/rx86unix.cpp create mode 100644 src/lib/libcrypto/rc4/rc4.org create mode 100644 src/lib/libcrypto/rc4/rc4_locl.org create mode 100644 src/lib/libcrypto/rc5/Makefile.ssl create mode 100644 src/lib/libcrypto/rc5/Makefile.uni create mode 100644 src/lib/libcrypto/rc5/asm/r5-win32.asm create mode 100644 src/lib/libcrypto/rc5/asm/r586unix.cpp create mode 100644 src/lib/libcrypto/rc5/asm/rc5-586.pl create mode 100644 src/lib/libcrypto/ripemd/Makefile.ssl create mode 100644 src/lib/libcrypto/ripemd/Makefile.uni create mode 100644 src/lib/libcrypto/ripemd/asm/rm-win32.asm create mode 100644 src/lib/libcrypto/ripemd/asm/rm86unix.cpp create mode 100644 src/lib/libcrypto/rsa/Makefile.ssl create mode 100644 src/lib/libcrypto/rsa/rsa.err create mode 100644 src/lib/libcrypto/sha/Makefile.ssl create mode 100644 src/lib/libcrypto/sha/Makefile.uni create mode 100644 src/lib/libcrypto/sha/asm/s1-win32.asm create mode 100644 src/lib/libcrypto/sha/asm/sx86unix.cpp create mode 100644 src/lib/libcrypto/sha/sha_sgst.c create mode 100644 src/lib/libcrypto/stack/Makefile.ssl create mode 100644 src/lib/libcrypto/txt_db/Makefile.ssl create mode 100644 src/lib/libcrypto/util/mklink.sh create mode 100644 src/lib/libcrypto/util/ranlib.sh create mode 100644 src/lib/libcrypto/util/sep_lib.sh create mode 100644 src/lib/libcrypto/util/ssldir.pl create mode 100644 src/lib/libcrypto/util/up_ver.pl create mode 100644 src/lib/libcrypto/x509/Makefile.ssl create mode 100644 src/lib/libcrypto/x509/attrib create mode 100644 src/lib/libcrypto/x509/v3_net.c create mode 100644 src/lib/libcrypto/x509/v3_x509.c create mode 100644 src/lib/libcrypto/x509/x509.doc create mode 100644 src/lib/libcrypto/x509/x509.err create mode 100644 src/lib/libcrypto/x509/x509pack.c create mode 100644 src/lib/libcrypto/x509/x509v3.doc create mode 100644 src/lib/libcrypto/x509v3/format create mode 100644 src/lib/libcrypto/x509v3/header create mode 100644 src/lib/libcrypto/x509v3/v3_ku.c create mode 100644 src/lib/libssl/Makefile create mode 100644 src/lib/libssl/Makefile.bsd-wrapper create mode 100644 src/lib/libssl/README.OPENBSD create mode 100644 src/lib/libssl/crypto-patent/Makefile create mode 100644 src/lib/libssl/crypto-patent/shlib_version create mode 100644 src/lib/libssl/crypto/Makefile create mode 100644 src/lib/libssl/crypto/shlib_version create mode 100644 src/lib/libssl/src/COPYRIGHT create mode 100644 src/lib/libssl/src/HISTORY create mode 100644 src/lib/libssl/src/HISTORY.066 create mode 100644 src/lib/libssl/src/MICROSOFT create mode 100644 src/lib/libssl/src/MINFO create mode 100644 src/lib/libssl/src/Makefile.ssl create mode 100644 src/lib/libssl/src/PATENTS create mode 100644 src/lib/libssl/src/README.066 create mode 100644 src/lib/libssl/src/README.080 create mode 100644 src/lib/libssl/src/README.090 create mode 100644 src/lib/libssl/src/TODO create mode 100644 src/lib/libssl/src/VERSION create mode 100644 src/lib/libssl/src/apps/Makefile.ssl create mode 100644 src/lib/libssl/src/apps/der_chop create mode 100644 src/lib/libssl/src/apps/eay.c create mode 100644 src/lib/libssl/src/apps/ext.v3 create mode 100644 src/lib/libssl/src/apps/g_ssleay.pl create mode 100644 src/lib/libssl/src/apps/mklinks create mode 100644 src/lib/libssl/src/apps/pem_mail.c create mode 100644 src/lib/libssl/src/apps/rmlinks create mode 100644 src/lib/libssl/src/apps/ssleay.c create mode 100644 src/lib/libssl/src/apps/ssleay.cnf create mode 100644 src/lib/libssl/src/apps/tkca create mode 100644 src/lib/libssl/src/certs/ICE-CA.pem create mode 100644 src/lib/libssl/src/certs/ICE-root.pem create mode 100644 src/lib/libssl/src/certs/ICE-user.pem create mode 100644 src/lib/libssl/src/certs/ICE.crl create mode 100644 src/lib/libssl/src/certs/ca-cert.pem create mode 100644 src/lib/libssl/src/certs/dsa-ca.pem create mode 100644 src/lib/libssl/src/certs/dsa-pca.pem create mode 100644 src/lib/libssl/src/certs/factory.pem create mode 100644 src/lib/libssl/src/certs/nortelCA.pem create mode 100644 src/lib/libssl/src/certs/pca-cert.pem create mode 100644 src/lib/libssl/src/certs/rsa-cca.pem create mode 100644 src/lib/libssl/src/certs/rsa-ssca.pem create mode 100644 src/lib/libssl/src/certs/timCA.pem create mode 100644 src/lib/libssl/src/certs/tjhCA.pem create mode 100644 src/lib/libssl/src/certs/vsign2.pem create mode 100644 src/lib/libssl/src/certs/vsign4.pem create mode 100644 src/lib/libssl/src/crypto/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/asn1/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/asn1/a_bmp.c create mode 100644 src/lib/libssl/src/crypto/asn1/asn1.err create mode 100644 src/lib/libssl/src/crypto/asn1/d2i_dhp.c create mode 100644 src/lib/libssl/src/crypto/asn1/d2i_dsap.c create mode 100644 src/lib/libssl/src/crypto/asn1/d2i_r_pr.c create mode 100644 src/lib/libssl/src/crypto/asn1/d2i_r_pu.c create mode 100644 src/lib/libssl/src/crypto/asn1/d2i_s_pr.c create mode 100644 src/lib/libssl/src/crypto/asn1/d2i_s_pu.c create mode 100644 src/lib/libssl/src/crypto/asn1/f.c create mode 100644 src/lib/libssl/src/crypto/asn1/i2d_dhp.c create mode 100644 src/lib/libssl/src/crypto/asn1/i2d_dsap.c create mode 100644 src/lib/libssl/src/crypto/asn1/i2d_r_pr.c create mode 100644 src/lib/libssl/src/crypto/asn1/i2d_r_pu.c create mode 100644 src/lib/libssl/src/crypto/asn1/i2d_s_pr.c create mode 100644 src/lib/libssl/src/crypto/asn1/i2d_s_pu.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_dgst.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_enc.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_enc_c.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_evp.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_i_s.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_lib.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_recip.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_s_e.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_signd.c create mode 100644 src/lib/libssl/src/crypto/asn1/p7_signi.c create mode 100644 src/lib/libssl/src/crypto/asn1/pkcs8.c create mode 100644 src/lib/libssl/src/crypto/asn1/x_cinf.c create mode 100644 src/lib/libssl/src/crypto/bf/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/bf/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/bf/asm/b-win32.asm create mode 100644 src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/bf/bf_locl.org create mode 100644 src/lib/libssl/src/crypto/bio/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/bio/bio.err create mode 100644 src/lib/libssl/src/crypto/bn/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/bn/asm/bn-win32.asm create mode 100644 src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp create mode 100644 src/lib/libssl/src/crypto/bn/asm/sparc.s create mode 100644 src/lib/libssl/src/crypto/bn/asm/x86w16.asm create mode 100644 src/lib/libssl/src/crypto/bn/asm/x86w32.asm create mode 100644 src/lib/libssl/src/crypto/bn/bn.err create mode 100644 src/lib/libssl/src/crypto/bn/bn.org create mode 100644 src/lib/libssl/src/crypto/bn/bn_m.c create mode 100644 src/lib/libssl/src/crypto/bn/bn_mulw.c create mode 100644 src/lib/libssl/src/crypto/bn/bn_sub.c create mode 100644 src/lib/libssl/src/crypto/buffer/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/buffer/buffer.err create mode 100644 src/lib/libssl/src/crypto/cast/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/cast/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/cast/asm/c-win32.asm create mode 100644 src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/conf/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/conf/conf.c create mode 100644 src/lib/libssl/src/crypto/conf/conf.err create mode 100644 src/lib/libssl/src/crypto/conf/conf_lcl.h create mode 100644 src/lib/libssl/src/crypto/cryptall.h create mode 100644 src/lib/libssl/src/crypto/crypto.c create mode 100644 src/lib/libssl/src/crypto/crypto.err create mode 100644 src/lib/libssl/src/crypto/date.h create mode 100644 src/lib/libssl/src/crypto/des/DES.pod create mode 100644 src/lib/libssl/src/crypto/des/FILES create mode 100644 src/lib/libssl/src/crypto/des/MODES.DES create mode 100644 src/lib/libssl/src/crypto/des/Makefile.PL create mode 100644 src/lib/libssl/src/crypto/des/Makefile.lit create mode 100644 src/lib/libssl/src/crypto/des/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/des/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/des/PC1 create mode 100644 src/lib/libssl/src/crypto/des/PC2 create mode 100644 src/lib/libssl/src/crypto/des/asm/d-win32.asm create mode 100644 src/lib/libssl/src/crypto/des/asm/dx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/des/asm/y-win32.asm create mode 100644 src/lib/libssl/src/crypto/des/asm/yx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/des/des.man create mode 100644 src/lib/libssl/src/crypto/des/des.org create mode 100644 src/lib/libssl/src/crypto/des/des.pl create mode 100644 src/lib/libssl/src/crypto/des/des_crypt.man create mode 100644 src/lib/libssl/src/crypto/des/des_locl.org create mode 100644 src/lib/libssl/src/crypto/des/doIP create mode 100644 src/lib/libssl/src/crypto/des/doPC1 create mode 100644 src/lib/libssl/src/crypto/des/doPC2 create mode 100644 src/lib/libssl/src/crypto/des/ede_enc.c create mode 100644 src/lib/libssl/src/crypto/des/podd.h create mode 100644 src/lib/libssl/src/crypto/des/ranlib.sh create mode 100644 src/lib/libssl/src/crypto/des/shifts.pl create mode 100644 src/lib/libssl/src/crypto/des/sk.h create mode 100644 src/lib/libssl/src/crypto/des/supp.c create mode 100644 src/lib/libssl/src/crypto/des/testdes.pl create mode 100644 src/lib/libssl/src/crypto/des/vms.com create mode 100644 src/lib/libssl/src/crypto/dh/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/dh/dh.err create mode 100644 src/lib/libssl/src/crypto/dsa/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/dsa/dsa.err create mode 100644 src/lib/libssl/src/crypto/err/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/err/err_code.pl create mode 100644 src/lib/libssl/src/crypto/err/err_genc.pl create mode 100644 src/lib/libssl/src/crypto/err/error.err create mode 100644 src/lib/libssl/src/crypto/err/ssleay.ec create mode 100644 src/lib/libssl/src/crypto/evp/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_3d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_bf.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_c.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_i.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_r2.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cbc_r5.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_3d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_bf.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_c.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_i.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_r2.c create mode 100644 src/lib/libssl/src/crypto/evp/e_cfb_r5.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_3d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_bf.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_c.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_i.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_r2.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ecb_r5.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_3d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_bf.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_c.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_d.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_i.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_r2.c create mode 100644 src/lib/libssl/src/crypto/evp/e_ofb_r5.c create mode 100644 src/lib/libssl/src/crypto/evp/evp.err create mode 100644 src/lib/libssl/src/crypto/evp/pk_lib.c create mode 100644 src/lib/libssl/src/crypto/hmac/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/idea/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/lhash/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/libvms.com create mode 100644 src/lib/libssl/src/crypto/md2/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/md2/md2.org create mode 100644 src/lib/libssl/src/crypto/md5/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/md5/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/md5/asm/m5-win32.asm create mode 100644 src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/mdc2/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/objects/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/objects/objects.err create mode 100644 src/lib/libssl/src/crypto/pem/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/pem/ctx_size.c create mode 100644 src/lib/libssl/src/crypto/pem/pem.err create mode 100644 src/lib/libssl/src/crypto/pem/pem.org create mode 100644 src/lib/libssl/src/crypto/pkcs7/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/pkcs7/README create mode 100644 src/lib/libssl/src/crypto/pkcs7/mf.p7 create mode 100644 src/lib/libssl/src/crypto/pkcs7/p7.tst create mode 100644 src/lib/libssl/src/crypto/pkcs7/pkcs7.err create mode 100644 src/lib/libssl/src/crypto/rand/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/ranlib.sh create mode 100644 src/lib/libssl/src/crypto/rc2/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/rc2/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/rc2/rc2.org create mode 100644 src/lib/libssl/src/crypto/rc4/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/rc4/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm create mode 100644 src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/rc4/rc4.org create mode 100644 src/lib/libssl/src/crypto/rc4/rc4_locl.org create mode 100644 src/lib/libssl/src/crypto/rc5/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/rc5/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm create mode 100644 src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp create mode 100644 src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl create mode 100644 src/lib/libssl/src/crypto/ripemd/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/ripemd/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm create mode 100644 src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp create mode 100644 src/lib/libssl/src/crypto/rsa/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/rsa/rsa.err create mode 100644 src/lib/libssl/src/crypto/sha/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/sha/Makefile.uni create mode 100644 src/lib/libssl/src/crypto/sha/asm/s1-win32.asm create mode 100644 src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp create mode 100644 src/lib/libssl/src/crypto/sha/sha_sgst.c create mode 100644 src/lib/libssl/src/crypto/stack/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/txt_db/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/x509/Makefile.ssl create mode 100644 src/lib/libssl/src/crypto/x509/attrib create mode 100644 src/lib/libssl/src/crypto/x509/v3_net.c create mode 100644 src/lib/libssl/src/crypto/x509/v3_x509.c create mode 100644 src/lib/libssl/src/crypto/x509/x509.doc create mode 100644 src/lib/libssl/src/crypto/x509/x509.err create mode 100644 src/lib/libssl/src/crypto/x509/x509pack.c create mode 100644 src/lib/libssl/src/crypto/x509/x509v3.doc create mode 100644 src/lib/libssl/src/crypto/x509v3/format create mode 100644 src/lib/libssl/src/crypto/x509v3/header create mode 100644 src/lib/libssl/src/crypto/x509v3/v3_ku.c create mode 100644 src/lib/libssl/src/dep/crypto.txt create mode 100644 src/lib/libssl/src/dep/files create mode 100644 src/lib/libssl/src/dep/gen.pl create mode 100644 src/lib/libssl/src/dep/ssl.txt create mode 100644 src/lib/libssl/src/doc/API.doc create mode 100644 src/lib/libssl/src/doc/a_verify.doc create mode 100644 src/lib/libssl/src/doc/apps.doc create mode 100644 src/lib/libssl/src/doc/asn1.doc create mode 100644 src/lib/libssl/src/doc/bio.doc create mode 100644 src/lib/libssl/src/doc/blowfish.doc create mode 100644 src/lib/libssl/src/doc/bn.doc create mode 100644 src/lib/libssl/src/doc/ca.1 create mode 100644 src/lib/libssl/src/doc/callback.doc create mode 100644 src/lib/libssl/src/doc/cipher.doc create mode 100644 src/lib/libssl/src/doc/cipher.m create mode 100644 src/lib/libssl/src/doc/conf.doc create mode 100644 src/lib/libssl/src/doc/des.doc create mode 100644 src/lib/libssl/src/doc/digest.doc create mode 100644 src/lib/libssl/src/doc/encode.doc create mode 100644 src/lib/libssl/src/doc/envelope.doc create mode 100644 src/lib/libssl/src/doc/error.doc create mode 100644 src/lib/libssl/src/doc/legal.doc create mode 100644 src/lib/libssl/src/doc/lhash.doc create mode 100644 src/lib/libssl/src/doc/md2.doc create mode 100644 src/lib/libssl/src/doc/md5.doc create mode 100644 src/lib/libssl/src/doc/memory.doc create mode 100644 src/lib/libssl/src/doc/ms3-ca.doc create mode 100644 src/lib/libssl/src/doc/ns-ca.doc create mode 100644 src/lib/libssl/src/doc/obj.doc create mode 100644 src/lib/libssl/src/doc/rand.doc create mode 100644 src/lib/libssl/src/doc/rc2.doc create mode 100644 src/lib/libssl/src/doc/rc4.doc create mode 100644 src/lib/libssl/src/doc/readme create mode 100644 src/lib/libssl/src/doc/ref.doc create mode 100644 src/lib/libssl/src/doc/req.1 create mode 100644 src/lib/libssl/src/doc/rsa.doc create mode 100644 src/lib/libssl/src/doc/rsaref.doc create mode 100644 src/lib/libssl/src/doc/s_mult.doc create mode 100644 src/lib/libssl/src/doc/session.doc create mode 100644 src/lib/libssl/src/doc/sha.doc create mode 100644 src/lib/libssl/src/doc/speed.doc create mode 100644 src/lib/libssl/src/doc/ssl-ciph.doc create mode 100644 src/lib/libssl/src/doc/ssl.doc create mode 100644 src/lib/libssl/src/doc/ssl_ctx.doc create mode 100644 src/lib/libssl/src/doc/ssleay.doc create mode 100644 src/lib/libssl/src/doc/ssluse.doc create mode 100644 src/lib/libssl/src/doc/stack.doc create mode 100644 src/lib/libssl/src/doc/threads.doc create mode 100644 src/lib/libssl/src/doc/txt_db.doc create mode 100644 src/lib/libssl/src/doc/verify create mode 100644 src/lib/libssl/src/doc/why.doc create mode 100644 src/lib/libssl/src/makefile.one create mode 100644 src/lib/libssl/src/ms/cipher.out create mode 100644 src/lib/libssl/src/ms/clear.out create mode 100644 src/lib/libssl/src/ms/libeay16.def create mode 100644 src/lib/libssl/src/ms/libeay32.def create mode 100644 src/lib/libssl/src/ms/ntdll.mak create mode 100644 src/lib/libssl/src/ms/ssleay16.def create mode 100644 src/lib/libssl/src/ms/ssleay32.def create mode 100644 src/lib/libssl/src/ms/w31dll.mak create mode 100644 src/lib/libssl/src/mt/README create mode 100644 src/lib/libssl/src/mt/mttest.c create mode 100644 src/lib/libssl/src/mt/profile.sh create mode 100644 src/lib/libssl/src/mt/ptest.bat create mode 100644 src/lib/libssl/src/mt/pthread.sh create mode 100644 src/lib/libssl/src/mt/purify.sh create mode 100644 src/lib/libssl/src/mt/solaris.sh create mode 100644 src/lib/libssl/src/mt/win32.bat create mode 100644 src/lib/libssl/src/perl/MANIFEST create mode 100644 src/lib/libssl/src/perl/Makefile.PL create mode 100644 src/lib/libssl/src/perl/SSLeay.pm create mode 100644 src/lib/libssl/src/perl/SSLeay.xs create mode 100644 src/lib/libssl/src/perl/b.pl create mode 100644 src/lib/libssl/src/perl/bio.pl create mode 100644 src/lib/libssl/src/perl/bio.txt create mode 100644 src/lib/libssl/src/perl/bio.xs create mode 100644 src/lib/libssl/src/perl/bn.pl create mode 100644 src/lib/libssl/src/perl/bn.txt create mode 100644 src/lib/libssl/src/perl/bn.xs create mode 100644 src/lib/libssl/src/perl/callback.c create mode 100644 src/lib/libssl/src/perl/cipher.pl create mode 100644 src/lib/libssl/src/perl/cipher.txt create mode 100644 src/lib/libssl/src/perl/cipher.xs create mode 100644 src/lib/libssl/src/perl/dh.pl create mode 100644 src/lib/libssl/src/perl/digest.txt create mode 100644 src/lib/libssl/src/perl/digest.xs create mode 100644 src/lib/libssl/src/perl/err.txt create mode 100644 src/lib/libssl/src/perl/err.xs create mode 100644 src/lib/libssl/src/perl/f.pl create mode 100644 src/lib/libssl/src/perl/g.pl create mode 100644 src/lib/libssl/src/perl/gen_rsa.pl create mode 100644 src/lib/libssl/src/perl/mul.pl create mode 100644 src/lib/libssl/src/perl/p5SSLeay.h create mode 100644 src/lib/libssl/src/perl/r.pl create mode 100644 src/lib/libssl/src/perl/s.pl create mode 100644 src/lib/libssl/src/perl/s2.pl create mode 100644 src/lib/libssl/src/perl/server.pem create mode 100644 src/lib/libssl/src/perl/ss.pl create mode 100644 src/lib/libssl/src/perl/ssl.pl create mode 100644 src/lib/libssl/src/perl/ssl.txt create mode 100644 src/lib/libssl/src/perl/ssl.xs create mode 100644 src/lib/libssl/src/perl/ssl_srvr.pl create mode 100644 src/lib/libssl/src/perl/sslbio.pl create mode 100644 src/lib/libssl/src/perl/t.pl create mode 100644 src/lib/libssl/src/perl/test create mode 100644 src/lib/libssl/src/perl/test.pl create mode 100644 src/lib/libssl/src/perl/test.txt create mode 100644 src/lib/libssl/src/perl/test2.pl create mode 100644 src/lib/libssl/src/perl/test3.pl create mode 100644 src/lib/libssl/src/perl/test8.pl create mode 100644 src/lib/libssl/src/perl/test9.pl create mode 100644 src/lib/libssl/src/perl/testbn.pl create mode 100644 src/lib/libssl/src/perl/testdec.pl create mode 100644 src/lib/libssl/src/perl/testmd.pl create mode 100644 src/lib/libssl/src/perl/tt.pl create mode 100644 src/lib/libssl/src/perl/typemap create mode 100644 src/lib/libssl/src/perl/x509.txt create mode 100644 src/lib/libssl/src/perl/x509.xs create mode 100644 src/lib/libssl/src/perl/xstmp.c create mode 100644 src/lib/libssl/src/perl/y.pl create mode 100644 src/lib/libssl/src/perl/yy.pl create mode 100644 src/lib/libssl/src/perl/z.pl create mode 100644 src/lib/libssl/src/perl/zz.pl create mode 100644 src/lib/libssl/src/shlib/linux.sh create mode 100644 src/lib/libssl/src/ssl/Makefile.ssl create mode 100644 src/lib/libssl/src/ssl/readme create mode 100644 src/lib/libssl/src/ssl/ssl.c create mode 100644 src/lib/libssl/src/ssl/ssl.err create mode 100644 src/lib/libssl/src/test/.rnd create mode 100644 src/lib/libssl/src/test/Makefile.ssl create mode 100644 src/lib/libssl/src/test/certCA.srl create mode 100644 src/lib/libssl/src/test/demoCA/index.txt create mode 100644 src/lib/libssl/src/test/demoCA/private/cakey.pem create mode 100644 src/lib/libssl/src/test/demoCA/serial create mode 100644 src/lib/libssl/src/test/dsa-ca.pem create mode 100644 src/lib/libssl/src/test/dsa-pca.pem create mode 100644 src/lib/libssl/src/test/p create mode 100644 src/lib/libssl/src/test/riptest create mode 100644 src/lib/libssl/src/test/test.txt create mode 100644 src/lib/libssl/src/test/testkey.pem create mode 100644 src/lib/libssl/src/test/testreq.pem create mode 100644 src/lib/libssl/src/tools/Makefile.ssl create mode 100644 src/lib/libssl/src/util/mklink.sh create mode 100644 src/lib/libssl/src/util/ranlib.sh create mode 100644 src/lib/libssl/src/util/sep_lib.sh create mode 100644 src/lib/libssl/src/util/ssldir.pl create mode 100644 src/lib/libssl/src/util/up_ver.pl create mode 100644 src/lib/libssl/ssl-patent/Makefile create mode 100644 src/lib/libssl/ssl-patent/shlib_version create mode 100644 src/lib/libssl/ssl/Makefile create mode 100644 src/lib/libssl/ssl/shlib_version create mode 100644 src/lib/libssl/ssleay/Makefile create mode 100644 src/lib/libssl/test/.rnd create mode 100644 src/lib/libssl/test/Makefile.ssl create mode 100644 src/lib/libssl/test/certCA.srl create mode 100644 src/lib/libssl/test/demoCA/index.txt create mode 100644 src/lib/libssl/test/demoCA/private/cakey.pem create mode 100644 src/lib/libssl/test/demoCA/serial create mode 100644 src/lib/libssl/test/dsa-ca.pem create mode 100644 src/lib/libssl/test/dsa-pca.pem create mode 100644 src/lib/libssl/test/p create mode 100644 src/lib/libssl/test/riptest create mode 100644 src/lib/libssl/test/test.txt create mode 100644 src/lib/libssl/test/testkey.pem create mode 100644 src/lib/libssl/test/testreq.pem (limited to 'src/lib') diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl new file mode 100644 index 0000000000..efdbba38ac --- /dev/null +++ b/src/lib/libcrypto/Makefile.ssl @@ -0,0 +1,161 @@ +# +# SSLeay/crypto/Makefile +# + +DIR= crypto +TOP= .. +CC= cc +INCLUDE= -I. -I../include +INCLUDES= -I.. -I../../include +CFLAG= -g +INSTALLTOP= /usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +RM= /bin/rm -f +AR= ar r + +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl + +PEX_LIBS= +EX_LIBS= + +CFLAGS= $(INCLUDE) $(CFLAG) -DCFLAGS=" \"$(CC) $(CFLAG)\" " + +ERR=crypto +ERRC=cpt_err + +LIBS= + +SDIRS= md2 md5 sha mdc2 hmac ripemd \ + des rc2 rc4 rc5 idea bf cast \ + bn rsa dsa dh \ + buffer bio stack lhash rand err objects \ + evp pem x509 \ + asn1 conf txt_db pkcs7 + +GENERAL=Makefile README + +LIB= $(TOP)/libcrypto.a +LIBSRC= cryptlib.c mem.c cversion.c ex_data.c $(ERRC).c +LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= crypto.h cryptall.h +HEADER= cryptlib.h date.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + @(cd ..; $(MAKE) DIRS=$(DIR) all) + +all: date.h lib subdirs + +date.h: ../Makefile.ssl ../VERSION + echo "#define DATE \"`date`\"" >date.h + +subdirs: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making all in $$i..."; \ + $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' all ); \ + done; + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making 'files' in $$i..."; \ + $(MAKE) files ); \ + done; + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../include $(HEADER) ; + $(TOP)/util/mklink.sh ../test $(TEST) ; + $(TOP)/util/mklink.sh ../apps $(APPS) ; + $(TOP)/util/point.sh Makefile.ssl Makefile; + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making links in $$i..."; \ + $(MAKE) links ); \ + done; + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +libs: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making libs in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \ + done; + +tests: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making tests in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \ + done; + +install: + @for i in $(EXHEADER) ;\ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making install in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \ + done; + +lint: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making lint in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \ + done; + +depend: + $(MAKEDEPEND) $(INCLUDE) $(PROGS) $(LIBSRC) + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making depend in $$i..."; \ + $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' MAKEDEPEND='${MAKEDEPEND}' depend ); \ + done; + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making clean in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \ + done; + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making dclean in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \ + done; + +errors: + perl ./err/err_code.pl -conf err/ssleay.ec *.c */*.c ../ssl/*.c ../rsaref/*.c + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl err/err_genc.pl -s $(ERR).h $(ERRC).c + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making errors in $$i..."; \ + $(MAKE) errors ); \ + done; + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl new file mode 100644 index 0000000000..30751bd156 --- /dev/null +++ b/src/lib/libcrypto/asn1/Makefile.ssl @@ -0,0 +1,120 @@ +# +# SSLeay/crypto/asn1/Makefile +# + +DIR= asn1 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=asn1 +ERRC=asn1_err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c \ + a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \ + a_sign.c a_digest.c a_verify.c \ + x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \ + x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c \ + d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \ + d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \ + d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\ + t_req.c t_x509.c t_pkey.c \ + p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \ + p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ + f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \ + a_hdr.c x_pkey.c a_bool.c x_exten.c \ + asn1_par.c asn1_lib.c $(ERRC).c a_meth.c a_bytes.c \ + evp_asn1.c +LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o \ + a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \ + a_sign.o a_digest.o a_verify.o \ + x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \ + x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o \ + d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \ + d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \ + d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \ + t_req.o t_x509.o t_pkey.o \ + p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \ + p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ + f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \ + a_hdr.o x_pkey.o a_bool.o x_exten.o \ + asn1_par.o asn1_lib.o $(ERRC).o a_meth.o a_bytes.o \ + evp_asn1.o + +SRC= $(LIBSRC) + +EXHEADER= asn1.h asn1_mac.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +test: test.c + cc -g -I../../include -c test.c + cc -g -I../../include -o test test.o -L../.. -lcrypto + +pk: pk.c + cc -g -I../../include -c pk.c + cc -g -I../../include -o pk pk.o -L../.. -lcrypto + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/asn1/a_bmp.c b/src/lib/libcrypto/asn1/a_bmp.c new file mode 100644 index 0000000000..774502b1fc --- /dev/null +++ b/src/lib/libcrypto/asn1/a_bmp.c @@ -0,0 +1,90 @@ +/* crypto/asn1/a_bmp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1.h" + +/* ASN1err(ASN1_F_D2I_ASN1_INTEGER,ASN1_R_EXPECTING_AN_INTEGER); + */ + +int i2d_ASN1_BMPSTRING(a, pp) +ASN1_BMPSTRING *a; +unsigned char **pp; + { + return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, + V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL)); + } + +ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(a, pp, length) +ASN1_BMPSTRING **a; +unsigned char **pp; +long length; + { + ASN1_BMPSTRING *ret=NULL; + + ret=(ASN1_BMPSTRING *)d2i_ASN1_bytes((ASN1_STRING **)a, + pp,length,V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL); + if (ret == NULL) + { + ASN1err(ASN1_F_D2I_ASN1_BMPSTRING,ASN1_R_ERROR_STACK); + return(NULL); + } + return(ret); + } + diff --git a/src/lib/libcrypto/asn1/asn1.err b/src/lib/libcrypto/asn1/asn1.err new file mode 100644 index 0000000000..c8b7011488 --- /dev/null +++ b/src/lib/libcrypto/asn1/asn1.err @@ -0,0 +1,182 @@ +/* Error codes for the ASN1 functions. */ + +/* Function codes. */ +#define ASN1_F_A2D_ASN1_OBJECT 100 +#define ASN1_F_A2I_ASN1_INTEGER 101 +#define ASN1_F_A2I_ASN1_STRING 102 +#define ASN1_F_ASN1_COLLATE_PRIMATIVE 103 +#define ASN1_F_ASN1_D2I_BIO 104 +#define ASN1_F_ASN1_D2I_FP 105 +#define ASN1_F_ASN1_DUP 106 +#define ASN1_F_ASN1_GET_OBJECT 107 +#define ASN1_F_ASN1_HEADER_NEW 108 +#define ASN1_F_ASN1_I2D_BIO 109 +#define ASN1_F_ASN1_I2D_FP 110 +#define ASN1_F_ASN1_INTEGER_SET 111 +#define ASN1_F_ASN1_INTEGER_TO_BN 112 +#define ASN1_F_ASN1_OBJECT_NEW 113 +#define ASN1_F_ASN1_SIGN 114 +#define ASN1_F_ASN1_STRING_NEW 115 +#define ASN1_F_ASN1_STRING_TYPE_NEW 116 +#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117 +#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118 +#define ASN1_F_ASN1_TYPE_NEW 119 +#define ASN1_F_ASN1_UTCTIME_NEW 120 +#define ASN1_F_ASN1_VERIFY 121 +#define ASN1_F_BN_TO_ASN1_INTEGER 122 +#define ASN1_F_D2I_ASN1_BIT_STRING 123 +#define ASN1_F_D2I_ASN1_BMPSTRING 124 +#define ASN1_F_D2I_ASN1_BOOLEAN 125 +#define ASN1_F_D2I_ASN1_BYTES 126 +#define ASN1_F_D2I_ASN1_HEADER 127 +#define ASN1_F_D2I_ASN1_INTEGER 128 +#define ASN1_F_D2I_ASN1_OBJECT 129 +#define ASN1_F_D2I_ASN1_OCTET_STRING 130 +#define ASN1_F_D2I_ASN1_PRINT_TYPE 131 +#define ASN1_F_D2I_ASN1_SET 132 +#define ASN1_F_D2I_ASN1_TYPE 133 +#define ASN1_F_D2I_ASN1_TYPE_BYTES 134 +#define ASN1_F_D2I_ASN1_UTCTIME 135 +#define ASN1_F_D2I_DHPARAMS 136 +#define ASN1_F_D2I_DSAPARAMS 137 +#define ASN1_F_D2I_DSAPRIVATEKEY 138 +#define ASN1_F_D2I_DSAPUBLICKEY 139 +#define ASN1_F_D2I_NETSCAPE_PKEY 140 +#define ASN1_F_D2I_NETSCAPE_RSA 141 +#define ASN1_F_D2I_NETSCAPE_RSA_2 142 +#define ASN1_F_D2I_NETSCAPE_SPKAC 143 +#define ASN1_F_D2I_NETSCAPE_SPKI 144 +#define ASN1_F_D2I_PKCS7 145 +#define ASN1_F_D2I_PKCS7_DIGEST 146 +#define ASN1_F_D2I_PKCS7_ENCRYPT 147 +#define ASN1_F_D2I_PKCS7_ENC_CONTENT 148 +#define ASN1_F_D2I_PKCS7_ENVELOPE 149 +#define ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL 150 +#define ASN1_F_D2I_PKCS7_RECIP_INFO 151 +#define ASN1_F_D2I_PKCS7_SIGNED 152 +#define ASN1_F_D2I_PKCS7_SIGNER_INFO 153 +#define ASN1_F_D2I_PKCS7_SIGN_ENVELOPE 154 +#define ASN1_F_D2I_PRIVATEKEY 155 +#define ASN1_F_D2I_PUBLICKEY 156 +#define ASN1_F_D2I_RSAPRIVATEKEY 157 +#define ASN1_F_D2I_RSAPUBLICKEY 158 +#define ASN1_F_D2I_X509 159 +#define ASN1_F_D2I_X509_ALGOR 160 +#define ASN1_F_D2I_X509_ATTRIBUTE 161 +#define ASN1_F_D2I_X509_CINF 162 +#define ASN1_F_D2I_X509_CRL 163 +#define ASN1_F_D2I_X509_CRL_INFO 164 +#define ASN1_F_D2I_X509_EXTENSION 165 +#define ASN1_F_D2I_X509_KEY 166 +#define ASN1_F_D2I_X509_NAME 167 +#define ASN1_F_D2I_X509_NAME_ENTRY 168 +#define ASN1_F_D2I_X509_PKEY 169 +#define ASN1_F_D2I_X509_PUBKEY 170 +#define ASN1_F_D2I_X509_REQ 171 +#define ASN1_F_D2I_X509_REQ_INFO 172 +#define ASN1_F_D2I_X509_REVOKED 173 +#define ASN1_F_D2I_X509_SIG 174 +#define ASN1_F_D2I_X509_VAL 175 +#define ASN1_F_I2D_ASN1_HEADER 176 +#define ASN1_F_I2D_DHPARAMS 177 +#define ASN1_F_I2D_DSAPARAMS 178 +#define ASN1_F_I2D_DSAPRIVATEKEY 179 +#define ASN1_F_I2D_DSAPUBLICKEY 180 +#define ASN1_F_I2D_NETSCAPE_RSA 181 +#define ASN1_F_I2D_PKCS7 182 +#define ASN1_F_I2D_PRIVATEKEY 183 +#define ASN1_F_I2D_PUBLICKEY 184 +#define ASN1_F_I2D_RSAPRIVATEKEY 185 +#define ASN1_F_I2D_RSAPUBLICKEY 186 +#define ASN1_F_I2D_X509_ATTRIBUTE 187 +#define ASN1_F_I2T_ASN1_OBJECT 188 +#define ASN1_F_NETSCAPE_PKEY_NEW 189 +#define ASN1_F_NETSCAPE_SPKAC_NEW 190 +#define ASN1_F_NETSCAPE_SPKI_NEW 191 +#define ASN1_F_PKCS7_DIGEST_NEW 192 +#define ASN1_F_PKCS7_ENCRYPT_NEW 193 +#define ASN1_F_PKCS7_ENC_CONTENT_NEW 194 +#define ASN1_F_PKCS7_ENVELOPE_NEW 195 +#define ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW 196 +#define ASN1_F_PKCS7_NEW 197 +#define ASN1_F_PKCS7_RECIP_INFO_NEW 198 +#define ASN1_F_PKCS7_SIGNED_NEW 199 +#define ASN1_F_PKCS7_SIGNER_INFO_NEW 200 +#define ASN1_F_PKCS7_SIGN_ENVELOPE_NEW 201 +#define ASN1_F_X509_ALGOR_NEW 202 +#define ASN1_F_X509_ATTRIBUTE_NEW 203 +#define ASN1_F_X509_CINF_NEW 204 +#define ASN1_F_X509_CRL_INFO_NEW 205 +#define ASN1_F_X509_CRL_NEW 206 +#define ASN1_F_X509_DHPARAMS_NEW 207 +#define ASN1_F_X509_EXTENSION_NEW 208 +#define ASN1_F_X509_INFO_NEW 209 +#define ASN1_F_X509_KEY_NEW 210 +#define ASN1_F_X509_NAME_ENTRY_NEW 211 +#define ASN1_F_X509_NAME_NEW 212 +#define ASN1_F_X509_NEW 213 +#define ASN1_F_X509_PKEY_NEW 214 +#define ASN1_F_X509_PUBKEY_NEW 215 +#define ASN1_F_X509_REQ_INFO_NEW 216 +#define ASN1_F_X509_REQ_NEW 217 +#define ASN1_F_X509_REVOKED_NEW 218 +#define ASN1_F_X509_SIG_NEW 219 +#define ASN1_F_X509_VAL_FREE 220 +#define ASN1_F_X509_VAL_NEW 221 + +/* Reason codes. */ +#define ASN1_R_BAD_CLASS 100 +#define ASN1_R_BAD_GET_OBJECT 101 +#define ASN1_R_BAD_OBJECT_HEADER 102 +#define ASN1_R_BAD_PASSWORD_READ 103 +#define ASN1_R_BAD_PKCS7_CONTENT 104 +#define ASN1_R_BAD_PKCS7_TYPE 105 +#define ASN1_R_BAD_TAG 106 +#define ASN1_R_BAD_TYPE 107 +#define ASN1_R_BN_LIB 108 +#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 109 +#define ASN1_R_BUFFER_TOO_SMALL 110 +#define ASN1_R_DATA_IS_WRONG 111 +#define ASN1_R_DECODING_ERROR 112 +#define ASN1_R_ERROR_STACK 113 +#define ASN1_R_EXPECTING_AN_INTEGER 114 +#define ASN1_R_EXPECTING_AN_OBJECT 115 +#define ASN1_R_EXPECTING_AN_OCTET_STRING 116 +#define ASN1_R_EXPECTING_A_BIT_STRING 117 +#define ASN1_R_EXPECTING_A_BOOLEAN 118 +#define ASN1_R_EXPECTING_A_SEQUENCE 119 +#define ASN1_R_EXPECTING_A_UTCTIME 120 +#define ASN1_R_FIRST_NUM_TOO_LARGE 121 +#define ASN1_R_HEADER_TOO_LONG 122 +#define ASN1_R_INVALID_DIGIT 123 +#define ASN1_R_INVALID_SEPARATOR 124 +#define ASN1_R_INVALID_TIME_FORMAT 125 +#define ASN1_R_IV_TOO_LARGE 126 +#define ASN1_R_LENGTH_ERROR 127 +#define ASN1_R_LENGTH_MISMATCH 128 +#define ASN1_R_MISSING_EOS 129 +#define ASN1_R_MISSING_SECOND_NUMBER 130 +#define ASN1_R_NON_HEX_CHARACTERS 131 +#define ASN1_R_NOT_ENOUGH_DATA 132 +#define ASN1_R_ODD_NUMBER_OF_CHARS 133 +#define ASN1_R_PARSING 134 +#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 135 +#define ASN1_R_SECOND_NUMBER_TOO_LARGE 136 +#define ASN1_R_SHORT_LINE 137 +#define ASN1_R_STRING_TOO_SHORT 138 +#define ASN1_R_TAG_VALUE_TOO_HIGH 139 +#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 140 +#define ASN1_R_TOO_LONG 141 +#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 142 +#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 143 +#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 144 +#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 145 +#define ASN1_R_UNKNOWN_OBJECT_TYPE 146 +#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 147 +#define ASN1_R_UNSUPPORTED_CIPHER 148 +#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 149 +#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 150 +#define ASN1_R_UTCTIME_TOO_LONG 151 +#define ASN1_R_WRONG_PRINTABLE_TYPE 152 +#define ASN1_R_WRONG_TAG 153 +#define ASN1_R_WRONG_TYPE 154 diff --git a/src/lib/libcrypto/asn1/d2i_dhp.c b/src/lib/libcrypto/asn1/d2i_dhp.c new file mode 100644 index 0000000000..616a308100 --- /dev/null +++ b/src/lib/libcrypto/asn1/d2i_dhp.c @@ -0,0 +1,108 @@ +/* crypto/asn1/d2i_dhp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dh.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DHPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +DH *d2i_DHparams(a,pp,length) +DH **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_ERROR_STACK; + ASN1_INTEGER *bs=NULL; + long v=0; + M_ASN1_D2I_vars(a,DH *,DH_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; + + if (!M_ASN1_D2I_end_sequence()) + { + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + for (i=0; ilength; i++) + v=(v<<8)|(bs->data[i]); + ret->length=(int)v; + } + + ASN1_BIT_STRING_free(bs); + + M_ASN1_D2I_Finish_2(a); + +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DHPARAMS,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret); + if (bs != NULL) ASN1_BIT_STRING_free(bs); + return(NULL); + } + diff --git a/src/lib/libcrypto/asn1/d2i_dsap.c b/src/lib/libcrypto/asn1/d2i_dsap.c new file mode 100644 index 0000000000..2c8ac7bbcf --- /dev/null +++ b/src/lib/libcrypto/asn1/d2i_dsap.c @@ -0,0 +1,101 @@ +/* crypto/asn1/d2i_dsap.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DSAPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +DSA *d2i_DSAparams(a,pp,length) +DSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_ERROR_STACK; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,DSA *,DSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; + + ASN1_BIT_STRING_free(bs); + + M_ASN1_D2I_Finish_2(a); + +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DSAPARAMS,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); + if (bs != NULL) ASN1_BIT_STRING_free(bs); + return(NULL); + } + diff --git a/src/lib/libcrypto/asn1/d2i_r_pr.c b/src/lib/libcrypto/asn1/d2i_r_pr.c new file mode 100644 index 0000000000..0c53aa94bf --- /dev/null +++ b/src/lib/libcrypto/asn1/d2i_r_pr.c @@ -0,0 +1,129 @@ +/* crypto/asn1/d2i_r_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_PARSING); + */ + +static ASN1_METHOD method={ + (int (*)()) i2d_RSAPrivateKey, + (char *(*)())d2i_RSAPrivateKey, + (char *(*)())RSA_new, + (void (*)()) RSA_free}; + +ASN1_METHOD *RSAPrivateKey_asn1_meth() + { + return(&method); + } + +RSA *d2i_RSAPrivateKey(a,pp,length) +RSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,RSA *,RSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if (bs->length == 0) + ret->version=0; + else ret->version=bs->data[0]; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->d=BN_bin2bn(bs->data,bs->length,ret->d)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->dmp1=BN_bin2bn(bs->data,bs->length,ret->dmp1)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->dmq1=BN_bin2bn(bs->data,bs->length,ret->dmq1)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL) + goto err_bn; + + ASN1_INTEGER_free(bs); + + M_ASN1_D2I_Finish_2(a); +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libcrypto/asn1/d2i_r_pu.c b/src/lib/libcrypto/asn1/d2i_r_pu.c new file mode 100644 index 0000000000..778b792b1e --- /dev/null +++ b/src/lib/libcrypto/asn1/d2i_r_pu.c @@ -0,0 +1,100 @@ +/* crypto/asn1/d2i_r_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +RSA *d2i_RSAPublicKey(a,pp,length) +RSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,RSA *,RSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; + + ASN1_INTEGER_free(bs); + bs=NULL; + + M_ASN1_D2I_Finish_2(a); + +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libcrypto/asn1/d2i_s_pr.c b/src/lib/libcrypto/asn1/d2i_s_pr.c new file mode 100644 index 0000000000..32ff8ba4b3 --- /dev/null +++ b/src/lib/libcrypto/asn1/d2i_s_pr.c @@ -0,0 +1,113 @@ +/* crypto/asn1/d2i_s_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Origional version from Steven Schoch */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_PARSING); + */ + +DSA *d2i_DSAPrivateKey(a,pp,length) +DSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,DSA *,DSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if (bs->length == 0) + ret->version=0; + else ret->version=bs->data[0]; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key)) + == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key)) + == NULL) goto err_bn; + + ASN1_INTEGER_free(bs); + + M_ASN1_D2I_Finish_2(a); +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libcrypto/asn1/d2i_s_pu.c b/src/lib/libcrypto/asn1/d2i_s_pu.c new file mode 100644 index 0000000000..1002f41cd8 --- /dev/null +++ b/src/lib/libcrypto/asn1/d2i_s_pu.c @@ -0,0 +1,124 @@ +/* crypto/asn1/d2i_s_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Origional version from Steven Schoch */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +DSA *d2i_DSAPublicKey(a,pp,length) +DSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,DSA *,DSA_new); + + M_ASN1_D2I_Init(); + if ((length != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) + == (V_ASN1_UNIVERSAL|(V_ASN1_INTEGER)))) + { + c.slen=length; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key)) + == NULL) + goto err_bn; + ret->write_params=0; + } + else + { + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key)) + == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) + goto err_bn; + + ret->write_params=1; + } + + ASN1_INTEGER_free(bs); + bs=NULL; + M_ASN1_D2I_Finish_2(a); +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libcrypto/asn1/f.c b/src/lib/libcrypto/asn1/f.c new file mode 100644 index 0000000000..2ab3a262ac --- /dev/null +++ b/src/lib/libcrypto/asn1/f.c @@ -0,0 +1,80 @@ +/* crypto/asn1/f.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#include +#include "asn1.h" +#include "err.h" + +main() + { + ASN1_TYPE *at; + char buf[512]; + int n; + long l; + + at=ASN1_TYPE_new(); + + n=ASN1_TYPE_set_int_octetstring(at,98736,"01234567",8); + printf("%d\n",n); + n=ASN1_TYPE_get_int_octetstring(at,&l,buf,8); + buf[8]='\0'; + printf("%ld %d %d\n",l,n,buf[8]); + buf[8]='\0'; + printf("%s\n",buf); + ERR_load_crypto_strings(); + ERR_print_errors_fp(stderr); + } diff --git a/src/lib/libcrypto/asn1/i2d_dhp.c b/src/lib/libcrypto/asn1/i2d_dhp.c new file mode 100644 index 0000000000..a454025ce3 --- /dev/null +++ b/src/lib/libcrypto/asn1/i2d_dhp.c @@ -0,0 +1,128 @@ +/* crypto/asn1/i2d_dhp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "asn1_mac.h" +#include "dh.h" + +/* + * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_DHPARAMS_NEW,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_DHparams(a,pp) +DH *a; +unsigned char **pp; + { + BIGNUM *num[3]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0; + int t,ret= -1; + unsigned char *p; + + if (a == NULL) return(0); + num[0]=a->p; + num[1]=a->g; + if (a->length != 0) + { + if ((num[2]=BN_new()) == NULL) goto err; + if (!BN_set_word(num[2],a->length)) goto err; + } + else + num[2]=NULL; + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DHPARAMS,ERR_R_MALLOC_FAILURE); + goto err; + } + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + ret=t; +err: + if (num[2] != NULL) BN_free(num[2]); + *pp=p; + return(ret); + } diff --git a/src/lib/libcrypto/asn1/i2d_dsap.c b/src/lib/libcrypto/asn1/i2d_dsap.c new file mode 100644 index 0000000000..94ecff1525 --- /dev/null +++ b/src/lib/libcrypto/asn1/i2d_dsap.c @@ -0,0 +1,121 @@ +/* crypto/asn1/i2d_dsap.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "asn1_mac.h" +#include "dsa.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_DSAparams(a,pp) +DSA *a; +unsigned char **pp; + { + BIGNUM *num[3]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0; + int t,ret= -1; + unsigned char *p; + + if (a == NULL) return(0); + num[0]=a->p; + num[1]=a->q; + num[2]=a->g; + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DSAPARAMS,ERR_R_MALLOC_FAILURE); + goto err; + } + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + ret=t; +err: + *pp=p; + return(ret); + } + diff --git a/src/lib/libcrypto/asn1/i2d_r_pr.c b/src/lib/libcrypto/asn1/i2d_r_pr.c new file mode 100644 index 0000000000..aadbb92d8e --- /dev/null +++ b/src/lib/libcrypto/asn1/i2d_r_pr.c @@ -0,0 +1,132 @@ +/* crypto/asn1/i2d_r_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_RSAPrivateKey(a,pp) +RSA *a; +unsigned char **pp; + { + BIGNUM *num[9]; + unsigned char data[1]; + ASN1_INTEGER bs; + unsigned int j,i,tot,t,len,max=0; + unsigned char *p; + + if (a == NULL) return(0); + + num[1]=a->n; + num[2]=a->e; + num[3]=a->d; + num[4]=a->p; + num[5]=a->q; + num[6]=a->dmp1; + num[7]=a->dmq1; + num[8]=a->iqmp; + + bs.length=1; + bs.data=data; + bs.type=V_ASN1_INTEGER; + data[0]=a->version&0x7f; + + tot=i2d_ASN1_INTEGER(&(bs),NULL); + for (i=1; i<9; i++) + { + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + i2d_ASN1_INTEGER(&bs,&p); + + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=1; i<9; i++) + { + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + *pp=p; + return(t); + } + diff --git a/src/lib/libcrypto/asn1/i2d_r_pu.c b/src/lib/libcrypto/asn1/i2d_r_pu.c new file mode 100644 index 0000000000..3c54f6709d --- /dev/null +++ b/src/lib/libcrypto/asn1/i2d_r_pu.c @@ -0,0 +1,118 @@ +/* crypto/asn1/i2d_r_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_RSAPublicKey(a,pp) +RSA *a; +unsigned char **pp; + { + BIGNUM *num[2]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0,t; + unsigned char *p; + + if (a == NULL) return(0); + + num[0]=a->n; + num[1]=a->e; + + for (i=0; i<2; i++) + { + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=0; i<2; i++) + { + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + *pp=p; + return(t); + } + diff --git a/src/lib/libcrypto/asn1/i2d_s_pr.c b/src/lib/libcrypto/asn1/i2d_s_pr.c new file mode 100644 index 0000000000..6e95305548 --- /dev/null +++ b/src/lib/libcrypto/asn1/i2d_s_pr.c @@ -0,0 +1,128 @@ +/* crypto/asn1/i2d_s_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_DSAPrivateKey(a,pp) +DSA *a; +unsigned char **pp; + { + BIGNUM *num[6]; + unsigned char data[1]; + ASN1_INTEGER bs; + unsigned int j,i,tot,t,len,max=0; + unsigned char *p; + + if (a == NULL) return(0); + + num[1]=a->p; + num[2]=a->q; + num[3]=a->g; + num[4]=a->pub_key; + num[5]=a->priv_key; + + bs.length=1; + bs.data=data; + bs.type=V_ASN1_INTEGER; + data[0]=a->version&0x7f; + + tot=i2d_ASN1_INTEGER(&(bs),NULL); + for (i=1; i<6; i++) + { + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + i2d_ASN1_INTEGER(&bs,&p); + + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=1; i<6; i++) + { + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + *pp=p; + return(t); + } + diff --git a/src/lib/libcrypto/asn1/i2d_s_pu.c b/src/lib/libcrypto/asn1/i2d_s_pu.c new file mode 100644 index 0000000000..5cf2877069 --- /dev/null +++ b/src/lib/libcrypto/asn1/i2d_s_pu.c @@ -0,0 +1,133 @@ +/* crypto/asn1/i2d_s_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_DSAPublicKey(a,pp) +DSA *a; +unsigned char **pp; + { + BIGNUM *num[4]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0,t=0,all,n=1; + unsigned char *p; + + if (a == NULL) return(0); + + all=a->write_params; + + num[0]=a->pub_key; + if (all) + { + num[1]=a->p; + num[2]=a->q; + num[3]=a->g; + n=4; + } + + for (i=0; i max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + if (all) + { + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + } + else + { + if (pp == NULL) return(tot); + } + + p= *pp; + if (all) + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=0; i +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_DIGEST_NEW,ASN1_R_MISSING_EOS); + * ASN1err(ASN1_F_D2I_PKCS7_DIGEST,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_DIGEST(a,pp) +PKCS7_DIGEST *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->md,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->contents,i2d_PKCS7); + M_ASN1_I2D_len(a->digest,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->md,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->contents,i2d_PKCS7); + M_ASN1_I2D_put(a->digest,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_finish(); + } + +PKCS7_DIGEST *d2i_PKCS7_DIGEST(a,pp,length) +PKCS7_DIGEST **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_DIGEST *,PKCS7_DIGEST_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->md,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->contents,d2i_PKCS7); + M_ASN1_D2I_get(ret->digest,d2i_ASN1_OCTET_STRING); + + M_ASN1_D2I_Finish(a,PKCS7_DIGEST_free,ASN1_F_D2I_PKCS7_DIGEST); + } + +PKCS7_DIGEST *PKCS7_DIGEST_new() + { + PKCS7_DIGEST *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_DIGEST); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->md,X509_ALGOR_new); + M_ASN1_New(ret->contents,PKCS7_new); + M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW); + } + +void PKCS7_DIGEST_free(a) +PKCS7_DIGEST *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + X509_ALGOR_free(a->md); + PKCS7_free(a->contents); + ASN1_OCTET_STRING_free(a->digest); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_enc.c b/src/lib/libcrypto/asn1/p7_enc.c new file mode 100644 index 0000000000..874dd78389 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_enc.c @@ -0,0 +1,120 @@ +/* crypto/asn1/p7_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ENCRYPT_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ENCRYPT,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ENCRYPT(a,pp) +PKCS7_ENCRYPT *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_finish(); + } + +PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(a,pp,length) +PKCS7_ENCRYPT **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ENCRYPT *,PKCS7_ENCRYPT_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT); + + M_ASN1_D2I_Finish(a,PKCS7_ENCRYPT_free,ASN1_F_D2I_PKCS7_ENCRYPT); + } + +PKCS7_ENCRYPT *PKCS7_ENCRYPT_new() + { + PKCS7_ENCRYPT *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW); + } + +void PKCS7_ENCRYPT_free(a) +PKCS7_ENCRYPT *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + PKCS7_ENC_CONTENT_free(a->enc_data); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_enc_c.c b/src/lib/libcrypto/asn1/p7_enc_c.c new file mode 100644 index 0000000000..2860d3e925 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_enc_c.c @@ -0,0 +1,127 @@ +/* crypto/asn1/p7_enc_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ENC_CONTENT_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ENC_CONTENT,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ENC_CONTENT(a,pp) +PKCS7_ENC_CONTENT *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->content_type,i2d_ASN1_OBJECT); + M_ASN1_I2D_len(a->algorithm,i2d_X509_ALGOR); + M_ASN1_I2D_len_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->content_type,i2d_ASN1_OBJECT); + M_ASN1_I2D_put(a->algorithm,i2d_X509_ALGOR); + M_ASN1_I2D_put_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING,0); + + M_ASN1_I2D_finish(); + } + +PKCS7_ENC_CONTENT *d2i_PKCS7_ENC_CONTENT(a,pp,length) +PKCS7_ENC_CONTENT **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ENC_CONTENT *,PKCS7_ENC_CONTENT_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->content_type,d2i_ASN1_OBJECT); + M_ASN1_D2I_get(ret->algorithm,d2i_X509_ALGOR); + M_ASN1_D2I_get_IMP_opt(ret->enc_data,d2i_ASN1_OCTET_STRING,0, + V_ASN1_OCTET_STRING); + + M_ASN1_D2I_Finish(a,PKCS7_ENC_CONTENT_free, + ASN1_F_D2I_PKCS7_ENC_CONTENT); + } + +PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new() + { + PKCS7_ENC_CONTENT *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT); + M_ASN1_New(ret->content_type,ASN1_OBJECT_new); + M_ASN1_New(ret->algorithm,X509_ALGOR_new); + ret->enc_data=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ENC_CONTENT_NEW); + } + +void PKCS7_ENC_CONTENT_free(a) +PKCS7_ENC_CONTENT *a; + { + if (a == NULL) return; + ASN1_OBJECT_free(a->content_type); + X509_ALGOR_free(a->algorithm); + ASN1_OCTET_STRING_free(a->enc_data); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_evp.c b/src/lib/libcrypto/asn1/p7_evp.c new file mode 100644 index 0000000000..4db0a7fe62 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_evp.c @@ -0,0 +1,125 @@ +/* crypto/asn1/p7_evp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ENVELOPE,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ENVELOPE(a,pp) +PKCS7_ENVELOPE *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_finish(); + } + +PKCS7_ENVELOPE *d2i_PKCS7_ENVELOPE(a,pp,length) +PKCS7_ENVELOPE **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ENVELOPE *,PKCS7_ENVELOPE_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO); + M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT); + + M_ASN1_D2I_Finish(a,PKCS7_ENVELOPE_free,ASN1_F_D2I_PKCS7_ENVELOPE); + } + +PKCS7_ENVELOPE *PKCS7_ENVELOPE_new() + { + PKCS7_ENVELOPE *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->recipientinfo,sk_new_null); + M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ENVELOPE_NEW); + } + +void PKCS7_ENVELOPE_free(a) +PKCS7_ENVELOPE *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); + PKCS7_ENC_CONTENT_free(a->enc_data); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_i_s.c b/src/lib/libcrypto/asn1/p7_i_s.c new file mode 100644 index 0000000000..9b00c556d9 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_i_s.c @@ -0,0 +1,120 @@ +/* crypto/asn1/p7_i_s.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ISSUER_AND_SERIAL(a,pp) +PKCS7_ISSUER_AND_SERIAL *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->issuer,i2d_X509_NAME); + M_ASN1_I2D_len(a->serial,i2d_ASN1_INTEGER); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->issuer,i2d_X509_NAME); + M_ASN1_I2D_put(a->serial,i2d_ASN1_INTEGER); + + M_ASN1_I2D_finish(); + } + +PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(a,pp,length) +PKCS7_ISSUER_AND_SERIAL **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ISSUER_AND_SERIAL *,PKCS7_ISSUER_AND_SERIAL_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); + M_ASN1_D2I_get(ret->serial,d2i_ASN1_INTEGER); + M_ASN1_D2I_Finish(a,PKCS7_ISSUER_AND_SERIAL_free, + ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL); + } + +PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new() + { + PKCS7_ISSUER_AND_SERIAL *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL); + M_ASN1_New(ret->issuer,X509_NAME_new); + M_ASN1_New(ret->serial,ASN1_INTEGER_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW); + } + +void PKCS7_ISSUER_AND_SERIAL_free(a) +PKCS7_ISSUER_AND_SERIAL *a; + { + if (a == NULL) return; + X509_NAME_free(a->issuer); + ASN1_INTEGER_free(a->serial); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_lib.c b/src/lib/libcrypto/asn1/p7_lib.c new file mode 100644 index 0000000000..2134e0974a --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_lib.c @@ -0,0 +1,299 @@ +/* crypto/asn1/p7_lib.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "objects.h" + +/* ASN1err(ASN1_F_D2I_PKCS7,ASN1_R_BAD_PKCS7_CONTENT); + * ASN1err(ASN1_F_I2D_PKCS7,ASN1_R_BAD_PKCS7_TYPE); + * ASN1err(ASN1_F_PKCS7_NEW,ASN1_R_BAD_PKCS7_TYPE); + */ + +int i2d_PKCS7(a,pp) +PKCS7 *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + if (a->asn1 != NULL) + { + if (pp == NULL) + return((int)a->length); + memcpy(*pp,a->asn1,(int)a->length); + *pp+=a->length; + return((int)a->length); + } + + ret+=4; /* sequence, BER header plus '0 0' end padding */ + M_ASN1_I2D_len(a->type,i2d_ASN1_OBJECT); + if (a->d.ptr != NULL) + { + ret+=4; /* explicit tag [ 0 ] BER plus '0 0' */ + switch (OBJ_obj2nid(a->type)) + { + case NID_pkcs7_data: + M_ASN1_I2D_len(a->d.data,i2d_ASN1_OCTET_STRING); + break; + case NID_pkcs7_signed: + M_ASN1_I2D_len(a->d.sign,i2d_PKCS7_SIGNED); + break; + case NID_pkcs7_enveloped: + M_ASN1_I2D_len(a->d.enveloped,i2d_PKCS7_ENVELOPE); + break; + case NID_pkcs7_signedAndEnveloped: + M_ASN1_I2D_len(a->d.signed_and_enveloped, + i2d_PKCS7_SIGN_ENVELOPE); + break; + case NID_pkcs7_digest: + M_ASN1_I2D_len(a->d.digest,i2d_PKCS7_DIGEST); + break; + case NID_pkcs7_encrypted: + M_ASN1_I2D_len(a->d.encrypted,i2d_PKCS7_ENCRYPT); + break; + default: + break; + } + } + r=ret; + if (pp == NULL) return(r); + p= *pp; + M_ASN1_I2D_INF_seq_start(V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + M_ASN1_I2D_put(a->type,i2d_ASN1_OBJECT); + + if (a->d.ptr != NULL) + { + M_ASN1_I2D_INF_seq_start(0,V_ASN1_CONTEXT_SPECIFIC); + switch (OBJ_obj2nid(a->type)) + { + case NID_pkcs7_data: + M_ASN1_I2D_put(a->d.data,i2d_ASN1_OCTET_STRING); + break; + case NID_pkcs7_signed: + M_ASN1_I2D_put(a->d.sign,i2d_PKCS7_SIGNED); + break; + case NID_pkcs7_enveloped: + M_ASN1_I2D_put(a->d.enveloped,i2d_PKCS7_ENVELOPE); + break; + case NID_pkcs7_signedAndEnveloped: + M_ASN1_I2D_put(a->d.signed_and_enveloped, + i2d_PKCS7_SIGN_ENVELOPE); + break; + case NID_pkcs7_digest: + M_ASN1_I2D_put(a->d.digest,i2d_PKCS7_DIGEST); + break; + case NID_pkcs7_encrypted: + M_ASN1_I2D_put(a->d.encrypted,i2d_PKCS7_ENCRYPT); + break; + default: + break; + } + M_ASN1_I2D_INF_seq_end(); + } + M_ASN1_I2D_INF_seq_end(); + M_ASN1_I2D_finish(); + } + +PKCS7 *d2i_PKCS7(a,pp,length) +PKCS7 **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new); + + if ((a != NULL) && ((*a) != NULL)) + { + if ((*a)->asn1 != NULL) + { + Free((char *)(*a)->asn1); + (*a)->asn1=NULL; + } + (*a)->length=0; + } + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->type,d2i_ASN1_OBJECT); + if (!M_ASN1_D2I_end_sequence()) + { + int Tinf,Ttag,Tclass; + long Tlen; + + if (M_ASN1_next != (V_ASN1_CONSTRUCTED| + V_ASN1_CONTEXT_SPECIFIC|0)) + { + c.error=ASN1_R_BAD_PKCS7_CONTENT; + goto err; + } + + ret->detached=0; + + c.q=c.p; + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass, + (c.inf & 1)?(length+ *pp-c.q):c.slen); + if (Tinf & 0x80) goto err; + c.slen-=(c.p-c.q); + + switch (OBJ_obj2nid(ret->type)) + { + case NID_pkcs7_data: + M_ASN1_D2I_get(ret->d.data,d2i_ASN1_OCTET_STRING); + break; + case NID_pkcs7_signed: + M_ASN1_D2I_get(ret->d.sign,d2i_PKCS7_SIGNED); + if (ret->d.sign->contents->d.ptr == NULL) + ret->detached=1; + break; + case NID_pkcs7_enveloped: + M_ASN1_D2I_get(ret->d.enveloped,d2i_PKCS7_ENVELOPE); + break; + case NID_pkcs7_signedAndEnveloped: + M_ASN1_D2I_get(ret->d.signed_and_enveloped, + d2i_PKCS7_SIGN_ENVELOPE); + break; + case NID_pkcs7_digest: + M_ASN1_D2I_get(ret->d.digest,d2i_PKCS7_DIGEST); + break; + case NID_pkcs7_encrypted: + M_ASN1_D2I_get(ret->d.encrypted,d2i_PKCS7_ENCRYPT); + break; + default: + c.error=ASN1_R_BAD_PKCS7_TYPE; + goto err; + break; + } + if (Tinf == (1|V_ASN1_CONSTRUCTED)) + { + if (!ASN1_check_infinite_end(&c.p,c.slen)) + { + c.error=ASN1_R_MISSING_EOS; + goto err; + } + } + } + else + ret->detached=1; + + M_ASN1_D2I_Finish(a,PKCS7_free,ASN1_F_D2I_PKCS7); + } + +PKCS7 *PKCS7_new() + { + PKCS7 *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7); + ret->type=ASN1_OBJECT_new(); + ret->asn1=NULL; + ret->length=0; + ret->detached=0; + ret->d.ptr=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_NEW); + } + +void PKCS7_free(a) +PKCS7 *a; + { + if (a == NULL) return; + + PKCS7_content_free(a); + if (a->type != NULL) + { + ASN1_OBJECT_free(a->type); + } + Free((char *)(char *)a); + } + +void PKCS7_content_free(a) +PKCS7 *a; + { + if (a->asn1 != NULL) Free((char *)a->asn1); + + if (a->d.ptr != NULL) + { + if (a->type == NULL) return; + + switch (OBJ_obj2nid(a->type)) + { + case NID_pkcs7_data: + ASN1_OCTET_STRING_free(a->d.data); + break; + case NID_pkcs7_signed: + PKCS7_SIGNED_free(a->d.sign); + break; + case NID_pkcs7_enveloped: + PKCS7_ENVELOPE_free(a->d.enveloped); + break; + case NID_pkcs7_signedAndEnveloped: + PKCS7_SIGN_ENVELOPE_free(a->d.signed_and_enveloped); + break; + case NID_pkcs7_digest: + PKCS7_DIGEST_free(a->d.digest); + break; + case NID_pkcs7_encrypted: + PKCS7_ENCRYPT_free(a->d.encrypted); + break; + default: + /* MEMORY LEAK */ + break; + } + } + a->d.ptr=NULL; + } + diff --git a/src/lib/libcrypto/asn1/p7_recip.c b/src/lib/libcrypto/asn1/p7_recip.c new file mode 100644 index 0000000000..f02233f5a8 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_recip.c @@ -0,0 +1,132 @@ +/* crypto/asn1/p7_recip.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_RECIP_INFO_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_RECIP_INFO,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_RECIP_INFO(a,pp) +PKCS7_RECIP_INFO *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_len(a->key_enc_algor,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->enc_key,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_put(a->key_enc_algor,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->enc_key,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_finish(); + } + +PKCS7_RECIP_INFO *d2i_PKCS7_RECIP_INFO(a,pp,length) +PKCS7_RECIP_INFO **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_RECIP_INFO *,PKCS7_RECIP_INFO_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_D2I_get(ret->key_enc_algor,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->enc_key,d2i_ASN1_OCTET_STRING); + + M_ASN1_D2I_Finish(a,PKCS7_RECIP_INFO_free,ASN1_F_D2I_PKCS7_RECIP_INFO); + } + +PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new() + { + PKCS7_RECIP_INFO *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); + M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new); + M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new); + ret->cert=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW); + } + +void PKCS7_RECIP_INFO_free(a) +PKCS7_RECIP_INFO *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); + X509_ALGOR_free(a->key_enc_algor); + ASN1_OCTET_STRING_free(a->enc_key); + if (a->cert != NULL) X509_free(a->cert); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_s_e.c b/src/lib/libcrypto/asn1/p7_s_e.c new file mode 100644 index 0000000000..d344211456 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_s_e.c @@ -0,0 +1,146 @@ +/* crypto/asn1/p7_s_e.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_SIGN_ENVELOPE(a,pp) +PKCS7_SIGN_ENVELOPE *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT); + M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT); + M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_finish(); + } + +PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(a,pp,length) +PKCS7_SIGN_ENVELOPE **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_SIGN_ENVELOPE *,PKCS7_SIGN_ENVELOPE_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO); + M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT); + M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0); + M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1); + M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO); + + M_ASN1_D2I_Finish(a,PKCS7_SIGN_ENVELOPE_free, + ASN1_F_D2I_PKCS7_SIGN_ENVELOPE); + } + +PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new() + { + PKCS7_SIGN_ENVELOPE *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->recipientinfo,sk_new_null); + M_ASN1_New(ret->md_algs,sk_new_null); + M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); + ret->cert=NULL; + ret->crl=NULL; + M_ASN1_New(ret->signer_info,sk_new_null); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW); + } + +void PKCS7_SIGN_ENVELOPE_free(a) +PKCS7_SIGN_ENVELOPE *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); + sk_pop_free(a->md_algs,X509_ALGOR_free); + PKCS7_ENC_CONTENT_free(a->enc_data); + sk_pop_free(a->cert,X509_free); + sk_pop_free(a->crl,X509_CRL_free); + sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_signd.c b/src/lib/libcrypto/asn1/p7_signd.c new file mode 100644 index 0000000000..40f9a44fa8 --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_signd.c @@ -0,0 +1,140 @@ +/* crypto/asn1/p7_signd.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_SIGNED_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_SIGNED,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_SIGNED(a,pp) +PKCS7_SIGNED *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->contents,i2d_PKCS7); + M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->contents,i2d_PKCS7); + M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_finish(); + } + +PKCS7_SIGNED *d2i_PKCS7_SIGNED(a,pp,length) +PKCS7_SIGNED **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_SIGNED *,PKCS7_SIGNED_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->contents,d2i_PKCS7); + M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0); + M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1); + M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO); + + M_ASN1_D2I_Finish(a,PKCS7_SIGNED_free,ASN1_F_D2I_PKCS7_SIGNED); + } + +PKCS7_SIGNED *PKCS7_SIGNED_new() + { + PKCS7_SIGNED *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_SIGNED); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->md_algs,sk_new_null); + M_ASN1_New(ret->contents,PKCS7_new); + ret->cert=NULL; + ret->crl=NULL; + M_ASN1_New(ret->signer_info,sk_new_null); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_SIGNED_NEW); + } + +void PKCS7_SIGNED_free(a) +PKCS7_SIGNED *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + sk_pop_free(a->md_algs,X509_ALGOR_free); + PKCS7_free(a->contents); + sk_pop_free(a->cert,X509_free); + sk_pop_free(a->crl,X509_CRL_free); + sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/p7_signi.c b/src/lib/libcrypto/asn1/p7_signi.c new file mode 100644 index 0000000000..0da92169fc --- /dev/null +++ b/src/lib/libcrypto/asn1/p7_signi.c @@ -0,0 +1,149 @@ +/* crypto/asn1/p7_signi.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_SIGNER_INFO_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_SIGNER_INFO,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_SIGNER_INFO(a,pp) +PKCS7_SIGNER_INFO *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_len(a->digest_alg,i2d_X509_ALGOR); + M_ASN1_I2D_len_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0); + M_ASN1_I2D_len(a->digest_enc_alg,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->enc_digest,i2d_ASN1_OCTET_STRING); + M_ASN1_I2D_len_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_put(a->digest_alg,i2d_X509_ALGOR); + M_ASN1_I2D_put_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0); + M_ASN1_I2D_put(a->digest_enc_alg,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->enc_digest,i2d_ASN1_OCTET_STRING); + M_ASN1_I2D_put_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1); + + M_ASN1_I2D_finish(); + } + +PKCS7_SIGNER_INFO *d2i_PKCS7_SIGNER_INFO(a,pp,length) +PKCS7_SIGNER_INFO **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_SIGNER_INFO *,PKCS7_SIGNER_INFO_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_D2I_get(ret->digest_alg,d2i_X509_ALGOR); + M_ASN1_D2I_get_IMP_set_opt(ret->auth_attr,d2i_X509_ATTRIBUTE,0); + M_ASN1_D2I_get(ret->digest_enc_alg,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->enc_digest,d2i_ASN1_OCTET_STRING); + M_ASN1_D2I_get_IMP_set_opt(ret->unauth_attr,d2i_X509_ATTRIBUTE,1); + + M_ASN1_D2I_Finish(a,PKCS7_SIGNER_INFO_free, + ASN1_F_D2I_PKCS7_SIGNER_INFO); + } + +PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new() + { + PKCS7_SIGNER_INFO *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); + M_ASN1_New(ret->digest_alg,X509_ALGOR_new); + ret->auth_attr=NULL; + M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new); + M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new); + ret->unauth_attr=NULL; + ret->pkey=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_SIGNER_INFO_NEW); + } + +void PKCS7_SIGNER_INFO_free(a) +PKCS7_SIGNER_INFO *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); + X509_ALGOR_free(a->digest_alg); + sk_pop_free(a->auth_attr,X509_ATTRIBUTE_free); + X509_ALGOR_free(a->digest_enc_alg); + ASN1_OCTET_STRING_free(a->enc_digest); + sk_pop_free(a->unauth_attr,X509_ATTRIBUTE_free); + if (a->pkey != NULL) + EVP_PKEY_free(a->pkey); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/pkcs8.c b/src/lib/libcrypto/asn1/pkcs8.c new file mode 100644 index 0000000000..03fdadd51a --- /dev/null +++ b/src/lib/libcrypto/asn1/pkcs8.c @@ -0,0 +1,142 @@ +/* crypto/asn1/pkcs8.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "objects.h" + +/* + * ASN1err(ASN1_F_D2I_X509_KEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_KEY_NEW,ASN1_R_BAD_GET_OBJECT); + */ + +int i2d_X509_KEY(a,pp) +X509 *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF); + M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR); + M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF); + M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR); + M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING); + + M_ASN1_I2D_finish(); + } + +X509 *d2i_X509_KEY(a,pp,length) +X509 **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,X509 *,X509_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF); + M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING); + M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509); + } + +X509 *X509_KEY_new() + { + X509_KEY *ret=NULL; + + M_ASN1_New_Malloc(ret,X509_KEY); + ret->references=1; + ret->type=NID + M_ASN1_New(ret->cert_info,X509_CINF_new); + M_ASN1_New(ret->sig_alg,X509_ALGOR_new); + M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); + return(ret); + M_ASN1_New_Error(ASN1_F_X509_NEW); + } + +void X509_KEY_free(a) +X509 *a; + { + int i; + + if (a == NULL) return; + + i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY); +#ifdef REF_PRINT + REF_PRINT("X509_KEY",a); +#endif + if (i > 0) return; +#ifdef REF_CHECK + if (i < 0) + { + fprintf(stderr,"X509_KEY_free, bad reference count\n"); + abort(); + } +#endif + + X509_CINF_free(a->cert_info); + X509_ALGOR_free(a->sig_alg); + ASN1_BIT_STRING_free(a->signature); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/asn1/x_cinf.c b/src/lib/libcrypto/asn1/x_cinf.c new file mode 100644 index 0000000000..4fc2cc9f6e --- /dev/null +++ b/src/lib/libcrypto/asn1/x_cinf.c @@ -0,0 +1,197 @@ +/* crypto/asn1/x_cinf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_X509_CINF,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_CINF_NEW,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_X509_CINF(a,pp) +X509_CINF *a; +unsigned char **pp; + { + int v1=0,v2=0; + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1); + M_ASN1_I2D_len(a->serialNumber, i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->signature, i2d_X509_ALGOR); + M_ASN1_I2D_len(a->issuer, i2d_X509_NAME); + M_ASN1_I2D_len(a->validity, i2d_X509_VAL); + M_ASN1_I2D_len(a->subject, i2d_X509_NAME); + M_ASN1_I2D_len(a->key, i2d_X509_PUBKEY); + M_ASN1_I2D_len_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING); + M_ASN1_I2D_len_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING); + M_ASN1_I2D_len_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1); + M_ASN1_I2D_put(a->serialNumber, i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->signature, i2d_X509_ALGOR); + M_ASN1_I2D_put(a->issuer, i2d_X509_NAME); + M_ASN1_I2D_put(a->validity, i2d_X509_VAL); + M_ASN1_I2D_put(a->subject, i2d_X509_NAME); + M_ASN1_I2D_put(a->key, i2d_X509_PUBKEY); + M_ASN1_I2D_put_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING,1); + M_ASN1_I2D_put_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING,2); + M_ASN1_I2D_put_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2); + + M_ASN1_I2D_finish(); + } + +X509_CINF *d2i_X509_CINF(a,pp,length) +X509_CINF **a; +unsigned char **pp; +long length; + { + int ver=0; + M_ASN1_D2I_vars(a,X509_CINF *,X509_CINF_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + /* we have the optional version field */ + if (M_ASN1_next == (V_ASN1_CONTEXT_SPECIFIC | V_ASN1_CONSTRUCTED | 0)) + { + M_ASN1_D2I_get_EXP_opt(ret->version,d2i_ASN1_INTEGER,0); + if (ret->version->data != NULL) + ver=ret->version->data[0]; + } + else + { + if (ret->version != NULL) + { + ASN1_INTEGER_free(ret->version); + ret->version=NULL; + } + } + M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->signature,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); + M_ASN1_D2I_get(ret->validity,d2i_X509_VAL); + M_ASN1_D2I_get(ret->subject,d2i_X509_NAME); + M_ASN1_D2I_get(ret->key,d2i_X509_PUBKEY); + if (ver >= 1) /* version 2 extensions */ + { + if (ret->issuerUID != NULL) + { + ASN1_BIT_STRING_free(ret->issuerUID); + ret->issuerUID=NULL; + } + if (ret->subjectUID != NULL) + { + ASN1_BIT_STRING_free(ret->subjectUID); + ret->issuerUID=NULL; + } + M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1, + V_ASN1_BIT_STRING); + M_ASN1_D2I_get_IMP_opt(ret->subjectUID,d2i_ASN1_BIT_STRING, 2, + V_ASN1_BIT_STRING); + } + if (ver >= 2) /* version 3 extensions */ + { + if (ret->extensions != NULL) + while (sk_num(ret->extensions)) + X509_EXTENSION_free((X509_EXTENSION *) + sk_pop(ret->extensions)); + M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,3, + V_ASN1_SEQUENCE); + } + M_ASN1_D2I_Finish(a,X509_CINF_free,ASN1_F_D2I_X509_CINF); + } + +X509_CINF *X509_CINF_new() + { + X509_CINF *ret=NULL; + + M_ASN1_New_Malloc(ret,X509_CINF); + ret->version=NULL; + M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); + M_ASN1_New(ret->signature,X509_ALGOR_new); + M_ASN1_New(ret->issuer,X509_NAME_new); + M_ASN1_New(ret->validity,X509_VAL_new); + M_ASN1_New(ret->subject,X509_NAME_new); + M_ASN1_New(ret->key,X509_PUBKEY_new); + ret->issuerUID=NULL; + ret->subjectUID=NULL; + ret->extensions=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_X509_CINF_NEW); + } + +void X509_CINF_free(a) +X509_CINF *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + ASN1_INTEGER_free(a->serialNumber); + X509_ALGOR_free(a->signature); + X509_NAME_free(a->issuer); + X509_VAL_free(a->validity); + X509_NAME_free(a->subject); + X509_PUBKEY_free(a->key); + ASN1_BIT_STRING_free(a->issuerUID); + ASN1_BIT_STRING_free(a->subjectUID); + sk_pop_free(a->extensions,X509_EXTENSION_free); + Free((char *)a); + } + diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl new file mode 100644 index 0000000000..236671f238 --- /dev/null +++ b/src/lib/libcrypto/bf/Makefile.ssl @@ -0,0 +1,107 @@ +# +# SSLeay/crypto/blowfish/Makefile +# + +DIR= bf +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +BF_ENC= bf_enc.o +# or use +#DES_ENC= bx86-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=bftest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c +LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= blowfish.h +HEADER= bf_pi.h bf_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/bx86-elf.o: asm/bx86unix.cpp + $(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o + +# solaris +asm/bx86-sol.o: asm/bx86unix.cpp + $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s + as -o asm/bx86-sol.o asm/bx86-sol.s + rm -f asm/bx86-sol.s + +# a.out +asm/bx86-out.o: asm/bx86unix.cpp + $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o + +# bsdi +asm/bx86bsdi.o: asm/bx86unix.cpp + $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o + +asm/bx86unix.cpp: + (cd asm; perl bf-586.pl cpp >bx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/bf/Makefile.uni b/src/lib/libcrypto/bf/Makefile.uni new file mode 100644 index 0000000000..9ba5b0c854 --- /dev/null +++ b/src/lib/libcrypto/bf/Makefile.uni @@ -0,0 +1,169 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= bf +TOP= . +# use BF_PTR2 for intel boxes, +# BF_PTR for sparc and MIPS/SGI +# use nothing for Alpha and HP. + +# There are 3 possible performance options, experiment :-) +#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI +#OPTS= -DBF_PTR2 # use for pentium +OPTS= # use for pentium pro, Alpha and HP + +MAKE=make -f Makefile +#CC=cc +#CFLAG= -O + +CC=gcc +#CFLAG= -O4 -funroll-loops -fomit-frame-pointer +CFLAG= -O3 -fomit-frame-pointer + +CFLAGS=$(OPTS) $(CFLAG) +CPP=$(CC) -E +AS=as + +# Assember version of bf_encrypt(). +BF_ENC=bf_enc.o # normal C version +#BF_ENC=asm/bx86-elf.o # elf format x86 +#BF_ENC=asm/bx86-out.o # a.out format x86 +#BF_ENC=asm/bx86-sol.o # solaris format x86 +#BF_ENC=asm/bx86bsdi.o # bsdi format x86 + +LIBDIR=/usr/local/lib +BINDIR=/usr/local/bin +INCDIR=/usr/local/include +MANDIR=/usr/local/man +MAN1=1 +MAN3=3 +SHELL=/bin/sh +LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o +LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c + +GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \ + COPYRIGHT blowfish.doc INSTALL + +TESTING= bftest bfspeed bf_opts +TESTING_SRC=bftest.c bfspeed.c bf_opts.c +HEADERS=bf_locl.h blowfish.h bf_pi.h + +ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS) + +BLIB= libblowfish.a + +all: $(BLIB) $(TESTING) + +cc: + $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all + +gcc: + $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all + +x86-elf: + $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all + +x86-out: + $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all + +x86-solaris: + $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all + +x86-bsdi: + $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all + +# elf +asm/bx86-elf.o: asm/bx86unix.cpp + $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o + +# solaris +asm/bx86-sol.o: asm/bx86unix.cpp + $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s + as -o asm/bx86-sol.o asm/bx86-sol.s + rm -f asm/bx86-sol.s + +# a.out +asm/bx86-out.o: asm/bx86unix.cpp + $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o + +# bsdi +asm/bx86bsdi.o: asm/bx86unix.cpp + $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o + +asm/bx86unix.cpp: + (cd asm; perl bf-586.pl cpp >bx86unix.cpp) + +test: all + ./bftest + +$(BLIB): $(LIBOBJ) + /bin/rm -f $(BLIB) + ar cr $(BLIB) $(LIBOBJ) + -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \ + else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \ + else exit 0; fi; fi + +bftest: bftest.o $(BLIB) + $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB) + +bfspeed: bfspeed.o $(BLIB) + $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB) + +bf_opts: bf_opts.o $(BLIB) + $(CC) $(CFLAGS) -o bf_opts bf_opts.o $(BLIB) + +tags: + ctags $(TESTING_SRC) $(LIBBF) + +tar: + tar chf libbf.tar $(ALL) + +shar: + shar $(ALL) >libbf.shar + +depend: + makedepend $(LIBBF) $(TESTING_SRC) + +clean: + /bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o + +dclean: + sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new + mv -f Makefile.new Makefile + +# Eric is probably going to choke when he next looks at this --tjh +install: $(BLIB) + if test $(INSTALLTOP); then \ + echo SSL style install; \ + cp $(BLIB) $(INSTALLTOP)/lib; \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ + fi; fi; \ + chmod 644 $(INSTALLTOP)/lib/$(BLIB); \ + cp blowfish.h $(INSTALLTOP)/include; \ + chmod 644 $(INSTALLTOP)/include/blowfish.h; \ + else \ + echo Standalone install; \ + cp $(BLIB) $(LIBDIR)/$(BLIB); \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(LIBDIR)/$(BLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(LIBDIR)/$(BLIB); \ + fi; \ + fi; \ + chmod 644 $(LIBDIR)/$(BLIB); \ + cp blowfish.h $(INCDIR)/blowfish.h; \ + chmod 644 $(INCDIR)/blowfish.h; \ + fi + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/bf/asm/b-win32.asm b/src/lib/libcrypto/bf/asm/b-win32.asm new file mode 100644 index 0000000000..138c99d0aa --- /dev/null +++ b/src/lib/libcrypto/bf/asm/b-win32.asm @@ -0,0 +1,906 @@ + ; Don't even think of reading this code + ; It was automatically generated by bf-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE bf-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _BF_encrypt + +_BF_encrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + mov ebx, DWORD PTR [ebp] + xor ecx, ecx + xor edi, ebx + ; + ; Round 0 + mov edx, DWORD PTR 4[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 1 + mov edx, DWORD PTR 8[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 2 + mov edx, DWORD PTR 12[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 3 + mov edx, DWORD PTR 16[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 4 + mov edx, DWORD PTR 20[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 5 + mov edx, DWORD PTR 24[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 6 + mov edx, DWORD PTR 28[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 7 + mov edx, DWORD PTR 32[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 8 + mov edx, DWORD PTR 36[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 9 + mov edx, DWORD PTR 40[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 10 + mov edx, DWORD PTR 44[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 11 + mov edx, DWORD PTR 48[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 12 + mov edx, DWORD PTR 52[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 13 + mov edx, DWORD PTR 56[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 14 + mov edx, DWORD PTR 60[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 15 + mov edx, DWORD PTR 64[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + ; Load parameter 0 (16) enc=1 + mov eax, DWORD PTR 20[esp] + xor edi, ebx + mov edx, DWORD PTR 68[ebp] + xor esi, edx + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_BF_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _BF_decrypt + +_BF_decrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + mov ebx, DWORD PTR 68[ebp] + xor ecx, ecx + xor edi, ebx + ; + ; Round 16 + mov edx, DWORD PTR 64[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 15 + mov edx, DWORD PTR 60[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 14 + mov edx, DWORD PTR 56[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 13 + mov edx, DWORD PTR 52[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 12 + mov edx, DWORD PTR 48[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 11 + mov edx, DWORD PTR 44[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 10 + mov edx, DWORD PTR 40[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 9 + mov edx, DWORD PTR 36[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 8 + mov edx, DWORD PTR 32[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 7 + mov edx, DWORD PTR 28[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 6 + mov edx, DWORD PTR 24[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 5 + mov edx, DWORD PTR 20[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 4 + mov edx, DWORD PTR 16[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 3 + mov edx, DWORD PTR 12[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 2 + mov edx, DWORD PTR 8[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 1 + mov edx, DWORD PTR 4[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + ; Load parameter 0 (1) enc=0 + mov eax, DWORD PTR 20[esp] + xor edi, ebx + mov edx, DWORD PTR [ebp] + xor esi, edx + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_BF_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _BF_cbc_encrypt + +_BF_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L000decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L001encrypt_finish +L002encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L002encrypt_loop +$L001encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4] + jmp ebp +L005ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L006ej6: + mov dh, BYTE PTR 5[esi] +L007ej5: + mov dl, BYTE PTR 4[esi] +L008ej4: + mov ecx, DWORD PTR [esi] + jmp $L009ejend +L010ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L011ej2: + mov ch, BYTE PTR 1[esi] +L012ej1: + mov cl, BYTE PTR [esi] +$L009ejend: + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L003finish +$L000decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L013decrypt_finish +L014decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L014decrypt_loop +$L013decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L015dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L016dj6: + mov BYTE PTR 5[edi],dh +L017dj5: + mov BYTE PTR 4[edi],dl +L018dj4: + mov DWORD PTR [edi],ecx + jmp $L019djend +L020dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L021dj2: + mov BYTE PTR 1[esi],ch +L022dj1: + mov BYTE PTR [esi], cl +$L019djend: + jmp $L003finish +$L003finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L004cbc_enc_jmp_table: + DD 0 + DD L012ej1 + DD L011ej2 + DD L010ej3 + DD L008ej4 + DD L007ej5 + DD L006ej6 + DD L005ej7 +L023cbc_dec_jmp_table: + DD 0 + DD L022dj1 + DD L021dj2 + DD L020dj3 + DD L018dj4 + DD L017dj5 + DD L016dj6 + DD L015dj7 +_BF_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/bf/asm/bx86unix.cpp b/src/lib/libcrypto/bf/asm/bx86unix.cpp new file mode 100644 index 0000000000..cdaa269378 --- /dev/null +++ b/src/lib/libcrypto/bf/asm/bx86unix.cpp @@ -0,0 +1,976 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define BF_encrypt _BF_encrypt +#define BF_decrypt _BF_decrypt +#define BF_cbc_encrypt _BF_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by bf-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "bf-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl BF_encrypt + TYPE(BF_encrypt,@function) +BF_encrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + movl (%ebp), %ebx + xorl %ecx, %ecx + xorl %ebx, %edi + + /* Round 0 */ + movl 4(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 1 */ + movl 8(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 2 */ + movl 12(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 3 */ + movl 16(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 4 */ + movl 20(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 5 */ + movl 24(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 6 */ + movl 28(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 7 */ + movl 32(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 8 */ + movl 36(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 9 */ + movl 40(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 10 */ + movl 44(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 11 */ + movl 48(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 12 */ + movl 52(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 13 */ + movl 56(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 14 */ + movl 60(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 15 */ + movl 64(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + /* Load parameter 0 (16) enc=1 */ + movl 20(%esp), %eax + xorl %ebx, %edi + movl 68(%ebp), %edx + xorl %edx, %esi + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.BF_encrypt_end: + SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt) +.ident "BF_encrypt" +.text + .align ALIGN +.globl BF_decrypt + TYPE(BF_decrypt,@function) +BF_decrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + movl 68(%ebp), %ebx + xorl %ecx, %ecx + xorl %ebx, %edi + + /* Round 16 */ + movl 64(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 15 */ + movl 60(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 14 */ + movl 56(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 13 */ + movl 52(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 12 */ + movl 48(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 11 */ + movl 44(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 10 */ + movl 40(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 9 */ + movl 36(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 8 */ + movl 32(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 7 */ + movl 28(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 6 */ + movl 24(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 5 */ + movl 20(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 4 */ + movl 16(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 3 */ + movl 12(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 2 */ + movl 8(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 1 */ + movl 4(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + /* Load parameter 0 (1) enc=0 */ + movl 20(%esp), %eax + xorl %ebx, %edi + movl (%ebp), %edx + xorl %edx, %esi + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.BF_decrypt_end: + SIZE(BF_decrypt,.BF_decrypt_end-BF_decrypt) +.ident "BF_decrypt" +.text + .align ALIGN +.globl BF_cbc_encrypt + TYPE(BF_cbc_encrypt,@function) +BF_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L000decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L001encrypt_finish +.L002encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L002encrypt_loop +.L001encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L005ej7: + movb 6(%esi), %dh + sall $8, %edx +.L006ej6: + movb 5(%esi), %dh +.L007ej5: + movb 4(%esi), %dl +.L008ej4: + movl (%esi), %ecx + jmp .L009ejend +.L010ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L011ej2: + movb 1(%esi), %ch +.L012ej1: + movb (%esi), %cl +.L009ejend: + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L003finish +.align ALIGN +.L000decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L013decrypt_finish +.L014decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L014decrypt_loop +.L013decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L015dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L016dj6: + movb %dh, 5(%edi) +.L017dj5: + movb %dl, 4(%edi) +.L018dj4: + movl %ecx, (%edi) + jmp .L019djend +.L020dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L021dj2: + movb %ch, 1(%esi) +.L022dj1: + movb %cl, (%esi) +.L019djend: + jmp .L003finish +.align ALIGN +.L003finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L004cbc_enc_jmp_table: + .long 0 + .long .L012ej1 + .long .L011ej2 + .long .L010ej3 + .long .L008ej4 + .long .L007ej5 + .long .L006ej6 + .long .L005ej7 +.align ALIGN +.L023cbc_dec_jmp_table: + .long 0 + .long .L022dj1 + .long .L021dj2 + .long .L020dj3 + .long .L018dj4 + .long .L017dj5 + .long .L016dj6 + .long .L015dj7 +.BF_cbc_encrypt_end: + SIZE(BF_cbc_encrypt,.BF_cbc_encrypt_end-BF_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/bf/bf_locl.org b/src/lib/libcrypto/bf/bf_locl.org new file mode 100644 index 0000000000..a5663de8ca --- /dev/null +++ b/src/lib/libcrypto/bf/bf_locl.org @@ -0,0 +1,242 @@ +/* crypto/bf/bf_locl.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify bf_locl.org since bf_locl.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define BF_PTR +#elif defined( __ultrix ) /* Older MIPS */ +# define BF_PTR +#elif defined( __osf1__ ) /* Alpha */ + /* None */ +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* None */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ + /* Unknown */ +#elif defined( __sgi ) /* Newer MIPS */ +# define BF_PTR +#elif defined( i386 ) /* x86 boxes, should be gcc */ +#elif defined( _MSC_VER ) /* x86 boxes, Visual C */ +#endif /* Systems-specific speed defines */ + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* This is actually a big endian algorithm, the most significate byte + * is used to lookup array 0 */ + +/* use BF_PTR2 for intel boxes, + * BF_PTR for sparc and MIPS/SGI + * use nothing for Alpha and HP. + */ +#if !defined(BF_PTR) && !defined(BF_PTR2) +#undef BF_PTR +#endif + +#define BF_M 0x3fc +#define BF_0 22L +#define BF_1 14L +#define BF_2 6L +#define BF_3 2L /* left shift */ + +#if defined(BF_PTR2) + +/* This is basically a special pentium verson */ +#define BF_ENC(LL,R,S,P) \ + { \ + BF_LONG t,u,v; \ + u=R>>BF_0; \ + v=R>>BF_1; \ + u&=BF_M; \ + v&=BF_M; \ + t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ + u=R>>BF_2; \ + t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ + v=R<>BF_0)&BF_M))+ \ + *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ + *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ + *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24L) ] + \ + S[0x0100+((int)(R>>16L)&0xff)])^ \ + S[0x0200+((int)(R>> 8L)&0xff)])+ \ + S[0x0300+((int)(R )&0xff)])&0xffffffffL; +#endif diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl new file mode 100644 index 0000000000..42e11e1c94 --- /dev/null +++ b/src/lib/libcrypto/bio/Makefile.ssl @@ -0,0 +1,92 @@ +# +# SSLeay/crypto/bio/Makefile +# + +DIR= bio +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=bio +ERRC=bio_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= bio_lib.c bio_cb.c $(ERRC).c \ + bss_mem.c bss_null.c bss_fd.c \ + bss_file.c bss_sock.c bss_conn.c \ + bf_null.c bf_buff.c b_print.c b_dump.c \ + b_sock.c bss_acpt.c bf_nbio.c +LIBOBJ= bio_lib.o bio_cb.o $(ERRC).o \ + bss_mem.o bss_null.o bss_fd.o \ + bss_file.o bss_sock.o bss_conn.o \ + bf_null.o bf_buff.o b_print.o b_dump.o \ + b_sock.o bss_acpt.o bf_nbio.o + +SRC= $(LIBSRC) + +EXHEADER= bio.h bss_file.c +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) bss_file.c ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/bio/bio.err b/src/lib/libcrypto/bio/bio.err new file mode 100644 index 0000000000..6e2f2b63ca --- /dev/null +++ b/src/lib/libcrypto/bio/bio.err @@ -0,0 +1,46 @@ +/* Error codes for the BIO functions. */ + +/* Function codes. */ +#define BIO_F_ACPT_STATE 100 +#define BIO_F_BIO_ACCEPT 101 +#define BIO_F_BIO_CTRL 102 +#define BIO_F_BIO_GETS 103 +#define BIO_F_BIO_GET_ACCEPT_SOCKET 104 +#define BIO_F_BIO_GET_HOST_IP 105 +#define BIO_F_BIO_GET_PORT 106 +#define BIO_F_BIO_NEW 107 +#define BIO_F_BIO_NEW_FILE 108 +#define BIO_F_BIO_PUTS 109 +#define BIO_F_BIO_READ 110 +#define BIO_F_BIO_SOCK_INIT 111 +#define BIO_F_BIO_WRITE 112 +#define BIO_F_BUFFER_CTRL 113 +#define BIO_F_CONN_STATE 114 +#define BIO_F_FILE_CTRL 115 +#define BIO_F_MEM_WRITE 116 +#define BIO_F_SSL_NEW 117 +#define BIO_F_WSASTARTUP 118 + +/* Reason codes. */ +#define BIO_R_ACCEPT_ERROR 100 +#define BIO_R_BAD_FOPEN_MODE 101 +#define BIO_R_BAD_HOSTNAME_LOOKUP 102 +#define BIO_R_CONNECT_ERROR 103 +#define BIO_R_ERROR_SETTING_NBIO 104 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 +#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +#define BIO_R_INVALID_IP_ADDRESS 108 +#define BIO_R_KEEPALIVE 109 +#define BIO_R_NBIO_CONNECT_ERROR 110 +#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 +#define BIO_R_NO_HOSTHNAME_SPECIFIED 112 +#define BIO_R_NO_PORT_DEFINED 113 +#define BIO_R_NO_PORT_SPECIFIED 114 +#define BIO_R_NULL_PARAMETER 115 +#define BIO_R_UNABLE_TO_BIND_SOCKET 116 +#define BIO_R_UNABLE_TO_CREATE_SOCKET 117 +#define BIO_R_UNABLE_TO_LISTEN_SOCKET 118 +#define BIO_R_UNINITALISED 119 +#define BIO_R_UNSUPPORTED_METHOD 120 +#define BIO_R_WSASTARTUP 121 diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl new file mode 100644 index 0000000000..9809d26cbc --- /dev/null +++ b/src/lib/libcrypto/bn/Makefile.ssl @@ -0,0 +1,133 @@ +# +# SSLeay/crypto/bn/Makefile +# + +DIR= bn +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +BN_MULW= bn_mulw.o +# or use +#BN_MULW= bn86-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=bn +ERRC=bn_err +GENERAL=Makefile +TEST=bntest.c exptest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c \ + bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c \ + bn_gcd.c bn_prime.c $(ERRC).c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c \ + bn_mpi.c + +LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o \ + bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o \ + bn_gcd.o bn_prime.o $(ERRC).o bn_sqr.o $(BN_MULW) bn_recp.o bn_mont.o \ + bn_mpi.o + + +SRC= $(LIBSRC) + +EXHEADER= bn.h +HEADER= bn_lcl.h bn_prime.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +knuth: bn_knuth.c + cc -pg -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a + +knuth.fast: bn_knuth.c + cc -pg -fast -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a + + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/bn86-elf.o: asm/bn86unix.cpp + $(CPP) -DELF asm/bn86unix.cpp | as -o asm/bn86-elf.o + +# solaris +asm/bn86-sol.o: asm/bn86unix.cpp + $(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s + as -o asm/bn86-sol.o asm/bn86-sol.s + rm -f asm/bn86-sol.s + +# a.out +asm/bn86-out.o: asm/bn86unix.cpp + $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o + +# bsdi +asm/bn86bsdi.o: asm/bn86unix.cpp + $(CPP) -DBSDI asm/bn86unix.cpp | as -o asm/bn86bsdi.o + +asm/bn86unix.cpp: + (cd asm; perl bn-586.pl cpp >bn86unix.cpp ) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +exptest: + /bin/rm -f exptest + gcc -I../../include -g2 -ggdb -o exptest exptest.c ../../libcrypto.a + +div: + /bin/rm -f a.out + gcc -I.. -g div.c ../../libcrypto.a + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_mulw.s + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # special case .org + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/bn/asm/bn-win32.asm b/src/lib/libcrypto/bn/asm/bn-win32.asm new file mode 100644 index 0000000000..017ea462b0 --- /dev/null +++ b/src/lib/libcrypto/bn/asm/bn-win32.asm @@ -0,0 +1,689 @@ + ; Don't even think of reading this code + ; It was automatically generated by bn-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE bn-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _bn_mul_add_words + +_bn_mul_add_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + xor esi, esi + mov edi, DWORD PTR 20[esp] + mov ecx, DWORD PTR 28[esp] + mov ebx, DWORD PTR 24[esp] + and ecx, 4294967288 + mov ebp, DWORD PTR 32[esp] + push ecx + jz $L000maw_finish +L001maw_loop: + mov DWORD PTR [esp],ecx + ; Round 0 + mov eax, DWORD PTR [ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR [edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR [edi],eax + mov esi, edx + ; Round 4 + mov eax, DWORD PTR 4[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 4[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 4[edi],eax + mov esi, edx + ; Round 8 + mov eax, DWORD PTR 8[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 8[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 8[edi],eax + mov esi, edx + ; Round 12 + mov eax, DWORD PTR 12[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 12[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 12[edi],eax + mov esi, edx + ; Round 16 + mov eax, DWORD PTR 16[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 16[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 16[edi],eax + mov esi, edx + ; Round 20 + mov eax, DWORD PTR 20[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 20[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 20[edi],eax + mov esi, edx + ; Round 24 + mov eax, DWORD PTR 24[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 24[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx + ; Round 28 + mov eax, DWORD PTR 28[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 28[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 28[edi],eax + mov esi, edx + ; + mov ecx, DWORD PTR [esp] + add ebx, 32 + add edi, 32 + sub ecx, 8 + jnz L001maw_loop +$L000maw_finish: + mov ecx, DWORD PTR 32[esp] + and ecx, 7 + jnz $L002maw_finish2 + jmp $L003maw_end +$L002maw_finish2: + ; Tail Round 0 + mov eax, DWORD PTR [ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR [edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR [edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 1 + mov eax, DWORD PTR 4[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 4[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 4[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 2 + mov eax, DWORD PTR 8[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 8[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 8[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 3 + mov eax, DWORD PTR 12[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 12[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 12[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 4 + mov eax, DWORD PTR 16[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 16[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 16[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 5 + mov eax, DWORD PTR 20[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 20[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 20[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 6 + mov eax, DWORD PTR 24[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 24[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx +$L003maw_end: + mov eax, esi + pop ecx + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_mul_add_words ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_mul_words + +_bn_mul_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + xor esi, esi + mov edi, DWORD PTR 20[esp] + mov ebx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 28[esp] + mov ecx, DWORD PTR 32[esp] + and ebp, 4294967288 + jz $L004mw_finish +L005mw_loop: + ; Round 0 + mov eax, DWORD PTR [ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR [edi],eax + mov esi, edx + ; Round 4 + mov eax, DWORD PTR 4[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 4[edi],eax + mov esi, edx + ; Round 8 + mov eax, DWORD PTR 8[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 8[edi],eax + mov esi, edx + ; Round 12 + mov eax, DWORD PTR 12[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 12[edi],eax + mov esi, edx + ; Round 16 + mov eax, DWORD PTR 16[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 16[edi],eax + mov esi, edx + ; Round 20 + mov eax, DWORD PTR 20[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 20[edi],eax + mov esi, edx + ; Round 24 + mov eax, DWORD PTR 24[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx + ; Round 28 + mov eax, DWORD PTR 28[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 28[edi],eax + mov esi, edx + ; + add ebx, 32 + add edi, 32 + sub ebp, 8 + jz $L004mw_finish + jmp L005mw_loop +$L004mw_finish: + mov ebp, DWORD PTR 28[esp] + and ebp, 7 + jnz $L006mw_finish2 + jmp $L007mw_end +$L006mw_finish2: + ; Tail Round 0 + mov eax, DWORD PTR [ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR [edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 1 + mov eax, DWORD PTR 4[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 4[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 2 + mov eax, DWORD PTR 8[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 8[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 3 + mov eax, DWORD PTR 12[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 12[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 4 + mov eax, DWORD PTR 16[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 16[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 5 + mov eax, DWORD PTR 20[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 20[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 6 + mov eax, DWORD PTR 24[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx +$L007mw_end: + mov eax, esi + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_mul_words ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_sqr_words + +_bn_sqr_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + mov esi, DWORD PTR 20[esp] + mov edi, DWORD PTR 24[esp] + mov ebx, DWORD PTR 28[esp] + and ebx, 4294967288 + jz $L008sw_finish +L009sw_loop: + ; Round 0 + mov eax, DWORD PTR [edi] + mul eax + mov DWORD PTR [esi],eax + mov DWORD PTR 4[esi],edx + ; Round 4 + mov eax, DWORD PTR 4[edi] + mul eax + mov DWORD PTR 8[esi],eax + mov DWORD PTR 12[esi],edx + ; Round 8 + mov eax, DWORD PTR 8[edi] + mul eax + mov DWORD PTR 16[esi],eax + mov DWORD PTR 20[esi],edx + ; Round 12 + mov eax, DWORD PTR 12[edi] + mul eax + mov DWORD PTR 24[esi],eax + mov DWORD PTR 28[esi],edx + ; Round 16 + mov eax, DWORD PTR 16[edi] + mul eax + mov DWORD PTR 32[esi],eax + mov DWORD PTR 36[esi],edx + ; Round 20 + mov eax, DWORD PTR 20[edi] + mul eax + mov DWORD PTR 40[esi],eax + mov DWORD PTR 44[esi],edx + ; Round 24 + mov eax, DWORD PTR 24[edi] + mul eax + mov DWORD PTR 48[esi],eax + mov DWORD PTR 52[esi],edx + ; Round 28 + mov eax, DWORD PTR 28[edi] + mul eax + mov DWORD PTR 56[esi],eax + mov DWORD PTR 60[esi],edx + ; + add edi, 32 + add esi, 64 + sub ebx, 8 + jnz L009sw_loop +$L008sw_finish: + mov ebx, DWORD PTR 28[esp] + and ebx, 7 + jz $L010sw_end + ; Tail Round 0 + mov eax, DWORD PTR [edi] + mul eax + mov DWORD PTR [esi],eax + dec ebx + mov DWORD PTR 4[esi],edx + jz $L010sw_end + ; Tail Round 1 + mov eax, DWORD PTR 4[edi] + mul eax + mov DWORD PTR 8[esi],eax + dec ebx + mov DWORD PTR 12[esi],edx + jz $L010sw_end + ; Tail Round 2 + mov eax, DWORD PTR 8[edi] + mul eax + mov DWORD PTR 16[esi],eax + dec ebx + mov DWORD PTR 20[esi],edx + jz $L010sw_end + ; Tail Round 3 + mov eax, DWORD PTR 12[edi] + mul eax + mov DWORD PTR 24[esi],eax + dec ebx + mov DWORD PTR 28[esi],edx + jz $L010sw_end + ; Tail Round 4 + mov eax, DWORD PTR 16[edi] + mul eax + mov DWORD PTR 32[esi],eax + dec ebx + mov DWORD PTR 36[esi],edx + jz $L010sw_end + ; Tail Round 5 + mov eax, DWORD PTR 20[edi] + mul eax + mov DWORD PTR 40[esi],eax + dec ebx + mov DWORD PTR 44[esi],edx + jz $L010sw_end + ; Tail Round 6 + mov eax, DWORD PTR 24[edi] + mul eax + mov DWORD PTR 48[esi],eax + mov DWORD PTR 52[esi],edx +$L010sw_end: + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_sqr_words ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_div64 + +_bn_div64 PROC NEAR + push ebp + push ebx + push esi + push edi + mov edx, DWORD PTR 20[esp] + mov eax, DWORD PTR 24[esp] + mov ebx, DWORD PTR 28[esp] + div ebx + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_div64 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_add_words + +_bn_add_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + mov ebx, DWORD PTR 20[esp] + mov esi, DWORD PTR 24[esp] + mov edi, DWORD PTR 28[esp] + mov ebp, DWORD PTR 32[esp] + xor eax, eax + and ebp, 4294967288 + jz $L011aw_finish +L012aw_loop: + ; Round 0 + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR [edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR [ebx],ecx + ; Round 1 + mov ecx, DWORD PTR 4[esi] + mov edx, DWORD PTR 4[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 4[ebx],ecx + ; Round 2 + mov ecx, DWORD PTR 8[esi] + mov edx, DWORD PTR 8[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 8[ebx],ecx + ; Round 3 + mov ecx, DWORD PTR 12[esi] + mov edx, DWORD PTR 12[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 12[ebx],ecx + ; Round 4 + mov ecx, DWORD PTR 16[esi] + mov edx, DWORD PTR 16[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 16[ebx],ecx + ; Round 5 + mov ecx, DWORD PTR 20[esi] + mov edx, DWORD PTR 20[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 20[ebx],ecx + ; Round 6 + mov ecx, DWORD PTR 24[esi] + mov edx, DWORD PTR 24[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 24[ebx],ecx + ; Round 7 + mov ecx, DWORD PTR 28[esi] + mov edx, DWORD PTR 28[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 28[ebx],ecx + ; + add esi, 32 + add edi, 32 + add ebx, 32 + sub ebp, 8 + jnz L012aw_loop +$L011aw_finish: + mov ebp, DWORD PTR 32[esp] + and ebp, 7 + jz $L013aw_end + ; Tail Round 0 + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR [edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR [ebx],ecx + jz $L013aw_end + ; Tail Round 1 + mov ecx, DWORD PTR 4[esi] + mov edx, DWORD PTR 4[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 4[ebx],ecx + jz $L013aw_end + ; Tail Round 2 + mov ecx, DWORD PTR 8[esi] + mov edx, DWORD PTR 8[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 8[ebx],ecx + jz $L013aw_end + ; Tail Round 3 + mov ecx, DWORD PTR 12[esi] + mov edx, DWORD PTR 12[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 12[ebx],ecx + jz $L013aw_end + ; Tail Round 4 + mov ecx, DWORD PTR 16[esi] + mov edx, DWORD PTR 16[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 16[ebx],ecx + jz $L013aw_end + ; Tail Round 5 + mov ecx, DWORD PTR 20[esi] + mov edx, DWORD PTR 20[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 20[ebx],ecx + jz $L013aw_end + ; Tail Round 6 + mov ecx, DWORD PTR 24[esi] + mov edx, DWORD PTR 24[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 24[ebx],ecx +$L013aw_end: + mov eax, eax + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_add_words ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/bn/asm/bn86unix.cpp b/src/lib/libcrypto/bn/asm/bn86unix.cpp new file mode 100644 index 0000000000..64702201ea --- /dev/null +++ b/src/lib/libcrypto/bn/asm/bn86unix.cpp @@ -0,0 +1,752 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define bn_mul_add_words _bn_mul_add_words +#define bn_mul_words _bn_mul_words +#define bn_sqr_words _bn_sqr_words +#define bn_div64 _bn_div64 +#define bn_add_words _bn_add_words + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by bn-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "bn-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl bn_mul_add_words + TYPE(bn_mul_add_words,@function) +bn_mul_add_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + xorl %esi, %esi + movl 20(%esp), %edi + movl 28(%esp), %ecx + movl 24(%esp), %ebx + andl $4294967288, %ecx + movl 32(%esp), %ebp + pushl %ecx + jz .L000maw_finish +.L001maw_loop: + movl %ecx, (%esp) + /* Round 0 */ + movl (%ebx), %eax + mull %ebp + addl %esi, %eax + movl (%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, (%edi) + movl %edx, %esi + /* Round 4 */ + movl 4(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 4(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 4(%edi) + movl %edx, %esi + /* Round 8 */ + movl 8(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 8(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 8(%edi) + movl %edx, %esi + /* Round 12 */ + movl 12(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 12(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 12(%edi) + movl %edx, %esi + /* Round 16 */ + movl 16(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 16(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 16(%edi) + movl %edx, %esi + /* Round 20 */ + movl 20(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 20(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 20(%edi) + movl %edx, %esi + /* Round 24 */ + movl 24(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 24(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi + /* Round 28 */ + movl 28(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 28(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 28(%edi) + movl %edx, %esi + + movl (%esp), %ecx + addl $32, %ebx + addl $32, %edi + subl $8, %ecx + jnz .L001maw_loop +.L000maw_finish: + movl 32(%esp), %ecx + andl $7, %ecx + jnz .L002maw_finish2 + jmp .L003maw_end +.align ALIGN +.L002maw_finish2: + /* Tail Round 0 */ + movl (%ebx), %eax + mull %ebp + addl %esi, %eax + movl (%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, (%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 1 */ + movl 4(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 4(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 4(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 2 */ + movl 8(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 8(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 8(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 3 */ + movl 12(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 12(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 12(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 4 */ + movl 16(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 16(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 16(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 5 */ + movl 20(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 20(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 20(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 6 */ + movl 24(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 24(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi +.L003maw_end: + movl %esi, %eax + popl %ecx + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_mul_add_words_end: + SIZE(bn_mul_add_words,.bn_mul_add_words_end-bn_mul_add_words) +.ident "bn_mul_add_words" +.text + .align ALIGN +.globl bn_mul_words + TYPE(bn_mul_words,@function) +bn_mul_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + xorl %esi, %esi + movl 20(%esp), %edi + movl 24(%esp), %ebx + movl 28(%esp), %ebp + movl 32(%esp), %ecx + andl $4294967288, %ebp + jz .L004mw_finish +.L005mw_loop: + /* Round 0 */ + movl (%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, (%edi) + movl %edx, %esi + /* Round 4 */ + movl 4(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 4(%edi) + movl %edx, %esi + /* Round 8 */ + movl 8(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 8(%edi) + movl %edx, %esi + /* Round 12 */ + movl 12(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 12(%edi) + movl %edx, %esi + /* Round 16 */ + movl 16(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 16(%edi) + movl %edx, %esi + /* Round 20 */ + movl 20(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 20(%edi) + movl %edx, %esi + /* Round 24 */ + movl 24(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi + /* Round 28 */ + movl 28(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 28(%edi) + movl %edx, %esi + + addl $32, %ebx + addl $32, %edi + subl $8, %ebp + jz .L004mw_finish + jmp .L005mw_loop +.L004mw_finish: + movl 28(%esp), %ebp + andl $7, %ebp + jnz .L006mw_finish2 + jmp .L007mw_end +.align ALIGN +.L006mw_finish2: + /* Tail Round 0 */ + movl (%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, (%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 1 */ + movl 4(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 4(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 2 */ + movl 8(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 8(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 3 */ + movl 12(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 12(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 4 */ + movl 16(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 16(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 5 */ + movl 20(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 20(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 6 */ + movl 24(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi +.L007mw_end: + movl %esi, %eax + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_mul_words_end: + SIZE(bn_mul_words,.bn_mul_words_end-bn_mul_words) +.ident "bn_mul_words" +.text + .align ALIGN +.globl bn_sqr_words + TYPE(bn_sqr_words,@function) +bn_sqr_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + movl 20(%esp), %esi + movl 24(%esp), %edi + movl 28(%esp), %ebx + andl $4294967288, %ebx + jz .L008sw_finish +.L009sw_loop: + /* Round 0 */ + movl (%edi), %eax + mull %eax + movl %eax, (%esi) + movl %edx, 4(%esi) + /* Round 4 */ + movl 4(%edi), %eax + mull %eax + movl %eax, 8(%esi) + movl %edx, 12(%esi) + /* Round 8 */ + movl 8(%edi), %eax + mull %eax + movl %eax, 16(%esi) + movl %edx, 20(%esi) + /* Round 12 */ + movl 12(%edi), %eax + mull %eax + movl %eax, 24(%esi) + movl %edx, 28(%esi) + /* Round 16 */ + movl 16(%edi), %eax + mull %eax + movl %eax, 32(%esi) + movl %edx, 36(%esi) + /* Round 20 */ + movl 20(%edi), %eax + mull %eax + movl %eax, 40(%esi) + movl %edx, 44(%esi) + /* Round 24 */ + movl 24(%edi), %eax + mull %eax + movl %eax, 48(%esi) + movl %edx, 52(%esi) + /* Round 28 */ + movl 28(%edi), %eax + mull %eax + movl %eax, 56(%esi) + movl %edx, 60(%esi) + + addl $32, %edi + addl $64, %esi + subl $8, %ebx + jnz .L009sw_loop +.L008sw_finish: + movl 28(%esp), %ebx + andl $7, %ebx + jz .L010sw_end + /* Tail Round 0 */ + movl (%edi), %eax + mull %eax + movl %eax, (%esi) + decl %ebx + movl %edx, 4(%esi) + jz .L010sw_end + /* Tail Round 1 */ + movl 4(%edi), %eax + mull %eax + movl %eax, 8(%esi) + decl %ebx + movl %edx, 12(%esi) + jz .L010sw_end + /* Tail Round 2 */ + movl 8(%edi), %eax + mull %eax + movl %eax, 16(%esi) + decl %ebx + movl %edx, 20(%esi) + jz .L010sw_end + /* Tail Round 3 */ + movl 12(%edi), %eax + mull %eax + movl %eax, 24(%esi) + decl %ebx + movl %edx, 28(%esi) + jz .L010sw_end + /* Tail Round 4 */ + movl 16(%edi), %eax + mull %eax + movl %eax, 32(%esi) + decl %ebx + movl %edx, 36(%esi) + jz .L010sw_end + /* Tail Round 5 */ + movl 20(%edi), %eax + mull %eax + movl %eax, 40(%esi) + decl %ebx + movl %edx, 44(%esi) + jz .L010sw_end + /* Tail Round 6 */ + movl 24(%edi), %eax + mull %eax + movl %eax, 48(%esi) + movl %edx, 52(%esi) +.L010sw_end: + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_sqr_words_end: + SIZE(bn_sqr_words,.bn_sqr_words_end-bn_sqr_words) +.ident "bn_sqr_words" +.text + .align ALIGN +.globl bn_div64 + TYPE(bn_div64,@function) +bn_div64: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + movl 20(%esp), %edx + movl 24(%esp), %eax + movl 28(%esp), %ebx + divl %ebx + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_div64_end: + SIZE(bn_div64,.bn_div64_end-bn_div64) +.ident "bn_div64" +.text + .align ALIGN +.globl bn_add_words + TYPE(bn_add_words,@function) +bn_add_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + movl 20(%esp), %ebx + movl 24(%esp), %esi + movl 28(%esp), %edi + movl 32(%esp), %ebp + xorl %eax, %eax + andl $4294967288, %ebp + jz .L011aw_finish +.L012aw_loop: + /* Round 0 */ + movl (%esi), %ecx + movl (%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, (%ebx) + /* Round 1 */ + movl 4(%esi), %ecx + movl 4(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 4(%ebx) + /* Round 2 */ + movl 8(%esi), %ecx + movl 8(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 8(%ebx) + /* Round 3 */ + movl 12(%esi), %ecx + movl 12(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 12(%ebx) + /* Round 4 */ + movl 16(%esi), %ecx + movl 16(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 16(%ebx) + /* Round 5 */ + movl 20(%esi), %ecx + movl 20(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 20(%ebx) + /* Round 6 */ + movl 24(%esi), %ecx + movl 24(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 24(%ebx) + /* Round 7 */ + movl 28(%esi), %ecx + movl 28(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 28(%ebx) + + addl $32, %esi + addl $32, %edi + addl $32, %ebx + subl $8, %ebp + jnz .L012aw_loop +.L011aw_finish: + movl 32(%esp), %ebp + andl $7, %ebp + jz .L013aw_end + /* Tail Round 0 */ + movl (%esi), %ecx + movl (%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, (%ebx) + jz .L013aw_end + /* Tail Round 1 */ + movl 4(%esi), %ecx + movl 4(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 4(%ebx) + jz .L013aw_end + /* Tail Round 2 */ + movl 8(%esi), %ecx + movl 8(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 8(%ebx) + jz .L013aw_end + /* Tail Round 3 */ + movl 12(%esi), %ecx + movl 12(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 12(%ebx) + jz .L013aw_end + /* Tail Round 4 */ + movl 16(%esi), %ecx + movl 16(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 16(%ebx) + jz .L013aw_end + /* Tail Round 5 */ + movl 20(%esi), %ecx + movl 20(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 20(%ebx) + jz .L013aw_end + /* Tail Round 6 */ + movl 24(%esi), %ecx + movl 24(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 24(%ebx) +.L013aw_end: + movl %eax, %eax + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_add_words_end: + SIZE(bn_add_words,.bn_add_words_end-bn_add_words) +.ident "bn_add_words" diff --git a/src/lib/libcrypto/bn/asm/sparc.s b/src/lib/libcrypto/bn/asm/sparc.s new file mode 100644 index 0000000000..f9e533caa8 --- /dev/null +++ b/src/lib/libcrypto/bn/asm/sparc.s @@ -0,0 +1,462 @@ + .file "bn_mulw.c" +gcc2_compiled.: +.section ".text" + .align 4 + .global bn_mul_add_words + .type bn_mul_add_words,#function + .proc 016 +bn_mul_add_words: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov %i0,%o0 + mov %i1,%o2 + mov %i2,%g1 + mov %i3,%o1 + mov 0,%i4 + add %o0,12,%g4 + add %o2,12,%o7 +.LL2: + mov %i4,%i3 + mov 0,%i2 + ld [%o0],%g2 + mov %g2,%i1 + ld [%o2],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%o0] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + mov %i4,%i3 + mov 0,%i2 + ld [%g4-8],%g2 + mov %g2,%i1 + ld [%o7-8],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%g4-8] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + mov %i4,%i3 + mov 0,%i2 + ld [%g4-4],%g2 + mov %g2,%i1 + ld [%o7-4],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%g4-4] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + mov %i4,%i3 + mov 0,%i2 + ld [%g4],%g2 + mov %g2,%i1 + ld [%o7],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%g4] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + add %o7,16,%o7 + add %o2,16,%o2 + add %g4,16,%g4 + b .LL2 + add %o0,16,%o0 +.LL3: + ret + restore %g0,%i4,%o0 +.LLfe1: + .size bn_mul_add_words,.LLfe1-bn_mul_add_words + .align 4 + .global bn_mul_words + .type bn_mul_words,#function + .proc 016 +bn_mul_words: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov %i0,%o7 + mov %i1,%o0 + mov %i2,%i4 + mov %i3,%g4 + mov 0,%i0 + add %o7,12,%g1 + add %o0,12,%i5 +.LL18: + mov %i0,%g3 + mov 0,%g2 + ld [%o0],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%o7] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + mov %i0,%g3 + mov 0,%g2 + ld [%i5-8],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%g1-8] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + mov %i0,%g3 + mov 0,%g2 + ld [%i5-4],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%g1-4] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + mov %i0,%g3 + mov 0,%g2 + ld [%i5],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%g1] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + add %i5,16,%i5 + add %o0,16,%o0 + add %g1,16,%g1 + b .LL18 + add %o7,16,%o7 +.LL19: + ret + restore +.LLfe2: + .size bn_mul_words,.LLfe2-bn_mul_words + .align 4 + .global bn_sqr_words + .type bn_sqr_words,#function + .proc 020 +bn_sqr_words: + !#PROLOGUE# 0 + !#PROLOGUE# 1 + mov %o0,%g4 + add %g4,28,%o3 + add %o1,12,%g1 +.LL34: + ld [%o1],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%g4] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3-24] + ld [%g1-8],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%o3-20] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3-16] + ld [%g1-4],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%o3-12] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3-8] + ld [%g1],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%o3-4] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3] + add %g1,16,%g1 + add %o1,16,%o1 + add %o3,32,%o3 + b .LL34 + add %g4,32,%g4 +.LL35: + retl + nop +.LLfe3: + .size bn_sqr_words,.LLfe3-bn_sqr_words + .align 4 + .global bn_add_words + .type bn_add_words,#function + .proc 016 +bn_add_words: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov %i0,%o2 + mov %i1,%o3 + mov %i2,%o4 + mov %i3,%i5 + mov 0,%o0 + mov 0,%o1 + add %o2,12,%o7 + add %o4,12,%g4 + b .LL42 + add %o3,12,%g1 +.LL45: + add %i5,-1,%i5 + mov %i4,%g3 + ld [%g4-8],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o7-8] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + ble .LL43 + add %i5,-1,%i5 + ld [%g1-4],%i4 + mov %i4,%g3 + ld [%g4-4],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o7-4] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + ble .LL43 + add %i5,-1,%i5 + ld [%g1],%i4 + mov %i4,%g3 + ld [%g4],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o7] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + ble .LL43 + add %g1,16,%g1 + add %o3,16,%o3 + add %g4,16,%g4 + add %o4,16,%o4 + add %o7,16,%o7 + add %o2,16,%o2 +.LL42: + ld [%o3],%i4 + add %i5,-1,%i5 + mov %i4,%g3 + ld [%o4],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o2] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + bg,a .LL45 + ld [%g1-8],%i4 +.LL43: + ret + restore %g0,%o1,%o0 +.LLfe4: + .size bn_add_words,.LLfe4-bn_add_words +.section ".rodata" + .align 8 +.LLC0: + .asciz "Division would overflow (%d)\n" +.section ".text" + .align 4 + .global bn_div64 + .type bn_div64,#function + .proc 016 +bn_div64: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov 0,%l1 + cmp %i2,0 + bne .LL51 + mov 2,%l0 + b .LL68 + mov -1,%i0 +.LL51: + call BN_num_bits_word,0 + mov %i2,%o0 + mov %o0,%o2 + cmp %o2,32 + be .LL52 + mov 1,%o0 + sll %o0,%o2,%o0 + cmp %i0,%o0 + bleu .LL69 + mov 32,%o0 + sethi %hi(__iob+32),%o0 + or %o0,%lo(__iob+32),%o0 + sethi %hi(.LLC0),%o1 + call fprintf,0 + or %o1,%lo(.LLC0),%o1 + call abort,0 + nop +.LL52: + mov 32,%o0 +.LL69: + cmp %i0,%i2 + blu .LL53 + sub %o0,%o2,%o2 + sub %i0,%i2,%i0 +.LL53: + cmp %o2,0 + be .LL54 + sll %i0,%o2,%o1 + sll %i2,%o2,%i2 + sub %o0,%o2,%o0 + srl %i1,%o0,%o0 + or %o1,%o0,%i0 + sll %i1,%o2,%i1 +.LL54: + srl %i2,16,%g2 + sethi %hi(65535),%o0 + or %o0,%lo(65535),%o1 + and %i2,%o1,%g3 + mov %o0,%g4 + sethi %hi(-65536),%o7 + mov %o1,%g1 +.LL55: + srl %i0,16,%o0 + cmp %o0,%g2 + be .LL59 + or %g4,%lo(65535),%o3 + wr %g0,%g0,%y + nop + nop + nop + udiv %i0,%g2,%o3 +.LL59: + and %i1,%o7,%o0 + srl %o0,16,%o5 + smul %o3,%g3,%o4 + smul %o3,%g2,%o2 +.LL60: + sub %i0,%o2,%o1 + andcc %o1,%o7,%g0 + bne .LL61 + sll %o1,16,%o0 + add %o0,%o5,%o0 + cmp %o4,%o0 + bleu .LL61 + sub %o4,%g3,%o4 + sub %o2,%g2,%o2 + b .LL60 + add %o3,-1,%o3 +.LL61: + smul %o3,%g2,%o2 + smul %o3,%g3,%o0 + srl %o0,16,%o1 + sll %o0,16,%o0 + and %o0,%o7,%o0 + cmp %i1,%o0 + bgeu .LL65 + add %o2,%o1,%o2 + add %o2,1,%o2 +.LL65: + cmp %i0,%o2 + bgeu .LL66 + sub %i1,%o0,%i1 + add %i0,%i2,%i0 + add %o3,-1,%o3 +.LL66: + addcc %l0,-1,%l0 + be .LL56 + sub %i0,%o2,%i0 + sll %o3,16,%l1 + sll %i0,16,%o0 + srl %i1,16,%o1 + or %o0,%o1,%i0 + and %i1,%g1,%o0 + b .LL55 + sll %o0,16,%i1 +.LL56: + or %l1,%o3,%i0 +.LL68: + ret + restore +.LLfe5: + .size bn_div64,.LLfe5-bn_div64 + .ident "GCC: (GNU) 2.7.2.3" diff --git a/src/lib/libcrypto/bn/asm/x86w16.asm b/src/lib/libcrypto/bn/asm/x86w16.asm new file mode 100644 index 0000000000..74a933a8cd --- /dev/null +++ b/src/lib/libcrypto/bn/asm/x86w16.asm @@ -0,0 +1,297 @@ +; Static Name Aliases +; + TITLE bn_mulw.c + .8087 +F_TEXT SEGMENT WORD PUBLIC 'CODE' +F_TEXT ENDS +_DATA SEGMENT WORD PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT WORD PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT WORD PUBLIC 'BSS' +_BSS ENDS +DGROUP GROUP CONST, _BSS, _DATA + ASSUME DS: DGROUP, SS: DGROUP +F_TEXT SEGMENT + ASSUME CS: F_TEXT + PUBLIC _bn_mul_add_words +_bn_mul_add_words PROC FAR +; Line 58 + push bp + push bx + push si + push di + push ds + push es + mov bp,sp +; w = 26 +; num = 24 +; ap = 20 +; rp = 16 + xor si,si ;c=0; + mov di,WORD PTR [bp+16] ; load r + mov ds,WORD PTR [bp+18] ; load r + mov bx,WORD PTR [bp+20] ; load a + mov es,WORD PTR [bp+22] ; load a + mov cx,WORD PTR [bp+26] ; load w + mov bp,WORD PTR [bp+24] ; load num + + shr bp,1 ; div count by 4 and do groups of 4 + shr bp,1 + je $L555 + +$L546: + mov ax,cx + mul WORD PTR es:[bx] ; w* *a + add ax,WORD PTR ds:[di] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di],ax + mov si,dx + ; + mov ax,cx + mul WORD PTR es:[bx+2] ; w* *a + add ax,WORD PTR ds:[di+2] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+2],ax + mov si,dx + ; + mov ax,cx + mul WORD PTR es:[bx+4] ; w* *a + add ax,WORD PTR ds:[di+4] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+4],ax + mov si,dx + ; + mov ax,cx + mul WORD PTR es:[bx+6] ; w* *a + add ax,WORD PTR ds:[di+6] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+6],ax + mov si,dx + ; + add bx,8 + add di,8 + ; + dec bp + je $L555 + jmp $L546 +; +; +$L555: + mov bp,sp + mov bp,WORD PTR [bp+24] ; load num + and bp,3 + dec bp + js $L547 + + mov ax,cx + mul WORD PTR es:[bx] ; w* *a + add ax,WORD PTR ds:[di] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di],ax + mov si,dx + dec bp + js $L547 ; Note that we are now testing for -1 + ; + mov ax,cx + mul WORD PTR es:[bx+2] ; w* *a + add ax,WORD PTR ds:[di+2] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+2],ax + mov si,dx + dec bp + js $L547 + ; + mov ax,cx + mul WORD PTR es:[bx+4] ; w* *a + add ax,WORD PTR ds:[di+4] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+4],ax + mov si,dx +$L547: + mov ax,si + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret + nop + +_bn_mul_add_words ENDP + PUBLIC _bn_mul_words +_bn_mul_words PROC FAR +; Line 76 + push bp + push bx + push si + push di + push ds + push es + xor si,si + mov bp,sp + mov di,WORD PTR [bp+16] ; r + mov ds,WORD PTR [bp+18] + mov bx,WORD PTR [bp+20] ; a + mov es,WORD PTR [bp+22] + mov cx,WORD PTR [bp+26] ; w + mov bp,WORD PTR [bp+24] ; num +$FC743: + mov ax,cx + mul WORD PTR es:[bx] + add ax,si + adc dx,0 + mov WORD PTR ds:[di],ax + mov si,dx + dec bp + je $L764 + ; + mov ax,cx + mul WORD PTR es:[bx+2] + add ax,si + adc dx,0 + mov WORD PTR ds:[di+2],ax + mov si,dx + dec bp + je $L764 + ; + mov ax,cx + mul WORD PTR es:[bx+4] + add ax,si + adc dx,0 + mov WORD PTR ds:[di+4],ax + mov si,dx + dec bp + je $L764 + ; + mov ax,cx + mul WORD PTR es:[bx+6] + add ax,si + adc dx,0 + mov WORD PTR ds:[di+6],ax + mov si,dx + dec bp + je $L764 + ; + add bx,8 + add di,8 + jmp $FC743 + nop +$L764: + mov ax,si + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret + nop +_bn_mul_words ENDP + PUBLIC _bn_sqr_words +_bn_sqr_words PROC FAR +; Line 92 + push bp + push bx + push si + push di + push ds + push es + mov bp,sp + mov si,WORD PTR [bp+16] + mov ds,WORD PTR [bp+18] + mov di,WORD PTR [bp+20] + mov es,WORD PTR [bp+22] + mov bx,WORD PTR [bp+24] + + mov bp,bx ; save a memory lookup later + shr bx,1 ; div count by 4 and do groups of 4 + shr bx,1 + je $L666 + +$L765: + mov ax,WORD PTR es:[di] + mul ax + mov WORD PTR ds:[si],ax + mov WORD PTR ds:[si+2],dx + ; + mov ax,WORD PTR es:[di+2] + mul ax + mov WORD PTR ds:[si+4],ax + mov WORD PTR ds:[si+6],dx + ; + mov ax,WORD PTR es:[di+4] + mul ax + mov WORD PTR ds:[si+8],ax + mov WORD PTR ds:[si+10],dx + ; + mov ax,WORD PTR es:[di+6] + mul ax + mov WORD PTR ds:[si+12],ax + mov WORD PTR ds:[si+14],dx + ; + add di,8 + add si,16 + dec bx + je $L666 + jmp $L765 +$L666: + and bp,3 + dec bp ; The copied value of bx (num) + js $L645 + ; + mov ax,WORD PTR es:[di] + mul ax + mov WORD PTR ds:[si],ax + mov WORD PTR ds:[si+2],dx + dec bp + js $L645 + ; + mov ax,WORD PTR es:[di+2] + mul ax + mov WORD PTR ds:[si+4],ax + mov WORD PTR ds:[si+6],dx + dec bp + js $L645 + ; + mov ax,WORD PTR es:[di+4] + mul ax + mov WORD PTR ds:[si+8],ax + mov WORD PTR ds:[si+10],dx +$L645: + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret + +_bn_sqr_words ENDP + PUBLIC _bn_div64 +_bn_div64 PROC FAR + push bp + mov bp,sp + mov dx, WORD PTR [bp+6] + mov ax, WORD PTR [bp+8] + div WORD PTR [bp+10] + pop bp + ret +_bn_div64 ENDP +F_TEXT ENDS +END diff --git a/src/lib/libcrypto/bn/asm/x86w32.asm b/src/lib/libcrypto/bn/asm/x86w32.asm new file mode 100644 index 0000000000..fc6f917714 --- /dev/null +++ b/src/lib/libcrypto/bn/asm/x86w32.asm @@ -0,0 +1,362 @@ +; Static Name Aliases +; + TITLE bn_mulw.c + .386 +F_TEXT SEGMENT WORD USE16 PUBLIC 'CODE' +F_TEXT ENDS +_DATA SEGMENT WORD USE16 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT WORD USE16 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT WORD USE16 PUBLIC 'BSS' +_BSS ENDS +DGROUP GROUP CONST, _BSS, _DATA + ASSUME DS: DGROUP, SS: DGROUP +F_TEXT SEGMENT + ASSUME CS: F_TEXT + PUBLIC _bn_mul_add_words +_bn_mul_add_words PROC FAR +; Line 58 + push bp + push bx + push esi + push di + push ds + push es + mov bp,sp +; w = 28 +; num = 26 +; ap = 22 +; rp = 18 + xor esi,esi ;c=0; + mov di,WORD PTR [bp+18] ; load r + mov ds,WORD PTR [bp+20] ; load r + mov bx,WORD PTR [bp+22] ; load a + mov es,WORD PTR [bp+24] ; load a + mov ecx,DWORD PTR [bp+28] ; load w + mov bp,WORD PTR [bp+26] ; load num + shr bp,1 ; div count by 4 and do groups of 4 + shr bp,1 + je $L555 + +$L546: + mov eax,ecx + mul DWORD PTR es:[bx] ; w* *a + add eax,DWORD PTR ds:[di] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di],eax + mov esi,edx + ; + mov eax,ecx + mul DWORD PTR es:[bx+4] ; w* *a + add eax,DWORD PTR ds:[di+4] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+4],eax + mov esi,edx + ; + mov eax,ecx + mul DWORD PTR es:[bx+8] ; w* *a + add eax,DWORD PTR ds:[di+8] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+8],eax + mov esi,edx + ; + mov eax,ecx + mul DWORD PTR es:[bx+12] ; w* *a + add eax,DWORD PTR ds:[di+12] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+12],eax + mov esi,edx + ; + add bx,16 + add di,16 + ; + dec bp + je $L555 + jmp $L546 +; +; +$L555: + mov bp,sp + mov bp,WORD PTR [bp+26] ; load num + and bp,3 + dec bp + js $L547 + + mov eax,ecx + mul DWORD PTR es:[bx] ; w* *a + add eax,DWORD PTR ds:[di] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di],eax + mov esi,edx + dec bp + js $L547 ; Note that we are now testing for -1 + ; + mov eax,ecx + mul DWORD PTR es:[bx+4] ; w* *a + add eax,DWORD PTR ds:[di+4] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+4],eax + mov esi,edx + dec bp + js $L547 + ; + mov eax,ecx + mul DWORD PTR es:[bx+8] ; w* *a + add eax,DWORD PTR ds:[di+8] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+8],eax + mov esi,edx +$L547: + mov eax,esi + mov edx,esi + shr edx,16 + pop es + pop ds + pop di + pop esi + pop bx + pop bp + ret + nop +_bn_mul_add_words ENDP + + PUBLIC _bn_mul_words +_bn_mul_words PROC FAR +; Line 76 + push bp + push bx + push esi + push di + push ds + push es + xor esi,esi + mov bp,sp + mov di,WORD PTR [bp+18] ; r + mov ds,WORD PTR [bp+20] + mov bx,WORD PTR [bp+22] ; a + mov es,WORD PTR [bp+24] + mov ecx,DWORD PTR [bp+28] ; w + mov bp,WORD PTR [bp+26] ; num + +$FC743: + mov eax,ecx + mul DWORD PTR es:[bx] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di],eax + mov esi,edx + dec bp + je $L764 + ; + mov eax,ecx + mul DWORD PTR es:[bx+4] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di+4],eax + mov esi,edx + dec bp + je $L764 + ; + mov eax,ecx + mul DWORD PTR es:[bx+8] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di+8],eax + mov esi,edx + dec bp + je $L764 + ; + mov eax,ecx + mul DWORD PTR es:[bx+12] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di+12],eax + mov esi,edx + dec bp + je $L764 + ; + add bx,16 + add di,16 + jmp $FC743 + nop +$L764: + mov eax,esi + mov edx,esi + shr edx,16 + pop es + pop ds + pop di + pop esi + pop bx + pop bp + ret + nop +_bn_mul_words ENDP + PUBLIC _bn_sqr_words +_bn_sqr_words PROC FAR +; Line 92 + push bp + push bx + push si + push di + push ds + push es + mov bp,sp + mov si,WORD PTR [bp+16] + mov ds,WORD PTR [bp+18] + mov di,WORD PTR [bp+20] + mov es,WORD PTR [bp+22] + mov bx,WORD PTR [bp+24] + + mov bp,bx ; save a memory lookup later + shr bx,1 ; div count by 4 and do groups of 4 + shr bx,1 + je $L666 + +$L765: + mov eax,DWORD PTR es:[di] + mul eax + mov DWORD PTR ds:[si],eax + mov DWORD PTR ds:[si+4],edx + ; + mov eax,DWORD PTR es:[di+4] + mul eax + mov DWORD PTR ds:[si+8],eax + mov DWORD PTR ds:[si+12],edx + ; + mov eax,DWORD PTR es:[di+8] + mul eax + mov DWORD PTR ds:[si+16],eax + mov DWORD PTR ds:[si+20],edx + ; + mov eax,DWORD PTR es:[di+12] + mul eax + mov DWORD PTR ds:[si+24],eax + mov DWORD PTR ds:[si+28],edx + ; + add di,16 + add si,32 + dec bx + je $L666 + jmp $L765 +$L666: + and bp,3 + dec bp ; The copied value of bx (num) + js $L645 + ; + mov eax,DWORD PTR es:[di] + mul eax + mov DWORD PTR ds:[si],eax + mov DWORD PTR ds:[si+4],edx + dec bp + js $L645 + ; + mov eax,DWORD PTR es:[di+4] + mul eax + mov DWORD PTR ds:[si+8],eax + mov DWORD PTR ds:[si+12],edx + dec bp + js $L645 + ; + mov eax,DWORD PTR es:[di+8] + mul eax + mov DWORD PTR ds:[si+16],eax + mov DWORD PTR ds:[si+20],edx +$L645: + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret +_bn_sqr_words ENDP + + PUBLIC _bn_div64 +_bn_div64 PROC FAR + push bp + mov bp,sp + mov edx, DWORD PTR [bp+6] + mov eax, DWORD PTR [bp+10] + div DWORD PTR [bp+14] + mov edx,eax + shr edx,16 + pop bp + ret +_bn_div64 ENDP + + PUBLIC _bn_add_words +_bn_add_words PROC FAR +; Line 58 + push bp + push bx + push esi + push di + push ds + push es + mov bp,sp +; w = 28 +; num = 26 +; ap = 22 +; rp = 18 + xor esi,esi ;c=0; + mov si,WORD PTR [bp+22] ; load a + mov es,WORD PTR [bp+24] ; load a + mov di,WORD PTR [bp+26] ; load b + mov ds,WORD PTR [bp+28] ; load b + + mov dx,WORD PTR [bp+30] ; load num + dec dx + js $L547 + xor ecx,ecx + +$L5477: + xor ebx,ebx + mov eax,DWORD PTR es:[si] ; *a + add eax,ecx + adc ebx,0 + add si,4 ; a++ + add eax,DWORD PTR ds:[di] ; + *b + mov ecx,ebx + adc ecx,0 + add di,4 + mov bx,WORD PTR [bp+18] + mov ds,WORD PTR [bp+20] + mov DWORD PTR ds:[bx],eax + add bx,4 + mov ds,WORD PTR [bp+28] + mov WORD PTR [bp+18],bx + dec dx + js $L547 ; Note that we are now testing for -1 + jmp $L5477 + ; +$L547: + mov eax,ecx + mov edx,ecx + shr edx,16 + pop es + pop ds + pop di + pop esi + pop bx + pop bp + ret + nop +_bn_add_words ENDP +F_TEXT ENDS +END diff --git a/src/lib/libcrypto/bn/bn.err b/src/lib/libcrypto/bn/bn.err new file mode 100644 index 0000000000..7ccc247c41 --- /dev/null +++ b/src/lib/libcrypto/bn/bn.err @@ -0,0 +1,27 @@ +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BN_BLINDING_CONVERT 100 +#define BN_F_BN_BLINDING_INVERT 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_DIV 107 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 + +/* Reason codes. */ +#define BN_R_BAD_RECIPROCAL 100 +#define BN_R_CALLED_WITH_EVEN_MODULUS 101 +#define BN_R_DIV_BY_ZERO 102 +#define BN_R_ENCODING_ERROR 103 +#define BN_R_INVALID_LENGTH 104 +#define BN_R_NOT_INITALISED 105 +#define BN_R_NO_INVERSE 106 diff --git a/src/lib/libcrypto/bn/bn.org b/src/lib/libcrypto/bn/bn.org new file mode 100644 index 0000000000..66dde285d6 --- /dev/null +++ b/src/lib/libcrypto/bn/bn.org @@ -0,0 +1,502 @@ +/* crypto/bn/bn.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify bn.org since bn.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_BN_H +#define HEADER_BN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#undef BN_LLONG + +#ifdef WIN32 +#define BN_LLONG /* This comment stops Configure mutilating things */ +#endif + +#define RECP_MUL_MOD +#define MONT_MUL_MOD + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using nornal cc. This would + * be a common occurance because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assember code. */ +#if defined(MSDOS) || defined(WINDOWS) || defined(linux) +#define BN_DIV2W +#endif + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits :-(, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG +/* #define BN_ULLONG unsigned long long */ +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef WIN32 +#define BN_ULLONG unsigned _int64 +#else +#define BN_ULLONG unsigned long long +#endif +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (100000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%05u" +#define BN_DEC_NUM 5 +#endif + +#ifdef EIGHT_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK2 (0xff) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#endif + +#define BN_DEFAULT_BITS 1280 + +#ifdef BIGNUM +#undef BIGNUM +#endif + +typedef struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int max; /* Size of the d array. */ + int neg; /* one if the number is negative */ + } BIGNUM; + +/* Used for temp variables */ +#define BN_CTX_NUM 12 +typedef struct bignum_ctx + { + int tos; + BIGNUM *bn[BN_CTX_NUM+1]; + } BN_CTX; + +typedef struct bn_blinding_st + { + int init; + BIGNUM *A; + BIGNUM *Ai; + BIGNUM *mod; /* just a reference */ + } BN_BLINDING; + +/* Used for montgomery multiplication */ +typedef struct bn_mont_ctx_st + { + int ri; /* number of bits in R */ + BIGNUM *RR; /* used to convert to montgomery form */ + BIGNUM *N; /* The modulus */ + BIGNUM *Ni; /* The inverse of N */ + BN_ULONG n0; /* word form of inverse, normally only one of + * Ni or n0 is defined */ + } BN_MONT_CTX; + +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + r,a,(mont)->RR,(mont),ctx) + +#define BN_prime_checks (5) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) +#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) +#define BN_is_zero(a) (((a)->top <= 1) && ((a)->d[0] == (BN_ULONG)0)) +#define BN_is_one(a) (BN_is_word((a),1)) +#define BN_is_odd(a) ((a)->d[0] & 1) +#define BN_one(a) (BN_set_word((a),1)) +#define BN_zero(a) (BN_set_word((a),0)) + +#define BN_ascii2bn(a) BN_hex2bn(a) +#define BN_bn2ascii(a) BN_bn2hex(a) + +#define bn_fix_top(a) \ + { \ + BN_ULONG *fix_top_l; \ + for (fix_top_l= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(fix_top_l--)) break; \ + } + +#define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?\ + (n):bn_expand2((n),(b)/BN_BITS2)) +#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b))) + + +#ifndef NOPROTO +BIGNUM *BN_value_one(void); +char * BN_options(void); +BN_CTX *BN_CTX_new(void); +void BN_CTX_free(BN_CTX *c); +int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_num_bits(BIGNUM *a); +int BN_num_bits_word(BN_ULONG); +BIGNUM *BN_new(void); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b); +void bn_qsub(BIGNUM *r, BIGNUM *a, BIGNUM *b); +void bn_qadd(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); +int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); +int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); +BN_ULONG BN_mod_word(BIGNUM *a, unsigned long w); +BN_ULONG BN_div_word(BIGNUM *a, unsigned long w); +int BN_mul_word(BIGNUM *a, unsigned long w); +int BN_add_word(BIGNUM *a, unsigned long w); +int BN_sub_word(BIGNUM *a, unsigned long w); +int BN_set_word(BIGNUM *a, unsigned long w); +unsigned long BN_get_word(BIGNUM *a); +int BN_cmp(BIGNUM *a, BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, BIGNUM *a); +int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx); +int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx, + BN_MONT_CTX *m_ctx); +int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, + BIGNUM *m,BN_CTX *ctx); +int BN_mask_bits(BIGNUM *a,int n); +int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BIGNUM *m, + BIGNUM *i, int nb, BN_CTX *ctx); +int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m, + BN_CTX *ctx); +#ifndef WIN16 +int BN_print_fp(FILE *fp, BIGNUM *a); +#endif +#ifdef HEADER_BIO_H +int BN_print(BIO *fp, BIGNUM *a); +#else +int BN_print(char *fp, BIGNUM *a); +#endif +int BN_reciprocal(BIGNUM *r, BIGNUM *m, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *bn_expand2(BIGNUM *b, int bits); +BIGNUM *BN_dup(BIGNUM *a); +int BN_ucmp(BIGNUM *a, BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(BIGNUM *a); +char * BN_bn2dec(BIGNUM *a); +int BN_hex2bn(BIGNUM **a,char *str); +int BN_dec2bn(BIGNUM **a,char *str); +int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); +BIGNUM *BN_mod_inverse(BIGNUM *a, BIGNUM *n,BN_CTX *ctx); +BIGNUM *BN_generate_prime(int bits,int strong,BIGNUM *add, + BIGNUM *rem,void (*callback)(int,int,char *),char *cb_arg); +int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,char *), + BN_CTX *ctx,char *cb_arg); +void ERR_load_BN_strings(void ); + +BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); +BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); +void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num); +BN_ULONG bn_div64(BN_ULONG h, BN_ULONG l, BN_ULONG d); +BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num); + +BN_MONT_CTX *BN_MONT_CTX_new(void ); +int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont, + BN_CTX *ctx); +int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont,BIGNUM *modulus,BN_CTX *ctx); + +BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *r, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); + +#else + +BIGNUM *BN_value_one(); +char * BN_options(); +BN_CTX *BN_CTX_new(); +void BN_CTX_free(); +int BN_rand(); +int BN_num_bits(); +int BN_num_bits_word(); +BIGNUM *BN_new(); +void BN_clear_free(); +BIGNUM *BN_copy(); +BIGNUM *BN_bin2bn(); +int BN_bn2bin(); +BIGNUM *BN_mpi2bn(); +int BN_bn2mpi(); +int BN_sub(); +void bn_qsub(); +void bn_qadd(); +int BN_add(); +int BN_mod(); +int BN_div(); +int BN_mul(); +int BN_sqr(); +BN_ULONG BN_mod_word(); +BN_ULONG BN_div_word(); +int BN_add_word(); +int BN_sub_word(); +int BN_mul_word(); +int BN_set_word(); +unsigned long BN_get_word(); +int BN_cmp(); +void BN_free(); +int BN_is_bit_set(); +int BN_lshift(); +int BN_lshift1(); +int BN_exp(); +int BN_mod_exp(); +int BN_mod_exp_mont(); +int BN_mod_exp_recp(); +int BN_mod_exp_simple(); +int BN_mask_bits(); +int BN_mod_mul_reciprocal(); +int BN_mod_mul(); +#ifndef WIN16 +int BN_print_fp(); +#endif +int BN_print(); +int BN_reciprocal(); +int BN_rshift(); +int BN_rshift1(); +void BN_clear(); +BIGNUM *bn_expand2(); +BIGNUM *BN_dup(); +int BN_ucmp(); +int BN_set_bit(); +int BN_clear_bit(); +char * BN_bn2hex(); +char * BN_bn2dec(); +int BN_hex2bn(); +int BN_dec2bn(); +int BN_gcd(); +BIGNUM *BN_mod_inverse(); +BIGNUM *BN_generate_prime(); +int BN_is_prime(); +void ERR_load_BN_strings(); + +BN_ULONG bn_mul_add_words(); +BN_ULONG bn_mul_words(); +void bn_sqr_words(); +BN_ULONG bn_div64(); +BN_ULONG bn_add_words(); + +int BN_mod_mul_montgomery(); +int BN_from_montgomery(); +BN_MONT_CTX *BN_MONT_CTX_new(); +void BN_MONT_CTX_free(); +int BN_MONT_CTX_set(); + +BN_BLINDING *BN_BLINDING_new(); +void BN_BLINDING_free(); +int BN_BLINDING_update(); +int BN_BLINDING_convert(); +int BN_BLINDING_invert(); + +#endif + +/* BEGIN ERROR CODES */ +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BN_BLINDING_CONVERT 100 +#define BN_F_BN_BLINDING_INVERT 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_DIV 107 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 + +/* Reason codes. */ +#define BN_R_BAD_RECIPROCAL 100 +#define BN_R_CALLED_WITH_EVEN_MODULUS 101 +#define BN_R_DIV_BY_ZERO 102 +#define BN_R_ENCODING_ERROR 103 +#define BN_R_INVALID_LENGTH 104 +#define BN_R_NOT_INITALISED 105 +#define BN_R_NO_INVERSE 106 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/lib/libcrypto/bn/bn_m.c b/src/lib/libcrypto/bn/bn_m.c new file mode 100644 index 0000000000..5166daaeec --- /dev/null +++ b/src/lib/libcrypto/bn/bn_m.c @@ -0,0 +1,169 @@ +/* crypto/bn/bn_m.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn_lcl.h" +#include "stack.h" + +int limit=16; + +typedef struct bn_pool_st + { + int used; + int tos; + STACK *sk; + } BN_POOL; + +BIGNUM *BN_POOL_push(bp) +BN_POOL *bp; + { + BIGNUM *ret; + + if (bp->used >= bp->tos) + { + ret=BN_new(); + sk_push(bp->sk,(char *)ret); + bp->tos++; + bp->used++; + } + else + { + ret=(BIGNUM *)sk_value(bp->sk,bp->used); + bp->used++; + } + return(ret); + } + +void BN_POOL_pop(bp,num) +BN_POOL *bp; +int num; + { + bp->used-=num; + } + +int BN_m(r,a,b) +BIGNUM *r,*a,*b; + { + static BN_POOL bp; + static init=1; + + if (init) + { + bp.used=0; + bp.tos=0; + bp.sk=sk_new_null(); + init=0; + } + return(BN_mm(r,a,b,&bp)); + } + +/* r must be different to a and b */ +int BN_mm(m, A, B, bp) +BIGNUM *m,*A,*B; +BN_POOL *bp; + { + int i,num; + int an,bn; + BIGNUM *a,*b,*c,*d,*ac,*bd; + + an=A->top; + bn=B->top; + if ((an <= limit) || (bn <= limit)) + { + return(BN_mul(m,A,B)); + } + + a=BN_POOL_push(bp); + b=BN_POOL_push(bp); + c=BN_POOL_push(bp); + d=BN_POOL_push(bp); + ac=BN_POOL_push(bp); + bd=BN_POOL_push(bp); + + num=(an <= bn)?an:bn; + num=1<<(BN_num_bits_word(num-1)-1); + + /* Are going to now chop things into 'num' word chunks. */ + num*=BN_BITS2; + + BN_copy(a,A); + BN_mask_bits(a,num); + BN_rshift(b,A,num); + + BN_copy(c,B); + BN_mask_bits(c,num); + BN_rshift(d,B,num); + + BN_sub(ac ,b,a); + BN_sub(bd,c,d); + BN_mm(m,ac,bd,bp); + BN_mm(ac,a,c,bp); + BN_mm(bd,b,d,bp); + + BN_add(m,m,ac); + BN_add(m,m,bd); + BN_lshift(m,m,num); + BN_lshift(bd,bd,num*2); + + BN_add(m,m,ac); + BN_add(m,m,bd); + BN_POOL_pop(bp,6); + return(1); + } + diff --git a/src/lib/libcrypto/bn/bn_mulw.c b/src/lib/libcrypto/bn/bn_mulw.c new file mode 100644 index 0000000000..abfc7e4d6c --- /dev/null +++ b/src/lib/libcrypto/bn/bn_mulw.c @@ -0,0 +1,366 @@ +/* crypto/bn/bn_mulw.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn_lcl.h" + +#ifdef BN_LLONG + +BN_ULONG bn_mul_add_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c1=0; + + for (;;) + { + mul_add(rp[0],ap[0],w,c1); + if (--num == 0) break; + mul_add(rp[1],ap[1],w,c1); + if (--num == 0) break; + mul_add(rp[2],ap[2],w,c1); + if (--num == 0) break; + mul_add(rp[3],ap[3],w,c1); + if (--num == 0) break; + ap+=4; + rp+=4; + } + + return(c1); + } + +BN_ULONG bn_mul_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c1=0; + + for (;;) + { + mul(rp[0],ap[0],w,c1); + if (--num == 0) break; + mul(rp[1],ap[1],w,c1); + if (--num == 0) break; + mul(rp[2],ap[2],w,c1); + if (--num == 0) break; + mul(rp[3],ap[3],w,c1); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(c1); + } + +void bn_sqr_words(r,a,n) +BN_ULONG *r,*a; +int n; + { + for (;;) + { + BN_ULLONG t; + + t=(BN_ULLONG)(a[0])*(a[0]); + r[0]=Lw(t); r[1]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[1])*(a[1]); + r[2]=Lw(t); r[3]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[2])*(a[2]); + r[4]=Lw(t); r[5]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[3])*(a[3]); + r[6]=Lw(t); r[7]=Hw(t); + if (--n == 0) break; + + a+=4; + r+=8; + } + } + +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULLONG ll; + + ll=0; + for (;;) + { + ll+= (BN_ULLONG)a[0]+b[0]; + r[0]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[1]+b[1]; + r[1]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[2]+b[2]; + r[2]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[3]+b[3]; + r[3]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + a+=4; + b+=4; + r+=4; + } + return(ll&BN_MASK2); + } + +#else + +BN_ULONG bn_mul_add_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c=0; + BN_ULONG bl,bh; + + bl=LBITS(w); + bh=HBITS(w); + + for (;;) + { + mul_add(rp[0],ap[0],bl,bh,c); + if (--num == 0) break; + mul_add(rp[1],ap[1],bl,bh,c); + if (--num == 0) break; + mul_add(rp[2],ap[2],bl,bh,c); + if (--num == 0) break; + mul_add(rp[3],ap[3],bl,bh,c); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(c); + } + +BN_ULONG bn_mul_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG carry=0; + BN_ULONG bl,bh; + + bl=LBITS(w); + bh=HBITS(w); + + for (;;) + { + mul(rp[0],ap[0],bl,bh,carry); + if (--num == 0) break; + mul(rp[1],ap[1],bl,bh,carry); + if (--num == 0) break; + mul(rp[2],ap[2],bl,bh,carry); + if (--num == 0) break; + mul(rp[3],ap[3],bl,bh,carry); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(carry); + } + +void bn_sqr_words(r,a,n) +BN_ULONG *r,*a; +int n; + { + for (;;) + { + sqr64(r[0],r[1],a[0]); + if (--n == 0) break; + + sqr64(r[2],r[3],a[1]); + if (--n == 0) break; + + sqr64(r[4],r[5],a[2]); + if (--n == 0) break; + + sqr64(r[6],r[7],a[3]); + if (--n == 0) break; + + a+=4; + r+=8; + } + } + +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULONG t1,t2; + int carry,i; + + carry=0; + for (i=0; i= ((~t1)&BN_MASK2)); + t2=(t1+t2+1)&BN_MASK2; + } + else + { + t2=(t1+t2)&BN_MASK2; + carry=(t2 (BN_ULONG)1<= d) h-=d; + + if (i) + { + d<<=i; + h=(h<>(BN_BITS2-i)); + l<<=i; + } + dh=(d&BN_MASK2h)>>BN_BITS4; + dl=(d&BN_MASK2l); + for (;;) + { + if ((h>>BN_BITS4) == dh) + q=BN_MASK2l; + else + q=h/dh; + + for (;;) + { + t=(h-q*dh); + if ((t&BN_MASK2h) || + ((dl*q) <= ( + (t<>BN_BITS4)))) + break; + q--; + } + th=q*dh; + tl=q*dl; + t=(tl>>BN_BITS4); + tl=(tl<>BN_BITS4))&BN_MASK2; + l=(l&BN_MASK2l)< +#include "cryptlib.h" +#include "bn_lcl.h" + +/* unsigned subtraction of b from a, a must be larger than b. */ +void bn_qsub(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + int max,min; + register BN_ULONG t1,t2,*ap,*bp,*rp; + int i,carry; +#if defined(IRIX_CC_BUG) && !defined(LINT) + int dummy; +#endif + + max=a->top; + min=b->top; + ap=a->d; + bp=b->d; + rp=r->d; + + carry=0; + for (i=0; i t2) break; + } + } +#if 0 + memcpy(rp,ap,sizeof(*rp)*(max-i)); +#else + for (; itop=max; + bn_fix_top(r); + } + +int BN_sub(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + int max,i; + int add=0,neg=0; + BIGNUM *tmp; + + /* a - b a-b + * a - -b a+b + * -a - b -(a+b) + * -a - -b b-a + */ + if (a->neg) + { + if (b->neg) + { tmp=a; a=b; b=tmp; } + else + { add=1; neg=1; } + } + else + { + if (b->neg) { add=1; neg=0; } + } + + if (add) + { + /* As a fast max size, do a a->top | b->top */ + i=(a->top | b->top)+1; + if (bn_wexpand(r,i) == NULL) + return(0); + if (i) + bn_qadd(r,a,b); + else + bn_qadd(r,b,a); + r->neg=neg; + return(1); + } + + /* We are actually doing a - b :-) */ + + max=(a->top > b->top)?a->top:b->top; + if (bn_wexpand(r,max) == NULL) return(0); + if (BN_ucmp(a,b) < 0) + { + bn_qsub(r,b,a); + r->neg=1; + } + else + { + bn_qsub(r,a,b); + r->neg=0; + } + return(1); + } + diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl new file mode 100644 index 0000000000..a5f150e523 --- /dev/null +++ b/src/lib/libcrypto/buffer/Makefile.ssl @@ -0,0 +1,84 @@ +# +# SSLeay/crypto/buffer/Makefile +# + +DIR= buffer +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=buffer +ERRC=buf_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= buffer.c $(ERRC).c +LIBOBJ= buffer.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= buffer.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/buffer/buffer.err b/src/lib/libcrypto/buffer/buffer.err new file mode 100644 index 0000000000..62b775e637 --- /dev/null +++ b/src/lib/libcrypto/buffer/buffer.err @@ -0,0 +1,9 @@ +/* Error codes for the BUF functions. */ + +/* Function codes. */ +#define BUF_F_BUF_MEM_GROW 100 +#define BUF_F_BUF_MEM_NEW 101 +#define BUF_F_BUF_STRDUP 102 +#define BUF_F_PXYCLNT_READ 103 + +/* Reason codes. */ diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl new file mode 100644 index 0000000000..0143827ae5 --- /dev/null +++ b/src/lib/libcrypto/cast/Makefile.ssl @@ -0,0 +1,109 @@ +# +# SSLeay/crypto/cast/Makefile +# + +DIR= cast +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CAST_ENC=c_enc.o +# or use +#CAST_ENC=asm/cx86-elf.o +#CAST_ENC=asm/cx86-out.o +#CAST_ENC=asm/cx86-sol.o +#CAST_ENC=asm/cx86bdsi.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=casttest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= cast.h +HEADER= cast_s.h cast_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/cx86-elf.o: asm/cx86unix.cpp + $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o + +# solaris +asm/cx86-sol.o: asm/cx86unix.cpp + $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s + as -o asm/cx86-sol.o asm/cx86-sol.s + rm -f asm/cx86-sol.s + +# a.out +asm/cx86-out.o: asm/cx86unix.cpp + $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o + +# bsdi +asm/cx86bsdi.o: asm/cx86unix.cpp + $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o + +asm/cx86unix.cpp: + (cd asm; perl cast-586.pl cpp >cx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/cast/Makefile.uni b/src/lib/libcrypto/cast/Makefile.uni new file mode 100644 index 0000000000..780073e75b --- /dev/null +++ b/src/lib/libcrypto/cast/Makefile.uni @@ -0,0 +1,123 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +# There are 3 possible performance options, experiment :-) +#OPTS= -DBF_PTR +#OPTS= -DBF_PTR2 +OPTS= + +DIR= cast +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +CAST_ENC=c_enc.o +# or use +#CAST_ENC=asm/cx86-elf.o +#CAST_ENC=asm/cx86-out.o +#CAST_ENC=asm/cx86-sol.o +#CAST_ENC=asm/cx86bdsi.o + +CFLAGS= $(OPTS) $(INCLUDES) $(CFLAG) -DFULL_TEST + +GENERAL=Makefile +TEST=casttest +APP1=cast_spd +APP2=castopts +APPS=$(APP1) $(APP2) + +LIB=libcast.a +LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= cast.h +HEADER= cast_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) +# elf +asm/cx86-elf.o: asm/cx86unix.cpp + $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o + +# solaris +asm/cx86-sol.o: asm/cx86unix.cpp + $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s + as -o asm/cx86-sol.o asm/cx86-sol.s + rm -f asm/cx86-sol.s + +# a.out +asm/cx86-out.o: asm/cx86unix.cpp + $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o + +# bsdi +asm/cx86bsdi.o: asm/cx86unix.cpp + $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o + +asm/cx86unix.cpp: + (cd asm; perl cast-586.pl cpp >cx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APP1): $(APP1).c $(LIB) + $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB) + +$(APP2): $(APP2).c $(LIB) + $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) CAST_ENC="asm/cx86-elf.o" CFLAG="-DELF $(CFLAGS)" all + +x86-out: + $(MAKE) CAST_ENC="asm/cx86-out.o" CFLAG="-DOUT $(CFLAGS)" all + +x86-solaris: + $(MAKE) CAST_ENC="asm/cx86-sol.o" CFLAG="-DSOL $(CFLAGS)" all + +x86-bdsi: + $(MAKE) CAST_ENC="asm/cx86-bdsi.o" CFLAG="-DBDSI $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/cast/asm/c-win32.asm b/src/lib/libcrypto/cast/asm/c-win32.asm new file mode 100644 index 0000000000..a1d8a2671a --- /dev/null +++ b/src/lib/libcrypto/cast/asm/c-win32.asm @@ -0,0 +1,940 @@ + ; Don't even think of reading this code + ; It was automatically generated by cast-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE cast-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _CAST_encrypt +EXTERN _CAST_S_table0:DWORD +EXTERN _CAST_S_table1:DWORD +EXTERN _CAST_S_table2:DWORD +EXTERN _CAST_S_table3:DWORD + +_CAST_encrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + ; round 0 + mov edx, DWORD PTR [ebp] + mov ecx, DWORD PTR 4[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 1 + mov edx, DWORD PTR 8[ebp] + mov ecx, DWORD PTR 12[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 2 + mov edx, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 20[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 3 + mov edx, DWORD PTR 24[ebp] + mov ecx, DWORD PTR 28[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 4 + mov edx, DWORD PTR 32[ebp] + mov ecx, DWORD PTR 36[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 5 + mov edx, DWORD PTR 40[ebp] + mov ecx, DWORD PTR 44[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 6 + mov edx, DWORD PTR 48[ebp] + mov ecx, DWORD PTR 52[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 7 + mov edx, DWORD PTR 56[ebp] + mov ecx, DWORD PTR 60[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 8 + mov edx, DWORD PTR 64[ebp] + mov ecx, DWORD PTR 68[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 9 + mov edx, DWORD PTR 72[ebp] + mov ecx, DWORD PTR 76[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 10 + mov edx, DWORD PTR 80[ebp] + mov ecx, DWORD PTR 84[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 11 + mov edx, DWORD PTR 88[ebp] + mov ecx, DWORD PTR 92[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 12 + mov edx, DWORD PTR 96[ebp] + mov ecx, DWORD PTR 100[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 13 + mov edx, DWORD PTR 104[ebp] + mov ecx, DWORD PTR 108[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 14 + mov edx, DWORD PTR 112[ebp] + mov ecx, DWORD PTR 116[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 15 + mov edx, DWORD PTR 120[ebp] + mov ecx, DWORD PTR 124[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + mov eax, DWORD PTR 20[esp] + xor esi, ecx + nop + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_CAST_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _CAST_decrypt +EXTERN _CAST_S_table0:DWORD +EXTERN _CAST_S_table1:DWORD +EXTERN _CAST_S_table2:DWORD +EXTERN _CAST_S_table3:DWORD + +_CAST_decrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + ; round 15 + mov edx, DWORD PTR 120[ebp] + mov ecx, DWORD PTR 124[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 14 + mov edx, DWORD PTR 112[ebp] + mov ecx, DWORD PTR 116[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 13 + mov edx, DWORD PTR 104[ebp] + mov ecx, DWORD PTR 108[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 12 + mov edx, DWORD PTR 96[ebp] + mov ecx, DWORD PTR 100[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 11 + mov edx, DWORD PTR 88[ebp] + mov ecx, DWORD PTR 92[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 10 + mov edx, DWORD PTR 80[ebp] + mov ecx, DWORD PTR 84[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 9 + mov edx, DWORD PTR 72[ebp] + mov ecx, DWORD PTR 76[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 8 + mov edx, DWORD PTR 64[ebp] + mov ecx, DWORD PTR 68[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 7 + mov edx, DWORD PTR 56[ebp] + mov ecx, DWORD PTR 60[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 6 + mov edx, DWORD PTR 48[ebp] + mov ecx, DWORD PTR 52[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 5 + mov edx, DWORD PTR 40[ebp] + mov ecx, DWORD PTR 44[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 4 + mov edx, DWORD PTR 32[ebp] + mov ecx, DWORD PTR 36[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 3 + mov edx, DWORD PTR 24[ebp] + mov ecx, DWORD PTR 28[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 2 + mov edx, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 20[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 1 + mov edx, DWORD PTR 8[ebp] + mov ecx, DWORD PTR 12[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 0 + mov edx, DWORD PTR [ebp] + mov ecx, DWORD PTR 4[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + mov eax, DWORD PTR 20[esp] + xor esi, ecx + nop + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_CAST_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _CAST_cbc_encrypt + +_CAST_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L000decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L001encrypt_finish +L002encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L002encrypt_loop +$L001encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4] + jmp ebp +L005ej7: + xor edx, edx + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L006ej6: + mov dh, BYTE PTR 5[esi] +L007ej5: + mov dl, BYTE PTR 4[esi] +L008ej4: + mov ecx, DWORD PTR [esi] + jmp $L009ejend +L010ej3: + mov ch, BYTE PTR 2[esi] + xor ecx, ecx + shl ecx, 8 +L011ej2: + mov ch, BYTE PTR 1[esi] +L012ej1: + mov cl, BYTE PTR [esi] +$L009ejend: + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L003finish +$L000decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L013decrypt_finish +L014decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L014decrypt_loop +$L013decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L015dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L016dj6: + mov BYTE PTR 5[edi],dh +L017dj5: + mov BYTE PTR 4[edi],dl +L018dj4: + mov DWORD PTR [edi],ecx + jmp $L019djend +L020dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L021dj2: + mov BYTE PTR 1[esi],ch +L022dj1: + mov BYTE PTR [esi], cl +$L019djend: + jmp $L003finish +$L003finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L004cbc_enc_jmp_table: + DD 0 + DD L012ej1 + DD L011ej2 + DD L010ej3 + DD L008ej4 + DD L007ej5 + DD L006ej6 + DD L005ej7 +L023cbc_dec_jmp_table: + DD 0 + DD L022dj1 + DD L021dj2 + DD L020dj3 + DD L018dj4 + DD L017dj5 + DD L016dj6 + DD L015dj7 +_CAST_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/cast/asm/cx86unix.cpp b/src/lib/libcrypto/cast/asm/cx86unix.cpp new file mode 100644 index 0000000000..035692a5af --- /dev/null +++ b/src/lib/libcrypto/cast/asm/cx86unix.cpp @@ -0,0 +1,1010 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define CAST_S_table0 _CAST_S_table0 +#define CAST_S_table1 _CAST_S_table1 +#define CAST_S_table2 _CAST_S_table2 +#define CAST_S_table3 _CAST_S_table3 +#define CAST_encrypt _CAST_encrypt +#define CAST_S_table0 _CAST_S_table0 +#define CAST_S_table1 _CAST_S_table1 +#define CAST_S_table2 _CAST_S_table2 +#define CAST_S_table3 _CAST_S_table3 +#define CAST_decrypt _CAST_decrypt +#define CAST_cbc_encrypt _CAST_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by cast-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "cast-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl CAST_encrypt + TYPE(CAST_encrypt,@function) +CAST_encrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + /* round 0 */ + movl (%ebp), %edx + movl 4(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 1 */ + movl 8(%ebp), %edx + movl 12(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 2 */ + movl 16(%ebp), %edx + movl 20(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 3 */ + movl 24(%ebp), %edx + movl 28(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 4 */ + movl 32(%ebp), %edx + movl 36(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 5 */ + movl 40(%ebp), %edx + movl 44(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 6 */ + movl 48(%ebp), %edx + movl 52(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 7 */ + movl 56(%ebp), %edx + movl 60(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 8 */ + movl 64(%ebp), %edx + movl 68(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 9 */ + movl 72(%ebp), %edx + movl 76(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 10 */ + movl 80(%ebp), %edx + movl 84(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 11 */ + movl 88(%ebp), %edx + movl 92(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 12 */ + movl 96(%ebp), %edx + movl 100(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 13 */ + movl 104(%ebp), %edx + movl 108(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 14 */ + movl 112(%ebp), %edx + movl 116(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 15 */ + movl 120(%ebp), %edx + movl 124(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + movl 20(%esp), %eax + xorl %ecx, %esi + nop + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.CAST_encrypt_end: + SIZE(CAST_encrypt,.CAST_encrypt_end-CAST_encrypt) +.ident "CAST_encrypt" +.text + .align ALIGN +.globl CAST_decrypt + TYPE(CAST_decrypt,@function) +CAST_decrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + /* round 15 */ + movl 120(%ebp), %edx + movl 124(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 14 */ + movl 112(%ebp), %edx + movl 116(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 13 */ + movl 104(%ebp), %edx + movl 108(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 12 */ + movl 96(%ebp), %edx + movl 100(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 11 */ + movl 88(%ebp), %edx + movl 92(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 10 */ + movl 80(%ebp), %edx + movl 84(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 9 */ + movl 72(%ebp), %edx + movl 76(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 8 */ + movl 64(%ebp), %edx + movl 68(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 7 */ + movl 56(%ebp), %edx + movl 60(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 6 */ + movl 48(%ebp), %edx + movl 52(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 5 */ + movl 40(%ebp), %edx + movl 44(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 4 */ + movl 32(%ebp), %edx + movl 36(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 3 */ + movl 24(%ebp), %edx + movl 28(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 2 */ + movl 16(%ebp), %edx + movl 20(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 1 */ + movl 8(%ebp), %edx + movl 12(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 0 */ + movl (%ebp), %edx + movl 4(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + movl 20(%esp), %eax + xorl %ecx, %esi + nop + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.CAST_decrypt_end: + SIZE(CAST_decrypt,.CAST_decrypt_end-CAST_decrypt) +.ident "CAST_decrypt" +.text + .align ALIGN +.globl CAST_cbc_encrypt + TYPE(CAST_cbc_encrypt,@function) +CAST_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L000decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L001encrypt_finish +.L002encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L002encrypt_loop +.L001encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L005ej7: + xorl %edx, %edx + movb 6(%esi), %dh + sall $8, %edx +.L006ej6: + movb 5(%esi), %dh +.L007ej5: + movb 4(%esi), %dl +.L008ej4: + movl (%esi), %ecx + jmp .L009ejend +.L010ej3: + movb 2(%esi), %ch + xorl %ecx, %ecx + sall $8, %ecx +.L011ej2: + movb 1(%esi), %ch +.L012ej1: + movb (%esi), %cl +.L009ejend: + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L003finish +.align ALIGN +.L000decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L013decrypt_finish +.L014decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L014decrypt_loop +.L013decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L015dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L016dj6: + movb %dh, 5(%edi) +.L017dj5: + movb %dl, 4(%edi) +.L018dj4: + movl %ecx, (%edi) + jmp .L019djend +.L020dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L021dj2: + movb %ch, 1(%esi) +.L022dj1: + movb %cl, (%esi) +.L019djend: + jmp .L003finish +.align ALIGN +.L003finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L004cbc_enc_jmp_table: + .long 0 + .long .L012ej1 + .long .L011ej2 + .long .L010ej3 + .long .L008ej4 + .long .L007ej5 + .long .L006ej6 + .long .L005ej7 +.align ALIGN +.L023cbc_dec_jmp_table: + .long 0 + .long .L022dj1 + .long .L021dj2 + .long .L020dj3 + .long .L018dj4 + .long .L017dj5 + .long .L016dj6 + .long .L015dj7 +.CAST_cbc_encrypt_end: + SIZE(CAST_cbc_encrypt,.CAST_cbc_encrypt_end-CAST_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl new file mode 100644 index 0000000000..00e917aa44 --- /dev/null +++ b/src/lib/libcrypto/conf/Makefile.ssl @@ -0,0 +1,85 @@ +# +# SSLeay/crypto/conf/Makefile +# + +DIR= conf +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=conf +ERRC=conf_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= conf.c $(ERRC).c + +LIBOBJ= conf.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= conf.h +HEADER= conf_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/conf/conf.c b/src/lib/libcrypto/conf/conf.c new file mode 100644 index 0000000000..9e84300c5e --- /dev/null +++ b/src/lib/libcrypto/conf/conf.c @@ -0,0 +1,727 @@ +/* crypto/conf/conf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include "cryptlib.h" +#include "stack.h" +#include "lhash.h" +#include "conf.h" +#include "buffer.h" +#include "err.h" + +#include "conf_lcl.h" + +#ifndef NOPROTO +static void value_free_hash(CONF_VALUE *a, LHASH *conf); +static void value_free_stack(CONF_VALUE *a,LHASH *conf); +static unsigned long hash(CONF_VALUE *v); +static int cmp(CONF_VALUE *a,CONF_VALUE *b); +static char *eat_ws(char *p); +static char *eat_alpha_numeric(char *p); +static void clear_comments(char *p); +static int str_copy(LHASH *conf,char *section,char **to, char *from); +static char *scan_quote(char *p); +static CONF_VALUE *new_section(LHASH *conf,char *section); +static CONF_VALUE *get_section(LHASH *conf,char *section); +#else +static void value_free_hash(); +static void value_free_stack(); +static unsigned long hash(); +static int cmp(); +static char *eat_ws(); +static char *eat_alpha_numeric(); +static void clear_comments(); +static int str_copy(); +static char *scan_quote(); +static CONF_VALUE *new_section(); +static CONF_VALUE *get_section(); +#endif + +#define scan_esc(p) ((*(++p) == '\0')?(p):(++p)) + +char *CONF_version="CONF part of SSLeay 0.9.0b 29-Jun-1998"; + +LHASH *CONF_load(h,file,line) +LHASH *h; +char *file; +long *line; + { + LHASH *ret=NULL; + FILE *in=NULL; +#define BUFSIZE 512 + int bufnum=0,i,ii; + BUF_MEM *buff=NULL; + char *s,*p,*end; + int again,n,eline=0; + CONF_VALUE *v=NULL,*vv,*tv; + CONF_VALUE *sv=NULL; + char *section=NULL,*buf; + STACK *section_sk=NULL,*ts; + char *start,*psection,*pname; + + if ((buff=BUF_MEM_new()) == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB); + goto err; + } + + in=fopen(file,"rb"); + if (in == NULL) + { + SYSerr(SYS_F_FOPEN,get_last_sys_error()); + ERR_set_error_data(BUF_strdup(file), + ERR_TXT_MALLOCED|ERR_TXT_STRING); + CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); + goto err; + } + + section=(char *)Malloc(10); + if (section == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + strcpy(section,"default"); + + if (h == NULL) + { + if ((ret=lh_new(hash,cmp)) == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + } + else + ret=h; + + sv=new_section(ret,section); + if (sv == NULL) + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + goto err; + } + section_sk=(STACK *)sv->value; + + bufnum=0; + for (;;) + { + again=0; + if (!BUF_MEM_grow(buff,bufnum+BUFSIZE)) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB); + goto err; + } + p= &(buff->data[bufnum]); + *p='\0'; + fgets(p,BUFSIZE-1,in); + p[BUFSIZE-1]='\0'; + ii=i=strlen(p); + if (i == 0) break; + while (i > 0) + { + if ((p[i-1] != '\r') && (p[i-1] != '\n')) + break; + else + i--; + } + /* we removed some trailing stuff so there is a new + * line on the end. */ + if (i == ii) + again=1; /* long line */ + else + { + p[i]='\0'; + eline++; /* another input line */ + } + + /* we now have a line with trailing \r\n removed */ + + /* i is the number of bytes */ + bufnum+=i; + + v=NULL; + /* check for line continuation */ + if (bufnum >= 1) + { + /* If we have bytes and the last char '\\' and + * second last char is not '\\' */ + p= &(buff->data[bufnum-1]); + if ( IS_ESC(p[0]) && + ((bufnum <= 1) || !IS_ESC(p[-1]))) + { + bufnum--; + again=1; + } + } + if (again) continue; + bufnum=0; + buf=buff->data; + + clear_comments(buf); + n=strlen(buf); + s=eat_ws(buf); + if (IS_EOF(*s)) continue; /* blank line */ + if (*s == '[') + { + s++; + start=eat_ws(s); + end=eat_alpha_numeric(start); + p=eat_ws(end); + if (*p != ']') + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_CLOSE_SQUARE_BRACKET); + goto err; + } + *end='\0'; + if (!str_copy(ret,NULL,§ion,start)) goto err; + if ((sv=get_section(ret,section)) == NULL) + sv=new_section(ret,section); + if (sv == NULL) + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + goto err; + } + section_sk=(STACK *)sv->value; + continue; + } + else + { + pname=s; + psection=NULL; + end=eat_alpha_numeric(s); + if ((end[0] == ':') && (end[1] == ':')) + { + *end='\0'; + end+=2; + psection=pname; + pname=end; + end=eat_alpha_numeric(end); + } + p=eat_ws(end); + if (*p != '=') + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_EQUAL_SIGN); + goto err; + } + *end='\0'; + p++; + start=eat_ws(p); + while (!IS_EOF(*p)) + p++; + p--; + while ((p != start) && (IS_WS(*p))) + p--; + p++; + *p='\0'; + + if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + if (psection == NULL) psection=section; + v->name=(char *)Malloc(strlen(pname)+1); + v->value=NULL; + if (v->name == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + strcpy(v->name,pname); + if (!str_copy(ret,psection,&(v->value),start)) goto err; + + if (strcmp(psection,section) != 0) + { + if ((tv=get_section(ret,psection)) + == NULL) + tv=new_section(ret,psection); + if (tv == NULL) + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + goto err; + } + ts=(STACK *)tv->value; + } + else + { + tv=sv; + ts=section_sk; + } + v->section=tv->section; + if (!sk_push(ts,(char *)v)) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + vv=(CONF_VALUE *)lh_insert(ret,(char *)v); + if (vv != NULL) + { + sk_delete_ptr(ts,(char *)vv); + Free(vv->name); + Free(vv->value); + Free(vv); + } + v=NULL; + } + } + if (buff != NULL) BUF_MEM_free(buff); + if (section != NULL) Free(section); + if (in != NULL) fclose(in); + return(ret); +err: + if (buff != NULL) BUF_MEM_free(buff); + if (section != NULL) Free(section); + if (line != NULL) *line=eline; + if (in != NULL) fclose(in); + if ((h != ret) && (ret != NULL)) CONF_free(ret); + if (v != NULL) + { + if (v->name != NULL) Free(v->name); + if (v->value != NULL) Free(v->value); + if (v != NULL) Free(v); + } + return(NULL); + } + +char *CONF_get_string(conf,section,name) +LHASH *conf; +char *section; +char *name; + { + CONF_VALUE *v,vv; + char *p; + + if (name == NULL) return(NULL); + if (conf != NULL) + { + if (section != NULL) + { + vv.name=name; + vv.section=section; + v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + if (v != NULL) return(v->value); + if (strcmp(section,"ENV") == 0) + { + p=Getenv(name); + if (p != NULL) return(p); + } + } + vv.section="default"; + vv.name=name; + v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + if (v != NULL) + return(v->value); + else + return(NULL); + } + else + return(Getenv(name)); + } + +static CONF_VALUE *get_section(conf,section) +LHASH *conf; +char *section; + { + CONF_VALUE *v,vv; + + if ((conf == NULL) || (section == NULL)) return(NULL); + vv.name=NULL; + vv.section=section; + v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + return(v); + } + +STACK *CONF_get_section(conf,section) +LHASH *conf; +char *section; + { + CONF_VALUE *v; + + v=get_section(conf,section); + if (v != NULL) + return((STACK *)v->value); + else + return(NULL); + } + +long CONF_get_number(conf,section,name) +LHASH *conf; +char *section; +char *name; + { + char *str; + long ret=0; + + str=CONF_get_string(conf,section,name); + if (str == NULL) return(0); + for (;;) + { + if (IS_NUMER(*str)) + ret=ret*10+(*str -'0'); + else + return(ret); + str++; + } + } + +void CONF_free(conf) +LHASH *conf; + { + if (conf == NULL) return; + + conf->down_load=0; /* evil thing to make sure the 'Free()' + * works as expected */ + lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf); + + /* We now have only 'section' entries in the hash table. + * Due to problems with */ + + lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf); + lh_free(conf); + } + +static void value_free_hash(a,conf) +CONF_VALUE *a; +LHASH *conf; + { + if (a->name != NULL) + { + a=(CONF_VALUE *)lh_delete(conf,(char *)a); + } + } + +static void value_free_stack(a,conf) +CONF_VALUE *a; +LHASH *conf; + { + CONF_VALUE *vv; + STACK *sk; + int i; + + if (a->name != NULL) return; + + sk=(STACK *)a->value; + for (i=sk_num(sk)-1; i>=0; i--) + { + vv=(CONF_VALUE *)sk_value(sk,i); + Free(vv->value); + Free(vv->name); + Free(vv); + } + if (sk != NULL) sk_free(sk); + Free(a->section); + Free(a); + } + +static void clear_comments(p) +char *p; + { + char *to; + + to=p; + for (;;) + { + if (IS_COMMENT(*p)) + { + *p='\0'; + return; + } + if (IS_QUOTE(*p)) + { + p=scan_quote(p); + continue; + } + if (IS_ESC(*p)) + { + p=scan_esc(p); + continue; + } + if (IS_EOF(*p)) + return; + else + p++; + } + } + +static int str_copy(conf,section,pto,from) +LHASH *conf; +char *section; +char **pto,*from; + { + int q,r,rr=0,to=0,len=0; + char *s,*e,*rp,*p,*rrp,*np,*cp,v; + BUF_MEM *buf; + + if ((buf=BUF_MEM_new()) == NULL) return(0); + + len=strlen(from)+1; + if (!BUF_MEM_grow(buf,len)) goto err; + + for (;;) + { + if (IS_QUOTE(*from)) + { + q= *from; + from++; + while ((*from != '\0') && (*from != q)) + { + if (*from == '\\') + { + from++; + if (*from == '\0') break; + } + buf->data[to++]= *(from++); + } + } + else if (*from == '\\') + { + from++; + v= *(from++); + if (v == '\0') break; + else if (v == 'r') v='\r'; + else if (v == 'n') v='\n'; + else if (v == 'b') v='\b'; + else if (v == 't') v='\t'; + buf->data[to++]= v; + } + else if (*from == '\0') + break; + else if (*from == '$') + { + /* try to expand it */ + rrp=NULL; + s= &(from[1]); + if (*s == '{') + q='}'; + else if (*s == '(') + q=')'; + else q=0; + + if (q) s++; + cp=section; + e=np=s; + while (IS_ALPHA_NUMERIC(*e)) + e++; + if ((e[0] == ':') && (e[1] == ':')) + { + cp=np; + rrp=e; + rr= *e; + *rrp='\0'; + e+=2; + np=e; + while (IS_ALPHA_NUMERIC(*e)) + e++; + } + r= *e; + *e='\0'; + rp=e; + if (q) + { + if (r != q) + { + CONFerr(CONF_F_STR_COPY,CONF_R_NO_CLOSE_BRACE); + goto err; + } + e++; + } + /* So at this point we have + * ns which is the start of the name string which is + * '\0' terminated. + * cs which is the start of the section string which is + * '\0' terminated. + * e is the 'next point after'. + * r and s are the chars replaced by the '\0' + * rp and sp is where 'r' and 's' came from. + */ + p=CONF_get_string(conf,cp,np); + if (rrp != NULL) *rrp=rr; + *rp=r; + if (p == NULL) + { + CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE); + goto err; + } + BUF_MEM_grow(buf,(strlen(p)+len-(e-from))); + while (*p) + buf->data[to++]= *(p++); + from=e; + } + else + buf->data[to++]= *(from++); + } + buf->data[to]='\0'; + if (*pto != NULL) Free(*pto); + *pto=buf->data; + Free(buf); + return(1); +err: + if (buf != NULL) BUF_MEM_free(buf); + return(0); + } + +static char *eat_ws(p) +char *p; + { + while (IS_WS(*p) && (!IS_EOF(*p))) + p++; + return(p); + } + +static char *eat_alpha_numeric(p) +char *p; + { + for (;;) + { + if (IS_ESC(*p)) + { + p=scan_esc(p); + continue; + } + if (!IS_ALPHA_NUMERIC_PUNCT(*p)) + return(p); + p++; + } + } + +static unsigned long hash(v) +CONF_VALUE *v; + { + return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); + } + +static int cmp(a,b) +CONF_VALUE *a,*b; + { + int i; + + if (a->section != b->section) + { + i=strcmp(a->section,b->section); + if (i) return(i); + } + + if ((a->name != NULL) && (b->name != NULL)) + { + i=strcmp(a->name,b->name); + return(i); + } + else if (a->name == b->name) + return(0); + else + return((a->name == NULL)?-1:1); + } + +static char *scan_quote(p) +char *p; + { + int q= *p; + + p++; + while (!(IS_EOF(*p)) && (*p != q)) + { + if (IS_ESC(*p)) + { + p++; + if (IS_EOF(*p)) return(p); + } + p++; + } + if (*p == q) p++; + return(p); + } + +static CONF_VALUE *new_section(conf,section) +LHASH *conf; +char *section; + { + STACK *sk=NULL; + int ok=0,i; + CONF_VALUE *v=NULL,*vv; + + if ((sk=sk_new_null()) == NULL) + goto err; + if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL) + goto err; + i=strlen(section)+1; + if ((v->section=(char *)Malloc(i)) == NULL) + goto err; + + memcpy(v->section,section,i); + v->name=NULL; + v->value=(char *)sk; + + vv=(CONF_VALUE *)lh_insert(conf,(char *)v); + if (vv != NULL) + { +#if !defined(NO_STDIO) && !defined(WIN16) + fprintf(stderr,"internal fault\n"); +#endif + abort(); + } + ok=1; +err: + if (!ok) + { + if (sk != NULL) sk_free(sk); + if (v != NULL) Free(v); + v=NULL; + } + return(v); + } diff --git a/src/lib/libcrypto/conf/conf.err b/src/lib/libcrypto/conf/conf.err new file mode 100644 index 0000000000..933d3d692a --- /dev/null +++ b/src/lib/libcrypto/conf/conf.err @@ -0,0 +1,12 @@ +/* Error codes for the CONF functions. */ + +/* Function codes. */ +#define CONF_F_CONF_LOAD 100 +#define CONF_F_STR_COPY 101 + +/* Reason codes. */ +#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +#define CONF_R_MISSING_EQUAL_SIGN 101 +#define CONF_R_NO_CLOSE_BRACE 102 +#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +#define CONF_R_VARIABLE_HAS_NO_VALUE 104 diff --git a/src/lib/libcrypto/conf/conf_lcl.h b/src/lib/libcrypto/conf/conf_lcl.h new file mode 100644 index 0000000000..4e5644ed79 --- /dev/null +++ b/src/lib/libcrypto/conf/conf_lcl.h @@ -0,0 +1,102 @@ +/* crypto/conf/conf_lcl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#define CONF_NUMBER 1 +#define CONF_UPPER 2 +#define CONF_LOWER 4 +#define CONF_UNDER 256 +#define CONF_PUNCTUATION 512 +#define CONF_WS 16 +#define CONF_ESC 32 +#define CONF_QUOTE 64 +#define CONF_COMMENT 128 +#define CONF_EOF 8 +#define CONF_ALPHA (CONF_UPPER|CONF_LOWER) +#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) +#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \ + CONF_PUNCTUATION) + +#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f])) +#define IS_EOF(a) ((a) == '\0') +#define IS_ESC(a) ((a) == '\\') +#define IS_NUMER(a) (CONF_type[(a)&0x7f]&CONF_NUMBER) +#define IS_WS(a) (CONF_type[(a)&0x7f]&CONF_WS) +#define IS_ALPHA_NUMERIC(a) (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC) +#define IS_ALPHA_NUMERIC_PUNCT(a) \ + (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) +#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE) + +static unsigned short CONF_type[128]={ + 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000, + 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000, + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, + 0x010,0x200,0x040,0x080,0x000,0x200,0x200,0x040, + 0x000,0x000,0x200,0x200,0x200,0x200,0x200,0x200, + 0x001,0x001,0x001,0x001,0x001,0x001,0x001,0x001, + 0x001,0x001,0x000,0x200,0x000,0x000,0x000,0x200, + 0x200,0x002,0x002,0x002,0x002,0x002,0x002,0x002, + 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, + 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, + 0x002,0x002,0x002,0x000,0x020,0x000,0x200,0x100, + 0x040,0x004,0x004,0x004,0x004,0x004,0x004,0x004, + 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, + 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, + 0x004,0x004,0x004,0x000,0x200,0x000,0x200,0x000, + }; + diff --git a/src/lib/libcrypto/cryptall.h b/src/lib/libcrypto/cryptall.h new file mode 100644 index 0000000000..65a46452a8 --- /dev/null +++ b/src/lib/libcrypto/cryptall.h @@ -0,0 +1,110 @@ +/* crypto/cryptall.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CRYPTOALL_H +#define HEADER_CRYPTOALL_H + +#include "buffer.h" +#include "stack.h" +#include "lhash.h" + +#include "err.h" + +#ifdef NO_MD2 +#include +#else +#include "md2.h" +#endif +#ifdef NO_MD5 +#include +#else +#include "md5.h" +#endif +#include "sha.h" + +#ifdef NO_DES +#include +#else +#include "des.h" +#endif +#include "rc2.h" +#include "rc4.h" +#include "idea.h" + +#include "bn.h" +#include "dh.h" +#include "rsa.h" +#include "dsa.h" + +#include "rand.h" +#include "conf.h" +#include "txt_db.h" + +#include "err.h" +#include "evp.h" + +#include "meth.h" +#include "x509.h" +#include "pkcs7.h" +#include "pem.h" +#include "asn1.h" +#include "objects.h" + +#include "crypto.h" + +#endif 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 @@ +/* crypto/crypto.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* If you are happy to use the assmbler version of bn/bn_mulw.c, define + * BN_ASM */ +#ifndef BN_ASM +#undef BN_ASM +#define X86_ASM +#endif + +#ifndef DES_ASM +#undef DES_ASM +#endif + +#ifndef BF_ASM +#undef BF_ASM +#endif + +/* The following defines are only to break the compiles into chunks. + * If you wish to not compile some sections, use the 'NO_XXX' macros + */ +#ifndef CRYPTO_SUBSET +/* Define all subset symbols. */ +#define CRYPTO_LIB_SUBSET +#define CRYPTO_ASN1_SUBSET +#define CRYPTO_BN_SUBSET +#define CRYPTO_BUFFER_SUBSET +#define CRYPTO_BIO_SUBSET +#define CRYPTO_CONF_SUBSET +#define CRYPTO_DES_SUBSET +#define CRYPTO_DH_SUBSET +#define CRYPTO_DSA_SUBSET +#define CRYPTO_ERROR_SUBSET +#define CRYPTO_EVP_SUBSET +#define CRYPTO_IDEA_SUBSET +#define CRYPTO_LHASH_SUBSET +#define CRYPTO_MD_SUBSET +#define CRYPTO_MDC2_SUBSET +#define CRYPTO_METH_SUBSET +#define CRYPTO_OBJECTS_SUBSET +#define CRYPTO_PEM_SUBSET +#define CRYPTO_RAND_SUBSET +#define CRYPTO_RC_SUBSET +#define CRYPTO_BLOWFISH_SUBSET +#define CRYPTO_CAST_SUBSET +#define CRYPTO_RSA_SUBSET +#define CRYPTO_SHA_SUBSET +#define CRYPTO_HMAC_SUBSET +#define CRYPTO_SHA1_SUBSET +#define CRYPTO_STACK_SUBSET +#define CRYPTO_TXT_DB_SUBSET +#define CRYPTO_X509_SUBSET +#define CRYPTO_PKCS7_SUBSET +#endif + +#include +#include +#include + +#define USE_SOCKETS +#include "../e_os.h" + +#include "buffer.h" +#include "bio.h" +#include "stack.h" +#include "lhash.h" + +#include "err.h" + +#include "bn.h" +#include "evp.h" + +#include "rand.h" +#include "conf.h" +#include "txt_db.h" + +#include "x509.h" +#include "pkcs7.h" +#include "pem.h" +#include "asn1.h" +#include "objects.h" + +#ifdef CRYPTO_LIB_SUBSET +#include "cryptlib.c" +#include "mem.c" +#include "cversion.c" +#endif + +#ifdef CRYPTO_ASN1_SUBSET +#include "asn1/a_meth.c" +#include "asn1/a_bitstr.c" +#include "asn1/a_d2i_fp.c" +#include "asn1/a_dup.c" +#include "asn1/a_hdr.c" +#include "asn1/a_i2d_fp.c" +#include "asn1/a_int.c" +#include "asn1/a_bool.c" +#include "asn1/a_bytes.c" +#include "asn1/a_object.c" +#include "asn1/a_octet.c" +#include "asn1/a_print.c" +#include "asn1/a_set.c" +#include "asn1/a_sign.c" +#include "asn1/a_type.c" +#include "asn1/a_utctm.c" +#include "asn1/a_verify.c" +#include "asn1/a_digest.c" +#include "asn1/asn1_err.c" +#include "asn1/asn1_lib.c" +#include "asn1/asn1_par.c" +#ifndef NO_DH +#include "asn1/d2i_dhp.c" +#include "asn1/i2d_dhp.c" +#endif +#ifndef NO_DSA +#include "asn1/d2i_dsap.c" +#include "asn1/i2d_dsap.c" +#include "asn1/d2i_s_pr.c" +#include "asn1/i2d_s_pr.c" +#include "asn1/d2i_s_pu.c" +#include "asn1/i2d_s_pu.c" +#endif +#ifndef NO_RSA +#include "asn1/d2i_r_pr.c" +#include "asn1/i2d_r_pr.c" +#include "asn1/d2i_r_pu.c" +#include "asn1/i2d_r_pu.c" +#include "asn1/n_pkey.c" +#endif +#include "asn1/d2i_pr.c" +#include "asn1/d2i_pu.c" +#include "asn1/i2d_pr.c" +#include "asn1/i2d_pu.c" +#include "asn1/f_int.c" +#include "asn1/f_string.c" +#include "asn1/p7_dgst.c" +#include "asn1/p7_enc.c" +#include "asn1/p7_enc_c.c" +#include "asn1/p7_evp.c" +#include "asn1/p7_i_s.c" +#include "asn1/p7_lib.c" +#include "asn1/p7_recip.c" +#include "asn1/p7_s_e.c" +#include "asn1/p7_signd.c" +#include "asn1/p7_signi.c" +#include "asn1/t_pkey.c" +#include "asn1/t_req.c" +#include "asn1/t_x509.c" +#include "asn1/x_algor.c" +#include "asn1/x_attrib.c" +#include "asn1/x_exten.c" +#include "asn1/x_cinf.c" +#include "asn1/x_crl.c" +#include "asn1/x_info.c" +#include "asn1/x_name.c" +#include "asn1/x_pkey.c" +#include "asn1/x_pubkey.c" +#include "asn1/x_req.c" +#include "asn1/x_sig.c" +#include "asn1/x_spki.c" +#include "asn1/x_val.c" +#include "asn1/x_x509.c" +#endif + +#ifdef CRYPTO_BN_SUBSET +#include "bn/bn_add.c" +#include "bn/bn_div.c" +#include "bn/bn_exp.c" +#include "bn/bn_mont.c" +#include "bn/bn_recp.c" +#include "bn/bn_gcd.c" +#include "bn/bn_lib.c" +#include "bn/bn_mod.c" +#include "bn/bn_mul.c" +#ifndef BN_ASM +#include "bn/bn_mulw.c" +#endif +#include "bn/bn_prime.c" +#include "bn/bn_rand.c" +#include "bn/bn_shift.c" +#include "bn/bn_sqr.c" +#include "bn/bn_sub.c" +#include "bn/bn_word.c" +#include "bn/bn_print.c" +#include "bn/bn_err.c" +#include "bn/bn_blind.c" +#endif + +#ifdef CRYPTO_BIO_SUBSET +#include "bio/bf_buff.c" +#include "bio/bf_null.c" +#include "bio/bf_nbio.c" +#include "bio/bio_cb.c" +#include "bio/bio_lib.c" +#include "bio/bss_fd.c" +#include "bio/bss_file.c" +#include "bio/bss_mem.c" +#include "bio/bss_null.c" +#ifdef VMS +#include "bio/bss_rtcp.c" +#endif +#include "bio/bss_sock.c" +#include "bio/bss_conn.c" +#include "bio/bss_acpt.c" +#include "bio/b_sock.c" +#include "bio/b_print.c" +#include "bio/b_dump.c" +#include "bio/bio_err.c" +#endif + +#ifdef CRYPTO_BUFFER_SUBSET +#include "buffer/buf_err.c" +#include "buffer/buffer.c" +#endif + +#ifdef CRYPTO_CONF_SUBSET +#include "conf/conf.c" +#include "conf/conf_err.c" +#endif + +#ifdef CRYPTO_DES_SUBSET +#include "des/read_pwd.c" +#ifndef NO_DES +#ifndef DES_ASM +#include "des/fcrypt_b.c" +#include "des/des_enc.c" +#endif +#include "des/cbc_cksm.c" +#include "des/xcbc_enc.c" +#include "des/cbc_enc.c" +#include "des/cfb64ede.c" +#include "des/cfb64enc.c" +#include "des/cfb_enc.c" +#include "des/ecb3_enc.c" +#include "des/ecb_enc.c" +#include "des/enc_read.c" +#include "des/enc_writ.c" +#include "des/fcrypt.c" +#include "des/ofb64ede.c" +#include "des/ofb64enc.c" +#include "des/ofb_enc.c" +#include "des/pcbc_enc.c" +#include "des/qud_cksm.c" +#include "des/rand_key.c" +#include "des/read2pwd.c" +#include "des/rpc_enc.c" +#include "des/set_key.c" +#include "des/str2key.c" +#include "des/supp.c" +#endif +#endif + +#ifdef CRYPTO_DH_SUBSET +#ifndef NO_DH +#include "dh/dh_check.c" +#include "dh/dh_err.c" +#include "dh/dh_gen.c" +#include "dh/dh_key.c" +#include "dh/dh_lib.c" +#endif +#endif + +#ifdef CRYPTO_DSA_SUBSET +#ifndef NO_DSA +#include "dsa/dsa_gen.c" +#include "dsa/dsa_key.c" +#include "dsa/dsa_lib.c" +#include "dsa/dsa_sign.c" +#include "dsa/dsa_vrf.c" +#include "dsa/dsa_err.c" +#endif +#endif + +#ifdef CRYPTO_ERROR_SUBSET +#include "err/err.c" +#include "err/err_all.c" +#include "err/err_prn.c" +#endif + +#ifdef CRYPTO_EVP_SUBSET +#include "evp/bio_md.c" +#include "evp/bio_b64.c" +#include "evp/bio_enc.c" +#include "evp/c_all.c" +#include "evp/digest.c" +#ifndef NO_DES +#include "evp/e_cbc_3d.c" +#include "evp/e_cfb_3d.c" +#include "evp/e_ecb_3d.c" +#include "evp/e_ofb_3d.c" +#include "evp/e_cbc_d.c" +#include "evp/e_cfb_d.c" +#include "evp/e_xcbc_d.c" +#include "evp/e_ecb_d.c" +#include "evp/e_ofb_d.c" +#endif +#ifndef NO_IDEA +#include "evp/e_cbc_i.c" +#include "evp/e_cfb_i.c" +#include "evp/e_ecb_i.c" +#include "evp/e_ofb_i.c" +#endif +#ifndef NO_RC2 +#include "evp/e_cbc_r2.c" +#include "evp/e_cfb_r2.c" +#include "evp/e_ecb_r2.c" +#include "evp/e_ofb_r2.c" +#endif +#ifndef NO_BLOWFISH +#include "evp/e_cbc_bf.c" +#include "evp/e_cfb_bf.c" +#include "evp/e_ecb_bf.c" +#include "evp/e_ofb_bf.c" +#endif +#ifndef NO_CAST +#include "evp/e_cbc_c.c" +#include "evp/e_cfb_c.c" +#include "evp/e_ecb_c.c" +#include "evp/e_ofb_c.c" +#endif +#ifndef NO_RC4 +#include "evp/e_rc4.c" +#endif +#include "rc5/rc5_enc.c" +#include "rc5/rc5cfb64.c" +#include "rc5/rc5_ecb.c" +#include "rc5/rc5_skey.c" +#include "rc5/rc5ofb64.c" +#include "ripemd/rmd160.c" +#include "ripemd/rmd_dgst.c" +#include "ripemd/rmd_one.c" +#include "evp/evp_lib.c" + +#include "evp/names.c" +#include "evp/e_null.c" +#include "evp/encode.c" +#include "evp/evp_enc.c" +#include "evp/evp_err.c" +#include "evp/evp_key.c" +#include "evp/m_null.c" +#include "evp/p_lib.c" +#ifndef NO_RSA +#include "evp/p_open.c" +#include "evp/p_seal.c" +#endif +#include "evp/p_sign.c" +#include "evp/p_verify.c" +#endif + +#ifdef CRYPTO_IDEA_SUBSET +#ifndef NO_IDEA +#include "idea/i_cbc.c" +#include "idea/i_cfb64.c" +#include "idea/i_ecb.c" +#include "idea/i_ofb64.c" +#include "idea/i_skey.c" +#endif +#endif + +#ifdef CRYPTO_BLOWFISH_SUBSET +#ifndef NO_BLOWFISH +#include "bf/bf_cfb64.c" +#include "bf/bf_ecb.c" +#ifndef BF_ASM +#include "bf/bf_enc.c" +#endif +#include "bf/bf_ofb64.c" +#include "bf/bf_skey.c" +#endif +#endif + +#ifdef CRYPTO_CAST_SUBSET +#ifndef NO_CAST +#include "cast/c_cfb64.c" +#include "cast/c_ecb.c" +#ifndef CAST_ASM +#include "cast/c_enc.c" +#endif +#include "cast/c_ofb64.c" +#include "cast/c_skey.c" +#endif +#endif + +#ifdef CRYPTO_LHASH_SUBSET +#include "lhash/lh_stats.c" +#include "lhash/lhash.c" +#endif + +#ifdef CRYPTO_MD_SUBSET +#ifndef NO_MD2 +#include "md2/md2_dgst.c" +#include "md2/md2_one.c" +#include "evp/m_md2.c" +#endif +#ifndef NO_MD5 +#include "md5/md5_dgst.c" +#include "md5/md5_one.c" +#include "evp/m_md5.c" +#endif +#endif + +#ifdef CRYPTO_MDC2_SUBSET +#ifndef NO_MDC2 +#include "mdc2/mdc2dgst.c" +#include "mdc2/mdc2_one.c" +#include "evp/m_mdc2.c" +#endif +#endif + +#ifdef CRYPTO_OBJECTS_SUBSET +#include "objects/obj_dat.c" +#include "objects/obj_err.c" +#include "objects/obj_lib.c" +#endif + +#ifdef CRYPTO_PEM_SUBSET +#include "pem/pem_err.c" +#include "pem/pem_info.c" +#include "pem/pem_lib.c" +#include "pem/pem_all.c" +#ifndef NO_RSA +#include "pem/pem_seal.c" +#include "pem/pem_sign.c" +#endif +#endif + +#ifdef CRYPTO_RAND_SUBSET +#include "rand/md_rand.c" +#include "rand/randfile.c" +#endif + +#ifdef CRYPTO_RC_SUBSET +#ifndef NO_RC2 +#include "rc2/rc2_cbc.c" +#include "rc2/rc2_ecb.c" +#include "rc2/rc2_skey.c" +#include "rc2/rc2cfb64.c" +#include "rc2/rc2ofb64.c" +#endif +#ifndef NO_RC4 +#include "rc4/rc4_skey.c" +#ifndef RC4_ASM +#include "rc4/rc4_enc.c" +#endif +#endif +#endif + +#ifdef CRYPTO_HMAC_SUBSET +#include "hmac/hmac.c" +#endif + +#ifdef CRYPTO_RSA_SUBSET +#ifndef NO_RSA +#include "rsa/rsa_eay.c" +#include "rsa/rsa_err.c" +#include "rsa/rsa_gen.c" +#include "rsa/rsa_lib.c" +#include "rsa/rsa_sign.c" +#include "rsa/rsa_saos.c" +#endif +#endif + +#ifdef CRYPTO_SHA1_SUBSET +#ifndef NO_SHA1 +#include "sha/sha1_one.c" +#include "sha/sha1dgst.c" +#include "evp/m_dss1.c" +#include "evp/m_sha1.c" +#endif +#endif + +#ifdef CRYPTO_SHA_SUBSET +#ifndef NO_SHA +#include "evp/m_dss.c" +#include "sha/sha_dgst.c" +#include "sha/sha_one.c" +#include "evp/m_sha.c" +#endif +#endif + +#ifdef CRYPTO_STACK_SUBSET +#include "stack/stack.c" +#endif + +#ifdef CRYPTO_TXT_DB_SUBSET +#include "txt_db/txt_db.c" +#endif + +#ifdef CRYPTO_X509_SUBSET +#include "x509/x509_cmp.c" +#include "x509/x509_d2.c" +#include "x509/x509_def.c" +#include "x509/x509_err.c" +#include "x509/x509_ext.c" +#include "x509/x509_lu.c" +#include "x509/x509_obj.c" +#include "x509/x509_r2x.c" +#include "x509/x509_req.c" +#include "x509/x509_set.c" +#include "x509/x509_v3.c" +#include "x509/x509_vfy.c" +#include "x509/x509name.c" +#include "x509/x509pack.c" +#include "x509/x509rset.c" +#include "x509/x509type.c" +#include "x509/x_all.c" +#include "x509/x509_txt.c" +#include "x509/by_dir.c" +#include "x509/by_file.c" +#include "x509/v3_net.c" +#include "x509/v3_x509.c" +#endif + + +#ifdef CRYPTO_PKCS7_SUBSET /* I have an explicit removal of 7 lines */ +#include "pkcs7/pk7_lib.c" +#include "pkcs7/pkcs7err.c" +#include "pkcs7/pk7_doit.c" +#endif /* CRYPTO_PKCS7_SUBSET */ + diff --git a/src/lib/libcrypto/crypto.err b/src/lib/libcrypto/crypto.err new file mode 100644 index 0000000000..4ea3385e73 --- /dev/null +++ b/src/lib/libcrypto/crypto.err @@ -0,0 +1,8 @@ +/* Error codes for the CRYPTO functions. */ + +/* Function codes. */ +#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 +#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 + +/* Reason codes. */ diff --git a/src/lib/libcrypto/date.h b/src/lib/libcrypto/date.h new file mode 100644 index 0000000000..dbb71bd1b7 --- /dev/null +++ b/src/lib/libcrypto/date.h @@ -0,0 +1 @@ +#define DATE "Sun Jul 12 21:04:32 MDT 1998" diff --git a/src/lib/libcrypto/des/DES.pod b/src/lib/libcrypto/des/DES.pod new file mode 100644 index 0000000000..8a739e7ca0 --- /dev/null +++ b/src/lib/libcrypto/des/DES.pod @@ -0,0 +1,16 @@ +crypt <= crypt(buf,salt) +key <= set_odd_parity(key) +int <= is_weak_key(key) +keysched<= set_key(key) +key <= ecb_encrypt(string8,ks,enc) +key <= ecb3_encrypt(input,ks1,ks2,enc) +string <= cbc_encrypt(input,ks,ivec,enc) => ivec +string <= cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,enc) => ivec1&ivec2 +ck1,ck2 <= cbc_cksum(input,ks,ivec) => ivec +string <= pcbc_encrypt(input,ks,ivec,enc) => ivec +string <= ofb_encrypt(input,numbits,ks,ivec) => ivec +string <= cfb_encrypt(input,numbits,ks,ivec,enc) => ivec +key <= random_key() +key <= string_to_key(string) +key1,key2<= string_to_2keys(string) + diff --git a/src/lib/libcrypto/des/FILES b/src/lib/libcrypto/des/FILES new file mode 100644 index 0000000000..4c7ea2de7a --- /dev/null +++ b/src/lib/libcrypto/des/FILES @@ -0,0 +1,96 @@ +/* General stuff */ +COPYRIGHT - Copyright info. +MODES.DES - A description of the features of the different modes of DES. +FILES - This file. +INSTALL - How to make things compile. +Imakefile - For use with kerberos. +README - What this package is. +VERSION - Which version this is and what was changed. +KERBEROS - Kerberos version 4 notes. +Makefile.PL - An old makefile to build with perl5, not current. +Makefile.ssl - The SSLeay makefile +Makefile.uni - The normal unix makefile. +GNUmakefile - The makefile for use with glibc. +makefile.bc - A Borland C makefile +times - Some outputs from 'speed' on some machines. +vms.com - For use when compiling under VMS + +/* My SunOS des(1) replacement */ +des.c - des(1) source code. +des.man - des(1) manual. + +/* Testing and timing programs. */ +destest.c - Source for libdes.a test program. +speed.c - Source for libdes.a timing program. +rpw.c - Source for libdes.a testing password reading routines. + +/* libdes.a source code */ +des_crypt.man - libdes.a manual page. +des.h - Public libdes.a header file. +ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code. +ecb3_enc.c - des_ecb3_encrypt() source. +cbc_ckm.c - des_cbc_cksum() source. +cbc_enc.c - des_cbc_encrypt() source. +ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies + the new iv values back in the passed iv vector. +ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES. +cbc3_enc.c - des_3cbc_encrypt() source, don't use this function. +cfb_enc.c - des_cfb_encrypt() source. +cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be + used as a stream cipher. +cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be + used as a stream cipher and using triple DES. +ofb_enc.c - des_cfb_encrypt() source. +ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be + used as a stream cipher. +ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be + used as a stream cipher and using triple DES. +enc_read.c - des_enc_read() source. +enc_writ.c - des_enc_write() source. +pcbc_enc.c - des_pcbc_encrypt() source. +qud_cksm.c - quad_cksum() source. +rand_key.c - des_random_key() source. +read_pwd.c - Source for des_read_password() plus related functions. +set_key.c - Source for des_set_key(). +str2key.c - Covert a string of any length into a key. +fcrypt.c - A small, fast version of crypt(3). +des_locl.h - Internal libdes.a header file. +podd.h - Odd parity tables - used in des_set_key(). +sk.h - Lookup tables used in des_set_key(). +spr.h - What is left of the S tables - used in ecb_encrypt(). +des_ver.h - header file for the external definition of the + version string. +des.doc - SSLeay documentation for the library. + +/* The perl scripts - you can ignore these files they are only + * included for the curious */ +des.pl - des in perl anyone? des_set_key and des_ecb_encrypt + both done in a perl library. +testdes.pl - Testing program for des.pl +doIP - Perl script used to develop IP xor/shift code. +doPC1 - Perl script used to develop PC1 xor/shift code. +doPC2 - Generates sk.h. +PC1 - Output of doPC1 should be the same as output from PC1. +PC2 - used in development of doPC2. +shifts.pl - Perl library used by my perl scripts. + +/* I started making a perl5 dynamic library for libdes + * but did not fully finish, these files are part of that effort. */ +DES.pm +DES.pod +DES.xs +t +typemap + +/* The following are for use with sun RPC implementaions. */ +rpc_des.h +rpc_enc.c + +/* The following are contibuted by Mark Murray . They + * are not normally built into libdes due to machine specific routines + * contained in them. They are for use in the most recent incarnation of + * export kerberos v 4 (eBones). */ +supp.c +new_rkey.c + + diff --git a/src/lib/libcrypto/des/MODES.DES b/src/lib/libcrypto/des/MODES.DES new file mode 100644 index 0000000000..0cbc44f51d --- /dev/null +++ b/src/lib/libcrypto/des/MODES.DES @@ -0,0 +1,84 @@ +Modes of DES +Quite a bit of the following information has been taken from + AS 2805.5.2 + Australian Standard + Electronic funds transfer - Requirements for interfaces, + Part 5.2: Modes of operation for an n-bit block cipher algorithm + Appendix A + +There are several different modes in which DES can be used, they are +as follows. + +Electronic Codebook Mode (ECB) (des_ecb_encrypt()) +- 64 bits are enciphered at a time. +- The order of the blocks can be rearranged without detection. +- The same plaintext block always produces the same ciphertext block + (for the same key) making it vulnerable to a 'dictionary attack'. +- An error will only affect one ciphertext block. + +Cipher Block Chaining Mode (CBC) (des_cbc_encrypt()) +- a multiple of 64 bits are enciphered at a time. +- The CBC mode produces the same ciphertext whenever the same + plaintext is encrypted using the same key and starting variable. +- The chaining operation makes the ciphertext blocks dependent on the + current and all preceding plaintext blocks and therefore blocks can not + be rearranged. +- The use of different starting variables prevents the same plaintext + enciphering to the same ciphertext. +- An error will affect the current and the following ciphertext blocks. + +Cipher Feedback Mode (CFB) (des_cfb_encrypt()) +- a number of bits (j) <= 64 are enciphered at a time. +- The CFB mode produces the same ciphertext whenever the same + plaintext is encrypted using the same key and starting variable. +- The chaining operation makes the ciphertext variables dependent on the + current and all preceding variables and therefore j-bit variables are + chained together and con not be rearranged. +- The use of different starting variables prevents the same plaintext + enciphering to the same ciphertext. +- The strength of the CFB mode depends on the size of k (maximal if + j == k). In my implementation this is always the case. +- Selection of a small value for j will require more cycles through + the encipherment algorithm per unit of plaintext and thus cause + greater processing overheads. +- Only multiples of j bits can be enciphered. +- An error will affect the current and the following ciphertext variables. + +Output Feedback Mode (OFB) (des_ofb_encrypt()) +- a number of bits (j) <= 64 are enciphered at a time. +- The OFB mode produces the same ciphertext whenever the same + plaintext enciphered using the same key and starting variable. More + over, in the OFB mode the same key stream is produced when the same + key and start variable are used. Consequently, for security reasons + a specific start variable should be used only once for a given key. +- The absence of chaining makes the OFB more vulnerable to specific attacks. +- The use of different start variables values prevents the same + plaintext enciphering to the same ciphertext, by producing different + key streams. +- Selection of a small value for j will require more cycles through + the encipherment algorithm per unit of plaintext and thus cause + greater processing overheads. +- Only multiples of j bits can be enciphered. +- OFB mode of operation does not extend ciphertext errors in the + resultant plaintext output. Every bit error in the ciphertext causes + only one bit to be in error in the deciphered plaintext. +- OFB mode is not self-synchronising. If the two operation of + encipherment and decipherment get out of synchronism, the system needs + to be re-initialised. +- Each re-initialisation should use a value of the start variable +different from the start variable values used before with the same +key. The reason for this is that an identical bit stream would be +produced each time from the same parameters. This would be +susceptible to a 'known plaintext' attack. + +Triple ECB Mode (des_ecb3_encrypt()) +- Encrypt with key1, decrypt with key2 and encrypt with key1 again. +- As for ECB encryption but increases the effective key length to 112 bits. +- If both keys are the same it is equivalent to encrypting once with + just one key. + +Triple CBC Mode (des_3cbc_encrypt()) +- Encrypt with key1, decrypt with key2 and encrypt with key1 again. +- As for CBC encryption but increases the effective key length to 112 bits. +- If both keys are the same it is equivalent to encrypting once with + just one key. diff --git a/src/lib/libcrypto/des/Makefile.PL b/src/lib/libcrypto/des/Makefile.PL new file mode 100644 index 0000000000..b54a24387c --- /dev/null +++ b/src/lib/libcrypto/des/Makefile.PL @@ -0,0 +1,14 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile being created. +&writeMakefile( + 'potential_libs' => '', # e.g., '-lm' + 'INC' => '', # e.g., '-I/usr/include/other' + 'DISTNAME' => 'DES', + 'VERSION' => '0.1', + 'DEFINE' => '-DPERL5', + 'OBJECT' => 'DES.o cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \ + rand_key.o set_key.o str2key.o \ + enc_read.o enc_writ.o fcrypt.o cfb_enc.o \ + ecb3_enc.o ofb_enc.o cbc3_enc.o des_enc.o', + ); diff --git a/src/lib/libcrypto/des/Makefile.lit b/src/lib/libcrypto/des/Makefile.lit new file mode 100644 index 0000000000..c09f6969da --- /dev/null +++ b/src/lib/libcrypto/des/Makefile.lit @@ -0,0 +1,250 @@ +# You must select the correct terminal control system to be used to +# turn character echo off when reading passwords. There a 5 systems +# SGTTY - the old BSD system +# TERMIO - most system V boxes +# TERMIOS - SGI (ala IRIX). +# VMS - the DEC operating system +# MSDOS - we all know what it is :-) +# read_pwd.c makes a reasonable guess at what is correct. + +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +# If you are on a DEC Alpha, edit des.h and change the DES_LONG +# define to 'unsigned int'. I have seen this give a %20 speedup. + +OPTS0= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST + +# Version 1.94 has changed the strings_to_key function so that it is +# now compatible with MITs when the string is longer than 8 characters. +# If you wish to keep the old version, uncomment the following line. +# This will affect the -E/-D options on des(1). +#OPTS1= -DOLD_STR_TO_KEY + +# There are 4 possible performance options +# -DDES_PTR +# -DDES_RISC1 +# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2) +# -DDES_UNROLL +# after the initial build, run 'des_opts' to see which options are best +# for your platform. There are some listed in options.txt +#OPTS2= -DDES_PTR +#OPTS3= -DDES_RISC1 # or DES_RISC2 +#OPTS4= -DDES_UNROLL + +OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4) + +MAKE=make -f Makefile +#CC=cc +#CFLAG= -O + +CC=gcc +#CFLAG= -O4 -funroll-loops -fomit-frame-pointer +CFLAG= -O3 -fomit-frame-pointer + +CFLAGS=$(OPTS) $(CFLAG) +CPP=$(CC) -E +AS=as + +# Assember version of des_encrypt*(). +DES_ENC=des_enc.o fcrypt_b.o # normal C version +#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86 +#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86 +#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86 +#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86 + +LIBDIR=/usr/local/lib +BINDIR=/usr/local/bin +INCDIR=/usr/local/include +MANDIR=/usr/local/man +MAN1=1 +MAN3=3 +SHELL=/bin/sh +OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o +OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \ + xcbc_enc.o qud_cksm.o \ + cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \ + enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \ + rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o + +GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \ + des.doc options.txt asm +GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \ + des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \ + Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \ + des.org des_locl.org +TESTING_LIT= destest speed des_opts +TESTING_FULL= rpw $(TESTING_LIT) +TESTING_SRC_LIT=destest.c speed.c des_opts.c +TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT) +HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h +HEADERS_FULL= $(HEADERS_LIT) rpc_des.h +LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c +LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \ + cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \ + enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \ + rand_key.c rpc_enc.c str2key.c supp.c \ + xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c + +PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl + +OBJ= $(OBJ_LIT) +GENERAL=$(GENERAL_LIT) +TESTING=$(TESTING_LIT) +TESTING_SRC=$(TESTING_SRC_LIT) +HEADERS=$(HEADERS_LIT) +LIBDES= $(LIBDES_LIT) + +ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS) + +DLIB= libdes.a + +all: $(DLIB) $(TESTING) + +cc: + $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all + +gcc: + $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all + +x86-elf: + $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all + +x86-out: + $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all + +x86-solaris: + $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all + +x86-bsdi: + $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all + +# elf +asm/dx86-elf.o: asm/dx86unix.cpp + $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o + +asm/yx86-elf.o: asm/yx86unix.cpp + $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o + +# solaris +asm/dx86-sol.o: asm/dx86unix.cpp + $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s + as -o asm/dx86-sol.o asm/dx86-sol.s + rm -f asm/dx86-sol.s + +asm/yx86-sol.o: asm/yx86unix.cpp + $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s + as -o asm/yx86-sol.o asm/yx86-sol.s + rm -f asm/yx86-sol.s + +# a.out +asm/dx86-out.o: asm/dx86unix.cpp + $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o + +asm/yx86-out.o: asm/yx86unix.cpp + $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o + +# bsdi +asm/dx86bsdi.o: asm/dx86unix.cpp + $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o + +asm/yx86bsdi.o: asm/yx86unix.cpp + $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o + +asm/dx86unix.cpp: + (cd asm; perl des-586.pl cpp >dx86unix.cpp) + +asm/yx86unix.cpp: + (cd asm; perl crypt586.pl cpp >yx86unix.cpp) + +test: all + ./destest + +$(DLIB): $(OBJ) + /bin/rm -f $(DLIB) + ar cr $(DLIB) $(OBJ) + -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \ + else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \ + else exit 0; fi; fi + +des_opts: des_opts.o $(DLIB) + $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB) + +destest: destest.o $(DLIB) + $(CC) $(CFLAGS) -o destest destest.o $(DLIB) + +rpw: rpw.o $(DLIB) + $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB) + +speed: speed.o $(DLIB) + $(CC) $(CFLAGS) -o speed speed.o $(DLIB) + +des: des.o $(DLIB) + $(CC) $(CFLAGS) -o des des.o $(DLIB) + +tags: + ctags $(TESTING_SRC) $(LIBDES) + +tar_lit: + /bin/mv Makefile Makefile.tmp + /bin/cp Makefile.lit Makefile + tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \ + $(GENERAL_LIT) $(TESTING_SRC_LIT) + /bin/rm -f Makefile + /bin/mv Makefile.tmp Makefile + +tar: + tar chf libdes.tar $(ALL) + +shar: + shar $(ALL) >libdes.shar + +depend: + makedepend $(LIBDES) $(TESTING_SRC) + +clean: + /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o + +dclean: + sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new + mv -f Makefile.new Makefile + +# Eric is probably going to choke when he next looks at this --tjh +install: + if test $(INSTALLTOP); then \ + echo SSL style install; \ + cp $(DLIB) $(INSTALLTOP)/lib; \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + fi; fi; \ + chmod 644 $(INSTALLTOP)/lib/$(DLIB); \ + cp des.h $(INSTALLTOP)/include; \ + chmod 644 $(INSTALLTOP)/include/des.h; \ + else \ + echo Standalone install; \ + cp $(DLIB) $(LIBDIR)/$(DLIB); \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(LIBDIR)/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(LIBDIR)/$(DLIB); \ + fi; \ + fi; \ + chmod 644 $(LIBDIR)/$(DLIB); \ + cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + cp des.h $(INCDIR)/des.h; \ + chmod 644 $(INCDIR)/des.h; \ + fi +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl new file mode 100644 index 0000000000..78b5189ee3 --- /dev/null +++ b/src/lib/libcrypto/des/Makefile.ssl @@ -0,0 +1,140 @@ +# +# SSLeay/crypto/des/Makefile +# + +DIR= des +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r +DES_ENC= des_enc.o fcrypt_b.o +# or use +#DES_ENC= dx86-elf.o yx86-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile des.org des_locl.org +TEST=destest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ + ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \ + fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ + qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ + des_enc.c fcrypt_b.c read2pwd.c \ + fcrypt.c xcbc_enc.c \ + str2key.c cfb64ede.c ofb64ede.c supp.c + +LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ + ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ + enc_read.o enc_writ.o ofb64enc.o \ + ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ + ${DES_ENC} read2pwd.o \ + fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o + +SRC= $(LIBSRC) + +EXHEADER= des.h +HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/dx86-elf.o: asm/dx86unix.cpp + $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o + +asm/yx86-elf.o: asm/yx86unix.cpp + $(CPP) -DELF asm/yx86unix.cpp | as -o asm/yx86-elf.o + +# solaris +asm/dx86-sol.o: asm/dx86unix.cpp + $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s + as -o asm/dx86-sol.o asm/dx86-sol.s + rm -f asm/dx86-sol.s + +asm/yx86-sol.o: asm/yx86unix.cpp + $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s + as -o asm/yx86-sol.o asm/yx86-sol.s + rm -f asm/yx86-sol.s + +# a.out +asm/dx86-out.o: asm/dx86unix.cpp + $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o + +asm/yx86-out.o: asm/yx86unix.cpp + $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o + +# bsdi +asm/dx86bsdi.o: asm/dx86unix.cpp + $(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o + +asm/yx86bsdi.o: asm/yx86unix.cpp + $(CPP) -DBSDI asm/yx86unix.cpp | as -o asm/yx86bsdi.o + +asm/dx86unix.cpp: + (cd asm; perl des-586.pl cpp >dx86unix.cpp) + +asm/yx86unix.cpp: + (cd asm; perl crypt586.pl cpp >yx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile + /bin/rm -f des.doc + /bin/rm -fr asm/perlasm + $(TOP)/util/point.sh ../../perlasm asm/perlasm + $(TOP)/util/point.sh ../../doc/des.doc des.doc + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: installs + +installs: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/des/Makefile.uni b/src/lib/libcrypto/des/Makefile.uni new file mode 100644 index 0000000000..8f1759748a --- /dev/null +++ b/src/lib/libcrypto/des/Makefile.uni @@ -0,0 +1,263 @@ +# You must select the correct terminal control system to be used to +# turn character echo off when reading passwords. There a 5 systems +# SGTTY - the old BSD system +# TERMIO - most system V boxes +# TERMIOS - SGI (ala IRIX). +# VMS - the DEC operating system +# MSDOS - we all know what it is :-) +# read_pwd.c makes a reasonable guess at what is correct. + +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +# If you are on a DEC Alpha, edit des.h and change the DES_LONG +# define to 'unsigned int'. I have seen this give a %20 speedup. + +OPTS0= -DRAND -DTERMIO #-DNOCONST + +# Version 1.94 has changed the strings_to_key function so that it is +# now compatible with MITs when the string is longer than 8 characters. +# If you wish to keep the old version, uncomment the following line. +# This will affect the -E/-D options on des(1). +#OPTS1= -DOLD_STR_TO_KEY + +# There are 4 possible performance options +# -DDES_PTR +# -DDES_RISC1 +# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2) +# -DDES_UNROLL +# after the initial build, run 'des_opts' to see which options are best +# for your platform. There are some listed in options.txt +#OPTS2= -DDES_PTR +#OPTS3= -DDES_RISC1 # or DES_RISC2 +#OPTS4= -DDES_UNROLL + +OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4) + +MAKE=make -f Makefile +#CC=cc +#CFLAG= -O + +CC=gcc +#CFLAG= -O4 -funroll-loops -fomit-frame-pointer +CFLAG= -O3 -fomit-frame-pointer + +CFLAGS=$(OPTS) $(CFLAG) +CPP=$(CC) -E +AS=as + +# Assember version of des_encrypt*(). +DES_ENC=des_enc.o fcrypt_b.o # normal C version +#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86 +#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86 +#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86 +#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86 + +LIBDIR=/usr/local/lib +BINDIR=/usr/local/bin +INCDIR=/usr/local/include +MANDIR=/usr/local/man +MAN1=1 +MAN3=3 +SHELL=/bin/sh +OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o +OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \ + xcbc_enc.o qud_cksm.o cbc3_enc.o \ + cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \ + enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \ + rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o + +GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \ + des.doc options.txt asm +GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \ + des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \ + Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \ + des.org des_locl.org +TESTING_LIT= destest speed des_opts +TESTING_FULL= rpw des $(TESTING_LIT) +TESTING_SRC_LIT=destest.c speed.c des_opts.c +TESTING_SRC_FULL=rpw.c des.c $(TESTING_SRC_LIT) +HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h +HEADERS_FULL= $(HEADERS_LIT) rpc_des.h +LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c +LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c cbc3_enc.c \ + cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \ + enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \ + rand_key.c rpc_enc.c str2key.c supp.c \ + xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c + +PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl + +OBJ= $(OBJ_FULL) +GENERAL=$(GENERAL_FULL) +TESTING=$(TESTING_FULL) +TESTING_SRC=$(TESTING_SRC_FULL) +HEADERS=$(HEADERS_FULL) +LIBDES= $(LIBDES_FULL) + +ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS) + +DLIB= libdes.a + +all: $(DLIB) $(TESTING) + +cc: + $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all + +gcc: + $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all + +x86-elf: + $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all + +x86-out: + $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all + +x86-solaris: + $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all + +x86-bsdi: + $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all + +# elf +asm/dx86-elf.o: asm/dx86unix.cpp + $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o + +asm/yx86-elf.o: asm/yx86unix.cpp + $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o + +# solaris +asm/dx86-sol.o: asm/dx86unix.cpp + $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s + as -o asm/dx86-sol.o asm/dx86-sol.s + rm -f asm/dx86-sol.s + +asm/yx86-sol.o: asm/yx86unix.cpp + $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s + as -o asm/yx86-sol.o asm/yx86-sol.s + rm -f asm/yx86-sol.s + +# a.out +asm/dx86-out.o: asm/dx86unix.cpp + $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o + +asm/yx86-out.o: asm/yx86unix.cpp + $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o + +# bsdi +asm/dx86bsdi.o: asm/dx86unix.cpp + $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o + +asm/yx86bsdi.o: asm/yx86unix.cpp + $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o + +asm/dx86unix.cpp: + (cd asm; perl des-586.pl cpp >dx86unix.cpp) + +asm/yx86unix.cpp: + (cd asm; perl crypt586.pl cpp >yx86unix.cpp) + +test: all + ./destest + +$(DLIB): $(OBJ) + /bin/rm -f $(DLIB) + ar cr $(DLIB) $(OBJ) + -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \ + else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \ + else exit 0; fi; fi + +des_opts: des_opts.o $(DLIB) + $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB) + +destest: destest.o $(DLIB) + $(CC) $(CFLAGS) -o destest destest.o $(DLIB) + +rpw: rpw.o $(DLIB) + $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB) + +speed: speed.o $(DLIB) + $(CC) $(CFLAGS) -o speed speed.o $(DLIB) + +des: des.o $(DLIB) + $(CC) $(CFLAGS) -o des des.o $(DLIB) + +tags: + ctags $(TESTING_SRC) $(LIBDES) + +tar_lit: + /bin/mv Makefile Makefile.tmp + /bin/cp Makefile.lit Makefile + for i in $(HEADERS_LIT) $(LIBDES_LIT) $(GENERAL_LIT) $(TESTING_SRC_LIT) ;\ + do \ + n="$$n des/$$i"; \ + done; \ + ( cd .. ; tar chf - $$n )| gzip > libdes-l.tgz + /bin/rm -f Makefile + /bin/mv Makefile.tmp Makefile + +tar: + mv Makefile Makefile.tmp + /bin/cp Makefile.uni Makefile + for i in $(ALL) ;\ + do \ + n="$$n des/$$i"; \ + done; \ + ( cd .. ; tar chf - $$n )| gzip > libdes.tgz + /bin/rm -f Makefile + /bin/mv Makefile.tmp Makefile + +shar: + shar $(ALL) >libdes.shar + +depend: + makedepend $(LIBDES) $(TESTING_SRC) + +clean: + /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o + +dclean: + sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new + mv -f Makefile.new Makefile + +# Eric is probably going to choke when he next looks at this --tjh +install: des + if test $(INSTALLTOP); then \ + echo SSL style install; \ + cp $(DLIB) $(INSTALLTOP)/lib; \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + fi; fi; \ + chmod 644 $(INSTALLTOP)/lib/$(DLIB); \ + cp des.h $(INSTALLTOP)/include; \ + chmod 644 $(INSTALLTOP)/include/des.h; \ + else \ + echo Standalone install; \ + cp $(DLIB) $(LIBDIR)/$(DLIB); \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(LIBDIR)/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(LIBDIR)/$(DLIB); \ + fi; \ + fi; \ + chmod 644 $(LIBDIR)/$(DLIB); \ + cp des $(BINDIR)/des; \ + chmod 711 $(BINDIR)/des; \ + cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + cp des.h $(INCDIR)/des.h; \ + chmod 644 $(INCDIR)/des.h; \ + fi +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/des/PC1 b/src/lib/libcrypto/des/PC1 new file mode 100644 index 0000000000..efb8348b72 --- /dev/null +++ b/src/lib/libcrypto/des/PC1 @@ -0,0 +1,28 @@ +#!/usr/local/bin/perl + +@PC1=( 57,49,41,33,25,17, 9, + 1,58,50,42,34,26,18, + 10, 2,59,51,43,35,27, + 19,11, 3,60,52,44,36, + "-","-","-","-", + 63,55,47,39,31,23,15, + 7,62,54,46,38,30,22, + 14, 6,61,53,45,37,29, + 21,13, 5,28,20,12, 4, + "-","-","-","-", + ); + +foreach (@PC1) + { + if ($_ ne "-") + { + $_--; + $_=int($_/8)*8+7-($_%8); + printf "%2d ",$_; + } + else + { print "-- "; } + print "\n" if (((++$i) % 8) == 0); + print "\n" if ((($i) % 32) == 0); + } + diff --git a/src/lib/libcrypto/des/PC2 b/src/lib/libcrypto/des/PC2 new file mode 100644 index 0000000000..2d560270ec --- /dev/null +++ b/src/lib/libcrypto/des/PC2 @@ -0,0 +1,57 @@ +#!/usr/local/bin/perl + +@PC2_C=(14,17,11,24, 1, 5, + 3,28,15, 6,21,10, + 23,19,12, 4,26, 8, + 16, 7,27,20,13, 2, + ); + +@PC2_D=(41,52,31,37,47,55, + 30,40,51,45,33,48, + 44,49,39,56,34,53, + 46,42,50,36,29,32, + ); + +foreach (@PC2_C) { + if ($_ ne "-") + { + $_--; + printf "%2d ",$_; } + else { print "-- "; } + $C{$_}=1; + print "\n" if (((++$i) % 8) == 0); + } +$i=0; +print "\n"; +foreach (@PC2_D) { + if ($_ ne "-") + { + $_-=29; + printf "%2d ",$_; } + else { print "-- "; } + $D{$_}=1; + print "\n" if (((++$i) % 8) == 0); } + +print "\n"; +foreach $i (0 .. 27) + { + $_=$C{$i}; + if ($_ ne "-") {printf "%2d ",$_;} + else { print "-- "; } + print "\n" if (((++$i) % 8) == 0); + } +print "\n"; + +print "\n"; +foreach $i (0 .. 27) + { + $_=$D{$i}; + if ($_ ne "-") {printf "%2d ",$_;} + else { print "-- "; } + print "\n" if (((++$i) % 8) == 0); + } +print "\n"; +sub numsort + { + $a-$b; + } diff --git a/src/lib/libcrypto/des/asm/d-win32.asm b/src/lib/libcrypto/des/asm/d-win32.asm new file mode 100644 index 0000000000..9e3dc9cd87 --- /dev/null +++ b/src/lib/libcrypto/des/asm/d-win32.asm @@ -0,0 +1,3132 @@ + ; Don't even think of reading this code + ; It was automatically generated by des-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE des-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _des_encrypt +EXTRN _des_SPtrans:DWORD +_des_encrypt PROC NEAR + push esi + push edi + ; + ; Load the 2 words + mov esi, DWORD PTR 12[esp] + xor ecx, ecx + push ebx + push ebp + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 28[esp] + mov edi, DWORD PTR 4[esi] + ; + ; IP + rol eax, 4 + mov esi, eax + xor eax, edi + and eax, 0f0f0f0f0h + xor esi, eax + xor edi, eax + ; + rol edi, 20 + mov eax, edi + xor edi, esi + and edi, 0fff0000fh + xor eax, edi + xor esi, edi + ; + rol eax, 14 + mov edi, eax + xor eax, esi + and eax, 033333333h + xor edi, eax + xor esi, eax + ; + rol esi, 22 + mov eax, esi + xor esi, edi + and esi, 003fc03fch + xor eax, esi + xor edi, esi + ; + rol eax, 9 + mov esi, eax + xor eax, edi + and eax, 0aaaaaaaah + xor esi, eax + xor edi, eax + ; + rol edi, 1 + mov ebp, DWORD PTR 24[esp] + cmp ebx, 0 + je $L000start_decrypt + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + jmp $L001end +$L000start_decrypt: + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx +$L001end: + ; + ; FP + mov edx, DWORD PTR 20[esp] + ror esi, 1 + mov eax, edi + xor edi, esi + and edi, 0aaaaaaaah + xor eax, edi + xor esi, edi + ; + rol eax, 23 + mov edi, eax + xor eax, esi + and eax, 003fc03fch + xor edi, eax + xor esi, eax + ; + rol edi, 10 + mov eax, edi + xor edi, esi + and edi, 033333333h + xor eax, edi + xor esi, edi + ; + rol esi, 18 + mov edi, esi + xor esi, eax + and esi, 0fff0000fh + xor edi, esi + xor eax, esi + ; + rol edi, 12 + mov esi, edi + xor edi, eax + and edi, 0f0f0f0f0h + xor esi, edi + xor eax, edi + ; + ror eax, 4 + mov DWORD PTR [edx],eax + mov DWORD PTR 4[edx],esi + pop ebp + pop ebx + pop edi + pop esi + ret +_des_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_encrypt2 +EXTRN _des_SPtrans:DWORD +_des_encrypt2 PROC NEAR + push esi + push edi + ; + ; Load the 2 words + mov eax, DWORD PTR 12[esp] + xor ecx, ecx + push ebx + push ebp + mov esi, DWORD PTR [eax] + mov ebx, DWORD PTR 28[esp] + rol esi, 3 + mov edi, DWORD PTR 4[eax] + rol edi, 3 + mov ebp, DWORD PTR 24[esp] + cmp ebx, 0 + je $L002start_decrypt + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + jmp $L003end +$L002start_decrypt: + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx +$L003end: + ; + ; Fixup + ror edi, 3 + mov eax, DWORD PTR 20[esp] + ror esi, 3 + mov DWORD PTR [eax],edi + mov DWORD PTR 4[eax],esi + pop ebp + pop ebx + pop edi + pop esi + ret +_des_encrypt2 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_encrypt3 + +_des_encrypt3 PROC NEAR + push ebx + mov ebx, DWORD PTR 8[esp] + push ebp + push esi + push edi + ; + ; Load the data words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + sub esp, 12 + ; + ; IP + rol edi, 4 + mov edx, edi + xor edi, esi + and edi, 0f0f0f0f0h + xor edx, edi + xor esi, edi + ; + rol esi, 20 + mov edi, esi + xor esi, edx + and esi, 0fff0000fh + xor edi, esi + xor edx, esi + ; + rol edi, 14 + mov esi, edi + xor edi, edx + and edi, 033333333h + xor esi, edi + xor edx, edi + ; + rol edx, 22 + mov edi, edx + xor edx, esi + and edx, 003fc03fch + xor edi, edx + xor esi, edx + ; + rol edi, 9 + mov edx, edi + xor edi, esi + and edi, 0aaaaaaaah + xor edx, edi + xor esi, edi + ; + ror edx, 3 + ror esi, 2 + mov DWORD PTR 4[ebx],esi + mov eax, DWORD PTR 36[esp] + mov DWORD PTR [ebx],edx + mov edi, DWORD PTR 40[esp] + mov esi, DWORD PTR 44[esp] + mov DWORD PTR 8[esp],1 + mov DWORD PTR 4[esp],eax + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],0 + mov DWORD PTR 4[esp],edi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],1 + mov DWORD PTR 4[esp],esi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + add esp, 12 + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + ; + ; FP + rol esi, 2 + rol edi, 3 + mov eax, edi + xor edi, esi + and edi, 0aaaaaaaah + xor eax, edi + xor esi, edi + ; + rol eax, 23 + mov edi, eax + xor eax, esi + and eax, 003fc03fch + xor edi, eax + xor esi, eax + ; + rol edi, 10 + mov eax, edi + xor edi, esi + and edi, 033333333h + xor eax, edi + xor esi, edi + ; + rol esi, 18 + mov edi, esi + xor esi, eax + and esi, 0fff0000fh + xor edi, esi + xor eax, esi + ; + rol edi, 12 + mov esi, edi + xor edi, eax + and edi, 0f0f0f0f0h + xor esi, edi + xor eax, edi + ; + ror eax, 4 + mov DWORD PTR [ebx],eax + mov DWORD PTR 4[ebx],esi + pop edi + pop esi + pop ebp + pop ebx + ret +_des_encrypt3 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_decrypt3 + +_des_decrypt3 PROC NEAR + push ebx + mov ebx, DWORD PTR 8[esp] + push ebp + push esi + push edi + ; + ; Load the data words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + sub esp, 12 + ; + ; IP + rol edi, 4 + mov edx, edi + xor edi, esi + and edi, 0f0f0f0f0h + xor edx, edi + xor esi, edi + ; + rol esi, 20 + mov edi, esi + xor esi, edx + and esi, 0fff0000fh + xor edi, esi + xor edx, esi + ; + rol edi, 14 + mov esi, edi + xor edi, edx + and edi, 033333333h + xor esi, edi + xor edx, edi + ; + rol edx, 22 + mov edi, edx + xor edx, esi + and edx, 003fc03fch + xor edi, edx + xor esi, edx + ; + rol edi, 9 + mov edx, edi + xor edi, esi + and edi, 0aaaaaaaah + xor edx, edi + xor esi, edi + ; + ror edx, 3 + ror esi, 2 + mov DWORD PTR 4[ebx],esi + mov esi, DWORD PTR 36[esp] + mov DWORD PTR [ebx],edx + mov edi, DWORD PTR 40[esp] + mov eax, DWORD PTR 44[esp] + mov DWORD PTR 8[esp],0 + mov DWORD PTR 4[esp],eax + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],1 + mov DWORD PTR 4[esp],edi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],0 + mov DWORD PTR 4[esp],esi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + add esp, 12 + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + ; + ; FP + rol esi, 2 + rol edi, 3 + mov eax, edi + xor edi, esi + and edi, 0aaaaaaaah + xor eax, edi + xor esi, edi + ; + rol eax, 23 + mov edi, eax + xor eax, esi + and eax, 003fc03fch + xor edi, eax + xor esi, eax + ; + rol edi, 10 + mov eax, edi + xor edi, esi + and edi, 033333333h + xor eax, edi + xor esi, edi + ; + rol esi, 18 + mov edi, esi + xor esi, eax + and esi, 0fff0000fh + xor edi, esi + xor eax, esi + ; + rol edi, 12 + mov esi, edi + xor edi, eax + and edi, 0f0f0f0f0h + xor esi, edi + xor eax, edi + ; + ror eax, 4 + mov DWORD PTR [ebx],eax + mov DWORD PTR 4[ebx],esi + pop edi + pop esi + pop ebp + pop ebx + ret +_des_decrypt3 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_ncbc_encrypt + +_des_ncbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 5 + push ecx + ; get and push parameter 3 + mov eax, DWORD PTR 52[esp] + push eax + push ebx + cmp ecx, 0 + jz $L004decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + jz $L005encrypt_finish +L006encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L006encrypt_loop +$L005encrypt_finish: + mov ebp, DWORD PTR 56[esp] + and ebp, 7 + jz $L007finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4] + jmp ebp +L009ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L010ej6: + mov dh, BYTE PTR 5[esi] +L011ej5: + mov dl, BYTE PTR 4[esi] +L012ej4: + mov ecx, DWORD PTR [esi] + jmp $L013ejend +L014ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L015ej2: + mov ch, BYTE PTR 1[esi] +L016ej1: + mov cl, BYTE PTR [esi] +$L013ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L007finish +$L004decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 20[esp] + mov ebx, DWORD PTR 24[esp] + jz $L017decrypt_finish +L018decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov ecx, DWORD PTR 20[esp] + mov edx, DWORD PTR 24[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 20[esp],eax + mov DWORD PTR 24[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L018decrypt_loop +$L017decrypt_finish: + mov ebp, DWORD PTR 56[esp] + and ebp, 7 + jz $L007finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov ecx, DWORD PTR 20[esp] + mov edx, DWORD PTR 24[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L019dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L020dj6: + mov BYTE PTR 5[edi],dh +L021dj5: + mov BYTE PTR 4[edi],dl +L022dj4: + mov DWORD PTR [edi],ecx + jmp $L023djend +L024dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L025dj2: + mov BYTE PTR 1[esi],ch +L026dj1: + mov BYTE PTR [esi], cl +$L023djend: + jmp $L007finish +$L007finish: + mov ecx, DWORD PTR 64[esp] + add esp, 28 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L008cbc_enc_jmp_table: + DD 0 + DD L016ej1 + DD L015ej2 + DD L014ej3 + DD L012ej4 + DD L011ej5 + DD L010ej6 + DD L009ej7 +L027cbc_dec_jmp_table: + DD 0 + DD L026dj1 + DD L025dj2 + DD L024dj3 + DD L022dj4 + DD L021dj5 + DD L020dj6 + DD L019dj7 +_des_ncbc_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_ede3_cbc_encrypt + +_des_ede3_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 6 + mov ebx, DWORD PTR 44[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 7 + mov ecx, DWORD PTR 64[esp] + ; get and push parameter 5 + mov eax, DWORD PTR 56[esp] + push eax + ; get and push parameter 4 + mov eax, DWORD PTR 56[esp] + push eax + ; get and push parameter 3 + mov eax, DWORD PTR 56[esp] + push eax + push ebx + cmp ecx, 0 + jz $L028decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L029encrypt_finish +L030encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_encrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L030encrypt_loop +$L029encrypt_finish: + mov ebp, DWORD PTR 60[esp] + and ebp, 7 + jz $L031finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L032cbc_enc_jmp_table[ebp*4] + jmp ebp +L033ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L034ej6: + mov dh, BYTE PTR 5[esi] +L035ej5: + mov dl, BYTE PTR 4[esi] +L036ej4: + mov ecx, DWORD PTR [esi] + jmp $L037ejend +L038ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L039ej2: + mov ch, BYTE PTR 1[esi] +L040ej1: + mov cl, BYTE PTR [esi] +$L037ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_encrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L031finish +$L028decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 24[esp] + mov ebx, DWORD PTR 28[esp] + jz $L041decrypt_finish +L042decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_decrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov ecx, DWORD PTR 24[esp] + mov edx, DWORD PTR 28[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 24[esp],eax + mov DWORD PTR 28[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L042decrypt_loop +$L041decrypt_finish: + mov ebp, DWORD PTR 60[esp] + and ebp, 7 + jz $L031finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_decrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov ecx, DWORD PTR 24[esp] + mov edx, DWORD PTR 28[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L043dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L044dj6: + mov BYTE PTR 5[edi],dh +L045dj5: + mov BYTE PTR 4[edi],dl +L046dj4: + mov DWORD PTR [edi],ecx + jmp $L047djend +L048dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L049dj2: + mov BYTE PTR 1[esi],ch +L050dj1: + mov BYTE PTR [esi], cl +$L047djend: + jmp $L031finish +$L031finish: + mov ecx, DWORD PTR 76[esp] + add esp, 32 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L032cbc_enc_jmp_table: + DD 0 + DD L040ej1 + DD L039ej2 + DD L038ej3 + DD L036ej4 + DD L035ej5 + DD L034ej6 + DD L033ej7 +L051cbc_dec_jmp_table: + DD 0 + DD L050dj1 + DD L049dj2 + DD L048dj3 + DD L046dj4 + DD L045dj5 + DD L044dj6 + DD L043dj7 +_des_ede3_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/des/asm/dx86unix.cpp b/src/lib/libcrypto/des/asm/dx86unix.cpp new file mode 100644 index 0000000000..6fca9afa16 --- /dev/null +++ b/src/lib/libcrypto/des/asm/dx86unix.cpp @@ -0,0 +1,3202 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define des_SPtrans _des_SPtrans +#define des_encrypt _des_encrypt +#define des_encrypt2 _des_encrypt2 +#define des_encrypt3 _des_encrypt3 +#define des_decrypt3 _des_decrypt3 +#define des_ncbc_encrypt _des_ncbc_encrypt +#define des_ede3_cbc_encrypt _des_ede3_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by des-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "des-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl des_encrypt + TYPE(des_encrypt,@function) +des_encrypt: + pushl %esi + pushl %edi + + /* Load the 2 words */ + movl 12(%esp), %esi + xorl %ecx, %ecx + pushl %ebx + pushl %ebp + movl (%esi), %eax + movl 28(%esp), %ebx + movl 4(%esi), %edi + + /* IP */ + roll $4, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0xf0f0f0f0, %eax + xorl %eax, %esi + xorl %eax, %edi + + roll $20, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xfff0000f, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $14, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x33333333, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $22, %esi + movl %esi, %eax + xorl %edi, %esi + andl $0x03fc03fc, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $9, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0xaaaaaaaa, %eax + xorl %eax, %esi + xorl %eax, %edi + +.byte 209 +.byte 199 /* roll $1 %edi */ + movl 24(%esp), %ebp + cmpl $0, %ebx + je .L000start_decrypt + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + jmp .L001end +.L000start_decrypt: + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi +.L001end: + + /* FP */ + movl 20(%esp), %edx +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%edx) + movl %esi, 4(%edx) + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +.des_encrypt_end: + SIZE(des_encrypt,.des_encrypt_end-des_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_encrypt2 + TYPE(des_encrypt2,@function) +des_encrypt2: + pushl %esi + pushl %edi + + /* Load the 2 words */ + movl 12(%esp), %eax + xorl %ecx, %ecx + pushl %ebx + pushl %ebp + movl (%eax), %esi + movl 28(%esp), %ebx + roll $3, %esi + movl 4(%eax), %edi + roll $3, %edi + movl 24(%esp), %ebp + cmpl $0, %ebx + je .L002start_decrypt + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + jmp .L003end +.L002start_decrypt: + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi +.L003end: + + /* Fixup */ + rorl $3, %edi + movl 20(%esp), %eax + rorl $3, %esi + movl %edi, (%eax) + movl %esi, 4(%eax) + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +.des_encrypt2_end: + SIZE(des_encrypt2,.des_encrypt2_end-des_encrypt2) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_encrypt3 + TYPE(des_encrypt3,@function) +des_encrypt3: + pushl %ebx + movl 8(%esp), %ebx + pushl %ebp + pushl %esi + pushl %edi + + /* Load the data words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + subl $12, %esp + + /* IP */ + roll $4, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %edx + xorl %edi, %esi + + roll $20, %esi + movl %esi, %edi + xorl %edx, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %edx + + roll $14, %edi + movl %edi, %esi + xorl %edx, %edi + andl $0x33333333, %edi + xorl %edi, %esi + xorl %edi, %edx + + roll $22, %edx + movl %edx, %edi + xorl %esi, %edx + andl $0x03fc03fc, %edx + xorl %edx, %edi + xorl %edx, %esi + + roll $9, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %edx + xorl %edi, %esi + + rorl $3, %edx + rorl $2, %esi + movl %esi, 4(%ebx) + movl 36(%esp), %eax + movl %edx, (%ebx) + movl 40(%esp), %edi + movl 44(%esp), %esi + movl $1, 8(%esp) + movl %eax, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $0, 8(%esp) + movl %edi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $1, 8(%esp) + movl %esi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + addl $12, %esp + movl (%ebx), %edi + movl 4(%ebx), %esi + + /* FP */ + roll $2, %esi + roll $3, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%ebx) + movl %esi, 4(%ebx) + popl %edi + popl %esi + popl %ebp + popl %ebx + ret +.des_encrypt3_end: + SIZE(des_encrypt3,.des_encrypt3_end-des_encrypt3) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_decrypt3 + TYPE(des_decrypt3,@function) +des_decrypt3: + pushl %ebx + movl 8(%esp), %ebx + pushl %ebp + pushl %esi + pushl %edi + + /* Load the data words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + subl $12, %esp + + /* IP */ + roll $4, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %edx + xorl %edi, %esi + + roll $20, %esi + movl %esi, %edi + xorl %edx, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %edx + + roll $14, %edi + movl %edi, %esi + xorl %edx, %edi + andl $0x33333333, %edi + xorl %edi, %esi + xorl %edi, %edx + + roll $22, %edx + movl %edx, %edi + xorl %esi, %edx + andl $0x03fc03fc, %edx + xorl %edx, %edi + xorl %edx, %esi + + roll $9, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %edx + xorl %edi, %esi + + rorl $3, %edx + rorl $2, %esi + movl %esi, 4(%ebx) + movl 36(%esp), %esi + movl %edx, (%ebx) + movl 40(%esp), %edi + movl 44(%esp), %eax + movl $0, 8(%esp) + movl %eax, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $1, 8(%esp) + movl %edi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $0, 8(%esp) + movl %esi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + addl $12, %esp + movl (%ebx), %edi + movl 4(%ebx), %esi + + /* FP */ + roll $2, %esi + roll $3, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%ebx) + movl %esi, 4(%ebx) + popl %edi + popl %esi + popl %ebp + popl %ebx + ret +.des_decrypt3_end: + SIZE(des_decrypt3,.des_decrypt3_end-des_decrypt3) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_ncbc_encrypt + TYPE(des_ncbc_encrypt,@function) +des_ncbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 5 */ + pushl %ecx + /* get and push parameter 3 */ + movl 52(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L004decrypt + andl $4294967288, %ebp + movl 12(%esp), %eax + movl 16(%esp), %ebx + jz .L005encrypt_finish +.L006encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L006encrypt_loop +.L005encrypt_finish: + movl 56(%esp), %ebp + andl $7, %ebp + jz .L007finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L009ej7: + movb 6(%esi), %dh + sall $8, %edx +.L010ej6: + movb 5(%esi), %dh +.L011ej5: + movb 4(%esi), %dl +.L012ej4: + movl (%esi), %ecx + jmp .L013ejend +.L014ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L015ej2: + movb 1(%esi), %ch +.L016ej1: + movb (%esi), %cl +.L013ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L007finish +.align ALIGN +.L004decrypt: + andl $4294967288, %ebp + movl 20(%esp), %eax + movl 24(%esp), %ebx + jz .L017decrypt_finish +.L018decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl 24(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 20(%esp) + movl %ebx, 24(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L018decrypt_loop +.L017decrypt_finish: + movl 56(%esp), %ebp + andl $7, %ebp + jz .L007finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl 24(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L019dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L020dj6: + movb %dh, 5(%edi) +.L021dj5: + movb %dl, 4(%edi) +.L022dj4: + movl %ecx, (%edi) + jmp .L023djend +.L024dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L025dj2: + movb %ch, 1(%esi) +.L026dj1: + movb %cl, (%esi) +.L023djend: + jmp .L007finish +.align ALIGN +.L007finish: + movl 64(%esp), %ecx + addl $28, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L008cbc_enc_jmp_table: + .long 0 + .long .L016ej1 + .long .L015ej2 + .long .L014ej3 + .long .L012ej4 + .long .L011ej5 + .long .L010ej6 + .long .L009ej7 +.align ALIGN +.L027cbc_dec_jmp_table: + .long 0 + .long .L026dj1 + .long .L025dj2 + .long .L024dj3 + .long .L022dj4 + .long .L021dj5 + .long .L020dj6 + .long .L019dj7 +.des_ncbc_encrypt_end: + SIZE(des_ncbc_encrypt,.des_ncbc_encrypt_end-des_ncbc_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_ede3_cbc_encrypt + TYPE(des_ede3_cbc_encrypt,@function) +des_ede3_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 6 */ + movl 44(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 7 */ + movl 64(%esp), %ecx + /* get and push parameter 5 */ + movl 56(%esp), %eax + pushl %eax + /* get and push parameter 4 */ + movl 56(%esp), %eax + pushl %eax + /* get and push parameter 3 */ + movl 56(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L028decrypt + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L029encrypt_finish +.L030encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_encrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L030encrypt_loop +.L029encrypt_finish: + movl 60(%esp), %ebp + andl $7, %ebp + jz .L031finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L032cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L033ej7: + movb 6(%esi), %dh + sall $8, %edx +.L034ej6: + movb 5(%esi), %dh +.L035ej5: + movb 4(%esi), %dl +.L036ej4: + movl (%esi), %ecx + jmp .L037ejend +.L038ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L039ej2: + movb 1(%esi), %ch +.L040ej1: + movb (%esi), %cl +.L037ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_encrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L031finish +.align ALIGN +.L028decrypt: + andl $4294967288, %ebp + movl 24(%esp), %eax + movl 28(%esp), %ebx + jz .L041decrypt_finish +.L042decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_decrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl 24(%esp), %ecx + movl 28(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 24(%esp) + movl %ebx, 28(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L042decrypt_loop +.L041decrypt_finish: + movl 60(%esp), %ebp + andl $7, %ebp + jz .L031finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_decrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl 24(%esp), %ecx + movl 28(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L043dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L044dj6: + movb %dh, 5(%edi) +.L045dj5: + movb %dl, 4(%edi) +.L046dj4: + movl %ecx, (%edi) + jmp .L047djend +.L048dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L049dj2: + movb %ch, 1(%esi) +.L050dj1: + movb %cl, (%esi) +.L047djend: + jmp .L031finish +.align ALIGN +.L031finish: + movl 76(%esp), %ecx + addl $32, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L032cbc_enc_jmp_table: + .long 0 + .long .L040ej1 + .long .L039ej2 + .long .L038ej3 + .long .L036ej4 + .long .L035ej5 + .long .L034ej6 + .long .L033ej7 +.align ALIGN +.L051cbc_dec_jmp_table: + .long 0 + .long .L050dj1 + .long .L049dj2 + .long .L048dj3 + .long .L046dj4 + .long .L045dj5 + .long .L044dj6 + .long .L043dj7 +.des_ede3_cbc_encrypt_end: + SIZE(des_ede3_cbc_encrypt,.des_ede3_cbc_encrypt_end-des_ede3_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/des/asm/y-win32.asm b/src/lib/libcrypto/des/asm/y-win32.asm new file mode 100644 index 0000000000..af5c102422 --- /dev/null +++ b/src/lib/libcrypto/des/asm/y-win32.asm @@ -0,0 +1,929 @@ + ; Don't even think of reading this code + ; It was automatically generated by crypt586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE crypt586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _fcrypt_body +EXTRN _des_SPtrans:DWORD +_fcrypt_body PROC NEAR + push ebp + push ebx + push esi + push edi + ; + ; Load the 2 words + xor edi, edi + xor esi, esi + mov ebp, DWORD PTR 24[esp] + push 25 +L000start: + ; + ; Round 0 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR [ebp] + xor eax, ebx + mov ecx, DWORD PTR 4[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 8[ebp] + xor eax, ebx + mov ecx, DWORD PTR 12[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 16[ebp] + xor eax, ebx + mov ecx, DWORD PTR 20[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 24[ebp] + xor eax, ebx + mov ecx, DWORD PTR 28[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 32[ebp] + xor eax, ebx + mov ecx, DWORD PTR 36[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 40[ebp] + xor eax, ebx + mov ecx, DWORD PTR 44[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 48[ebp] + xor eax, ebx + mov ecx, DWORD PTR 52[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 56[ebp] + xor eax, ebx + mov ecx, DWORD PTR 60[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 64[ebp] + xor eax, ebx + mov ecx, DWORD PTR 68[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 72[ebp] + xor eax, ebx + mov ecx, DWORD PTR 76[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 80[ebp] + xor eax, ebx + mov ecx, DWORD PTR 84[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 88[ebp] + xor eax, ebx + mov ecx, DWORD PTR 92[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 96[ebp] + xor eax, ebx + mov ecx, DWORD PTR 100[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 104[ebp] + xor eax, ebx + mov ecx, DWORD PTR 108[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 112[ebp] + xor eax, ebx + mov ecx, DWORD PTR 116[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 15 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 120[ebp] + xor eax, ebx + mov ecx, DWORD PTR 124[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + mov ebx, DWORD PTR [esp] + mov eax, edi + dec ebx + mov edi, esi + mov esi, eax + mov DWORD PTR [esp],ebx + jnz L000start + ; + ; FP + mov edx, DWORD PTR 24[esp] + ror edi, 1 + mov eax, esi + xor esi, edi + and esi, 0aaaaaaaah + xor eax, esi + xor edi, esi + ; + rol eax, 23 + mov esi, eax + xor eax, edi + and eax, 003fc03fch + xor esi, eax + xor edi, eax + ; + rol esi, 10 + mov eax, esi + xor esi, edi + and esi, 033333333h + xor eax, esi + xor edi, esi + ; + rol edi, 18 + mov esi, edi + xor edi, eax + and edi, 0fff0000fh + xor esi, edi + xor eax, edi + ; + rol esi, 12 + mov edi, esi + xor esi, eax + and esi, 0f0f0f0f0h + xor edi, esi + xor eax, esi + ; + ror eax, 4 + mov DWORD PTR [edx],eax + mov DWORD PTR 4[edx],edi + pop ecx + pop edi + pop esi + pop ebx + pop ebp + ret +_fcrypt_body ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/des/asm/yx86unix.cpp b/src/lib/libcrypto/des/asm/yx86unix.cpp new file mode 100644 index 0000000000..8719e38607 --- /dev/null +++ b/src/lib/libcrypto/des/asm/yx86unix.cpp @@ -0,0 +1,976 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define des_SPtrans _des_SPtrans +#define fcrypt_body _fcrypt_body + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by crypt586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "crypt586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl fcrypt_body + TYPE(fcrypt_body,@function) +fcrypt_body: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + /* Load the 2 words */ + xorl %edi, %edi + xorl %esi, %esi + movl 24(%esp), %ebp + pushl $25 +.L000start: + + /* Round 0 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl (%ebp), %ebx + xorl %ebx, %eax + movl 4(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 1 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 8(%ebp), %ebx + xorl %ebx, %eax + movl 12(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 2 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 16(%ebp), %ebx + xorl %ebx, %eax + movl 20(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 3 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 24(%ebp), %ebx + xorl %ebx, %eax + movl 28(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 4 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 32(%ebp), %ebx + xorl %ebx, %eax + movl 36(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 5 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 40(%ebp), %ebx + xorl %ebx, %eax + movl 44(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 6 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 48(%ebp), %ebx + xorl %ebx, %eax + movl 52(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 7 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 56(%ebp), %ebx + xorl %ebx, %eax + movl 60(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 8 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 64(%ebp), %ebx + xorl %ebx, %eax + movl 68(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 9 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 72(%ebp), %ebx + xorl %ebx, %eax + movl 76(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 10 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 80(%ebp), %ebx + xorl %ebx, %eax + movl 84(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 11 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 88(%ebp), %ebx + xorl %ebx, %eax + movl 92(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 12 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 96(%ebp), %ebx + xorl %ebx, %eax + movl 100(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 13 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 104(%ebp), %ebx + xorl %ebx, %eax + movl 108(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 14 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 112(%ebp), %ebx + xorl %ebx, %eax + movl 116(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 15 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 120(%ebp), %ebx + xorl %ebx, %eax + movl 124(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + movl (%esp), %ebx + movl %edi, %eax + decl %ebx + movl %esi, %edi + movl %eax, %esi + movl %ebx, (%esp) + jnz .L000start + + /* FP */ + movl 24(%esp), %edx +.byte 209 +.byte 207 /* rorl $1 %edi */ + movl %esi, %eax + xorl %edi, %esi + andl $0xaaaaaaaa, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $23, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %esi + xorl %eax, %edi + + roll $10, %esi + movl %esi, %eax + xorl %edi, %esi + andl $0x33333333, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $18, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xfff0000f, %edi + xorl %edi, %esi + xorl %edi, %eax + + roll $12, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xf0f0f0f0, %esi + xorl %esi, %edi + xorl %esi, %eax + + rorl $4, %eax + movl %eax, (%edx) + movl %edi, 4(%edx) + popl %ecx + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.fcrypt_body_end: + SIZE(fcrypt_body,.fcrypt_body_end-fcrypt_body) +.ident "fcrypt_body" diff --git a/src/lib/libcrypto/des/des.man b/src/lib/libcrypto/des/des.man new file mode 100644 index 0000000000..7e06a1851a --- /dev/null +++ b/src/lib/libcrypto/des/des.man @@ -0,0 +1,186 @@ +.TH DES 1 +.SH NAME +des - encrypt or decrypt data using Data Encryption Standard +.SH SYNOPSIS +.B des +( +.B \-e +| +.B \-E +) | ( +.B \-d +| +.B \-D +) | ( +.B \-\fR[\fPcC\fR][\fPckname\fR]\fP +) | +[ +.B \-b3hfs +] [ +.B \-k +.I key +] +] [ +.B \-u\fR[\fIuuname\fR] +[ +.I input-file +[ +.I output-file +] ] +.SH DESCRIPTION +.B des +encrypts and decrypts data using the +Data Encryption Standard algorithm. +One of +.B \-e, \-E +(for encrypt) or +.B \-d, \-D +(for decrypt) must be specified. +It is also possible to use +.B \-c +or +.B \-C +in conjunction or instead of the a encrypt/decrypt option to generate +a 16 character hexadecimal checksum, generated via the +.I des_cbc_cksum. +.LP +Two standard encryption modes are supported by the +.B des +program, Cipher Block Chaining (the default) and Electronic Code Book +(specified with +.B \-b +). +.LP +The key used for the DES +algorithm is obtained by prompting the user unless the +.B `\-k +.I key' +option is given. +If the key is an argument to the +.B des +command, it is potentially visible to users executing +.BR ps (1) +or a derivative. To minimise this possibility, +.B des +takes care to destroy the key argument immediately upon entry. +If your shell keeps a history file be careful to make sure it is not +world readable. +.LP +Since this program attempts to maintain compatability with sunOS's +des(1) command, there are 2 different methods used to convert the user +supplied key to a des key. +Whenever and one or more of +.B \-E, \-D, \-C +or +.B \-3 +options are used, the key conversion procedure will not be compatible +with the sunOS des(1) version but will use all the user supplied +character to generate the des key. +.B des +command reads from standard input unless +.I input-file +is specified and writes to standard output unless +.I output-file +is given. +.SH OPTIONS +.TP +.B \-b +Select ECB +(eight bytes at a time) encryption mode. +.TP +.B \-3 +Encrypt using triple encryption. +By default triple cbc encryption is used but if the +.B \-b +option is used then triple ecb encryption is performed. +If the key is less than 8 characters long, the flag has no effect. +.TP +.B \-e +Encrypt data using an 8 byte key in a manner compatible with sunOS +des(1). +.TP +.B \-E +Encrypt data using a key of nearly unlimited length (1024 bytes). +This will product a more secure encryption. +.TP +.B \-d +Decrypt data that was encrypted with the \-e option. +.TP +.B \-D +Decrypt data that was encrypted with the \-E option. +.TP +.B \-c +Generate a 16 character hexadecimal cbc checksum and output this to +stderr. +If a filename was specified after the +.B \-c +option, the checksum is output to that file. +The checksum is generated using a key generated in a sunOS compatible +manner. +.TP +.B \-C +A cbc checksum is generated in the same manner as described for the +.B \-c +option but the DES key is generated in the same manner as used for the +.B \-E +and +.B \-D +options +.TP +.B \-f +Does nothing - allowed for compatibility with sunOS des(1) command. +.TP +.B \-s +Does nothing - allowed for compatibility with sunOS des(1) command. +.TP +.B "\-k \fIkey\fP" +Use the encryption +.I key +specified. +.TP +.B "\-h" +The +.I key +is assumed to be a 16 character hexadecimal number. +If the +.B "\-3" +option is used the key is assumed to be a 32 character hexadecimal +number. +.TP +.B \-u +This flag is used to read and write uuencoded files. If decrypting, +the input file is assumed to contain uuencoded, DES encrypted data. +If encrypting, the characters following the -u are used as the name of +the uuencoded file to embed in the begin line of the uuencoded +output. If there is no name specified after the -u, the name text.des +will be embedded in the header. +.SH SEE ALSO +.B ps (1) +.B des_crypt(3) +.SH BUGS +.LP +The problem with using the +.B -e +option is the short key length. +It would be better to use a real 56-bit key rather than an +ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII +radically reduces the time necessary for a brute-force cryptographic attack. +My attempt to remove this problem is to add an alternative text-key to +DES-key function. This alternative function (accessed via +.B -E, -D, -S +and +.B -3 +) +uses DES to help generate the key. +.LP +Be carefully when using the -u option. Doing des -ud will +not decrypt filename (the -u option will gobble the d option). +.LP +The VMS operating system operates in a world where files are always a +multiple of 512 bytes. This causes problems when encrypted data is +send from unix to VMS since a 88 byte file will suddenly be padded +with 424 null bytes. To get around this problem, use the -u option +to uuencode the data before it is send to the VMS system. +.SH AUTHOR +.LP +Eric Young (eay@cryptsoft.com) diff --git a/src/lib/libcrypto/des/des.org b/src/lib/libcrypto/des/des.org new file mode 100644 index 0000000000..a4cf5c8770 --- /dev/null +++ b/src/lib/libcrypto/des/des.org @@ -0,0 +1,301 @@ +/* crypto/des/des.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify des.org since des.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_DES_H +#define HEADER_DES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif + +typedef unsigned char des_cblock[8]; +typedef struct des_ks_struct + { + union { + des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; +#undef _ +#define _ ks._ + } des_key_schedule[16]; + +#define DES_KEY_SZ (sizeof(des_cblock)) +#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define C_Block des_cblock +#define Key_schedule des_key_schedule +#ifdef KERBEROS +#define ENCRYPT DES_ENCRYPT +#define DECRYPT DES_DECRYPT +#endif +#define KEY_SZ DES_KEY_SZ +#define string_to_key des_string_to_key +#define read_pw_string des_read_pw_string +#define random_key des_random_key +#define pcbc_encrypt des_pcbc_encrypt +#define set_key des_set_key +#define key_sched des_key_sched +#define ecb_encrypt des_ecb_encrypt +#define cbc_encrypt des_cbc_encrypt +#define ncbc_encrypt des_ncbc_encrypt +#define xcbc_encrypt des_xcbc_encrypt +#define cbc_cksum des_cbc_cksum +#define quad_cksum des_quad_cksum + +/* For compatibility with the MIT lib - eay 20/05/92 */ +typedef des_key_schedule bit_64; +#define des_fixup_key_parity des_set_odd_parity +#define des_check_key_parity check_parity + +extern int des_check_key; /* defaults to false */ +extern int des_rw_mode; /* defaults to DES_PCBC_MODE */ + +/* The next line is used to disable full ANSI prototypes, if your + * compiler has problems with the prototypes, make sure this line always + * evaluates to true :-) */ +#if defined(MSDOS) || defined(__STDC__) +#undef NOPROTO +#endif +#ifndef NOPROTO +char *des_options(void); +void des_ecb3_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks1,des_key_schedule ks2, + des_key_schedule ks3, int enc); +DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output, + long length,des_key_schedule schedule,des_cblock *ivec); +void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec, + des_cblock *inw,des_cblock *outw,int enc); +void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,des_key_schedule schedule,des_cblock *ivec,int enc); +void des_ecb_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks,int enc); +void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc); +void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc); +void des_encrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3); +void des_decrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3); +void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int enc); +void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num, int enc); +void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num); + +void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white), + des_cblock (*out_white)); + +int des_enc_read(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv); +int des_enc_write(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv); +char *des_fcrypt(const char *buf,const char *salt, char *ret); +#ifdef PERL5 +char *des_crypt(const char *buf,const char *salt); +#else +/* some stupid compilers complain because I have declared char instead + * of const char */ +#ifdef HEADER_DES_LOCL_H +char *crypt(const char *buf,const char *salt); +#else +char *crypt(); +#endif +#endif +void des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,des_key_schedule schedule,des_cblock *ivec); +void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output, + long length,int out_count,des_cblock *seed); +void des_random_seed(des_cblock key); +void des_random_key(des_cblock ret); +int des_read_password(des_cblock *key,char *prompt,int verify); +int des_read_2passwords(des_cblock *key1,des_cblock *key2, + char *prompt,int verify); +int des_read_pw_string(char *buf,int length,char *prompt,int verify); +void des_set_odd_parity(des_cblock *key); +int des_is_weak_key(des_cblock *key); +int des_set_key(des_cblock *key,des_key_schedule schedule); +int des_key_sched(des_cblock *key,des_key_schedule schedule); +void des_string_to_key(char *str,des_cblock *key); +void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2); +void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num, int enc); +void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num); +int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify); + +/* Extra functions from Mark Murray */ +void des_cblock_print_file(des_cblock *cb, FILE *fp); +/* The following functions are not in the normal unix build or the + * SSLeay build. When using the SSLeay build, use RAND_seed() + * and RAND_bytes() instead. */ +int des_new_random_key(des_cblock *key); +void des_init_random_number_generator(des_cblock *key); +void des_set_random_generator_seed(des_cblock *key); +void des_set_sequence_number(des_cblock new_sequence_number); +void des_generate_random_block(des_cblock *block); + +#else + +char *des_options(); +void des_ecb3_encrypt(); +DES_LONG des_cbc_cksum(); +void des_cbc_encrypt(); +void des_ncbc_encrypt(); +void des_xcbc_encrypt(); +void des_cfb_encrypt(); +void des_ede3_cfb64_encrypt(); +void des_ede3_ofb64_encrypt(); +void des_ecb_encrypt(); +void des_encrypt(); +void des_encrypt2(); +void des_encrypt3(); +void des_decrypt3(); +void des_ede3_cbc_encrypt(); +int des_enc_read(); +int des_enc_write(); +char *des_fcrypt(); +#ifdef PERL5 +char *des_crypt(); +#else +char *crypt(); +#endif +void des_ofb_encrypt(); +void des_pcbc_encrypt(); +DES_LONG des_quad_cksum(); +void des_random_seed(); +void des_random_key(); +int des_read_password(); +int des_read_2passwords(); +int des_read_pw_string(); +void des_set_odd_parity(); +int des_is_weak_key(); +int des_set_key(); +int des_key_sched(); +void des_string_to_key(); +void des_string_to_2keys(); +void des_cfb64_encrypt(); +void des_ofb64_encrypt(); +int des_read_pw(); +void des_xwhite_in2out(); + +/* Extra functions from Mark Murray */ +void des_cblock_print_file(); +/* The following functions are not in the normal unix build or the + * SSLeay build. When using the SSLeay build, use RAND_seed() + * and RAND_bytes() instead. */ +#ifdef FreeBSD +int des_new_random_key(); +void des_init_random_number_generator(); +void des_set_random_generator_seed(); +void des_set_sequence_number(); +void des_generate_random_block(); +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libcrypto/des/des.pl b/src/lib/libcrypto/des/des.pl new file mode 100644 index 0000000000..935eacb504 --- /dev/null +++ b/src/lib/libcrypto/des/des.pl @@ -0,0 +1,552 @@ +#!/usr/bin/perl +# des.pl - eric young 22/11/1991 eay@cryptsoft.com +# +# Copyright (C) 1993 Eric Young +# +# 11 April 1996 - patched to circumvent Perl 5 (through 5.002) problem +# with sign-extension on right shift operations. +# Ed Kubaitis - ejk@uiuc.edu +# +# eay - 92/08/31 - I think I have fixed all problems for 64bit +# versions of perl but I could be wrong since I have not tested it yet :-). +# +# This is an implementation of DES in perl. +# The two routines (des_set_key and des_ecb_encrypt) +# take 8 byte objects as arguments. +# +# des_set_key takes an 8 byte string as a key and returns a key schedule +# for use in calls to des_ecb_encrypt. +# des_ecb_encrypt takes three arguments, the first is a key schedule +# (make sure to pass it by reference with the *), the second is 1 +# to encrypt, 0 to decrypt. The third argument is an 8 byte object +# to encrypt. The function returns an 8 byte object that has been +# DES encrypted. +# +# example: +# require 'des.pl' +# +# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef); +# @ks= &des_set_key($key); +# +# $outbytes= &des_ecb_encrypt(*ks,1,$data); +# @enc =unpack("C8",$outbytes); +# + +package des; + +eval("use integer;") if (int($]) > 4); + +# The following 8 arrays are used in des_set_key +@skb0=( +# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 +0x00000000,0x00000010,0x20000000,0x20000010, +0x00010000,0x00010010,0x20010000,0x20010010, +0x00000800,0x00000810,0x20000800,0x20000810, +0x00010800,0x00010810,0x20010800,0x20010810, +0x00000020,0x00000030,0x20000020,0x20000030, +0x00010020,0x00010030,0x20010020,0x20010030, +0x00000820,0x00000830,0x20000820,0x20000830, +0x00010820,0x00010830,0x20010820,0x20010830, +0x00080000,0x00080010,0x20080000,0x20080010, +0x00090000,0x00090010,0x20090000,0x20090010, +0x00080800,0x00080810,0x20080800,0x20080810, +0x00090800,0x00090810,0x20090800,0x20090810, +0x00080020,0x00080030,0x20080020,0x20080030, +0x00090020,0x00090030,0x20090020,0x20090030, +0x00080820,0x00080830,0x20080820,0x20080830, +0x00090820,0x00090830,0x20090820,0x20090830, +); +@skb1=( +# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 +0x00000000,0x02000000,0x00002000,0x02002000, +0x00200000,0x02200000,0x00202000,0x02202000, +0x00000004,0x02000004,0x00002004,0x02002004, +0x00200004,0x02200004,0x00202004,0x02202004, +0x00000400,0x02000400,0x00002400,0x02002400, +0x00200400,0x02200400,0x00202400,0x02202400, +0x00000404,0x02000404,0x00002404,0x02002404, +0x00200404,0x02200404,0x00202404,0x02202404, +0x10000000,0x12000000,0x10002000,0x12002000, +0x10200000,0x12200000,0x10202000,0x12202000, +0x10000004,0x12000004,0x10002004,0x12002004, +0x10200004,0x12200004,0x10202004,0x12202004, +0x10000400,0x12000400,0x10002400,0x12002400, +0x10200400,0x12200400,0x10202400,0x12202400, +0x10000404,0x12000404,0x10002404,0x12002404, +0x10200404,0x12200404,0x10202404,0x12202404, +); +@skb2=( +# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 +0x00000000,0x00000001,0x00040000,0x00040001, +0x01000000,0x01000001,0x01040000,0x01040001, +0x00000002,0x00000003,0x00040002,0x00040003, +0x01000002,0x01000003,0x01040002,0x01040003, +0x00000200,0x00000201,0x00040200,0x00040201, +0x01000200,0x01000201,0x01040200,0x01040201, +0x00000202,0x00000203,0x00040202,0x00040203, +0x01000202,0x01000203,0x01040202,0x01040203, +0x08000000,0x08000001,0x08040000,0x08040001, +0x09000000,0x09000001,0x09040000,0x09040001, +0x08000002,0x08000003,0x08040002,0x08040003, +0x09000002,0x09000003,0x09040002,0x09040003, +0x08000200,0x08000201,0x08040200,0x08040201, +0x09000200,0x09000201,0x09040200,0x09040201, +0x08000202,0x08000203,0x08040202,0x08040203, +0x09000202,0x09000203,0x09040202,0x09040203, +); +@skb3=( +# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 +0x00000000,0x00100000,0x00000100,0x00100100, +0x00000008,0x00100008,0x00000108,0x00100108, +0x00001000,0x00101000,0x00001100,0x00101100, +0x00001008,0x00101008,0x00001108,0x00101108, +0x04000000,0x04100000,0x04000100,0x04100100, +0x04000008,0x04100008,0x04000108,0x04100108, +0x04001000,0x04101000,0x04001100,0x04101100, +0x04001008,0x04101008,0x04001108,0x04101108, +0x00020000,0x00120000,0x00020100,0x00120100, +0x00020008,0x00120008,0x00020108,0x00120108, +0x00021000,0x00121000,0x00021100,0x00121100, +0x00021008,0x00121008,0x00021108,0x00121108, +0x04020000,0x04120000,0x04020100,0x04120100, +0x04020008,0x04120008,0x04020108,0x04120108, +0x04021000,0x04121000,0x04021100,0x04121100, +0x04021008,0x04121008,0x04021108,0x04121108, +); +@skb4=( +# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 +0x00000000,0x10000000,0x00010000,0x10010000, +0x00000004,0x10000004,0x00010004,0x10010004, +0x20000000,0x30000000,0x20010000,0x30010000, +0x20000004,0x30000004,0x20010004,0x30010004, +0x00100000,0x10100000,0x00110000,0x10110000, +0x00100004,0x10100004,0x00110004,0x10110004, +0x20100000,0x30100000,0x20110000,0x30110000, +0x20100004,0x30100004,0x20110004,0x30110004, +0x00001000,0x10001000,0x00011000,0x10011000, +0x00001004,0x10001004,0x00011004,0x10011004, +0x20001000,0x30001000,0x20011000,0x30011000, +0x20001004,0x30001004,0x20011004,0x30011004, +0x00101000,0x10101000,0x00111000,0x10111000, +0x00101004,0x10101004,0x00111004,0x10111004, +0x20101000,0x30101000,0x20111000,0x30111000, +0x20101004,0x30101004,0x20111004,0x30111004, +); +@skb5=( +# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 +0x00000000,0x08000000,0x00000008,0x08000008, +0x00000400,0x08000400,0x00000408,0x08000408, +0x00020000,0x08020000,0x00020008,0x08020008, +0x00020400,0x08020400,0x00020408,0x08020408, +0x00000001,0x08000001,0x00000009,0x08000009, +0x00000401,0x08000401,0x00000409,0x08000409, +0x00020001,0x08020001,0x00020009,0x08020009, +0x00020401,0x08020401,0x00020409,0x08020409, +0x02000000,0x0A000000,0x02000008,0x0A000008, +0x02000400,0x0A000400,0x02000408,0x0A000408, +0x02020000,0x0A020000,0x02020008,0x0A020008, +0x02020400,0x0A020400,0x02020408,0x0A020408, +0x02000001,0x0A000001,0x02000009,0x0A000009, +0x02000401,0x0A000401,0x02000409,0x0A000409, +0x02020001,0x0A020001,0x02020009,0x0A020009, +0x02020401,0x0A020401,0x02020409,0x0A020409, +); +@skb6=( +# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 +0x00000000,0x00000100,0x00080000,0x00080100, +0x01000000,0x01000100,0x01080000,0x01080100, +0x00000010,0x00000110,0x00080010,0x00080110, +0x01000010,0x01000110,0x01080010,0x01080110, +0x00200000,0x00200100,0x00280000,0x00280100, +0x01200000,0x01200100,0x01280000,0x01280100, +0x00200010,0x00200110,0x00280010,0x00280110, +0x01200010,0x01200110,0x01280010,0x01280110, +0x00000200,0x00000300,0x00080200,0x00080300, +0x01000200,0x01000300,0x01080200,0x01080300, +0x00000210,0x00000310,0x00080210,0x00080310, +0x01000210,0x01000310,0x01080210,0x01080310, +0x00200200,0x00200300,0x00280200,0x00280300, +0x01200200,0x01200300,0x01280200,0x01280300, +0x00200210,0x00200310,0x00280210,0x00280310, +0x01200210,0x01200310,0x01280210,0x01280310, +); +@skb7=( +# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 +0x00000000,0x04000000,0x00040000,0x04040000, +0x00000002,0x04000002,0x00040002,0x04040002, +0x00002000,0x04002000,0x00042000,0x04042000, +0x00002002,0x04002002,0x00042002,0x04042002, +0x00000020,0x04000020,0x00040020,0x04040020, +0x00000022,0x04000022,0x00040022,0x04040022, +0x00002020,0x04002020,0x00042020,0x04042020, +0x00002022,0x04002022,0x00042022,0x04042022, +0x00000800,0x04000800,0x00040800,0x04040800, +0x00000802,0x04000802,0x00040802,0x04040802, +0x00002800,0x04002800,0x00042800,0x04042800, +0x00002802,0x04002802,0x00042802,0x04042802, +0x00000820,0x04000820,0x00040820,0x04040820, +0x00000822,0x04000822,0x00040822,0x04040822, +0x00002820,0x04002820,0x00042820,0x04042820, +0x00002822,0x04002822,0x00042822,0x04042822, +); + +@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0); + +# used in ecb_encrypt +@SP0=( +0x00410100, 0x00010000, 0x40400000, 0x40410100, +0x00400000, 0x40010100, 0x40010000, 0x40400000, +0x40010100, 0x00410100, 0x00410000, 0x40000100, +0x40400100, 0x00400000, 0x00000000, 0x40010000, +0x00010000, 0x40000000, 0x00400100, 0x00010100, +0x40410100, 0x00410000, 0x40000100, 0x00400100, +0x40000000, 0x00000100, 0x00010100, 0x40410000, +0x00000100, 0x40400100, 0x40410000, 0x00000000, +0x00000000, 0x40410100, 0x00400100, 0x40010000, +0x00410100, 0x00010000, 0x40000100, 0x00400100, +0x40410000, 0x00000100, 0x00010100, 0x40400000, +0x40010100, 0x40000000, 0x40400000, 0x00410000, +0x40410100, 0x00010100, 0x00410000, 0x40400100, +0x00400000, 0x40000100, 0x40010000, 0x00000000, +0x00010000, 0x00400000, 0x40400100, 0x00410100, +0x40000000, 0x40410000, 0x00000100, 0x40010100, +); +@SP1=( +0x08021002, 0x00000000, 0x00021000, 0x08020000, +0x08000002, 0x00001002, 0x08001000, 0x00021000, +0x00001000, 0x08020002, 0x00000002, 0x08001000, +0x00020002, 0x08021000, 0x08020000, 0x00000002, +0x00020000, 0x08001002, 0x08020002, 0x00001000, +0x00021002, 0x08000000, 0x00000000, 0x00020002, +0x08001002, 0x00021002, 0x08021000, 0x08000002, +0x08000000, 0x00020000, 0x00001002, 0x08021002, +0x00020002, 0x08021000, 0x08001000, 0x00021002, +0x08021002, 0x00020002, 0x08000002, 0x00000000, +0x08000000, 0x00001002, 0x00020000, 0x08020002, +0x00001000, 0x08000000, 0x00021002, 0x08001002, +0x08021000, 0x00001000, 0x00000000, 0x08000002, +0x00000002, 0x08021002, 0x00021000, 0x08020000, +0x08020002, 0x00020000, 0x00001002, 0x08001000, +0x08001002, 0x00000002, 0x08020000, 0x00021000, +); +@SP2=( +0x20800000, 0x00808020, 0x00000020, 0x20800020, +0x20008000, 0x00800000, 0x20800020, 0x00008020, +0x00800020, 0x00008000, 0x00808000, 0x20000000, +0x20808020, 0x20000020, 0x20000000, 0x20808000, +0x00000000, 0x20008000, 0x00808020, 0x00000020, +0x20000020, 0x20808020, 0x00008000, 0x20800000, +0x20808000, 0x00800020, 0x20008020, 0x00808000, +0x00008020, 0x00000000, 0x00800000, 0x20008020, +0x00808020, 0x00000020, 0x20000000, 0x00008000, +0x20000020, 0x20008000, 0x00808000, 0x20800020, +0x00000000, 0x00808020, 0x00008020, 0x20808000, +0x20008000, 0x00800000, 0x20808020, 0x20000000, +0x20008020, 0x20800000, 0x00800000, 0x20808020, +0x00008000, 0x00800020, 0x20800020, 0x00008020, +0x00800020, 0x00000000, 0x20808000, 0x20000020, +0x20800000, 0x20008020, 0x00000020, 0x00808000, +); +@SP3=( +0x00080201, 0x02000200, 0x00000001, 0x02080201, +0x00000000, 0x02080000, 0x02000201, 0x00080001, +0x02080200, 0x02000001, 0x02000000, 0x00000201, +0x02000001, 0x00080201, 0x00080000, 0x02000000, +0x02080001, 0x00080200, 0x00000200, 0x00000001, +0x00080200, 0x02000201, 0x02080000, 0x00000200, +0x00000201, 0x00000000, 0x00080001, 0x02080200, +0x02000200, 0x02080001, 0x02080201, 0x00080000, +0x02080001, 0x00000201, 0x00080000, 0x02000001, +0x00080200, 0x02000200, 0x00000001, 0x02080000, +0x02000201, 0x00000000, 0x00000200, 0x00080001, +0x00000000, 0x02080001, 0x02080200, 0x00000200, +0x02000000, 0x02080201, 0x00080201, 0x00080000, +0x02080201, 0x00000001, 0x02000200, 0x00080201, +0x00080001, 0x00080200, 0x02080000, 0x02000201, +0x00000201, 0x02000000, 0x02000001, 0x02080200, +); +@SP4=( +0x01000000, 0x00002000, 0x00000080, 0x01002084, +0x01002004, 0x01000080, 0x00002084, 0x01002000, +0x00002000, 0x00000004, 0x01000004, 0x00002080, +0x01000084, 0x01002004, 0x01002080, 0x00000000, +0x00002080, 0x01000000, 0x00002004, 0x00000084, +0x01000080, 0x00002084, 0x00000000, 0x01000004, +0x00000004, 0x01000084, 0x01002084, 0x00002004, +0x01002000, 0x00000080, 0x00000084, 0x01002080, +0x01002080, 0x01000084, 0x00002004, 0x01002000, +0x00002000, 0x00000004, 0x01000004, 0x01000080, +0x01000000, 0x00002080, 0x01002084, 0x00000000, +0x00002084, 0x01000000, 0x00000080, 0x00002004, +0x01000084, 0x00000080, 0x00000000, 0x01002084, +0x01002004, 0x01002080, 0x00000084, 0x00002000, +0x00002080, 0x01002004, 0x01000080, 0x00000084, +0x00000004, 0x00002084, 0x01002000, 0x01000004, +); +@SP5=( +0x10000008, 0x00040008, 0x00000000, 0x10040400, +0x00040008, 0x00000400, 0x10000408, 0x00040000, +0x00000408, 0x10040408, 0x00040400, 0x10000000, +0x10000400, 0x10000008, 0x10040000, 0x00040408, +0x00040000, 0x10000408, 0x10040008, 0x00000000, +0x00000400, 0x00000008, 0x10040400, 0x10040008, +0x10040408, 0x10040000, 0x10000000, 0x00000408, +0x00000008, 0x00040400, 0x00040408, 0x10000400, +0x00000408, 0x10000000, 0x10000400, 0x00040408, +0x10040400, 0x00040008, 0x00000000, 0x10000400, +0x10000000, 0x00000400, 0x10040008, 0x00040000, +0x00040008, 0x10040408, 0x00040400, 0x00000008, +0x10040408, 0x00040400, 0x00040000, 0x10000408, +0x10000008, 0x10040000, 0x00040408, 0x00000000, +0x00000400, 0x10000008, 0x10000408, 0x10040400, +0x10040000, 0x00000408, 0x00000008, 0x10040008, +); +@SP6=( +0x00000800, 0x00000040, 0x00200040, 0x80200000, +0x80200840, 0x80000800, 0x00000840, 0x00000000, +0x00200000, 0x80200040, 0x80000040, 0x00200800, +0x80000000, 0x00200840, 0x00200800, 0x80000040, +0x80200040, 0x00000800, 0x80000800, 0x80200840, +0x00000000, 0x00200040, 0x80200000, 0x00000840, +0x80200800, 0x80000840, 0x00200840, 0x80000000, +0x80000840, 0x80200800, 0x00000040, 0x00200000, +0x80000840, 0x00200800, 0x80200800, 0x80000040, +0x00000800, 0x00000040, 0x00200000, 0x80200800, +0x80200040, 0x80000840, 0x00000840, 0x00000000, +0x00000040, 0x80200000, 0x80000000, 0x00200040, +0x00000000, 0x80200040, 0x00200040, 0x00000840, +0x80000040, 0x00000800, 0x80200840, 0x00200000, +0x00200840, 0x80000000, 0x80000800, 0x80200840, +0x80200000, 0x00200840, 0x00200800, 0x80000800, +); +@SP7=( +0x04100010, 0x04104000, 0x00004010, 0x00000000, +0x04004000, 0x00100010, 0x04100000, 0x04104010, +0x00000010, 0x04000000, 0x00104000, 0x00004010, +0x00104010, 0x04004010, 0x04000010, 0x04100000, +0x00004000, 0x00104010, 0x00100010, 0x04004000, +0x04104010, 0x04000010, 0x00000000, 0x00104000, +0x04000000, 0x00100000, 0x04004010, 0x04100010, +0x00100000, 0x00004000, 0x04104000, 0x00000010, +0x00100000, 0x00004000, 0x04000010, 0x04104010, +0x00004010, 0x04000000, 0x00000000, 0x00104000, +0x04100010, 0x04004010, 0x04004000, 0x00100010, +0x04104000, 0x00000010, 0x00100010, 0x04004000, +0x04104010, 0x00100000, 0x04100000, 0x04000010, +0x00104000, 0x00004010, 0x04004010, 0x04100000, +0x00000010, 0x04104000, 0x00104010, 0x00000000, +0x04000000, 0x04100010, 0x00004000, 0x00104010, +); + +sub main'des_set_key + { + local($param)=@_; + local(@key); + local($c,$d,$i,$s,$t); + local(@ks)=(); + + # Get the bytes in the order we want. + @key=unpack("C8",$param); + + $c= ($key[0] )| + ($key[1]<< 8)| + ($key[2]<<16)| + ($key[3]<<24); + $d= ($key[4] )| + ($key[5]<< 8)| + ($key[6]<<16)| + ($key[7]<<24); + + &doPC1(*c,*d); + + for $i (@shifts2) + { + if ($i) + { + $c=($c>>2)|($c<<26); + $d=($d>>2)|($d<<26); + } + else + { + $c=($c>>1)|($c<<27); + $d=($d>>1)|($d<<27); + } + $c&=0x0fffffff; + $d&=0x0fffffff; + $s= $skb0[ ($c )&0x3f ]| + $skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]| + $skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]| + $skb3[(($c>>20)&0x01)|(($c>>21)&0x06) | + (($c>>22)&0x38)]; + $t= $skb4[ ($d )&0x3f ]| + $skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]| + $skb6[ ($d>>15)&0x3f ]| + $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)]; + push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff); + $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ; + push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff); + } + @ks; + } + +sub doPC1 + { + local(*a,*b)=@_; + local($t); + + $t=(($b>>4)^$a)&0x0f0f0f0f; + $b^=($t<<4); $a^=$t; + # do $a first + $t=(($a<<18)^$a)&0xcccc0000; + $a=$a^$t^(($t>>18)&0x00003fff); + $t=(($a<<17)^$a)&0xaaaa0000; + $a=$a^$t^(($t>>17)&0x00007fff); + $t=(($a<< 8)^$a)&0x00ff0000; + $a=$a^$t^(($t>> 8)&0x00ffffff); + $t=(($a<<17)^$a)&0xaaaa0000; + $a=$a^$t^(($t>>17)&0x00007fff); + + # now do $b + $t=(($b<<24)^$b)&0xff000000; + $b=$b^$t^(($t>>24)&0x000000ff); + $t=(($b<< 8)^$b)&0x00ff0000; + $b=$b^$t^(($t>> 8)&0x00ffffff); + $t=(($b<<14)^$b)&0x33330000; + $b=$b^$t^(($t>>14)&0x0003ffff); + $b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55); + $b=(($b>>8)&0x00ffffff)|((($a&0xf0000000)>>4)&0x0fffffff); + $a&=0x0fffffff; + } + +sub doIP + { + local(*a,*b)=@_; + local($t); + + $t=(($b>> 4)^$a)&0x0f0f0f0f; + $b^=($t<< 4); $a^=$t; + $t=(($a>>16)^$b)&0x0000ffff; + $a^=($t<<16); $b^=$t; + $t=(($b>> 2)^$a)&0x33333333; + $b^=($t<< 2); $a^=$t; + $t=(($a>> 8)^$b)&0x00ff00ff; + $a^=($t<< 8); $b^=$t; + $t=(($b>> 1)^$a)&0x55555555; + $b^=($t<< 1); $a^=$t; + $t=$a; + $a=$b&0xffffffff; + $b=$t&0xffffffff; + } + +sub doFP + { + local(*a,*b)=@_; + local($t); + + $t=(($b>> 1)^$a)&0x55555555; + $b^=($t<< 1); $a^=$t; + $t=(($a>> 8)^$b)&0x00ff00ff; + $a^=($t<< 8); $b^=$t; + $t=(($b>> 2)^$a)&0x33333333; + $b^=($t<< 2); $a^=$t; + $t=(($a>>16)^$b)&0x0000ffff; + $a^=($t<<16); $b^=$t; + $t=(($b>> 4)^$a)&0x0f0f0f0f; + $b^=($t<< 4); $a^=$t; + $a&=0xffffffff; + $b&=0xffffffff; + } + +sub main'des_ecb_encrypt + { + local(*ks,$encrypt,$in)=@_; + local($l,$r,$i,$t,$u,@input); + + @input=unpack("C8",$in); + # Get the bytes in the order we want. + $l= ($input[0] )| + ($input[1]<< 8)| + ($input[2]<<16)| + ($input[3]<<24); + $r= ($input[4] )| + ($input[5]<< 8)| + ($input[6]<<16)| + ($input[7]<<24); + + $l&=0xffffffff; + $r&=0xffffffff; + &doIP(*l,*r); + if ($encrypt) + { + for ($i=0; $i<32; $i+=4) + { + $t=((($r&0x7fffffff)<<1)|(($r>>31)&0x00000001)); + $u=$t^$ks[$i ]; + $t=$t^$ks[$i+1]; + $t2=(($t&0x0000000f)<<28); + + $t=((($t>>4)&0x0fffffff)|(($t&0x0000000f)<<28)); + $l^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + + $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff; + $u=$t^$ks[$i+2]; + $t=$t^$ks[$i+3]; + $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff; + $r^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + } + } + else + { + for ($i=30; $i>0; $i-=4) + { + $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff; + $u=$t^$ks[$i ]; + $t=$t^$ks[$i+1]; + $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff; + $l^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + + $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff; + $u=$t^$ks[$i-2]; + $t=$t^$ks[$i-1]; + $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff; + $r^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + } + } + &doFP(*l,*r); + pack("C8",$l&0xff, + ($l>> 8)&0x00ffffff, + ($l>>16)&0x0000ffff, + ($l>>24)&0x000000ff, + $r&0xff, + ($r>> 8)&0x00ffffff, + ($r>>16)&0x0000ffff, + ($r>>24)&0x000000ff); + } diff --git a/src/lib/libcrypto/des/des_crypt.man b/src/lib/libcrypto/des/des_crypt.man new file mode 100644 index 0000000000..0ecc416877 --- /dev/null +++ b/src/lib/libcrypto/des/des_crypt.man @@ -0,0 +1,508 @@ +.TH DES_CRYPT 3 +.SH NAME +des_read_password, des_read_2password, +des_string_to_key, des_string_to_2key, des_read_pw_string, +des_random_key, des_set_key, +des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt, +des_3cbc_encrypt, +des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt, +des_cbc_cksum, des_quad_cksum, +des_enc_read, des_enc_write, des_set_odd_parity, +des_is_weak_key, crypt \- (non USA) DES encryption +.SH SYNOPSIS +.nf +.nj +.ft B +#include +.PP +.B int des_read_password(key,prompt,verify) +des_cblock *key; +char *prompt; +int verify; +.PP +.B int des_read_2password(key1,key2,prompt,verify) +des_cblock *key1,*key2; +char *prompt; +int verify; +.PP +.B int des_string_to_key(str,key) +char *str; +des_cblock *key; +.PP +.B int des_string_to_2keys(str,key1,key2) +char *str; +des_cblock *key1,*key2; +.PP +.B int des_read_pw_string(buf,length,prompt,verify) +char *buf; +int length; +char *prompt; +int verify; +.PP +.B int des_random_key(key) +des_cblock *key; +.PP +.B int des_set_key(key,schedule) +des_cblock *key; +des_key_schedule schedule; +.PP +.B int des_key_sched(key,schedule) +des_cblock *key; +des_key_schedule schedule; +.PP +.B int des_ecb_encrypt(input,output,schedule,encrypt) +des_cblock *input; +des_cblock *output; +des_key_schedule schedule; +int encrypt; +.PP +.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt) +des_cblock *input; +des_cblock *output; +des_key_schedule ks1,ks2; +int encrypt; +.PP +.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule schedule; +des_cblock *ivec; +int encrypt; +.PP +.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule sk1; +des_key_schedule sk2; +des_cblock *ivec1; +des_cblock *ivec2; +int encrypt; +.PP +.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule schedule; +des_cblock *ivec; +int encrypt; +.PP +.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt) +unsigned char *input; +unsigned char *output; +int numbits; +long length; +des_key_schedule schedule; +des_cblock *ivec; +int encrypt; +.PP +.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec) +unsigned char *input,*output; +int numbits; +long length; +des_key_schedule schedule; +des_cblock *ivec; +.PP +.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule schedule; +des_cblock *ivec; +.PP +.B unsigned long des_quad_cksum(input,output,length,out_count,seed) +des_cblock *input; +des_cblock *output; +long length; +int out_count; +des_cblock *seed; +.PP +.B int des_check_key; +.PP +.B int des_enc_read(fd,buf,len,sched,iv) +int fd; +char *buf; +int len; +des_key_schedule sched; +des_cblock *iv; +.PP +.B int des_enc_write(fd,buf,len,sched,iv) +int fd; +char *buf; +int len; +des_key_schedule sched; +des_cblock *iv; +.PP +.B extern int des_rw_mode; +.PP +.B void des_set_odd_parity(key) +des_cblock *key; +.PP +.B int des_is_weak_key(key) +des_cblock *key; +.PP +.B char *crypt(passwd,salt) +char *passwd; +char *salt; +.PP +.fi +.SH DESCRIPTION +This library contains a fast implementation of the DES encryption +algorithm. +.PP +There are two phases to the use of DES encryption. +The first is the generation of a +.I des_key_schedule +from a key, +the second is the actual encryption. +A des key is of type +.I des_cblock. +This type is made from 8 characters with odd parity. +The least significant bit in the character is the parity bit. +The key schedule is an expanded form of the key; it is used to speed the +encryption process. +.PP +.I des_read_password +writes the string specified by prompt to the standard output, +turns off echo and reads an input string from standard input +until terminated with a newline. +If verify is non-zero, it prompts and reads the input again and verifies +that both entered passwords are the same. +The entered string is converted into a des key by using the +.I des_string_to_key +routine. +The new key is placed in the +.I des_cblock +that was passed (by reference) to the routine. +If there were no errors, +.I des_read_password +returns 0, +-1 is returned if there was a terminal error and 1 is returned for +any other error. +.PP +.I des_read_2password +operates in the same way as +.I des_read_password +except that it generates 2 keys by using the +.I des_string_to_2key +function. +.PP +.I des_read_pw_string +is called by +.I des_read_password +to read and verify a string from a terminal device. +The string is returned in +.I buf. +The size of +.I buf +is passed to the routine via the +.I length +parameter. +.PP +.I des_string_to_key +converts a string into a valid des key. +.PP +.I des_string_to_2key +converts a string into 2 valid des keys. +This routine is best suited for used to generate keys for use with +.I des_ecb3_encrypt. +.PP +.I des_random_key +returns a random key that is made of a combination of process id, +time and an increasing counter. +.PP +Before a des key can be used it is converted into a +.I des_key_schedule +via the +.I des_set_key +routine. +If the +.I des_check_key +flag is non-zero, +.I des_set_key +will check that the key passed is of odd parity and is not a week or +semi-weak key. +If the parity is wrong, +then -1 is returned. +If the key is a weak key, +then -2 is returned. +If an error is returned, +the key schedule is not generated. +.PP +.I des_key_sched +is another name for the +.I des_set_key +function. +.PP +The following routines mostly operate on an input and output stream of +.I des_cblock's. +.PP +.I des_ecb_encrypt +is the basic DES encryption routine that encrypts or decrypts a single 8-byte +.I des_cblock +in +.I electronic code book +mode. +It always transforms the input data, pointed to by +.I input, +into the output data, +pointed to by the +.I output +argument. +If the +.I encrypt +argument is non-zero (DES_ENCRYPT), +the +.I input +(cleartext) is encrypted in to the +.I output +(ciphertext) using the key_schedule specified by the +.I schedule +argument, +previously set via +.I des_set_key. +If +.I encrypt +is zero (DES_DECRYPT), +the +.I input +(now ciphertext) +is decrypted into the +.I output +(now cleartext). +Input and output may overlap. +No meaningful value is returned. +.PP +.I des_ecb3_encrypt +encrypts/decrypts the +.I input +block by using triple ecb DES encryption. +This involves encrypting the input with +.I ks1, +decryption with the key schedule +.I ks2, +and then encryption with the first again. +This routine greatly reduces the chances of brute force breaking of +DES and has the advantage of if +.I ks1 +and +.I ks2 +are the same, it is equivalent to just encryption using ecb mode and +.I ks1 +as the key. +.PP +.I des_cbc_encrypt +encrypts/decrypts using the +.I cipher-block-chaining +mode of DES. +If the +.I encrypt +argument is non-zero, +the routine cipher-block-chain encrypts the cleartext data pointed to by the +.I input +argument into the ciphertext pointed to by the +.I output +argument, +using the key schedule provided by the +.I schedule +argument, +and initialisation vector provided by the +.I ivec +argument. +If the +.I length +argument is not an integral multiple of eight bytes, +the last block is copied to a temporary area and zero filled. +The output is always +an integral multiple of eight bytes. +To make multiple cbc encrypt calls on a large amount of data appear to +be one +.I des_cbc_encrypt +call, the +.I ivec +of subsequent calls should be the last 8 bytes of the output. +.PP +.I des_3cbc_encrypt +encrypts/decrypts the +.I input +block by using triple cbc DES encryption. +This involves encrypting the input with key schedule +.I ks1, +decryption with the key schedule +.I ks2, +and then encryption with the first again. +2 initialisation vectors are required, +.I ivec1 +and +.I ivec2. +Unlike +.I des_cbc_encrypt, +these initialisation vectors are modified by the subroutine. +This routine greatly reduces the chances of brute force breaking of +DES and has the advantage of if +.I ks1 +and +.I ks2 +are the same, it is equivalent to just encryption using cbc mode and +.I ks1 +as the key. +.PP +.I des_pcbc_encrypt +encrypt/decrypts using a modified block chaining mode. +It provides better error propagation characteristics than cbc +encryption. +.PP +.I des_cfb_encrypt +encrypt/decrypts using cipher feedback mode. This method takes an +array of characters as input and outputs and array of characters. It +does not require any padding to 8 character groups. Note: the ivec +variable is changed and the new changed value needs to be passed to +the next call to this function. Since this function runs a complete +DES ecb encryption per numbits, this function is only suggested for +use when sending small numbers of characters. +.PP +.I des_ofb_encrypt +encrypt using output feedback mode. This method takes an +array of characters as input and outputs and array of characters. It +does not require any padding to 8 character groups. Note: the ivec +variable is changed and the new changed value needs to be passed to +the next call to this function. Since this function runs a complete +DES ecb encryption per numbits, this function is only suggested for +use when sending small numbers of characters. +.PP +.I des_cbc_cksum +produces an 8 byte checksum based on the input stream (via cbc encryption). +The last 4 bytes of the checksum is returned and the complete 8 bytes is +placed in +.I output. +.PP +.I des_quad_cksum +returns a 4 byte checksum from the input bytes. +The algorithm can be iterated over the input, +depending on +.I out_count, +1, 2, 3 or 4 times. +If +.I output +is non-NULL, +the 8 bytes generated by each pass are written into +.I output. +.PP +.I des_enc_write +is used to write +.I len +bytes +to file descriptor +.I fd +from buffer +.I buf. +The data is encrypted via +.I pcbc_encrypt +(default) using +.I sched +for the key and +.I iv +as a starting vector. +The actual data send down +.I fd +consists of 4 bytes (in network byte order) containing the length of the +following encrypted data. The encrypted data then follows, padded with random +data out to a multiple of 8 bytes. +.PP +.I des_enc_read +is used to read +.I len +bytes +from file descriptor +.I fd +into buffer +.I buf. +The data being read from +.I fd +is assumed to have come from +.I des_enc_write +and is decrypted using +.I sched +for the key schedule and +.I iv +for the initial vector. +The +.I des_enc_read/des_enc_write +pair can be used to read/write to files, pipes and sockets. +I have used them in implementing a version of rlogin in which all +data is encrypted. +.PP +.I des_rw_mode +is used to specify the encryption mode to use with +.I des_enc_read +and +.I des_end_write. +If set to +.I DES_PCBC_MODE +(the default), des_pcbc_encrypt is used. +If set to +.I DES_CBC_MODE +des_cbc_encrypt is used. +These two routines and the variable are not part of the normal MIT library. +.PP +.I des_set_odd_parity +sets the parity of the passed +.I key +to odd. This routine is not part of the standard MIT library. +.PP +.I des_is_weak_key +returns 1 is the passed key is a weak key (pick again :-), +0 if it is ok. +This routine is not part of the standard MIT library. +.PP +.I crypt +is a replacement for the normal system crypt. +It is much faster than the system crypt. +.PP +.SH FILES +/usr/include/des.h +.br +/usr/lib/libdes.a +.PP +The encryption routines have been tested on 16bit, 32bit and 64bit +machines of various endian and even works under VMS. +.PP +.SH BUGS +.PP +If you think this manual is sparse, +read the des_crypt(3) manual from the MIT kerberos (or bones outside +of the USA) distribution. +.PP +.I des_cfb_encrypt +and +.I des_ofb_encrypt +operates on input of 8 bits. What this means is that if you set +numbits to 12, and length to 2, the first 12 bits will come from the 1st +input byte and the low half of the second input byte. The second 12 +bits will have the low 8 bits taken from the 3rd input byte and the +top 4 bits taken from the 4th input byte. The same holds for output. +This function has been implemented this way because most people will +be using a multiple of 8 and because once you get into pulling bytes input +bytes apart things get ugly! +.PP +.I des_read_pw_string +is the most machine/OS dependent function and normally generates the +most problems when porting this code. +.PP +.I des_string_to_key +is probably different from the MIT version since there are lots +of fun ways to implement one-way encryption of a text string. +.PP +The routines are optimised for 32 bit machines and so are not efficient +on IBM PCs. +.PP +NOTE: extensive work has been done on this library since this document +was origionally written. Please try to read des.doc from the libdes +distribution since it is far more upto date and documents more of the +functions. Libdes is now also being shipped as part of SSLeay, a +general cryptographic library that amonst other things implements +netscapes SSL protocoll. The most recent version can be found in +SSLeay distributions. +.SH AUTHOR +Eric Young (eay@cryptsoft.com) diff --git a/src/lib/libcrypto/des/des_locl.org b/src/lib/libcrypto/des/des_locl.org new file mode 100644 index 0000000000..e2e503cbed --- /dev/null +++ b/src/lib/libcrypto/des/des_locl.org @@ -0,0 +1,516 @@ +/* crypto/des/des_locl.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify des_locl.org since des_locl.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_DES_LOCL_H +#define HEADER_DES_LOCL_H + +#if defined(WIN32) || defined(WIN16) +#ifndef MSDOS +#define MSDOS +#endif +#endif + +#include +#include +#ifndef MSDOS +#include +#endif +#include "des.h" + +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ + #define DES_PTR + #define DES_RISC1 + #define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ + #define DES_PTR + #define DES_RISC2 + #define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ + #define DES_PTR + #define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ + #define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ + #define DES_PTR + #define DES_RISC2 + #define DES_UNROLL +#elif defined( i386 ) /* x86 boxes, should be gcc */ + #define DES_PTR + #define DES_RISC1 + #define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ + +#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ +#include +#include +#include +#include +#ifndef RAND +#define RAND +#endif +#undef NOPROTO +#endif + +#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) +#include +#endif + +#ifndef RAND +#define RAND +#endif + +#ifdef linux +#undef RAND +#endif + +#ifdef MSDOS +#define getpid() 2 +#define RAND +#undef NOPROTO +#endif + +#if defined(NOCONST) +#define const +#endif + +#ifdef __STDC__ +#undef NOPROTO +#endif + +#ifdef RAND +#define srandom(s) srand(s) +#define random rand +#endif + +#define ITERATIONS 16 +#define HALF_ITERATIONS 8 + +/* used in des_read and des_write */ +#define MAXWRITE (1024*16) +#define BSIZE (MAXWRITE+4) + +#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ + case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ + case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ + case 5: l2|=((DES_LONG)(*(--(c)))); \ + case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ + case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ + case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ + case 1: l1|=((DES_LONG)(*(--(c)))); \ + } \ + } + +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* replacements for htonl and ntohl since I have no idea what to do + * when faced with machines with 8 byte longs. */ +#define HDRSIZE 4 + +#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))) + +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +#if defined(WIN32) +#define ROTATE(a,n) (_lrotr(a,n)) +#else +#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) +#endif + +/* Don't worry about the LOAD_DATA() stuff, that is used by + * fcrypt() to add it's little bit to the front */ + +#ifdef DES_FCRYPT + +#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ + { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } + +#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + t=R^(R>>16L); \ + u=t&E0; t&=E1; \ + tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ + tmp=(t<<16); t^=R^s[S+1]; t^=tmp +#else +#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) +#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + u=R^s[S ]; \ + t=R^s[S+1] +#endif + +/* The changes to this macro may help or hinder, depending on the + * compiler and the achitecture. gcc2 always seems to do well :-). + * Inspired by Dana How + * DO NOT use the alternative version on machines with 8 byte longs. + * It does not seem to work on the Alpha, even when DES_LONG is 4 + * bytes, probably an issue of accessing non-word aligned objects :-( */ +#ifdef DES_PTR + +/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there + * is no reason to not xor all the sub items together. This potentially + * saves a register since things can be xored directly into L */ + +#if defined(DES_RISC1) || defined(DES_RISC2) +#ifdef DES_RISC1 +#define D_ENCRYPT(LL,R,S) { \ + unsigned int u1,u2,u3; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u2=(int)u>>8L; \ + u1=(int)u&0xfc; \ + u2&=0xfc; \ + t=ROTATE(t,4); \ + u>>=16L; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \ + u3=(int)(u>>8L); \ + u1=(int)u&0xfc; \ + u3&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \ + u2=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u2&=0xfc; \ + t>>=16L; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \ + u3=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u3&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); } +#endif +#ifdef DES_RISC2 +#define D_ENCRYPT(LL,R,S) { \ + unsigned int u1,u2,s1,s2; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u2=(int)u>>8L; \ + u1=(int)u&0xfc; \ + u2&=0xfc; \ + t=ROTATE(t,4); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \ + s1=(int)(u>>16L); \ + s2=(int)(u>>24L); \ + s1&=0xfc; \ + s2&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \ + u2=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u2&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \ + s1=(int)(t>>16L); \ + s2=(int)(t>>24L); \ + s1&=0xfc; \ + s2&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); } +#endif +#else +#define D_ENCRYPT(LL,R,S) { \ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^= \ + *(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); } +#endif + +#else /* original version */ + +#if defined(DES_RISC1) || defined(DES_RISC2) +#ifdef DES_RISC1 +#define D_ENCRYPT(LL,R,S) {\ + unsigned int u1,u2,u3; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u>>=2L; \ + t=ROTATE(t,6); \ + u2=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u2&=0x3f; \ + u>>=16L; \ + LL^=des_SPtrans[0][u1]; \ + LL^=des_SPtrans[2][u2]; \ + u3=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u3&=0x3f; \ + LL^=des_SPtrans[4][u1]; \ + LL^=des_SPtrans[6][u3]; \ + u2=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u2&=0x3f; \ + t>>=16L; \ + LL^=des_SPtrans[1][u1]; \ + LL^=des_SPtrans[3][u2]; \ + u3=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u3&=0x3f; \ + LL^=des_SPtrans[5][u1]; \ + LL^=des_SPtrans[7][u3]; } +#endif +#ifdef DES_RISC2 +#define D_ENCRYPT(LL,R,S) {\ + unsigned int u1,u2,s1,s2; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u>>=2L; \ + t=ROTATE(t,6); \ + u2=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u2&=0x3f; \ + LL^=des_SPtrans[0][u1]; \ + LL^=des_SPtrans[2][u2]; \ + s1=(int)u>>16L; \ + s2=(int)u>>24L; \ + s1&=0x3f; \ + s2&=0x3f; \ + LL^=des_SPtrans[4][s1]; \ + LL^=des_SPtrans[6][s2]; \ + u2=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u2&=0x3f; \ + LL^=des_SPtrans[1][u1]; \ + LL^=des_SPtrans[3][u2]; \ + s1=(int)t>>16; \ + s2=(int)t>>24L; \ + s1&=0x3f; \ + s2&=0x3f; \ + LL^=des_SPtrans[5][s1]; \ + LL^=des_SPtrans[7][s2]; } +#endif + +#else + +#define D_ENCRYPT(LL,R,S) {\ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^=\ + des_SPtrans[0][(u>> 2L)&0x3f]^ \ + des_SPtrans[2][(u>>10L)&0x3f]^ \ + des_SPtrans[4][(u>>18L)&0x3f]^ \ + des_SPtrans[6][(u>>26L)&0x3f]^ \ + des_SPtrans[1][(t>> 2L)&0x3f]^ \ + des_SPtrans[3][(t>>10L)&0x3f]^ \ + des_SPtrans[5][(t>>18L)&0x3f]^ \ + des_SPtrans[7][(t>>26L)&0x3f]; } +#endif +#endif + + /* IP and FP + * The problem is more of a geometric problem that random bit fiddling. + 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 + 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 + 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 + 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 + + 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 + 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 + 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 + 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 + + The output has been subject to swaps of the form + 0 1 -> 3 1 but the odd and even bits have been put into + 2 3 2 0 + different words. The main trick is to remember that + t=((l>>size)^r)&(mask); + r^=t; + l^=(t<>(n))^(b))&(m)),\ + (b)^=(t),\ + (a)^=((t)<<(n))) + +#define IP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ + PERM_OP(l,r,tt,16,0x0000ffffL); \ + PERM_OP(r,l,tt, 2,0x33333333L); \ + PERM_OP(l,r,tt, 8,0x00ff00ffL); \ + PERM_OP(r,l,tt, 1,0x55555555L); \ + } + +#define FP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(l,r,tt, 1,0x55555555L); \ + PERM_OP(r,l,tt, 8,0x00ff00ffL); \ + PERM_OP(l,r,tt, 2,0x33333333L); \ + PERM_OP(r,l,tt,16,0x0000ffffL); \ + PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ + } + +extern const DES_LONG des_SPtrans[8][64]; + +#ifndef NOPROTO +void fcrypt_body(DES_LONG *out,des_key_schedule ks, + DES_LONG Eswap0, DES_LONG Eswap1); +#else +void fcrypt_body(); +#endif + +#endif diff --git a/src/lib/libcrypto/des/doIP b/src/lib/libcrypto/des/doIP new file mode 100644 index 0000000000..18cf231303 --- /dev/null +++ b/src/lib/libcrypto/des/doIP @@ -0,0 +1,46 @@ +#!/usr/local/bin/perl + +@l=( + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23, + 24,25,26,27,28,29,30,31 + ); +@r=( + 32,33,34,35,36,37,38,39, + 40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55, + 56,57,58,59,60,61,62,63 + ); + +require 'shifts.pl'; + +sub PERM_OP + { + local(*a,*b,*t,$n,$m)=@_; + + @z=&shift(*a,-$n); + @z=&xor(*b,*z); + @z=&and(*z,$m); + @b=&xor(*b,*z); + @z=&shift(*z,$n); + @a=&xor(*a,*z); + } + + +@L=@l; +@R=@r; +&PERM_OP(*R,*L,*T,4,0x0f0f0f0f); +&PERM_OP(*L,*R,*T,16,0x0000ffff); +&PERM_OP(*R,*L,*T,2,0x33333333); +&PERM_OP(*L,*R,*T,8,0x00ff00ff); +&PERM_OP(*R,*L,*T,1,0x55555555); + &printit(@L); + &printit(@R); +&PERM_OP(*R,*L,*T,1,0x55555555); +&PERM_OP(*L,*R,*T,8,0x00ff00ff); +&PERM_OP(*R,*L,*T,2,0x33333333); +&PERM_OP(*L,*R,*T,16,0x0000ffff); +&PERM_OP(*R,*L,*T,4,0x0f0f0f0f); + &printit(@L); + &printit(@R); diff --git a/src/lib/libcrypto/des/doPC1 b/src/lib/libcrypto/des/doPC1 new file mode 100644 index 0000000000..096afd8c46 --- /dev/null +++ b/src/lib/libcrypto/des/doPC1 @@ -0,0 +1,110 @@ +#!/usr/local/bin/perl + +@l=( + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23, + 24,25,26,27,28,29,30,31 + ); +@r=( + 32,33,34,35,36,37,38,39, + 40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55, + 56,57,58,59,60,61,62,63 + ); + +require 'shifts.pl'; + +sub PERM_OP + { + local(*a,*b,*t,$n,$m)=@_; + + @z=&shift(*a,-$n); + @z=&xor(*b,*z); + @z=&and(*z,$m); + @b=&xor(*b,*z); + @z=&shift(*z,$n); + @a=&xor(*a,*z); + } + +sub HPERM_OP2 + { + local(*a,*t,$n,$m)=@_; + local(@x,@y,$i); + + @z=&shift(*a,16-$n); + @z=&xor(*a,*z); + @z=&and(*z,$m); + @a=&xor(*a,*z); + @z=&shift(*z,$n-16); + @a=&xor(*a,*z); + } + +sub HPERM_OP + { + local(*a,*t,$n,$m)=@_; + local(@x,@y,$i); + + for ($i=0; $i<16; $i++) + { + $x[$i]=$a[$i]; + $y[$i]=$a[16+$i]; + } + @z=&shift(*x,-$n); + @z=&xor(*y,*z); + @z=&and(*z,$m); + @y=&xor(*y,*z); + @z=&shift(*z,$n); + @x=&xor(*x,*z); + for ($i=0; $i<16; $i++) + { + $a[$i]=$x[$i]; + $a[16+$i]=$y[$i]; + } + } + +@L=@l; +@R=@r; + + print "---\n"; &printit(@R); +&PERM_OP(*R,*L,*T,4,0x0f0f0f0f); + print "---\n"; &printit(@R); +&HPERM_OP2(*L,*T,-2,0xcccc0000); +&HPERM_OP2(*R,*T,-2,0xcccc0000); + print "---\n"; &printit(@R); +&PERM_OP(*R,*L,*T,1,0x55555555); + print "---\n"; &printit(@R); +&PERM_OP(*L,*R,*T,8,0x00ff00ff); + print "---\n"; &printit(@R); +&PERM_OP(*R,*L,*T,1,0x55555555); + print "---\n"; &printit(@R); +# &printit(@L); + &printit(@R); +print <<"EOF"; +============================== +63 55 47 39 31 23 15 7 +62 54 46 38 30 22 14 6 +61 53 45 37 29 21 13 5 +60 52 44 36 -- -- -- -- + +57 49 41 33 25 17 9 1 +58 50 42 34 26 18 10 2 +59 51 43 35 27 19 11 3 +28 20 12 4 -- -- -- -- +EOF +exit(1); +@A=&and(*R,0x000000ff); +@A=&shift(*A,16); +@B=&and(*R,0x0000ff00); +@C=&and(*R,0x00ff0000); +@C=&shift(*C,-16); +@D=&and(*L,0xf0000000); +@D=&shift(*D,-4); +@A=&or(*A,*B); +@B=&or(*D,*C); +@R=&or(*A,*B); +@L=&and(*L,0x0fffffff); + + &printit(@L); + &printit(@R); + diff --git a/src/lib/libcrypto/des/doPC2 b/src/lib/libcrypto/des/doPC2 new file mode 100644 index 0000000000..fa5cf74cf7 --- /dev/null +++ b/src/lib/libcrypto/des/doPC2 @@ -0,0 +1,94 @@ +#!/usr/local/bin/perl + +@PC2_C=(14,17,11,24, 1, 5, + 3,28,15, 6,21,10, + 23,19,12, 4,26, 8, + 16, 7,27,20,13, 2, + ); + +@PC2_D=(41,52,31,37,47,55, + 30,40,51,45,33,48, + 44,49,39,56,34,53, + 46,42,50,36,29,32, + ); + +$i=0; +foreach (@PC2_C) { + $_--; +# printf "%2d,",$_; + $C{$_}=$i; + ++$i; +# print "\n" if ((($i) % 8) == 0); + } +$i=0; +#print "\n"; +foreach (@PC2_D) { + $_-=28; + $_--; +# printf "%2d,",$_; + $D{$_}=$i; + $i++; +# print "\n" if ((($i) % 8) == 0); + } + +#print "\n"; +foreach $i (0 .. 27) + { + $_=$C{$i}; +# printf "%2d,",$_; + $i++; +# print "\n" if ((($i) % 8) == 0); + } +#print "\n"; + +#print "\n"; +foreach $i (0 .. 27) + { + $_=$D{$i}; +# printf "%2d,",$_; + $i++; +# print "\n" if ((($i) % 8) == 0); + } +#print "\n"; + +print "static ulong skb[8][64]={\n"; +&doit("C",*C, 0, 1, 2, 3, 4, 5); +&doit("C",*C, 6, 7, 9,10,11,12); +&doit("C",*C,13,14,15,16,18,19); +&doit("C",*C,20,22,23,25,26,27); + +&doit("D",*D, 0, 1, 2, 3, 4, 5); +&doit("D",*D, 7, 8,10,11,12,13); +&doit("D",*D,15,16,17,18,19,20); +&doit("D",*D,21,22,23,24,26,27); +print "};\n"; + +sub doit + { + local($l,*A,@b)=@_; + local(@out); + + printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n", + $b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1); + for ($i=0; $i<64; $i++) + { + $out[$i]=0; + $j=1; +#print "\n"; + for ($k=0; $k<6; $k++) + { + $l=$A{$b[$k]}; +#print"$l - "; + if ((1<<$k) & $i) + { + $ll=int($l/6)*8+($l%6); + $out[$i]|=1<<($ll); + } + } + $pp=$out[$i]; + $pp=($pp&0xff0000ff)| (($pp&0x00ff0000)>>8)| + (($pp&0x0000ff00)<<8); + printf("0x%08X,",$pp); + print "\n" if (($i+1) % 4 == 0); + } + } diff --git a/src/lib/libcrypto/des/ede_enc.c b/src/lib/libcrypto/des/ede_enc.c new file mode 100644 index 0000000000..9f75dd1037 --- /dev/null +++ b/src/lib/libcrypto/des/ede_enc.c @@ -0,0 +1,190 @@ +/* crypto/des/ede_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "des_locl.h" + +void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc) +des_cblock (*input); +des_cblock (*output); +long length; +des_key_schedule ks1; +des_key_schedule ks2; +des_key_schedule ks3; +des_cblock (*ivec); +int enc; + { + register DES_LONG tin0,tin1; + register DES_LONG tout0,tout1,xor0,xor1; + register unsigned char *in,*out; + register long l=length; + DES_LONG tin[2]; + unsigned char *iv; + + in=(unsigned char *)input; + out=(unsigned char *)output; + iv=(unsigned char *)ivec; + + if (enc) + { + c2l(iv,tout0); + c2l(iv,tout1); + for (l-=8; l>=0; l-=8) + { + c2l(in,tin0); + c2l(in,tin1); + tin0^=tout0; + tin1^=tout1; + + tin[0]=tin0; + tin[1]=tin1; + des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + l2c(tout0,out); + l2c(tout1,out); + } + if (l != -8) + { + c2ln(in,tin0,tin1,l+8); + tin0^=tout0; + tin1^=tout1; + + tin[0]=tin0; + tin[1]=tin1; + des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + l2c(tout0,out); + l2c(tout1,out); + } + iv=(unsigned char *)ivec; + l2c(tout0,iv); + l2c(tout1,iv); + } + else + { + register DES_LONG t0,t1; + + c2l(iv,xor0); + c2l(iv,xor1); + for (l-=8; l>=0; l-=8) + { + c2l(in,tin0); + c2l(in,tin1); + + t0=tin0; + t1=tin1; + + tin[0]=tin0; + tin[1]=tin1; + des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + tout0^=xor0; + tout1^=xor1; + l2c(tout0,out); + l2c(tout1,out); + xor0=t0; + xor1=t1; + } + if (l != -8) + { + c2l(in,tin0); + c2l(in,tin1); + + t0=tin0; + t1=tin1; + + tin[0]=tin0; + tin[1]=tin1; + des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + tout0^=xor0; + tout1^=xor1; + l2cn(tout0,tout1,out,l+8); + xor0=t0; + xor1=t1; + } + + iv=(unsigned char *)ivec; + l2c(xor0,iv); + l2c(xor1,iv); + } + tin0=tin1=tout0=tout1=xor0=xor1=0; + tin[0]=tin[1]=0; + } + +#ifdef undef /* MACRO */ +void des_ede2_cbc_encrypt(input, output, length, ks1, ks2, ivec, enc) +des_cblock (*input); +des_cblock (*output); +long length; +des_key_schedule ks1; +des_key_schedule ks2; +des_cblock (*ivec); +int enc; + { + des_ede3_cbc_encrypt(input,output,length,ks1,ks2,ks1,ivec,enc); + } +#endif + diff --git a/src/lib/libcrypto/des/podd.h b/src/lib/libcrypto/des/podd.h new file mode 100644 index 0000000000..1b2bfe0843 --- /dev/null +++ b/src/lib/libcrypto/des/podd.h @@ -0,0 +1,75 @@ +/* crypto/des/podd.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +static const unsigned char odd_parity[256]={ + 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, + 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, + 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, + 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, + 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, + 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, + 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, +112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, +128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, +145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, +161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, +176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, +193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, +208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, +224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, +241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; diff --git a/src/lib/libcrypto/des/ranlib.sh b/src/lib/libcrypto/des/ranlib.sh new file mode 100644 index 0000000000..543f712c6b --- /dev/null +++ b/src/lib/libcrypto/des/ranlib.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cwd=`pwd` +cd /tmp + +if [ -s /bin/ranlib ] ; then + RL=/bin/ranlib +else if [ -s /usr/bin/ranlib ] ; then + RL=/usr/bin/ranlib +fi +fi + +if [ "x$RL" != "x" ] +then + case "$1" in + /*) + $RL "$1" + ;; + *) + $RL "$cwd/$1" + ;; + esac +fi diff --git a/src/lib/libcrypto/des/shifts.pl b/src/lib/libcrypto/des/shifts.pl new file mode 100644 index 0000000000..d8a240c1ba --- /dev/null +++ b/src/lib/libcrypto/des/shifts.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl + +sub lab_shift + { + local(*a,$n)=@_; + local(@r,$i,$j,$k,$d,@z); + + @r=&shift(*a,$n); + foreach $i (0 .. 31) + { + @z=split(/\^/,$r[$i]); + for ($j=0; $j <= $#z; $j++) + { + ($d)=($z[$j] =~ /^(..)/); + ($k)=($z[$j] =~ /\[(.*)\]$/); + $k.=",$n" if ($k ne ""); + $k="$n" if ($k eq ""); + $d="$d[$k]"; + $z[$j]=$d; + } + $r[$i]=join('^',@z); + } + return(@r); + } + +sub shift + { + local(*a,$n)=@_; + local(@f); + + if ($n > 0) + { + @f=&shiftl(*a,$n); + } + else + { + @f=&shiftr(*a,-$n); + } + return(@f); + } + +sub rotate + { + local(*a,$n)=@_; + local(@f); + + if ($n > 0) + { @f=&rotatel(*a,$n); } + else + { @f=&rotater(*a,-$n); } + return(@f); + } + +sub rotater + { + local(*a,$n)=@_; + local(@f,@g); + + @f=&shiftr(*a,$n); + @g=&shiftl(*a,32-$n); + $#f=31; + $#g=31; + return(&or(*f,*g)); + } + +sub rotatel + { + local(*a,$n)=@_; + local(@f,@g); + + @f=&shiftl(*a,$n); + @g=&shiftr(*a,32-$n); + $#f=31; + $#g=31; + return(&or(*f,*g)); + } + +sub shiftr + { + local(*a,$n)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + if (($i+$n) > 31) + { + $r[$i]="--"; + } + else + { + $r[$i]=$a[$i+$n]; + } + } + return(@r); + } + +sub shiftl + { + local(*a,$n)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + if ($i < $n) + { + $r[$i]="--"; + } + else + { + $r[$i]=$a[$i-$n]; + } + } + return(@r); + } + +sub printit + { + local(@a)=@_; + local($i); + + foreach $i (0 .. 31) + { + printf "%2s ",$a[$i]; + print "\n" if (($i%8) == 7); + } + print "\n"; + } + +sub xor + { + local(*a,*b)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + $r[$i]=&compress($a[$i].'^'.$b[$i]); +# $r[$i]=$a[$i]."^".$b[$i]; + } + return(@r); + } + +sub and + { + local(*a,$m)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + $r[$i]=(($m & (1<<$i))?($a[$i]):('--')); + } + return(@r); + } + +sub or + { + local(*a,*b)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + $r[$i]='--' if (($a[$i] eq '--') && ($b[$i] eq '--')); + $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--')); + $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--')); + $r[$i]='++' if (($a[$i] ne '--') && ($b[$i] ne '--')); + } + return(@r); + } + +sub compress + { + local($s)=@_; + local($_,$i,@a,%a,$r); + + $s =~ s/\^\^/\^/g; + $s =~ s/^\^//; + $s =~ s/\^$//; + @a=split(/\^/,$s); + + while ($#a >= 0) + { + $_=shift(@a); + next unless /\d/; + $a{$_}++; + } + foreach $i (sort keys %a) + { + next if ($a{$i}%2 == 0); + $r.="$i^"; + } + chop($r); + return($r); + } +1; diff --git a/src/lib/libcrypto/des/sk.h b/src/lib/libcrypto/des/sk.h new file mode 100644 index 0000000000..f2ade88c7c --- /dev/null +++ b/src/lib/libcrypto/des/sk.h @@ -0,0 +1,204 @@ +/* crypto/des/sk.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +static const DES_LONG des_skb[8][64]={ +{ +/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ +0x00000000L,0x00000010L,0x20000000L,0x20000010L, +0x00010000L,0x00010010L,0x20010000L,0x20010010L, +0x00000800L,0x00000810L,0x20000800L,0x20000810L, +0x00010800L,0x00010810L,0x20010800L,0x20010810L, +0x00000020L,0x00000030L,0x20000020L,0x20000030L, +0x00010020L,0x00010030L,0x20010020L,0x20010030L, +0x00000820L,0x00000830L,0x20000820L,0x20000830L, +0x00010820L,0x00010830L,0x20010820L,0x20010830L, +0x00080000L,0x00080010L,0x20080000L,0x20080010L, +0x00090000L,0x00090010L,0x20090000L,0x20090010L, +0x00080800L,0x00080810L,0x20080800L,0x20080810L, +0x00090800L,0x00090810L,0x20090800L,0x20090810L, +0x00080020L,0x00080030L,0x20080020L,0x20080030L, +0x00090020L,0x00090030L,0x20090020L,0x20090030L, +0x00080820L,0x00080830L,0x20080820L,0x20080830L, +0x00090820L,0x00090830L,0x20090820L,0x20090830L, +},{ +/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ +0x00000000L,0x02000000L,0x00002000L,0x02002000L, +0x00200000L,0x02200000L,0x00202000L,0x02202000L, +0x00000004L,0x02000004L,0x00002004L,0x02002004L, +0x00200004L,0x02200004L,0x00202004L,0x02202004L, +0x00000400L,0x02000400L,0x00002400L,0x02002400L, +0x00200400L,0x02200400L,0x00202400L,0x02202400L, +0x00000404L,0x02000404L,0x00002404L,0x02002404L, +0x00200404L,0x02200404L,0x00202404L,0x02202404L, +0x10000000L,0x12000000L,0x10002000L,0x12002000L, +0x10200000L,0x12200000L,0x10202000L,0x12202000L, +0x10000004L,0x12000004L,0x10002004L,0x12002004L, +0x10200004L,0x12200004L,0x10202004L,0x12202004L, +0x10000400L,0x12000400L,0x10002400L,0x12002400L, +0x10200400L,0x12200400L,0x10202400L,0x12202400L, +0x10000404L,0x12000404L,0x10002404L,0x12002404L, +0x10200404L,0x12200404L,0x10202404L,0x12202404L, +},{ +/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ +0x00000000L,0x00000001L,0x00040000L,0x00040001L, +0x01000000L,0x01000001L,0x01040000L,0x01040001L, +0x00000002L,0x00000003L,0x00040002L,0x00040003L, +0x01000002L,0x01000003L,0x01040002L,0x01040003L, +0x00000200L,0x00000201L,0x00040200L,0x00040201L, +0x01000200L,0x01000201L,0x01040200L,0x01040201L, +0x00000202L,0x00000203L,0x00040202L,0x00040203L, +0x01000202L,0x01000203L,0x01040202L,0x01040203L, +0x08000000L,0x08000001L,0x08040000L,0x08040001L, +0x09000000L,0x09000001L,0x09040000L,0x09040001L, +0x08000002L,0x08000003L,0x08040002L,0x08040003L, +0x09000002L,0x09000003L,0x09040002L,0x09040003L, +0x08000200L,0x08000201L,0x08040200L,0x08040201L, +0x09000200L,0x09000201L,0x09040200L,0x09040201L, +0x08000202L,0x08000203L,0x08040202L,0x08040203L, +0x09000202L,0x09000203L,0x09040202L,0x09040203L, +},{ +/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ +0x00000000L,0x00100000L,0x00000100L,0x00100100L, +0x00000008L,0x00100008L,0x00000108L,0x00100108L, +0x00001000L,0x00101000L,0x00001100L,0x00101100L, +0x00001008L,0x00101008L,0x00001108L,0x00101108L, +0x04000000L,0x04100000L,0x04000100L,0x04100100L, +0x04000008L,0x04100008L,0x04000108L,0x04100108L, +0x04001000L,0x04101000L,0x04001100L,0x04101100L, +0x04001008L,0x04101008L,0x04001108L,0x04101108L, +0x00020000L,0x00120000L,0x00020100L,0x00120100L, +0x00020008L,0x00120008L,0x00020108L,0x00120108L, +0x00021000L,0x00121000L,0x00021100L,0x00121100L, +0x00021008L,0x00121008L,0x00021108L,0x00121108L, +0x04020000L,0x04120000L,0x04020100L,0x04120100L, +0x04020008L,0x04120008L,0x04020108L,0x04120108L, +0x04021000L,0x04121000L,0x04021100L,0x04121100L, +0x04021008L,0x04121008L,0x04021108L,0x04121108L, +},{ +/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ +0x00000000L,0x10000000L,0x00010000L,0x10010000L, +0x00000004L,0x10000004L,0x00010004L,0x10010004L, +0x20000000L,0x30000000L,0x20010000L,0x30010000L, +0x20000004L,0x30000004L,0x20010004L,0x30010004L, +0x00100000L,0x10100000L,0x00110000L,0x10110000L, +0x00100004L,0x10100004L,0x00110004L,0x10110004L, +0x20100000L,0x30100000L,0x20110000L,0x30110000L, +0x20100004L,0x30100004L,0x20110004L,0x30110004L, +0x00001000L,0x10001000L,0x00011000L,0x10011000L, +0x00001004L,0x10001004L,0x00011004L,0x10011004L, +0x20001000L,0x30001000L,0x20011000L,0x30011000L, +0x20001004L,0x30001004L,0x20011004L,0x30011004L, +0x00101000L,0x10101000L,0x00111000L,0x10111000L, +0x00101004L,0x10101004L,0x00111004L,0x10111004L, +0x20101000L,0x30101000L,0x20111000L,0x30111000L, +0x20101004L,0x30101004L,0x20111004L,0x30111004L, +},{ +/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ +0x00000000L,0x08000000L,0x00000008L,0x08000008L, +0x00000400L,0x08000400L,0x00000408L,0x08000408L, +0x00020000L,0x08020000L,0x00020008L,0x08020008L, +0x00020400L,0x08020400L,0x00020408L,0x08020408L, +0x00000001L,0x08000001L,0x00000009L,0x08000009L, +0x00000401L,0x08000401L,0x00000409L,0x08000409L, +0x00020001L,0x08020001L,0x00020009L,0x08020009L, +0x00020401L,0x08020401L,0x00020409L,0x08020409L, +0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, +0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, +0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, +0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, +0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, +0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, +0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, +0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, +},{ +/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ +0x00000000L,0x00000100L,0x00080000L,0x00080100L, +0x01000000L,0x01000100L,0x01080000L,0x01080100L, +0x00000010L,0x00000110L,0x00080010L,0x00080110L, +0x01000010L,0x01000110L,0x01080010L,0x01080110L, +0x00200000L,0x00200100L,0x00280000L,0x00280100L, +0x01200000L,0x01200100L,0x01280000L,0x01280100L, +0x00200010L,0x00200110L,0x00280010L,0x00280110L, +0x01200010L,0x01200110L,0x01280010L,0x01280110L, +0x00000200L,0x00000300L,0x00080200L,0x00080300L, +0x01000200L,0x01000300L,0x01080200L,0x01080300L, +0x00000210L,0x00000310L,0x00080210L,0x00080310L, +0x01000210L,0x01000310L,0x01080210L,0x01080310L, +0x00200200L,0x00200300L,0x00280200L,0x00280300L, +0x01200200L,0x01200300L,0x01280200L,0x01280300L, +0x00200210L,0x00200310L,0x00280210L,0x00280310L, +0x01200210L,0x01200310L,0x01280210L,0x01280310L, +},{ +/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ +0x00000000L,0x04000000L,0x00040000L,0x04040000L, +0x00000002L,0x04000002L,0x00040002L,0x04040002L, +0x00002000L,0x04002000L,0x00042000L,0x04042000L, +0x00002002L,0x04002002L,0x00042002L,0x04042002L, +0x00000020L,0x04000020L,0x00040020L,0x04040020L, +0x00000022L,0x04000022L,0x00040022L,0x04040022L, +0x00002020L,0x04002020L,0x00042020L,0x04042020L, +0x00002022L,0x04002022L,0x00042022L,0x04042022L, +0x00000800L,0x04000800L,0x00040800L,0x04040800L, +0x00000802L,0x04000802L,0x00040802L,0x04040802L, +0x00002800L,0x04002800L,0x00042800L,0x04042800L, +0x00002802L,0x04002802L,0x00042802L,0x04042802L, +0x00000820L,0x04000820L,0x00040820L,0x04040820L, +0x00000822L,0x04000822L,0x00040822L,0x04040822L, +0x00002820L,0x04002820L,0x00042820L,0x04042820L, +0x00002822L,0x04002822L,0x00042822L,0x04042822L, +}}; diff --git a/src/lib/libcrypto/des/supp.c b/src/lib/libcrypto/des/supp.c new file mode 100644 index 0000000000..f8e5833f69 --- /dev/null +++ b/src/lib/libcrypto/des/supp.c @@ -0,0 +1,109 @@ +/* crypto/des/supp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* + * Copyright (c) 1995 + * Mark Murray. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Mark Murray + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: supp.c,v 1.1.1.1 1998/10/05 20:12:45 ryker Exp $ + */ + +#include +#include "des_locl.h" + +void des_cblock_print_file(cb, fp) + des_cblock *cb; + FILE *fp; +{ + int i; + unsigned int *p = (unsigned int *)cb; + + fprintf(fp, " 0x { "); + for (i = 0; i < 8; i++) { + fprintf(fp, "%x", p[i]); + if (i != 7) fprintf(fp, ", "); + } + fprintf(fp, " }"); +} diff --git a/src/lib/libcrypto/des/testdes.pl b/src/lib/libcrypto/des/testdes.pl new file mode 100644 index 0000000000..67fbd47f36 --- /dev/null +++ b/src/lib/libcrypto/des/testdes.pl @@ -0,0 +1,167 @@ +#!/usr/bin/perl + +# des.pl tesing code + +require 'des.pl'; + +$num_tests=34; +@key_data=( + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10, + 0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57, + 0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E, + 0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86, + 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E, + 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6, + 0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE, + 0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6, + 0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE, + 0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16, + 0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F, + 0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46, + 0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E, + 0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76, + 0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07, + 0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F, + 0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7, + 0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF, + 0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6, + 0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E, + 0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10, + ); + +@plain_data=( + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42, + 0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA, + 0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72, + 0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A, + 0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2, + 0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A, + 0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2, + 0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A, + 0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02, + 0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A, + 0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32, + 0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA, + 0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62, + 0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2, + 0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA, + 0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92, + 0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A, + 0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2, + 0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF); + +@cipher_data=( + 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7, + 0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58, + 0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B, + 0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33, + 0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D, + 0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD, + 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7, + 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4, + 0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B, + 0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71, + 0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A, + 0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A, + 0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95, + 0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B, + 0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09, + 0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A, + 0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F, + 0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88, + 0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77, + 0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A, + 0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56, + 0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56, + 0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56, + 0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC, + 0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A, + 0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41, + 0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93, + 0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00, + 0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06, + 0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7, + 0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51, + 0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE, + 0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D, + 0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2); + +print "Doing ecb tests\n"; +for ($i=0; $i<$num_tests; $i++) + { + printf "Doing test $i\n"; + $key =pack("C8",splice(@key_data ,0,8)); + $data=pack("C8",splice(@plain_data ,0,8)); + $res =pack("C8",splice(@cipher_data,0,8)); + + @ks= &des_set_key($key); + $out1= &des_ecb_encrypt(*ks,1,$data); + $out2= &des_ecb_encrypt(*ks,0,$out1); + $out3= &des_ecb_encrypt(*ks,0,$res); + &eprint("encryption failure",$res,$out1) + if ($out1 ne $res); + &eprint("encryption/decryption failure",$data,$out2) + if ($out2 ne $data); + &eprint("decryption failure",$data,$out3) + if ($data ne $out3); + } +print "Done\n"; + +print "doing speed test over 30 seconds\n"; +$SIG{'ALRM'}='done'; +sub done {$done=1;} +$done=0; + +$count=0; +$d=pack("C8",0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef); +@ks= &des_set_key($d); +alarm(30); +$start=(times)[0]; +while (!$done) + { + $count++; + $d=&des_ecb_encrypt(*ks,1,$d); + } +$end=(times)[0]; +$t=$end-$start; +printf "$count DESs in %.2f seconds is %.2f DESs/sec or %.2f bytes/sec\n", + 1.0*$t,1.0*$count/$t,$count*8.0/$t; + +sub eprint + { + local($s,$c,$e)=@_; + local(@k); + + @k=unpack("C8",$c); + printf "%02x%02x%02x%02x %02x%02x%02x%02x - ",unpack("C8",$c); + printf "%02x%02x%02x%02x %02x%02x%02x%02x :",unpack("C8",$e); + print " $s\n"; + } diff --git a/src/lib/libcrypto/des/vms.com b/src/lib/libcrypto/des/vms.com new file mode 100644 index 0000000000..62ca1fbda4 --- /dev/null +++ b/src/lib/libcrypto/des/vms.com @@ -0,0 +1,90 @@ +$! --- VMS.com --- +$! +$ GoSub defines +$ GoSub linker_options +$ If (P1 .nes. "") +$ Then +$ GoSub 'P1' +$ Else +$ GoSub lib +$ GoSub destest +$ GoSub rpw +$ GoSub speed +$ GoSub des +$ EndIF +$! +$ Exit +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$DEFINES: +$ OPT_FILE := "VAX_LINKER_OPTIONS.OPT" +$! +$ CC_OPTS := "/NODebug/OPTimize/NOWarn" +$! +$ LINK_OPTS := "/NODebug/NOTraceback/Contiguous" +$! +$ OBJS = "cbc_cksm.obj,cbc_enc.obj,ecb_enc.obj,pcbc_enc.obj," + - + "qud_cksm.obj,rand_key.obj,read_pwd.obj,set_key.obj," + - + "str2key.obj,enc_read.obj,enc_writ.obj,fcrypt.obj," + - + "cfb_enc.obj,ecb3_enc.obj,ofb_enc.obj" + + +$! +$ LIBDES = "cbc_cksm.c,cbc_enc.c,ecb_enc.c,enc_read.c," + - + "enc_writ.c,pcbc_enc.c,qud_cksm.c,rand_key.c," + - + "read_pwd.c,set_key.c,str2key.c,fcrypt.c," + - + "cfb_enc.c,ecb3_enc.c,ofb_enc.c" +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$LINKER_OPTIONS: +$ If (f$search(OPT_FILE) .eqs. "") +$ Then +$ Create 'OPT_FILE' +$DECK +! Default system options file to link against the sharable C runtime library +! +Sys$Share:VAXcRTL.exe/Share +$EOD +$ EndIF +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$LIB: +$ CC 'CC_OPTS' 'LIBDES' +$ If (f$search("LIBDES.OLB") .nes. "") +$ Then Library /Object /Replace libdes 'OBJS' +$ Else Library /Create /Object libdes 'OBJS' +$ EndIF +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$DESTEST: +$ CC 'CC_OPTS' destest +$ Link 'link_opts' /Exec=destest destest.obj,libdes/LIBRARY,'opt_file'/Option +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$RPW: +$ CC 'CC_OPTS' rpw +$ Link 'link_opts' /Exec=rpw rpw.obj,libdes/LIBRARY,'opt_file'/Option +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$SPEED: +$ CC 'CC_OPTS' speed +$ Link 'link_opts' /Exec=speed speed.obj,libdes/LIBRARY,'opt_file'/Option +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$DES: +$ CC 'CC_OPTS' des +$ Link 'link_opts' /Exec=des des.obj,libdes/LIBRARY,'opt_file'/Option +$ Return diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl new file mode 100644 index 0000000000..dfa7e4525d --- /dev/null +++ b/src/lib/libcrypto/dh/Makefile.ssl @@ -0,0 +1,84 @@ +# +# SSLeay/crypto/dh/Makefile +# + +DIR= dh +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=dh +ERRC=dh_err +GENERAL=Makefile +TEST= dhtest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= dh_gen.c dh_key.c dh_lib.c dh_check.c $(ERRC).c +LIBOBJ= dh_gen.o dh_key.o dh_lib.o dh_check.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= dh.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/dh/dh.err b/src/lib/libcrypto/dh/dh.err new file mode 100644 index 0000000000..a4fe746985 --- /dev/null +++ b/src/lib/libcrypto/dh/dh.err @@ -0,0 +1,12 @@ +/* Error codes for the DH functions. */ + +/* Function codes. */ +#define DH_F_DHPARAMS_PRINT 100 +#define DH_F_DHPARAMS_PRINT_FP 101 +#define DH_F_DH_COMPUTE_KEY 102 +#define DH_F_DH_GENERATE_KEY 103 +#define DH_F_DH_GENERATE_PARAMETERS 104 +#define DH_F_DH_NEW 105 + +/* Reason codes. */ +#define DH_R_NO_PRIVATE_VALUE 100 diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl new file mode 100644 index 0000000000..2cc4ddb39e --- /dev/null +++ b/src/lib/libcrypto/dsa/Makefile.ssl @@ -0,0 +1,84 @@ +# +# SSLeay/crypto/dsa/Makefile +# + +DIR= dsa +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=dsa +ERRC=dsa_err +GENERAL=Makefile +TEST=dsatest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c $(ERRC).c +LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= dsa.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/dsa/dsa.err b/src/lib/libcrypto/dsa/dsa.err new file mode 100644 index 0000000000..1131e9fa74 --- /dev/null +++ b/src/lib/libcrypto/dsa/dsa.err @@ -0,0 +1,15 @@ +/* Error codes for the DSA functions. */ + +/* Function codes. */ +#define DSA_F_DSAPARAMS_PRINT 100 +#define DSA_F_DSAPARAMS_PRINT_FP 101 +#define DSA_F_DSA_IS_PRIME 102 +#define DSA_F_DSA_NEW 103 +#define DSA_F_DSA_PRINT 104 +#define DSA_F_DSA_PRINT_FP 105 +#define DSA_F_DSA_SIGN 106 +#define DSA_F_DSA_SIGN_SETUP 107 +#define DSA_F_DSA_VERIFY 108 + +/* Reason codes. */ +#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 diff --git a/src/lib/libcrypto/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl new file mode 100644 index 0000000000..57c87eb041 --- /dev/null +++ b/src/lib/libcrypto/err/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/err/Makefile +# + +DIR= err +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=err.c err_all.c err_prn.c +LIBOBJ=err.o err_all.o err_prn.o + +SRC= $(LIBSRC) + +EXHEADER= err.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/err/err_code.pl b/src/lib/libcrypto/err/err_code.pl new file mode 100644 index 0000000000..ebc8eef913 --- /dev/null +++ b/src/lib/libcrypto/err/err_code.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl + +while (@ARGV) + { + $in=shift(@ARGV); + if ($in =~ /^-conf$/) + { + $in=shift(@ARGV); + open(IN,"<$in") || die "unable to open '$in'\n"; + while () + { + s/#.*$//; + s/\s+$//; + next if (/^$/); + if (/^L\s+(\S+)\s+(\S+)$/) + { $errfile{$1}=$2; } + elsif (/^F\s+(\S+)$/) + { $function{$1}=1; } + elsif (/^R\s+(\S+)\s+(\S+)$/) + { $r_value{$1}=$2; } + else { die "bad input line: $in:$.\n"; } + } + close(IN); + next; + } + + open(IN,"<$in") || die "unable to open '$in'\n"; + $last=""; + while () + { + if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/) + { + if ($1 != $last) + { + if ($function{$1} == 0) + { + printf STDERR "$. $1 is bad\n"; + } + } + $function{$1}++; + $last=$1; + $reason{$2}++; + } + } + close(IN); + } + +foreach (keys %function,keys %reason) + { + /^([A-Z0-9]+)_/; + $prefix{$1}++; + } + +@F=sort keys %function; +@R=sort keys %reason; +foreach $j (sort keys %prefix) + { + next if $errfile{$j} eq "NONE"; + printf STDERR "doing %-6s - ",$j; + if (defined($errfile{$j})) + { + open(OUT,">$errfile{$j}") || + die "unable to open '$errfile{$j}':$!\n"; + $close_file=1; + } + else + { + *OUT=*STDOUT; + $close=0; + } + @f=grep(/^${j}_/,@F); + @r=grep(/^${j}_/,@R); + $num=100; + print OUT "/* Error codes for the $j functions. */\n\n"; + print OUT "/* Function codes. */\n"; + $f_count=0; + foreach $i (@f) + { + $z=6-int(length($i)/8); + printf OUT "#define $i%s $num\n","\t" x $z; + $num++; + $f_count++; + } + $num=100; + print OUT "\n/* Reason codes. */\n"; + $r_count=0; + foreach $i (@r) + { + $z=6-int(length($i)/8); + if (defined($r_value{$i})) + { + printf OUT "#define $i%s $r_value{$i}\n","\t" x $z; + } + else + { + printf OUT "#define $i%s $num\n","\t" x $z; + $num++; + } + $r_count++; + } + close(OUT) if $close_file; + + printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count; + } + diff --git a/src/lib/libcrypto/err/err_genc.pl b/src/lib/libcrypto/err/err_genc.pl new file mode 100644 index 0000000000..a8e36c2f0c --- /dev/null +++ b/src/lib/libcrypto/err/err_genc.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl + +if ($ARGV[0] eq "-s") { $static=1; shift @ARGV; } + +($#ARGV == 1) || die "usage: $0 [-s]
\n"; +open(IN,"<$ARGV[0]") || die "unable to open $ARGV[0]:$!\n"; +open(STDOUT,">$ARGV[1]") || die "unable to open $ARGV[1]:$!\n"; + +$Func=0; +$Reas=0; +$fuction{'FOPEN'}='fopen'; +while () + { + if (/(\S+)\s*\(\);/) + { + $t=$1; + $t =~ s/\*//; + ($upper=$t) =~ tr/a-z/A-Z/; + $fuction{$upper}=$t; + } + next unless (/^#define\s+(\S+)\s/); + + $o=$1; + if ($o =~ /^([^_]+)_F_(.*)/) + { + $type=$1; + $Func++; + $n=$2; + $n=$fuction{$n} if (defined($fuction{$n})); + $out{$1."_str_functs"}.= + sprintf("{ERR_PACK(0,%s,0),\t\"$n\"},\n",$o); + } + elsif ($o =~ /^([^_]+)_R_(.*)/) + { + $type=$1; + $Reas++; + $r=$2; + $r =~ tr/A-Z_/a-z /; + $pkg{$type."_str_reasons"}=$type; + $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o); + } + elsif ($ARGV[0] =~ /rsaref/ && $o =~ /^RE_(.*)/) + { + $type="RSAREF"; + $Reas++; + $r=$1; + $r =~ tr/A-Z_/a-z /; + $pkg{$type."_str_reasons"}=$type; + $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o); + } + } +close(IN); + +&header($type,$ARGV[0]); + +foreach (sort keys %out) + { + print "static ERR_STRING_DATA ${_}[]=\n\t{\n"; + print $out{$_}; + print "{0,NULL},\n"; + print "\t};\n\n"; + } +print "#endif\n"; + +if ($static) + { $lib="ERR_LIB_$type"; } +else + { $lib="${type}_lib_error_code"; } + +$str=""; +$str.="#ifndef NO_ERR\n"; +$str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func; +$str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas; +$str.="#endif\n"; + +if (!$static) + { +print <<"EOF"; + +static int ${type}_lib_error_code=0; + +void ERR_load_${type}_strings() + { + static int init=1; + + if (${type}_lib_error_code == 0) + ${type}_lib_error_code=ERR_get_next_error_library(); + + if (init); + {; + init=0; +$str + } + } + +void ERR_${type}_error(function,reason,file,line) +int function; +int reason; +char *file; +int line; + { + if (${type}_lib_error_code == 0) + ${type}_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(${type}_lib_error_code,function,reason,file,line); + } +EOF + } +else # $static + { + print <<"EOF"; + +void ERR_load_${type}_strings() + { + static int init=1; + + if (init); + {; + init=0; +$str + } + } +EOF + } + +sub header + { + ($type,$header)=@_; + + ($lc=$type) =~ tr/A-Z/a-z/; + $header =~ s/^.*\///; + + print "/* lib/$lc/${lc}\_err.c */\n"; + print <<'EOF'; +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +EOF + + print "#include \n"; + print "#include \"err.h\"\n"; + print "#include \"$header\"\n"; + print "\n/* BEGIN ERROR CODES */\n"; + print "#ifndef NO_ERR\n"; + } + diff --git a/src/lib/libcrypto/err/error.err b/src/lib/libcrypto/err/error.err new file mode 100644 index 0000000000..f09557d8d9 --- /dev/null +++ b/src/lib/libcrypto/err/error.err @@ -0,0 +1,13 @@ +/* Error codes for the ERR functions. */ + +/* Function codes. */ + +/* Reason codes. */ +#define ERR_R_BN_LIB 100 +#define ERR_R_DER_LIB 101 +#define ERR_R_MALLOC_FAILURE 102 +#define ERR_R_PEM_LIB 103 +#define ERR_R_RSA_LIB 104 +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED 105 +#define ERR_R_SYS_LIB 106 +#define ERR_R_X509_LIB 107 diff --git a/src/lib/libcrypto/err/ssleay.ec b/src/lib/libcrypto/err/ssleay.ec new file mode 100644 index 0000000000..10b5dbb59d --- /dev/null +++ b/src/lib/libcrypto/err/ssleay.ec @@ -0,0 +1,57 @@ +L ERR NONE +L CRYPTO crypto.err +L BN bn/bn.err +L RSA rsa/rsa.err +L DSA dsa/dsa.err +L DH dh/dh.err +L EVP evp/evp.err +L BUF buffer/buffer.err +L BIO bio/bio.err +L OBJ objects/objects.err +L PEM pem/pem.err +L X509 x509/x509.err +L METH meth/meth.err +L ASN1 asn1/asn1.err +L CONF conf/conf.err +L PROXY proxy/proxy.err +L PKCS7 pkcs7/pkcs7.err +L RSAREF ../rsaref/rsaref.err +L SSL ../ssl/ssl.err +L SSL2 ../ssl/ssl2.err +L SSL3 ../ssl/ssl3.err +L SSL23 ../ssl/ssl23.err + +F RSAREF_F_RSA_BN2BIN +F RSAREF_F_RSA_PRIVATE_DECRYPT +F RSAREF_F_RSA_PRIVATE_ENCRYPT +F RSAREF_F_RSA_PUBLIC_DECRYPT +F RSAREF_F_RSA_PUBLIC_ENCRYPT +#F SSL_F_CLIENT_CERTIFICATE + +R SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +R SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +R SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +R SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +R SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +R SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +R SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +R SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +R SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +R SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +R SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 + +R RSAREF_R_CONTENT_ENCODING 0x0400 +R RSAREF_R_DATA 0x0401 +R RSAREF_R_DIGEST_ALGORITHM 0x0402 +R RSAREF_R_ENCODING 0x0403 +R RSAREF_R_KEY 0x0404 +R RSAREF_R_KEY_ENCODING 0x0405 +R RSAREF_R_LEN 0x0406 +R RSAREF_R_MODULUS_LEN 0x0407 +R RSAREF_R_NEED_RANDOM 0x0408 +R RSAREF_R_PRIVATE_KEY 0x0409 +R RSAREF_R_PUBLIC_KEY 0x040a +R RSAREF_R_SIGNATURE 0x040b +R RSAREF_R_SIGNATURE_ENCODING 0x040c +R RSAREF_R_ENCRYPTION_ALGORITHM 0x040d + diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl new file mode 100644 index 0000000000..8bf2516458 --- /dev/null +++ b/src/lib/libcrypto/evp/Makefile.ssl @@ -0,0 +1,111 @@ +# +# SSLeay/crypto/evp/Makefile +# + +DIR= evp +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=evp +ERRC=evp_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= encode.c digest.c evp_enc.c evp_key.c \ + e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c \ + e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c \ + e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c \ + e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c \ + e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c \ + e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c \ + e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c \ + e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c \ + m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c \ + m_ripemd.c \ + p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ + bio_md.c bio_b64.c bio_enc.c $(ERRC).c e_null.c \ + c_all.c evp_lib.c + +LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \ + e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \ + e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o \ + e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o \ + e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o \ + e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o \ + e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o \ + e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o \ + e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o \ + m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o \ + m_ripemd.o \ + p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ + bio_md.o bio_b64.o bio_enc.o $(ERRC).o e_null.o \ + c_all.o evp_lib.o + +SRC= $(LIBSRC) + +EXHEADER= evp.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/evp/e_cbc_3d.c b/src/lib/libcrypto/evp/e_cbc_3d.c new file mode 100644 index 0000000000..5761bf186a --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_3d.c @@ -0,0 +1,163 @@ +/* crypto/evp/e_cbc_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_cbc_ede_init_key(); +static void des_cbc_ede3_init_key(); +static void des_cbc_ede_cipher(); +#endif + +static EVP_CIPHER d_cbc_ede_cipher2= + { + NID_des_ede_cbc, + 8,16,8, + des_cbc_ede_init_key, + des_cbc_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +static EVP_CIPHER d_cbc_ede_cipher3= + { + NID_des_ede3_cbc, + 8,24,8, + des_cbc_ede3_init_key, + des_cbc_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ede_cbc() + { + return(&d_cbc_ede_cipher2); + } + +EVP_CIPHER *EVP_des_ede3_cbc() + { + return(&d_cbc_ede_cipher3); + } + +static void des_cbc_ede_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_cbc_ede3_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_cbc_ede_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ede3_cbc_encrypt( + (des_cblock *)in,(des_cblock *)out, + (long)inl, ctx->c.des_ede.ks1, + ctx->c.des_ede.ks2,ctx->c.des_ede.ks3, + (des_cblock *)&(ctx->iv[0]), + ctx->encrypt); + } diff --git a/src/lib/libcrypto/evp/e_cbc_bf.c b/src/lib/libcrypto/evp/e_cbc_bf.c new file mode 100644 index 0000000000..be605f4a13 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_bf.c @@ -0,0 +1,119 @@ +/* crypto/evp/e_cbc_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_cbc_init_key(); +static void bf_cbc_cipher(); +#endif + +static EVP_CIPHER bfish_cbc_cipher= + { + NID_bf_cbc, + 8,EVP_BLOWFISH_KEY_SIZE,8, + bf_cbc_init_key, + bf_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_bf_cbc() + { + return(&bfish_cbc_cipher); + } + +static void bf_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + BF_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.bf_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_cbc_c.c b/src/lib/libcrypto/evp/e_cbc_c.c new file mode 100644 index 0000000000..b50c7874b3 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_c.c @@ -0,0 +1,119 @@ +/* crypto/evp/e_cbc_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_cbc_init_key(); +static void cast_cbc_cipher(); +#endif + +static EVP_CIPHER cast5_cbc_cipher= + { + NID_cast5_cbc, + 8,EVP_CAST5_KEY_SIZE,8, + cast_cbc_init_key, + cast_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_cast5_cbc() + { + return(&cast5_cbc_cipher); + } + +static void cast_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + CAST_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.cast_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_cbc_d.c b/src/lib/libcrypto/evp/e_cbc_d.c new file mode 100644 index 0000000000..c67706e3a0 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_d.c @@ -0,0 +1,116 @@ +/* crypto/evp/e_cbc_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_cbc_init_key(); +static void des_cbc_cipher(); +#endif + +static EVP_CIPHER d_cbc_cipher= + { + NID_des_cbc, + 8,8,8, + des_cbc_init_key, + des_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_des_cbc() + { + return(&d_cbc_cipher); + } + +static void des_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ncbc_encrypt( + (des_cblock *)in,(des_cblock *)out, + (long)inl, ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + ctx->encrypt); + } diff --git a/src/lib/libcrypto/evp/e_cbc_i.c b/src/lib/libcrypto/evp/e_cbc_i.c new file mode 100644 index 0000000000..312ffcb721 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_i.c @@ -0,0 +1,131 @@ +/* crypto/evp/e_cbc_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_cbc_init_key(); +static void idea_cbc_cipher(); +#endif + +static EVP_CIPHER i_cbc_cipher= + { + NID_idea_cbc, + 8,16,8, + idea_cbc_init_key, + idea_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_idea_cbc() + { + return(&i_cbc_cipher); + } + +static void idea_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + if (enc) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + else + { + IDEA_KEY_SCHEDULE tmp; + + idea_set_encrypt_key(key,&tmp); + idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks)); + memset((unsigned char *)&tmp,0, + sizeof(IDEA_KEY_SCHEDULE)); + } + } + } + +static void idea_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + idea_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.idea_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_cbc_r2.c b/src/lib/libcrypto/evp/e_cbc_r2.c new file mode 100644 index 0000000000..4f8002f16d --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_r2.c @@ -0,0 +1,136 @@ +/* crypto/evp/e_cbc_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_cbc_init_key(); +static void rc2_cbc_cipher(); +#endif + +static EVP_CIPHER r2_cbc_cipher= + { + NID_rc2_cbc, + 8,EVP_RC2_KEY_SIZE,8, + rc2_cbc_init_key, + rc2_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +static EVP_CIPHER r2_40_cbc_cipher= + { + NID_rc2_40_cbc, + 8,5 /* 40 bit */,8, + rc2_cbc_init_key, + rc2_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + }; + +EVP_CIPHER *EVP_rc2_cbc() + { + return(&r2_cbc_cipher); + } + +EVP_CIPHER *EVP_rc2_40_cbc() + { + return(&r2_40_cbc_cipher); + } + +static void rc2_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx), + key,EVP_CIPHER_CTX_key_length(ctx)*8); + } + +static void rc2_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC2_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.rc2_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_cbc_r5.c b/src/lib/libcrypto/evp/e_cbc_r5.c new file mode 100644 index 0000000000..f7d46ca91f --- /dev/null +++ b/src/lib/libcrypto/evp/e_cbc_r5.c @@ -0,0 +1,120 @@ +/* crypto/evp/e_cbc_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void r_32_12_16_cbc_init_key(); +static void r_32_12_16_cbc_cipher(); +#endif + +static EVP_CIPHER rc5_32_12_16_cbc_cipher= + { + NID_rc5_cbc, + 8,EVP_RC5_32_12_16_KEY_SIZE,8, + r_32_12_16_cbc_init_key, + r_32_12_16_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_cbc() + { + return(&rc5_32_12_16_cbc_cipher); + } + +static void r_32_12_16_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE, + key,RC5_12_ROUNDS); + } + +static void r_32_12_16_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC5_32_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.rc5_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_cfb_3d.c b/src/lib/libcrypto/evp/e_cfb_3d.c new file mode 100644 index 0000000000..e7e3419411 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_3d.c @@ -0,0 +1,166 @@ +/* crypto/evp/e_cfb_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ede_cfb_init_key(); +static void des_ede3_cfb_init_key(); +static void des_ede_cfb_cipher(); +#endif + +static EVP_CIPHER d_ede_cfb_cipher2= + { + NID_des_ede_cfb64, + 1,16,8, + des_ede_cfb_init_key, + des_ede_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +static EVP_CIPHER d_ede3_cfb_cipher3= + { + NID_des_ede3_cfb64, + 1,24,8, + des_ede3_cfb_init_key, + des_ede_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ede_cfb() + { + return(&d_ede_cfb_cipher2); + } + +EVP_CIPHER *EVP_des_ede3_cfb() + { + return(&d_ede3_cfb_cipher3); + } + +static void des_ede_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_ede3_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_ede_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ede3_cfb64_encrypt( + in,out,(long)inl, + ctx->c.des_ede.ks1, + ctx->c.des_ede.ks2, + ctx->c.des_ede.ks3, + (des_cblock *)&(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } diff --git a/src/lib/libcrypto/evp/e_cfb_bf.c b/src/lib/libcrypto/evp/e_cfb_bf.c new file mode 100644 index 0000000000..8aba2564b8 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_bf.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_cfb_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_cfb_init_key(); +static void bf_cfb_cipher(); +#endif + +static EVP_CIPHER bfish_cfb_cipher= + { + NID_bf_cfb64, + 1,EVP_BLOWFISH_KEY_SIZE,8, + bf_cfb_init_key, + bf_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_bf_cfb() + { + return(&bfish_cfb_cipher); + } + +static void bf_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + BF_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.bf_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libcrypto/evp/e_cfb_c.c b/src/lib/libcrypto/evp/e_cfb_c.c new file mode 100644 index 0000000000..936df55fd8 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_c.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_cfb_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_cfb_init_key(); +static void cast_cfb_cipher(); +#endif + +static EVP_CIPHER cast5_cfb_cipher= + { + NID_cast5_cfb64, + 1,EVP_CAST5_KEY_SIZE,8, + cast_cfb_init_key, + cast_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_cast5_cfb() + { + return(&cast5_cfb_cipher); + } + +static void cast_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + CAST_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.cast_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libcrypto/evp/e_cfb_d.c b/src/lib/libcrypto/evp/e_cfb_d.c new file mode 100644 index 0000000000..9ae4558f51 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_d.c @@ -0,0 +1,118 @@ +/* crypto/evp/e_cfb_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_cfb_init_key(); +static void des_cfb_cipher(); +#endif + +static EVP_CIPHER d_cfb_cipher= + { + NID_des_cfb64, + 1,8,8, + des_cfb_init_key, + des_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_cfb() + { + return(&d_cfb_cipher); + } + +static void des_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_cfb64_encrypt( + in,out, + (long)inl, ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } diff --git a/src/lib/libcrypto/evp/e_cfb_i.c b/src/lib/libcrypto/evp/e_cfb_i.c new file mode 100644 index 0000000000..9225efaa86 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_i.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_cfb_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_cfb_init_key(); +static void idea_cfb_cipher(); +#endif + +static EVP_CIPHER i_cfb_cipher= + { + NID_idea_cfb64, + 1,IDEA_KEY_LENGTH,IDEA_BLOCK, + idea_cfb_init_key, + idea_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_idea_cfb() + { + return(&i_cfb_cipher); + } + +static void idea_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + } + +static void idea_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + idea_cfb64_encrypt( + in,out,(long)inl, + &(ctx->c.idea_ks),&(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_cfb_r2.c b/src/lib/libcrypto/evp/e_cfb_r2.c new file mode 100644 index 0000000000..af5a39d1f4 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_r2.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_cfb_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_cfb_init_key(); +static void rc2_cfb_cipher(); +#endif + +static EVP_CIPHER r2_cfb_cipher= + { + NID_rc2_cfb64, + 1,EVP_RC2_KEY_SIZE,8, + rc2_cfb_init_key, + rc2_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc2_cfb() + { + return(&r2_cfb_cipher); + } + +static void rc2_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, + EVP_RC2_KEY_SIZE*8); + } + +static void rc2_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC2_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc2_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libcrypto/evp/e_cfb_r5.c b/src/lib/libcrypto/evp/e_cfb_r5.c new file mode 100644 index 0000000000..a2fddaedc0 --- /dev/null +++ b/src/lib/libcrypto/evp/e_cfb_r5.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_cfb_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc5_32_12_16_cfb_init_key(); +static void rc5_32_12_16_cfb_cipher(); +#endif + +static EVP_CIPHER rc5_cfb_cipher= + { + NID_rc5_cfb64, + 1,EVP_RC5_32_12_16_KEY_SIZE,8, + rc5_32_12_16_cfb_init_key, + rc5_32_12_16_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_cfb() + { + return(&rc5_cfb_cipher); + } + +static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, + RC5_12_ROUNDS); + } + +static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC5_32_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc5_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libcrypto/evp/e_ecb_3d.c b/src/lib/libcrypto/evp/e_ecb_3d.c new file mode 100644 index 0000000000..908fc0760a --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_3d.c @@ -0,0 +1,161 @@ +/* crypto/evp/e_ecb_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ede_init_key(); +static void des_ede3_init_key(); +static void des_ede_cipher(); +#endif + +static EVP_CIPHER d_ede_cipher2= + { + NID_des_ede, + 8,16,0, + des_ede_init_key, + des_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + NULL, + NULL, + }; + +static EVP_CIPHER d_ede3_cipher3= + { + NID_des_ede3, + 8,24,0, + des_ede3_init_key, + des_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + NULL, + }; + +EVP_CIPHER *EVP_des_ede() + { + return(&d_ede_cipher2); + } + +EVP_CIPHER *EVP_des_ede3() + { + return(&d_ede3_cipher3); + } + +static void des_ede_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_ede3_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_ede_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + des_ecb3_encrypt( + (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), + ctx->c.des_ede.ks1, + ctx->c.des_ede.ks2, + ctx->c.des_ede.ks3, + ctx->encrypt); + } + } diff --git a/src/lib/libcrypto/evp/e_ecb_bf.c b/src/lib/libcrypto/evp/e_ecb_bf.c new file mode 100644 index 0000000000..142a9d3123 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_bf.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ecb_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_ecb_init_key(); +static void bf_ecb_cipher(); +#endif + +static EVP_CIPHER bfish_ecb_cipher= + { + NID_bf_ecb, + 8,EVP_BLOWFISH_KEY_SIZE,0, + bf_ecb_init_key, + bf_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_bf_ecb() + { + return(&bfish_ecb_cipher); + } + +static void bf_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + BF_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.bf_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ecb_c.c b/src/lib/libcrypto/evp/e_ecb_c.c new file mode 100644 index 0000000000..34e0c18296 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_c.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ecb_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_ecb_init_key(); +static void cast_ecb_cipher(); +#endif + +static EVP_CIPHER cast5_ecb_cipher= + { + NID_cast5_ecb, + 8,EVP_CAST5_KEY_SIZE,0, + cast_ecb_init_key, + cast_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_cast5_ecb() + { + return(&cast5_ecb_cipher); + } + +static void cast_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + CAST_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.cast_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ecb_d.c b/src/lib/libcrypto/evp/e_ecb_d.c new file mode 100644 index 0000000000..7a409d6459 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_d.c @@ -0,0 +1,118 @@ +/* crypto/evp/e_ecb_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ecb_init_key(); +static void des_ecb_cipher(); +#endif + +static EVP_CIPHER d_ecb_cipher= + { + NID_des_ecb, + 8,8,0, + des_ecb_init_key, + des_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_des_ecb() + { + return(&d_ecb_cipher); + } + +static void des_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + des_ecb_encrypt( + (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), + ctx->c.des_ks,ctx->encrypt); + } + } diff --git a/src/lib/libcrypto/evp/e_ecb_i.c b/src/lib/libcrypto/evp/e_ecb_i.c new file mode 100644 index 0000000000..e24022a12c --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_i.c @@ -0,0 +1,133 @@ +/* crypto/evp/e_ecb_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_ecb_init_key(); +static void idea_ecb_cipher(); +#endif + +static EVP_CIPHER i_ecb_cipher= + { + NID_idea_ecb, + 8,16,0, + idea_ecb_init_key, + idea_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_idea_ecb() + { + return(&i_ecb_cipher); + } + +static void idea_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + { + if (enc) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + else + { + IDEA_KEY_SCHEDULE tmp; + + idea_set_encrypt_key(key,&tmp); + idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks)); + memset((unsigned char *)&tmp,0, + sizeof(IDEA_KEY_SCHEDULE)); + } + } + } + +static void idea_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + idea_ecb_encrypt( + &(in[i]),&(out[i]),&(ctx->c.idea_ks)); + } + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ecb_r2.c b/src/lib/libcrypto/evp/e_ecb_r2.c new file mode 100644 index 0000000000..e35b06dc6d --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_r2.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ecb_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_ecb_init_key(); +static void rc2_ecb_cipher(); +#endif + +static EVP_CIPHER r2_ecb_cipher= + { + NID_rc2_ecb, + 8,EVP_RC2_KEY_SIZE,0, + rc2_ecb_init_key, + rc2_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_rc2_ecb() + { + return(&r2_ecb_cipher); + } + +static void rc2_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, + EVP_RC2_KEY_SIZE*8); + } + +static void rc2_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + RC2_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.rc2_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ecb_r5.c b/src/lib/libcrypto/evp/e_ecb_r5.c new file mode 100644 index 0000000000..08f4a82651 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ecb_r5.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ecb_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc5_32_12_16_ecb_init_key(); +static void rc5_32_12_16_ecb_cipher(); +#endif + +static EVP_CIPHER rc5_ecb_cipher= + { + NID_rc5_ecb, + 8,EVP_RC5_32_12_16_KEY_SIZE,0, + rc5_32_12_16_ecb_init_key, + rc5_32_12_16_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_ecb() + { + return(&rc5_ecb_cipher); + } + +static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, + RC5_12_ROUNDS); + } + +static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + RC5_32_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.rc5_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ofb_3d.c b/src/lib/libcrypto/evp/e_ofb_3d.c new file mode 100644 index 0000000000..c3add18e93 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_3d.c @@ -0,0 +1,165 @@ +/* crypto/evp/e_ofb_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ede_ofb_init_key(); +static void des_ede3_ofb_init_key(); +static void des_ede_ofb_cipher(); +#endif + +static EVP_CIPHER d_ede_ofb_cipher2= + { + NID_des_ede_ofb64, + 1,16,8, + des_ede_ofb_init_key, + des_ede_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +static EVP_CIPHER d_ede3_ofb_cipher3= + { + NID_des_ede3_ofb64, + 1,24,8, + des_ede3_ofb_init_key, + des_ede_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ede_ofb() + { + return(&d_ede_ofb_cipher2); + } + +EVP_CIPHER *EVP_des_ede3_ofb() + { + return(&d_ede3_ofb_cipher3); + } + +static void des_ede_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_ede3_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_ede_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ede3_ofb64_encrypt( + in,out, + (long)inl, + ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, + (des_cblock *)&(ctx->iv[0]), + &ctx->num); + } diff --git a/src/lib/libcrypto/evp/e_ofb_bf.c b/src/lib/libcrypto/evp/e_ofb_bf.c new file mode 100644 index 0000000000..492f9b9082 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_bf.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ofb_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_ofb_init_key(); +static void bf_ofb_cipher(); +#endif + +static EVP_CIPHER bfish_ofb_cipher= + { + NID_bf_ofb64, + 1,EVP_BLOWFISH_KEY_SIZE,8, + bf_ofb_init_key, + bf_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_bf_ofb() + { + return(&bfish_ofb_cipher); + } + +static void bf_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + BF_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.bf_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ofb_c.c b/src/lib/libcrypto/evp/e_ofb_c.c new file mode 100644 index 0000000000..f1eef4469c --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_c.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ofb_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_ofb_init_key(); +static void cast_ofb_cipher(); +#endif + +static EVP_CIPHER cast5_ofb_cipher= + { + NID_cast5_ofb64, + 1,EVP_CAST5_KEY_SIZE,8, + cast_ofb_init_key, + cast_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_cast5_ofb() + { + return(&cast5_ofb_cipher); + } + +static void cast_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + CAST_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.cast_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ofb_d.c b/src/lib/libcrypto/evp/e_ofb_d.c new file mode 100644 index 0000000000..09d4b4139d --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_d.c @@ -0,0 +1,118 @@ +/* crypto/evp/e_ofb_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ofb_init_key(); +static void des_ofb_cipher(); +#endif + +static EVP_CIPHER d_ofb_cipher= + { + NID_des_ofb64, + 1,8,8, + des_ofb_init_key, + des_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ofb() + { + return(&d_ofb_cipher); + } + +static void des_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ofb64_encrypt( + in,out, + (long)inl, ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + &ctx->num); + } diff --git a/src/lib/libcrypto/evp/e_ofb_i.c b/src/lib/libcrypto/evp/e_ofb_i.c new file mode 100644 index 0000000000..96c8afd9c8 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_i.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_ofb_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_ofb_init_key(); +static void idea_ofb_cipher(); +#endif + +static EVP_CIPHER i_ofb_cipher= + { + NID_idea_ofb64, + 1,IDEA_KEY_LENGTH,IDEA_BLOCK, + idea_ofb_init_key, + idea_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_idea_ofb() + { + return(&i_ofb_cipher); + } + +static void idea_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + } + +static void idea_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + idea_ofb64_encrypt( + in,out,(long)inl, + &(ctx->c.idea_ks),&(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ofb_r2.c b/src/lib/libcrypto/evp/e_ofb_r2.c new file mode 100644 index 0000000000..0f6d729988 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_r2.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ofb_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_ofb_init_key(); +static void rc2_ofb_cipher(); +#endif + +static EVP_CIPHER r2_ofb_cipher= + { + NID_rc2_ofb64, + 1,EVP_RC2_KEY_SIZE,8, + rc2_ofb_init_key, + rc2_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc2_ofb() + { + return(&r2_ofb_cipher); + } + +static void rc2_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, + EVP_RC2_KEY_SIZE*8); + } + +static void rc2_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC2_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc2_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libcrypto/evp/e_ofb_r5.c b/src/lib/libcrypto/evp/e_ofb_r5.c new file mode 100644 index 0000000000..db28d6c317 --- /dev/null +++ b/src/lib/libcrypto/evp/e_ofb_r5.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ofb_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc5_32_12_16_ofb_init_key(); +static void rc5_32_12_16_ofb_cipher(); +#endif + +static EVP_CIPHER rc5_ofb_cipher= + { + NID_rc5_ofb64, + 1,EVP_RC5_32_12_16_KEY_SIZE,8, + rc5_32_12_16_ofb_init_key, + rc5_32_12_16_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_ofb() + { + return(&rc5_ofb_cipher); + } + +static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, + RC5_12_ROUNDS); + } + +static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC5_32_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc5_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libcrypto/evp/evp.err b/src/lib/libcrypto/evp/evp.err new file mode 100644 index 0000000000..cfc17437bc --- /dev/null +++ b/src/lib/libcrypto/evp/evp.err @@ -0,0 +1,24 @@ +/* Error codes for the EVP functions. */ + +/* Function codes. */ +#define EVP_F_D2I_PKEY 100 +#define EVP_F_EVP_DECRYPTFINAL 101 +#define EVP_F_EVP_OPENINIT 102 +#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 +#define EVP_F_EVP_PKEY_DECRYPT 104 +#define EVP_F_EVP_PKEY_ENCRYPT 105 +#define EVP_F_EVP_PKEY_NEW 106 +#define EVP_F_EVP_SIGNFINAL 107 +#define EVP_F_EVP_VERIFYFINAL 108 + +/* Reason codes. */ +#define EVP_R_BAD_DECRYPT 100 +#define EVP_R_DIFFERENT_KEY_TYPES 101 +#define EVP_R_IV_TOO_LARGE 102 +#define EVP_R_MISSING_PARMATERS 103 +#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 +#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_R_UNSUPPORTED_CIPHER 107 +#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108 +#define EVP_R_WRONG_PUBLIC_KEY_TYPE 109 diff --git a/src/lib/libcrypto/evp/pk_lib.c b/src/lib/libcrypto/evp/pk_lib.c new file mode 100644 index 0000000000..08f9fabbae --- /dev/null +++ b/src/lib/libcrypto/evp/pk_lib.c @@ -0,0 +1,82 @@ +/* crypto/evp/pk_lib.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +static LHASH *pk_md=NULL; + +static LHASH *pk_md=NULL; + +int EVP_add_pkey_md(oid,pkm,md) +int oid; +EVP_PKEY_METHOD *pkm; +EVP_MD *md; + { + } + +EVP_add_pkey(pkm) +EVP_PKEY_METHOD *pkm; + { + } + +EVP_PKEY_METHOD:q + + diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl new file mode 100644 index 0000000000..7a042b7261 --- /dev/null +++ b/src/lib/libcrypto/hmac/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/md/Makefile +# + +DIR= hmac +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=hmactest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=hmac.c +LIBOBJ=hmac.o + +SRC= $(LIBSRC) + +EXHEADER= hmac.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/idea/Makefile.ssl b/src/lib/libcrypto/idea/Makefile.ssl new file mode 100644 index 0000000000..41b42ce03b --- /dev/null +++ b/src/lib/libcrypto/idea/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/idea/Makefile +# + +DIR= idea +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=ideatest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c +LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o + +SRC= $(LIBSRC) + +EXHEADER= idea.h +HEADER= idea_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl new file mode 100644 index 0000000000..cb08547b4f --- /dev/null +++ b/src/lib/libcrypto/lhash/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/lhash/Makefile +# + +DIR= lhash +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=lhash.c lh_stats.c +LIBOBJ=lhash.o lh_stats.o + +SRC= $(LIBSRC) + +EXHEADER= lhash.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/libvms.com b/src/lib/libcrypto/libvms.com new file mode 100644 index 0000000000..44f90c65b0 --- /dev/null +++ b/src/lib/libcrypto/libvms.com @@ -0,0 +1,31 @@ +$! +$! Compile crypto.c as several subset modules and insert in crypto-xxx.olb. +$! If P1 is specifed, it specifies alternate list of subsets to compile. +$! +$ libname = "CRYPTO-AXP.OLB" +$ subset_list = "LIB,ASN1,BN,BUFFER,CONF,DES,DH,DSA,ERROR,EVP,IDEA,LHASH,MD," + - + "METH,OBJECTS,PEM,RAND,RC,RSA,SHA,STACK,TXT_DB,X509" +$ if p1 .nes. "" then subset_list = p1 +$! +$ if f$getsyi("CPU") .lt. 128 then libname = "CRYPTO-VAX.OLB" +$ if f$search(libname) .eqs. "" then library/create/object/log 'libname' +$! +$ cc = "cc/include=[-.include]/prefix=all" + P2 +$! +$ i = 0 +$ next_subset: +$ subset = f$element(i,",",subset_list) +$ if subset .eqs. "," then goto done +$ i = i + 1 +$ create crypto_'subset'.subset +#include "crypto.c" +$ ofile = "sys$disk:[]crypto_" + subset + ".obj" +$ on warning then goto next_subset +$ write sys$output "Compiling ", ofile +$ cc /object='ofile' crypto_'subset'.subset - + /define=(CRYPTO_SUBSET,CRYPTO_'subset'_SUBSET) +$ library/replace/log 'libname'/module=CRYPTO_'subset' 'ofile' +$ goto next_subset +$! +$ done: +$ exit diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl new file mode 100644 index 0000000000..d8e7200c83 --- /dev/null +++ b/src/lib/libcrypto/md2/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/md/Makefile +# + +DIR= md +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=md2_dgst.c md5_one.c +LIBOBJ=md2_dgst.o md2_one.o + +SRC= $(LIBSRC) + +EXHEADER= md2.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/md2/md2.org b/src/lib/libcrypto/md2/md2.org new file mode 100644 index 0000000000..9f39933790 --- /dev/null +++ b/src/lib/libcrypto/md2/md2.org @@ -0,0 +1,106 @@ +/* crypto/md/md2.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify md2.org since md2.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + + +#ifndef HEADER_MD2_H +#define HEADER_MD2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MD2_DIGEST_LENGTH 16 +#define MD2_BLOCK 16 + +#define MD2_INT unsigned int + +typedef struct MD2state_st + { + int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; + } MD2_CTX; + +#ifndef NOPROTO +char *MD2_options(void); +void MD2_Init(MD2_CTX *c); +void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len); +void MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md); +#else +char *MD2_options(); +void MD2_Init(); +void MD2_Update(); +void MD2_Final(); +unsigned char *MD2(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl new file mode 100644 index 0000000000..47e1ce05ca --- /dev/null +++ b/src/lib/libcrypto/md5/Makefile.ssl @@ -0,0 +1,104 @@ +# +# SSLeay/crypto/md5/Makefile +# + +DIR= md5 +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +MD5_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md5test.c +APPS=md5.c + +LIB=$(TOP)/libcrypto.a +LIBSRC=md5_dgst.c md5_one.c +LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= md5.h +HEADER= md5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/mx86-elf.o: asm/mx86unix.cpp + $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o + +# solaris +asm/mx86-sol.o: asm/mx86unix.cpp + $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s + as -o asm/mx86-sol.o asm/mx86-sol.s + rm -f asm/mx86-sol.s + +# a.out +asm/mx86-out.o: asm/mx86unix.cpp + $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o + +# bsdi +asm/mx86bsdi.o: asm/mx86unix.cpp + $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o + +asm/mx86unix.cpp: + (cd asm; perl md5-586.pl cpp >mx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/md5/Makefile.uni b/src/lib/libcrypto/md5/Makefile.uni new file mode 100644 index 0000000000..54685712db --- /dev/null +++ b/src/lib/libcrypto/md5/Makefile.uni @@ -0,0 +1,109 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= md5 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +MD5_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md5test +APPS=md5 + +LIB=libmd5.a +LIBSRC=md5_dgst.c md5_one.c +LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= md5.h +HEADER= md5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/mx86-elf.o: asm/mx86unix.cpp + $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o + +# solaris +asm/mx86-sol.o: asm/mx86unix.cpp + $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s + as -o asm/mx86-sol.o asm/mx86-sol.s + rm -f asm/mx86-sol.s + +# a.out +asm/mx86-out.o: asm/mx86unix.cpp + $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o + +# bsdi +asm/mx86bsdi.o: asm/mx86unix.cpp + $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o + +asm/mx86unix.cpp: + (cd asm; perl md5-586.pl cpp >mx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-out: + $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-solaris: + $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-bdsi: + $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/md5/asm/m5-win32.asm b/src/lib/libcrypto/md5/asm/m5-win32.asm new file mode 100644 index 0000000000..c2081da746 --- /dev/null +++ b/src/lib/libcrypto/md5/asm/m5-win32.asm @@ -0,0 +1,686 @@ + ; Don't even think of reading this code + ; It was automatically generated by md5-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE md5-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _md5_block_x86 + +_md5_block_x86 PROC NEAR + push esi + push edi + mov edi, DWORD PTR 12[esp] + mov esi, DWORD PTR 16[esp] + mov ecx, DWORD PTR 20[esp] + push ebp + push ebx + add ecx, esi + sub ecx, 64 + mov eax, DWORD PTR [edi] + push ecx + mov ebx, DWORD PTR 4[edi] + mov ecx, DWORD PTR 8[edi] + mov edx, DWORD PTR 12[edi] +L000start: + ; + ; R0 section + mov edi, ecx + mov ebp, DWORD PTR [esi] + ; R0 0 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 3614090360[ebp*1+eax] + mov ebp, DWORD PTR 4[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 1 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 3905402710[ebp*1+edx] + mov ebp, DWORD PTR 8[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 2 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 606105819[ebp*1+ecx] + mov ebp, DWORD PTR 12[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 3 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 3250441966[ebp*1+ebx] + mov ebp, DWORD PTR 16[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; R0 4 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 4118548399[ebp*1+eax] + mov ebp, DWORD PTR 20[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 5 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 1200080426[ebp*1+edx] + mov ebp, DWORD PTR 24[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 6 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 2821735955[ebp*1+ecx] + mov ebp, DWORD PTR 28[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 7 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 4249261313[ebp*1+ebx] + mov ebp, DWORD PTR 32[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; R0 8 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 1770035416[ebp*1+eax] + mov ebp, DWORD PTR 36[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 9 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 2336552879[ebp*1+edx] + mov ebp, DWORD PTR 40[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 10 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 4294925233[ebp*1+ecx] + mov ebp, DWORD PTR 44[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 11 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 2304563134[ebp*1+ebx] + mov ebp, DWORD PTR 48[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; R0 12 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 1804603682[ebp*1+eax] + mov ebp, DWORD PTR 52[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 13 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 4254626195[ebp*1+edx] + mov ebp, DWORD PTR 56[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 14 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 2792965006[ebp*1+ecx] + mov ebp, DWORD PTR 60[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 15 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 1236535329[ebp*1+ebx] + mov ebp, DWORD PTR 4[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; + ; R1 section + ; R1 16 + lea eax, DWORD PTR 4129170786[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 24[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 17 + lea edx, DWORD PTR 3225465664[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 44[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 18 + lea ecx, DWORD PTR 643717713[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR [esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 19 + lea ebx, DWORD PTR 3921069994[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 20[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; R1 20 + lea eax, DWORD PTR 3593408605[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 40[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 21 + lea edx, DWORD PTR 38016083[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 60[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 22 + lea ecx, DWORD PTR 3634488961[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR 16[esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 23 + lea ebx, DWORD PTR 3889429448[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 36[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; R1 24 + lea eax, DWORD PTR 568446438[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 56[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 25 + lea edx, DWORD PTR 3275163606[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 12[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 26 + lea ecx, DWORD PTR 4107603335[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR 32[esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 27 + lea ebx, DWORD PTR 1163531501[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 52[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; R1 28 + lea eax, DWORD PTR 2850285829[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 8[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 29 + lea edx, DWORD PTR 4243563512[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 28[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 30 + lea ecx, DWORD PTR 1735328473[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR 48[esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 31 + lea ebx, DWORD PTR 2368359562[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 20[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; + ; R2 section + ; R2 32 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 4294588738[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR 32[esi] + rol eax, 4 + mov edi, ebx + ; R2 33 + lea edx, DWORD PTR 2272392833[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 44[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 34 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 1839030562[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 56[esi] + rol ecx, 16 + mov edi, edx + ; R2 35 + lea ebx, DWORD PTR 4259657740[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR 4[esi] + add ebx, edi + mov edi, ecx + rol ebx, 23 + add ebx, ecx + ; R2 36 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 2763975236[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR 16[esi] + rol eax, 4 + mov edi, ebx + ; R2 37 + lea edx, DWORD PTR 1272893353[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 28[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 38 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 4139469664[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 40[esi] + rol ecx, 16 + mov edi, edx + ; R2 39 + lea ebx, DWORD PTR 3200236656[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR 52[esi] + add ebx, edi + mov edi, ecx + rol ebx, 23 + add ebx, ecx + ; R2 40 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 681279174[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR [esi] + rol eax, 4 + mov edi, ebx + ; R2 41 + lea edx, DWORD PTR 3936430074[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 12[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 42 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 3572445317[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 24[esi] + rol ecx, 16 + mov edi, edx + ; R2 43 + lea ebx, DWORD PTR 76029189[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR 36[esi] + add ebx, edi + mov edi, ecx + rol ebx, 23 + add ebx, ecx + ; R2 44 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 3654602809[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR 48[esi] + rol eax, 4 + mov edi, ebx + ; R2 45 + lea edx, DWORD PTR 3873151461[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 60[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 46 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 530742520[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 8[esi] + rol ecx, 16 + mov edi, edx + ; R2 47 + lea ebx, DWORD PTR 3299628645[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR [esi] + add ebx, edi + mov edi, -1 + rol ebx, 23 + add ebx, ecx + ; + ; R3 section + ; R3 48 + xor edi, edx + or edi, ebx + lea eax, DWORD PTR 4096336452[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 28[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 49 + or edi, eax + lea edx, DWORD PTR 1126891415[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 56[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 50 + or edi, edx + lea ecx, DWORD PTR 2878612391[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 20[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 51 + or edi, ecx + lea ebx, DWORD PTR 4237533241[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 48[esi] + add ebx, edi + mov edi, -1 + rol ebx, 21 + xor edi, edx + add ebx, ecx + ; R3 52 + or edi, ebx + lea eax, DWORD PTR 1700485571[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 12[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 53 + or edi, eax + lea edx, DWORD PTR 2399980690[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 40[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 54 + or edi, edx + lea ecx, DWORD PTR 4293915773[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 4[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 55 + or edi, ecx + lea ebx, DWORD PTR 2240044497[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 32[esi] + add ebx, edi + mov edi, -1 + rol ebx, 21 + xor edi, edx + add ebx, ecx + ; R3 56 + or edi, ebx + lea eax, DWORD PTR 1873313359[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 60[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 57 + or edi, eax + lea edx, DWORD PTR 4264355552[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 24[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 58 + or edi, edx + lea ecx, DWORD PTR 2734768916[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 52[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 59 + or edi, ecx + lea ebx, DWORD PTR 1309151649[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 16[esi] + add ebx, edi + mov edi, -1 + rol ebx, 21 + xor edi, edx + add ebx, ecx + ; R3 60 + or edi, ebx + lea eax, DWORD PTR 4149444226[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 44[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 61 + or edi, eax + lea edx, DWORD PTR 3174756917[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 8[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 62 + or edi, edx + lea ecx, DWORD PTR 718787259[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 36[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 63 + or edi, ecx + lea ebx, DWORD PTR 3951481745[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 24[esp] + add ebx, edi + add esi, 64 + rol ebx, 21 + mov edi, DWORD PTR [ebp] + add ebx, ecx + add eax, edi + mov edi, DWORD PTR 4[ebp] + add ebx, edi + mov edi, DWORD PTR 8[ebp] + add ecx, edi + mov edi, DWORD PTR 12[ebp] + add edx, edi + mov DWORD PTR [ebp],eax + mov DWORD PTR 4[ebp],ebx + mov edi, DWORD PTR [esp] + mov DWORD PTR 8[ebp],ecx + mov DWORD PTR 12[ebp],edx + cmp edi, esi + jge L000start + pop eax + pop ebx + pop ebp + pop edi + pop esi + ret +_md5_block_x86 ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/md5/asm/mx86unix.cpp b/src/lib/libcrypto/md5/asm/mx86unix.cpp new file mode 100644 index 0000000000..5d399122b6 --- /dev/null +++ b/src/lib/libcrypto/md5/asm/mx86unix.cpp @@ -0,0 +1,730 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define md5_block_x86 _md5_block_x86 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by md5-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "md5-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl md5_block_x86 + TYPE(md5_block_x86,@function) +md5_block_x86: + pushl %esi + pushl %edi + movl 12(%esp), %edi + movl 16(%esp), %esi + movl 20(%esp), %ecx + pushl %ebp + pushl %ebx + addl %esi, %ecx + subl $64, %ecx + movl (%edi), %eax + pushl %ecx + movl 4(%edi), %ebx + movl 8(%edi), %ecx + movl 12(%edi), %edx +.L000start: + + /* R0 section */ + movl %ecx, %edi + movl (%esi), %ebp + /* R0 0 */ + xorl %edx, %edi + andl %ebx, %edi + leal 3614090360(%eax,%ebp,1),%eax + movl 4(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 1 */ + xorl %ecx, %edi + andl %eax, %edi + leal 3905402710(%edx,%ebp,1),%edx + movl 8(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 2 */ + xorl %ebx, %edi + andl %edx, %edi + leal 606105819(%ecx,%ebp,1),%ecx + movl 12(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 3 */ + xorl %eax, %edi + andl %ecx, %edi + leal 3250441966(%ebx,%ebp,1),%ebx + movl 16(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + /* R0 4 */ + xorl %edx, %edi + andl %ebx, %edi + leal 4118548399(%eax,%ebp,1),%eax + movl 20(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 5 */ + xorl %ecx, %edi + andl %eax, %edi + leal 1200080426(%edx,%ebp,1),%edx + movl 24(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 6 */ + xorl %ebx, %edi + andl %edx, %edi + leal 2821735955(%ecx,%ebp,1),%ecx + movl 28(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 7 */ + xorl %eax, %edi + andl %ecx, %edi + leal 4249261313(%ebx,%ebp,1),%ebx + movl 32(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + /* R0 8 */ + xorl %edx, %edi + andl %ebx, %edi + leal 1770035416(%eax,%ebp,1),%eax + movl 36(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 9 */ + xorl %ecx, %edi + andl %eax, %edi + leal 2336552879(%edx,%ebp,1),%edx + movl 40(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 10 */ + xorl %ebx, %edi + andl %edx, %edi + leal 4294925233(%ecx,%ebp,1),%ecx + movl 44(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 11 */ + xorl %eax, %edi + andl %ecx, %edi + leal 2304563134(%ebx,%ebp,1),%ebx + movl 48(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + /* R0 12 */ + xorl %edx, %edi + andl %ebx, %edi + leal 1804603682(%eax,%ebp,1),%eax + movl 52(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 13 */ + xorl %ecx, %edi + andl %eax, %edi + leal 4254626195(%edx,%ebp,1),%edx + movl 56(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 14 */ + xorl %ebx, %edi + andl %edx, %edi + leal 2792965006(%ecx,%ebp,1),%ecx + movl 60(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 15 */ + xorl %eax, %edi + andl %ecx, %edi + leal 1236535329(%ebx,%ebp,1),%ebx + movl 4(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + + /* R1 section */ + /* R1 16 */ + leal 4129170786(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 24(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 17 */ + leal 3225465664(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 44(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 18 */ + leal 643717713(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl (%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 19 */ + leal 3921069994(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 20(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + /* R1 20 */ + leal 3593408605(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 40(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 21 */ + leal 38016083(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 60(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 22 */ + leal 3634488961(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl 16(%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 23 */ + leal 3889429448(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 36(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + /* R1 24 */ + leal 568446438(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 56(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 25 */ + leal 3275163606(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 12(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 26 */ + leal 4107603335(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl 32(%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 27 */ + leal 1163531501(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 52(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + /* R1 28 */ + leal 2850285829(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 8(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 29 */ + leal 4243563512(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 28(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 30 */ + leal 1735328473(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl 48(%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 31 */ + leal 2368359562(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 20(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + + /* R2 section */ + /* R2 32 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 4294588738(%eax,%ebp,1),%eax + addl %edi, %eax + movl 32(%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 33 */ + leal 2272392833(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 44(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 34 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 1839030562(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 56(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 35 */ + leal 4259657740(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl 4(%esi), %ebp + addl %edi, %ebx + movl %ecx, %edi + roll $23, %ebx + addl %ecx, %ebx + /* R2 36 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 2763975236(%eax,%ebp,1),%eax + addl %edi, %eax + movl 16(%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 37 */ + leal 1272893353(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 28(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 38 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 4139469664(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 40(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 39 */ + leal 3200236656(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl 52(%esi), %ebp + addl %edi, %ebx + movl %ecx, %edi + roll $23, %ebx + addl %ecx, %ebx + /* R2 40 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 681279174(%eax,%ebp,1),%eax + addl %edi, %eax + movl (%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 41 */ + leal 3936430074(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 12(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 42 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 3572445317(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 24(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 43 */ + leal 76029189(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl 36(%esi), %ebp + addl %edi, %ebx + movl %ecx, %edi + roll $23, %ebx + addl %ecx, %ebx + /* R2 44 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 3654602809(%eax,%ebp,1),%eax + addl %edi, %eax + movl 48(%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 45 */ + leal 3873151461(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 60(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 46 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 530742520(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 8(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 47 */ + leal 3299628645(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl (%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $23, %ebx + addl %ecx, %ebx + + /* R3 section */ + /* R3 48 */ + xorl %edx, %edi + orl %ebx, %edi + leal 4096336452(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 28(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 49 */ + orl %eax, %edi + leal 1126891415(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 56(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 50 */ + orl %edx, %edi + leal 2878612391(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 20(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 51 */ + orl %ecx, %edi + leal 4237533241(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 48(%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $21, %ebx + xorl %edx, %edi + addl %ecx, %ebx + /* R3 52 */ + orl %ebx, %edi + leal 1700485571(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 12(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 53 */ + orl %eax, %edi + leal 2399980690(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 40(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 54 */ + orl %edx, %edi + leal 4293915773(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 4(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 55 */ + orl %ecx, %edi + leal 2240044497(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 32(%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $21, %ebx + xorl %edx, %edi + addl %ecx, %ebx + /* R3 56 */ + orl %ebx, %edi + leal 1873313359(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 60(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 57 */ + orl %eax, %edi + leal 4264355552(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 24(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 58 */ + orl %edx, %edi + leal 2734768916(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 52(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 59 */ + orl %ecx, %edi + leal 1309151649(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 16(%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $21, %ebx + xorl %edx, %edi + addl %ecx, %ebx + /* R3 60 */ + orl %ebx, %edi + leal 4149444226(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 44(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 61 */ + orl %eax, %edi + leal 3174756917(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 8(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 62 */ + orl %edx, %edi + leal 718787259(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 36(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 63 */ + orl %ecx, %edi + leal 3951481745(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 24(%esp), %ebp + addl %edi, %ebx + addl $64, %esi + roll $21, %ebx + movl (%ebp), %edi + addl %ecx, %ebx + addl %edi, %eax + movl 4(%ebp), %edi + addl %edi, %ebx + movl 8(%ebp), %edi + addl %edi, %ecx + movl 12(%ebp), %edi + addl %edi, %edx + movl %eax, (%ebp) + movl %ebx, 4(%ebp) + movl (%esp), %edi + movl %ecx, 8(%ebp) + movl %edx, 12(%ebp) + cmpl %esi, %edi + jge .L000start + popl %eax + popl %ebx + popl %ebp + popl %edi + popl %esi + ret +.md5_block_x86_end: + SIZE(md5_block_x86,.md5_block_x86_end-md5_block_x86) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl new file mode 100644 index 0000000000..495a2789a0 --- /dev/null +++ b/src/lib/libcrypto/mdc2/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/mdc2/Makefile +# + +DIR= mdc2 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= mdc2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=mdc2dgst.c mdc2_one.c +LIBOBJ=mdc2dgst.o mdc2_one.o + +SRC= $(LIBSRC) + +EXHEADER= mdc2.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl new file mode 100644 index 0000000000..320523cea1 --- /dev/null +++ b/src/lib/libcrypto/objects/Makefile.ssl @@ -0,0 +1,87 @@ +# +# SSLeay/crypto/objects/Makefile +# + +DIR= objects +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=objects +ERRC=obj_err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= obj_dat.c obj_lib.c $(ERRC).c +LIBOBJ= obj_dat.o obj_lib.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= objects.h +HEADER= $(EXHEADER) obj_dat.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: obj_dat.h lib + +obj_dat.h: objects.h obj_dat.pl + perl ./obj_dat.pl < objects.h > obj_dat.h + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/objects/objects.err b/src/lib/libcrypto/objects/objects.err new file mode 100644 index 0000000000..8bec3eaea2 --- /dev/null +++ b/src/lib/libcrypto/objects/objects.err @@ -0,0 +1,12 @@ +/* Error codes for the OBJ functions. */ + +/* Function codes. */ +#define OBJ_F_OBJ_CREATE 100 +#define OBJ_F_OBJ_DUP 101 +#define OBJ_F_OBJ_NID2LN 102 +#define OBJ_F_OBJ_NID2OBJ 103 +#define OBJ_F_OBJ_NID2SN 104 + +/* Reason codes. */ +#define OBJ_R_MALLOC_FAILURE 100 +#define OBJ_R_UNKNOWN_NID 101 diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl new file mode 100644 index 0000000000..fc04a88fd9 --- /dev/null +++ b/src/lib/libcrypto/pem/Makefile.ssl @@ -0,0 +1,96 @@ +# +# SSLeay/crypto/pem/Makefile +# + +DIR= pem +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=pem +ERRC=pem_err +GENERAL=Makefile +TEST= +APPS= + +CTX_SIZE= ctx_size + +LIB=$(TOP)/libcrypto.a +LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c $(ERRC).c + +LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= pem.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: pem.h lib + +pem.h: $(CTX_SIZE) + ./$(CTX_SIZE) pem.new + if [ -f pem.h ]; then mv -f pem.h pem.old; fi + mv -f pem.new pem.h + +$(CTX_SIZE): $(CTX_SIZE).o + $(CC) $(CFLAGS) -o $(CTX_SIZE) $(CTX_SIZE).o + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(CTX_SIZE).c $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(CTX_SIZE) *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # SPECIAL CASE .org + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/pem/ctx_size.c b/src/lib/libcrypto/pem/ctx_size.c new file mode 100644 index 0000000000..87469bc4af --- /dev/null +++ b/src/lib/libcrypto/pem/ctx_size.c @@ -0,0 +1,122 @@ +/* crypto/pem/ctx_size.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" + +int main(argc,argv) +int argc; +char *argv[]; + { + int i,j; + char buf[256]; + + for (;;) + { + char *str; + buf[0]='\0'; + fgets(buf,256,stdin); + if (buf[0] == '\0') break; + + str="#define EVP_ENCODE_CTX_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_ENCODE_CTX)); + continue; + } + str="#define EVP_MD_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_MD)); + continue; + } + str="#define EVP_MD_CTX_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_MD_CTX)); + continue; + } + str="#define EVP_CIPHER_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_CIPHER)); + continue; + } + str="#define EVP_CIPHER_CTX_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_CIPHER_CTX)); + continue; + } + + str="#define EVP_MAX_MD_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + i=MD2_DIGEST_LENGTH; + j=MD5_DIGEST_LENGTH; + if (j > i) i=j; + j=SHA_DIGEST_LENGTH; + if (j > i) i=j; + printf("%s %d\n",str,i); + continue; + } + fputs(buf,stdout); + } + exit(0); + } diff --git a/src/lib/libcrypto/pem/pem.err b/src/lib/libcrypto/pem/pem.err new file mode 100644 index 0000000000..0e523abf82 --- /dev/null +++ b/src/lib/libcrypto/pem/pem.err @@ -0,0 +1,38 @@ +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_DEF_CALLBACK 100 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 diff --git a/src/lib/libcrypto/pem/pem.org b/src/lib/libcrypto/pem/pem.org new file mode 100644 index 0000000000..38952509dd --- /dev/null +++ b/src/lib/libcrypto/pem/pem.org @@ -0,0 +1,562 @@ +/* crypto/pem/pem.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify pem.org since pem.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_PEM_H +#define HEADER_PEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "evp.h" +#include "x509.h" + +#define PEM_OBJ_UNDEF 0 +#define PEM_OBJ_X509 1 +#define PEM_OBJ_X509_REQ 2 +#define PEM_OBJ_CRL 3 +#define PEM_OBJ_SSL_SESSION 4 +#define PEM_OBJ_PRIV_KEY 10 +#define PEM_OBJ_PRIV_RSA 11 +#define PEM_OBJ_PRIV_DSA 12 +#define PEM_OBJ_PRIV_DH 13 +#define PEM_OBJ_PUB_RSA 14 +#define PEM_OBJ_PUB_DSA 15 +#define PEM_OBJ_PUB_DH 16 +#define PEM_OBJ_DHPARAMS 17 +#define PEM_OBJ_DSAPARAMS 18 +#define PEM_OBJ_PRIV_RSA_PUBLIC 19 + +#define PEM_ERROR 30 +#define PEM_DEK_DES_CBC 40 +#define PEM_DEK_IDEA_CBC 45 +#define PEM_DEK_DES_EDE 50 +#define PEM_DEK_DES_ECB 60 +#define PEM_DEK_RSA 70 +#define PEM_DEK_RSA_MD2 80 +#define PEM_DEK_RSA_MD5 90 + +#define PEM_MD_MD2 NID_md2 +#define PEM_MD_MD5 NID_md5 +#define PEM_MD_SHA NID_sha +#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption +#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption +#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption + +#define PEM_STRING_X509_OLD "X509 CERTIFICATE" +#define PEM_STRING_X509 "CERTIFICATE" +#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +#define PEM_STRING_X509_CRL "X509 CRL" +#define PEM_STRING_EVP_PKEY "PRIVATE KEY" +#define PEM_STRING_RSA "RSA PRIVATE KEY" +#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +#define PEM_STRING_DSA "DSA PRIVATE KEY" +#define PEM_STRING_PKCS7 "PKCS7" +#define PEM_STRING_DHPARAMS "DH PARAMETERS" +#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" + +#ifndef HEADER_ENVELOPE_H + +#define EVP_ENCODE_CTX_SIZE 92 +#define EVP_MD_SIZE 48 +#define EVP_MD_CTX_SIZE 152 +#define EVP_CIPHER_SIZE 28 +#define EVP_CIPHER_CTX_SIZE 4212 +#define EVP_MAX_MD_SIZE 20 + +typedef struct evp_encode_ctx_st + { + char data[EVP_ENCODE_CTX_SIZE]; + } EVP_ENCODE_CTX; + +typedef struct env_md_ctx_st + { + char data[EVP_MD_CTX_SIZE]; + } EVP_MD_CTX; + +typedef struct evp_cipher_st + { + char data[EVP_CIPHER_SIZE]; + } EVP_CIPHER; + +typedef struct evp_cipher_ctx_st + { + char data[EVP_CIPHER_CTX_SIZE]; + } EVP_CIPHER_CTX; +#endif + + +typedef struct PEM_Encode_Seal_st + { + EVP_ENCODE_CTX encode; + EVP_MD_CTX md; + EVP_CIPHER_CTX cipher; + } PEM_ENCODE_SEAL_CTX; + +/* enc_type is one off */ +#define PEM_TYPE_ENCRYPTED 10 +#define PEM_TYPE_MIC_ONLY 20 +#define PEM_TYPE_MIC_CLEAR 30 +#define PEM_TYPE_CLEAR 40 + +typedef struct pem_recip_st + { + char *name; + X509_NAME *dn; + + int cipher; + int key_enc; + char iv[8]; + } PEM_USER; + +typedef struct pem_ctx_st + { + int type; /* what type of object */ + + struct { + int version; + int mode; + } proc_type; + + char *domain; + + struct { + int cipher; + unsigned char iv[8]; + } DEK_info; + + PEM_USER *originator; + + int num_recipient; + PEM_USER **recipient; + +#ifdef HEADER_STACK_H + STACK *x509_chain; /* certificate chain */ +#else + char *x509_chain; /* certificate chain */ +#endif + EVP_MD *md; /* signature type */ + + int md_enc; /* is the md encrypted or not? */ + int md_len; /* length of md_data */ + char *md_data; /* message digest, could be pkey encrypted */ + + EVP_CIPHER *dec; /* date encryption cipher */ + int key_len; /* key length */ + unsigned char *key; /* key */ + unsigned char iv[8]; /* the iv */ + + + int data_enc; /* is the data encrypted */ + int data_len; + unsigned char *data; + } PEM_CTX; + +#ifdef SSLEAY_MACROS + +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL) +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ + NULL,NULL,0,NULL) +#define PEM_write_X509_CRL(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ + fp,(char *)x, NULL,NULL,0,NULL) +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ + (char *)x,enc,kstr,klen,cb) +#define PEM_write_RSAPublicKey(fp,x) \ + PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ + PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ + (char *)x,enc,kstr,klen,cb) +#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_PKCS7(fp,x) \ + PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_DHparams(fp,x) \ + PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ + (char *)x,NULL,NULL,0,NULL) + +#define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb) +#define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \ + (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb) +#define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb) +#define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb) +#define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb) +#define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb) +#define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb) +#define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb) +#define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb) +#define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb) + +#define PEM_write_bio_SSL_SESSION(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_X509(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ + NULL,NULL,0,NULL) +#define PEM_write_bio_X509_CRL(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ + bp,(char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_bio_RSAPublicKey(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ + PEM_STRING_RSA_PUBLIC,\ + bp,(char *)x,NULL,NULL,0,NULL) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_bio_PKCS7(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_DHparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ + bp,(char *)x,NULL,NULL,0,NULL) +#define PEM_write_bio_DSAparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ + PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL) + +#define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb) +#define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb) +#define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb) +#define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb) +#define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb) +#define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb) + +#define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb) +#define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb) +#define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb) + +#endif + +#ifndef NOPROTO +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + int (*callback)()); + +#ifdef HEADER_BIO_H +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write_bio(BIO *bp,char *name,char *hdr,unsigned char *data, + long len); +char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x, + int (*cb)()); +int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x, + EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)()); +STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)()); +int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, + unsigned char *kstr, int klen, int (*cb)()); +#endif + +#ifndef WIN16 +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); +char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x, + int (*cb)()); +int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x, + EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)()); +STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)()); +#endif + +int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, + EVP_MD *md_type, unsigned char **ek, int *ekl, + unsigned char *iv, EVP_PKEY **pubk, int npubk); +void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, + unsigned char *in, int inl); +int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, + unsigned char *out, int *outl, EVP_PKEY *priv); + +void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +void ERR_load_PEM_strings(void); + +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, char *type, int len, char *str); + +#ifndef SSLEAY_MACROS + +#ifndef WIN16 +X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)()); +X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)()); +X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)()); +RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)()); +RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)()); +DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)()); +EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)()); +PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)()); +DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)()); +DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)()); +int PEM_write_X509(FILE *fp,X509 *x); +int PEM_write_X509_REQ(FILE *fp,X509_REQ *x); +int PEM_write_X509_CRL(FILE *fp,X509_CRL *x); +int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr, + int klen,int (*cb)()); +int PEM_write_RSAPublicKey(FILE *fp,RSA *x); +int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,EVP_CIPHER *enc,unsigned char *kstr, + int klen,int (*cb)()); +int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_PKCS7(FILE *fp,PKCS7 *x); +int PEM_write_DHparams(FILE *fp,DH *x); +int PEM_write_DSAparams(FILE *fp,DSA *x); +#endif + +#ifdef HEADER_BIO_H +X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)()); +X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)()); +X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)()); +RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)()); +RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)()); +DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)()); +EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)()); +PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)()); +DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)()); +DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)()); +int PEM_write_bio_X509(BIO *bp,X509 *x); +int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x); +int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x); +int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x); +int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x); +int PEM_write_bio_DHparams(BIO *bp,DH *x); +int PEM_write_bio_DSAparams(BIO *bp,DSA *x); +#endif + +#endif /* SSLEAY_MACROS */ + + +#else + +int PEM_get_EVP_CIPHER_INFO(); +int PEM_do_header(); +int PEM_read_bio(); +int PEM_write_bio(); +#ifndef WIN16 +int PEM_read(); +int PEM_write(); +STACK * PEM_X509_INFO_read(); +char * PEM_ASN1_read(); +int PEM_ASN1_write(); +#endif +STACK * PEM_X509_INFO_read_bio(); +int PEM_X509_INFO_write_bio(); +char * PEM_ASN1_read_bio(); +int PEM_ASN1_write_bio(); +int PEM_SealInit(); +void PEM_SealUpdate(); +int PEM_SealFinal(); +int PEM_SignFinal(); + +void ERR_load_PEM_strings(); + +void PEM_proc_type(); +void PEM_dek_info(); + +#ifndef SSLEAY_MACROS +#ifndef WIN16 +X509 *PEM_read_X509(); +X509_REQ *PEM_read_X509_REQ(); +X509_CRL *PEM_read_X509_CRL(); +RSA *PEM_read_RSAPrivateKey(); +RSA *PEM_read_RSAPublicKey(); +DSA *PEM_read_DSAPrivateKey(); +EVP_PKEY *PEM_read_PrivateKey(); +PKCS7 *PEM_read_PKCS7(); +DH *PEM_read_DHparams(); +DSA *PEM_read_DSAparams(); +int PEM_write_X509(); +int PEM_write_X509_REQ(); +int PEM_write_X509_CRL(); +int PEM_write_RSAPrivateKey(); +int PEM_write_RSAPublicKey(); +int PEM_write_DSAPrivateKey(); +int PEM_write_PrivateKey(); +int PEM_write_PKCS7(); +int PEM_write_DHparams(); +int PEM_write_DSAparams(); +#endif + +X509 *PEM_read_bio_X509(); +X509_REQ *PEM_read_bio_X509_REQ(); +X509_CRL *PEM_read_bio_X509_CRL(); +RSA *PEM_read_bio_RSAPrivateKey(); +RSA *PEM_read_bio_RSAPublicKey(); +DSA *PEM_read_bio_DSAPrivateKey(); +EVP_PKEY *PEM_read_bio_PrivateKey(); +PKCS7 *PEM_read_bio_PKCS7(); +DH *PEM_read_bio_DHparams(); +DSA *PEM_read_bio_DSAparams(); +int PEM_write_bio_X509(); +int PEM_write_bio_X509_REQ(); +int PEM_write_bio_X509_CRL(); +int PEM_write_bio_RSAPrivateKey(); +int PEM_write_bio_RSAPublicKey(); +int PEM_write_bio_DSAPrivateKey(); +int PEM_write_bio_PrivateKey(); +int PEM_write_bio_PKCS7(); +int PEM_write_bio_DHparams(); +int PEM_write_bio_DSAparams(); + +#endif /* SSLEAY_MACROS */ + +#endif + +/* BEGIN ERROR CODES */ +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_DEF_CALLBACK 100 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl new file mode 100644 index 0000000000..a88359b320 --- /dev/null +++ b/src/lib/libcrypto/pkcs7/Makefile.ssl @@ -0,0 +1,86 @@ +# +# SSLeay/crypto/asn1/Makefile +# + +DIR= pkcs7 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=pkcs7 +ERRC=pkcs7err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c +LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o + +SRC= $(LIBSRC) + +EXHEADER= pkcs7.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +test: + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/pkcs7/README b/src/lib/libcrypto/pkcs7/README new file mode 100644 index 0000000000..27001c6970 --- /dev/null +++ b/src/lib/libcrypto/pkcs7/README @@ -0,0 +1,5 @@ +WARNING + +Everything in this directory is experimental and is subject to change. + +Do not rely on the stuff in here not changing in the next release diff --git a/src/lib/libcrypto/pkcs7/mf.p7 b/src/lib/libcrypto/pkcs7/mf.p7 new file mode 100644 index 0000000000..524335b4b3 --- /dev/null +++ b/src/lib/libcrypto/pkcs7/mf.p7 @@ -0,0 +1,18 @@ +-----BEGIN PKCS7----- +MIAGCSqGSIb3DQEHAqCAMIIC2QIBATEMMAoGCCqGSIb3DQIFMIAGCSqGSIb3DQEH +AQAAoIIB7TCCAekwggFSAgEAMA0GCSqGSIb3DQEBBAUAMFsxCzAJBgNVBAYTAkFV +MRMwEQYDVQQIEwpRdWVlbnNsYW5kMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0 +ZDEbMBkGA1UEAxMSVGVzdCBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0NloX +DTk4MDYwOTEzNTc0NlowYzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xh +bmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMSMwIQYDVQQDExpTZXJ2ZXIg +dGVzdCBjZXJ0ICg1MTIgYml0KTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCfs8OE +J5X/EjFSDxXvRhHErYDmNlsP3YDXYY3g/HJFCTT+VWZFQ0xol2r+qKCl3194/+7X +ZLg/BMtv/yr+/rntAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAeEzEdgr2nChPcALL +vY8gl/GIlpoAjPmKD+pLeGZI9s+SEX5u1q8nCrJ6ZzkfrRnqgI5Anmev9+qPZfdU +bz5zdVSf4sUL9nX9ChXjK9NCJA3UzQHSFqhZErGUwGNkAHYHp2+zAdY6Ho6rmMzt +g0CDu/sKR4qzm6REsQGS8kgpjz4xgcUwgcICAQEwYDBbMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKUXVlZW5zbGFuZDEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQx +GzAZBgNVBAMTElRlc3QgQ0EgKDEwMjQgYml0KQIBADAKBggqhkiG9w0CBTANBgkq +hkiG9w0BAQQFAARALnrxJiOX9XZf2D+3vL8SKMQmMq55LltomwOLGUru/q1uVXzi +ARg7FSCegOpA1nunsTURMUGgrPXKK4XmL4IseQAAAAA= +-----END PKCS7----- diff --git a/src/lib/libcrypto/pkcs7/p7.tst b/src/lib/libcrypto/pkcs7/p7.tst new file mode 100644 index 0000000000..6d14dce163 --- /dev/null +++ b/src/lib/libcrypto/pkcs7/p7.tst @@ -0,0 +1,33 @@ +-----BEGIN PKCS7----- +MIAGCSqGSIb3DQEHAqCAMIIFsQIBATELMAkGBSsOAwIaBQAwgAYJKoZIhvcNAQcB +AACgggQdMIICJTCCAc+gAwIBAgIBIjANBgkqhkiG9w0BAQQFADCBgjELMAkGA1UE +BhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRow +GAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEUMBIGA1UECxMLZGV2ZWxvcG1lbnQx +GTAXBgNVBAMTEENyeXB0U29mdCBEZXYgQ0EwHhcNOTcwNjEzMTgxMDE3WhcNOTgw +NjEzMTgxMDE3WjCBiDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx +ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEU +MBIGA1UECxMLSUlTIHRlc3RpbmcxDjAMBgNVBAMTBXRlc3QxMQ8wDQYJKoZIhvcN +AQkBFgAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAxtWiv59VH42+rotrmFAyDxTc +J2osFt5uy/zEllx3vvjtwewqQxGUOwf6cjqFOTrnpEdVvwywpEhIQ5364bJqIwID +AQABoygwJjAkBglghkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0G +CSqGSIb3DQEBBAUAA0EAMnYkNV2AdpeHPy/qlcdZx6MDGIJgrLhklhcn6Or6KiAP +t9+nv9XdOGHyMyQr9ufsweuQfAgJ9yjKPZR2/adTjTCCAfAwggGaAgEAMA0GCSqG +SIb3DQEBBAUAMIGCMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDER +MA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRQw +EgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UEAxMQQ3J5cHRTb2Z0IERldiBDQTAe +Fw05NzAzMjIxMzM0MDRaFw05ODAzMjIxMzM0MDRaMIGCMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoT +EUNyeXB0U29mdCBQdHkgTHRkMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UE +AxMQQ3J5cHRTb2Z0IERldiBDQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgDgKq +IBuUMAJi4c8juAqEZ8f8FcuDWT+HcScvNztRJy9K8DnbGpiSrzzix4El6N4A7vbl +crwn/0CZmQJguZpfAgMBAAEwDQYJKoZIhvcNAQEEBQADQQA0UUvxlXXe6wKkVukn +ZoCyXbjlNsqt2rwbvfZEam6fQP3S7uq+o1Pnj+KDgE33WxWbQAA9h8fY1LWN7X3a +yTm/MYIBbTCCAWkCAQEwgYgwgYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVl +bnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0 +eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQg +RGV2IENBAgEiMAkGBSsOAwIaBQCgfTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcB +MCMGCSqGSIb3DQEJBDEWBBSUVhbGkNE+KGqpOK13+FkfOkaoizAcBgkqhkiG9w0B +CQUxDxcNOTcwNzAxMDE0MzM0WjAeBgkqhkiG9w0BCQ8xETAPMA0GCCqGSIb3DQMC +AgEoMA0GCSqGSIb3DQEBAQUABECa9Jpo4w/fZOc3Vy78wZFAVF8kvpn7il99Ldsr +AQ4JiBmcfiSwEBBY6WuKT+/SYtFwZl1oXkTwB5AVCFIC/IFNAAAAAA== +-----END PKCS7----- diff --git a/src/lib/libcrypto/pkcs7/pkcs7.err b/src/lib/libcrypto/pkcs7/pkcs7.err new file mode 100644 index 0000000000..91413aae43 --- /dev/null +++ b/src/lib/libcrypto/pkcs7/pkcs7.err @@ -0,0 +1,26 @@ +/* Error codes for the PKCS7 functions. */ + +/* Function codes. */ +#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 +#define PKCS7_F_PKCS7_ADD_CRL 101 +#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 +#define PKCS7_F_PKCS7_ADD_SIGNER 103 +#define PKCS7_F_PKCS7_CTRL 104 +#define PKCS7_F_PKCS7_DATAINIT 105 +#define PKCS7_F_PKCS7_DATASIGN 106 +#define PKCS7_F_PKCS7_DATAVERIFY 107 +#define PKCS7_F_PKCS7_SET_CIPHER 108 +#define PKCS7_F_PKCS7_SET_CONTENT 109 +#define PKCS7_F_PKCS7_SET_TYPE 110 + +/* Reason codes. */ +#define PKCS7_R_INTERNAL_ERROR 100 +#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 101 +#define PKCS7_R_SIGNATURE_FAILURE 102 +#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 103 +#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 104 +#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 105 +#define PKCS7_R_UNKNOWN_DIGEST_TYPE 106 +#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 107 +#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 108 +#define PKCS7_R_WRONG_CONTENT_TYPE 109 diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl new file mode 100644 index 0000000000..d04f0a9b43 --- /dev/null +++ b/src/lib/libcrypto/rand/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/rand/Makefile +# + +DIR= rand +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= randtest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=md_rand.c randfile.c +LIBOBJ=md_rand.o randfile.o + +SRC= $(LIBSRC) + +EXHEADER= rand.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/ranlib.sh b/src/lib/libcrypto/ranlib.sh new file mode 100644 index 0000000000..543f712c6b --- /dev/null +++ b/src/lib/libcrypto/ranlib.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cwd=`pwd` +cd /tmp + +if [ -s /bin/ranlib ] ; then + RL=/bin/ranlib +else if [ -s /usr/bin/ranlib ] ; then + RL=/usr/bin/ranlib +fi +fi + +if [ "x$RL" != "x" ] +then + case "$1" in + /*) + $RL "$1" + ;; + *) + $RL "$cwd/$1" + ;; + esac +fi diff --git a/src/lib/libcrypto/rc2/Makefile.ssl b/src/lib/libcrypto/rc2/Makefile.ssl new file mode 100644 index 0000000000..c5138f13e2 --- /dev/null +++ b/src/lib/libcrypto/rc2/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/rc2/Makefile +# + +DIR= rc2 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc2.h +HEADER= rc2_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rc2/Makefile.uni b/src/lib/libcrypto/rc2/Makefile.uni new file mode 100644 index 0000000000..e50b3f2d19 --- /dev/null +++ b/src/lib/libcrypto/rc2/Makefile.uni @@ -0,0 +1,72 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options + +DIR= rc2 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +IDEA_ENC=rc2_cbc.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc2test +APPS=rc2speed + +LIB=librc2.a +LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc2.h +HEADER= rc2_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rc2/rc2.org b/src/lib/libcrypto/rc2/rc2.org new file mode 100644 index 0000000000..37354cfa62 --- /dev/null +++ b/src/lib/libcrypto/rc2/rc2.org @@ -0,0 +1,118 @@ +/* crypto/rc2/rc2.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify rc2.org since rc2.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_RC2_H +#define HEADER_RC2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define RC2_ENCRYPT 1 +#define RC2_DECRYPT 0 + +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned short + +#define RC2_BLOCK 8 +#define RC2_KEY_LENGTH 16 + +typedef struct rc2_key_st + { + RC2_INT data[64]; + } RC2_KEY; + +#ifndef NOPROTO + +void RC2_set_key(RC2_KEY *key, int len, unsigned char *data,int bits); +void RC2_ecb_encrypt(unsigned char *in,unsigned char *out,RC2_KEY *key, + int enc); +void RC2_encrypt(unsigned long *data,RC2_KEY *key); +void RC2_decrypt(unsigned long *data,RC2_KEY *key); +void RC2_cbc_encrypt(unsigned char *in, unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, int enc); +void RC2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + RC2_KEY *schedule, unsigned char *ivec, int *num, int enc); +void RC2_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + RC2_KEY *schedule, unsigned char *ivec, int *num); + +#else + +void RC2_set_key(); +void RC2_ecb_encrypt(); +void RC2_encrypt(); +void RC2_decrypt(); +void RC2_cbc_encrypt(); +void RC2_cfb64_encrypt(); +void RC2_ofb64_encrypt(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libcrypto/rc4/Makefile.ssl b/src/lib/libcrypto/rc4/Makefile.ssl new file mode 100644 index 0000000000..19c1e980f3 --- /dev/null +++ b/src/lib/libcrypto/rc4/Makefile.ssl @@ -0,0 +1,108 @@ +# +# SSLeay/crypto/rc4/Makefile +# + +DIR= rc4 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +RC4_ENC=rc4_enc.o +# or use +#RC4_ENC=asm/rx86-elf.o +#RC4_ENC=asm/rx86-out.o +#RC4_ENC=asm/rx86-sol.o +#RC4_ENC=asm/rx86bdsi.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc4test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=rc4_skey.c rc4_enc.c +LIBOBJ=rc4_skey.o $(RC4_ENC) + +SRC= $(LIBSRC) + +EXHEADER= rc4.h +HEADER= $(EXHEADER) rc4_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/rx86-elf.o: asm/rx86unix.cpp + $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o + +# solaris +asm/rx86-sol.o: asm/rx86unix.cpp + $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s + as -o asm/rx86-sol.o asm/rx86-sol.s + rm -f asm/rx86-sol.s + +# a.out +asm/rx86-out.o: asm/rx86unix.cpp + $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o + +# bsdi +asm/rx86bsdi.o: asm/rx86unix.cpp + $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o + +asm/rx86unix.cpp: + (cd asm; perl rc4-586.pl cpp >rx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rc4/Makefile.uni b/src/lib/libcrypto/rc4/Makefile.uni new file mode 100644 index 0000000000..79dc17b8d1 --- /dev/null +++ b/src/lib/libcrypto/rc4/Makefile.uni @@ -0,0 +1,102 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= rc4 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +RC4_ENC=rc4_enc.o +# or use +#RC4_ENC=asm/rx86-elf.o +#RC4_ENC=asm/rx86-out.o +#RC4_ENC=asm/rx86-sol.o +#RC4_ENC=asm/rx86bdsi.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc4test +APPS=rc4speed + +LIB=librc4.a +LIBSRC=rc4_skey.c rc4_enc.c +LIBOBJ=rc4_skey.o $(RC4_ENC) + +SRC= $(LIBSRC) + +EXHEADER= rc4.h +HEADER= $(EXHEADER) rc4_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/rx86-elf.o: asm/rx86unix.cpp + $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o + +# solaris +asm/rx86-sol.o: asm/rx86unix.cpp + $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s + as -o asm/rx86-sol.o asm/rx86-sol.s + rm -f asm/rx86-sol.s + +# a.out +asm/rx86-out.o: asm/rx86unix.cpp + $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o + +# bsdi +asm/rx86bsdi.o: asm/rx86unix.cpp + $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o + +asm/rx86unix.cpp: + (cd asm; perl rc4-586.pl cpp >rx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rc4/asm/r4-win32.asm b/src/lib/libcrypto/rc4/asm/r4-win32.asm new file mode 100644 index 0000000000..70b0f7484c --- /dev/null +++ b/src/lib/libcrypto/rc4/asm/r4-win32.asm @@ -0,0 +1,314 @@ + ; Don't even think of reading this code + ; It was automatically generated by rc4-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE rc4-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _RC4 + +_RC4 PROC NEAR + ; + push ebp + push ebx + mov ebp, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + push esi + push edi + mov ecx, DWORD PTR [ebp] + mov edx, DWORD PTR 4[ebp] + mov esi, DWORD PTR 28[esp] + inc ecx + sub esp, 12 + add ebp, 8 + and ecx, 255 + lea ebx, DWORD PTR [esi+ebx-8] + mov edi, DWORD PTR 44[esp] + mov DWORD PTR 8[esp],ebx + mov eax, DWORD PTR [ecx*4+ebp] + cmp ebx, esi + jl $L000end +L001start: + add esi, 8 + ; Round 0 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR [esp], bl + ; Round 1 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 1[esp],bl + ; Round 2 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 2[esp],bl + ; Round 3 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 3[esp],bl + ; Round 4 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 4[esp],bl + ; Round 5 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 5[esp],bl + ; Round 6 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 6[esp],bl + ; Round 7 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + add edi, 8 + mov BYTE PTR 7[esp],bl + ; apply the cipher text + mov eax, DWORD PTR [esp] + mov ebx, DWORD PTR [esi-8] + xor eax, ebx + mov ebx, DWORD PTR [esi-4] + mov DWORD PTR [edi-8],eax + mov eax, DWORD PTR 4[esp] + xor eax, ebx + mov ebx, DWORD PTR 8[esp] + mov DWORD PTR [edi-4],eax + mov eax, DWORD PTR [ecx*4+ebp] + cmp esi, ebx + jle L001start +$L000end: + ; Round 0 + add ebx, 8 + inc esi + cmp ebx, esi + jl $L002finished + mov DWORD PTR 8[esp],ebx + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR [edi], bl + ; Round 1 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 1[edi],bl + ; Round 2 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 2[edi],bl + ; Round 3 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 3[edi],bl + ; Round 4 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 4[edi],bl + ; Round 5 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 5[edi],bl + ; Round 6 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 6[edi],bl +$L002finished: + dec ecx + add esp, 12 + mov DWORD PTR [ebp-4],edx + mov BYTE PTR [ebp-8],cl + pop edi + pop esi + pop ebx + pop ebp + ret +_RC4 ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/rc4/asm/rx86unix.cpp b/src/lib/libcrypto/rc4/asm/rx86unix.cpp new file mode 100644 index 0000000000..ec1d72a110 --- /dev/null +++ b/src/lib/libcrypto/rc4/asm/rx86unix.cpp @@ -0,0 +1,358 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define RC4 _RC4 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rc4-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "rc4-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl RC4 + TYPE(RC4,@function) +RC4: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebp + movl 16(%esp), %ebx + pushl %esi + pushl %edi + movl (%ebp), %ecx + movl 4(%ebp), %edx + movl 28(%esp), %esi + incl %ecx + subl $12, %esp + addl $8, %ebp + andl $255, %ecx + leal -8(%ebx,%esi,), %ebx + movl 44(%esp), %edi + movl %ebx, 8(%esp) + movl (%ebp,%ecx,4), %eax + cmpl %esi, %ebx + jl .L000end +.L001start: + addl $8, %esi + /* Round 0 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, (%esp) + /* Round 1 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 1(%esp) + /* Round 2 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 2(%esp) + /* Round 3 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 3(%esp) + /* Round 4 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 4(%esp) + /* Round 5 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 5(%esp) + /* Round 6 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 6(%esp) + /* Round 7 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + addl $8, %edi + movb %bl, 7(%esp) + /* apply the cipher text */ + movl (%esp), %eax + movl -8(%esi), %ebx + xorl %ebx, %eax + movl -4(%esi), %ebx + movl %eax, -8(%edi) + movl 4(%esp), %eax + xorl %ebx, %eax + movl 8(%esp), %ebx + movl %eax, -4(%edi) + movl (%ebp,%ecx,4), %eax + cmpl %ebx, %esi + jle .L001start +.L000end: + /* Round 0 */ + addl $8, %ebx + incl %esi + cmpl %esi, %ebx + jl .L002finished + movl %ebx, 8(%esp) + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, (%edi) + /* Round 1 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 1(%edi) + /* Round 2 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 2(%edi) + /* Round 3 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 3(%edi) + /* Round 4 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 4(%edi) + /* Round 5 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 5(%edi) + /* Round 6 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 6(%edi) +.L002finished: + decl %ecx + addl $12, %esp + movl %edx, -4(%ebp) + movb %cl, -8(%ebp) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.RC4_end: + SIZE(RC4,.RC4_end-RC4) +.ident "RC4" diff --git a/src/lib/libcrypto/rc4/rc4.org b/src/lib/libcrypto/rc4/rc4.org new file mode 100644 index 0000000000..c558651af8 --- /dev/null +++ b/src/lib/libcrypto/rc4/rc4.org @@ -0,0 +1,103 @@ +/* crypto/rc4/rc4.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify rc4.org since rc4.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_RC4_H +#define HEADER_RC4_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +#define RC4_INT unsigned int + +typedef struct rc4_key_st + { + RC4_INT x,y; + RC4_INT data[256]; + } RC4_KEY; + +#ifndef NOPROTO + +char *RC4_options(void); +void RC4_set_key(RC4_KEY *key, int len, unsigned char *data); +void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, + unsigned char *outdata); + +#else + +char *RC4_options(); +void RC4_set_key(); +void RC4(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libcrypto/rc4/rc4_locl.org b/src/lib/libcrypto/rc4/rc4_locl.org new file mode 100644 index 0000000000..1ef4455fb7 --- /dev/null +++ b/src/lib/libcrypto/rc4/rc4_locl.org @@ -0,0 +1,70 @@ +/* crypto/rc4/rc4_locl.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify bf_locl.org since bf_locl.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX + diff --git a/src/lib/libcrypto/rc5/Makefile.ssl b/src/lib/libcrypto/rc5/Makefile.ssl new file mode 100644 index 0000000000..5e98ee2348 --- /dev/null +++ b/src/lib/libcrypto/rc5/Makefile.ssl @@ -0,0 +1,107 @@ +# +# SSLeay/crypto/rc5/Makefile +# + +DIR= rc5 +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +RC5_ENC= rc5_enc.o +# or use +#DES_ENC= r586-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc5test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c +LIBOBJ=rc5_skey.o rc5_ecb.o $(RC5_ENC) rc5cfb64.o rc5ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc5.h +HEADER= rc5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/r586-elf.o: asm/r586unix.cpp + $(CPP) -DELF asm/r586unix.cpp | as -o asm/r586-elf.o + +# solaris +asm/r586-sol.o: asm/r586unix.cpp + $(CC) -E -DSOL asm/r586unix.cpp | sed 's/^#.*//' > asm/r586-sol.s + as -o asm/r586-sol.o asm/r586-sol.s + rm -f asm/r586-sol.s + +# a.out +asm/r586-out.o: asm/r586unix.cpp + $(CPP) -DOUT asm/r586unix.cpp | as -o asm/r586-out.o + +# bsdi +asm/r586bsdi.o: asm/r586unix.cpp + $(CPP) -DBSDI asm/r586unix.cpp | as -o asm/r586bsdi.o + +asm/r586unix.cpp: + (cd asm; perl rc5-586.pl cpp >r586unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/point.sh ../../doc/rc5.doc rc5.doc ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rc5/Makefile.uni b/src/lib/libcrypto/rc5/Makefile.uni new file mode 100644 index 0000000000..e50b3f2d19 --- /dev/null +++ b/src/lib/libcrypto/rc5/Makefile.uni @@ -0,0 +1,72 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options + +DIR= rc2 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +IDEA_ENC=rc2_cbc.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc2test +APPS=rc2speed + +LIB=librc2.a +LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc2.h +HEADER= rc2_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rc5/asm/r5-win32.asm b/src/lib/libcrypto/rc5/asm/r5-win32.asm new file mode 100644 index 0000000000..f43d3711f0 --- /dev/null +++ b/src/lib/libcrypto/rc5/asm/r5-win32.asm @@ -0,0 +1,574 @@ + ; Don't even think of reading this code + ; It was automatically generated by rc5-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE rc5-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _RC5_32_encrypt + +_RC5_32_encrypt PROC NEAR + ; + push ebp + push esi + push edi + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 20[esp] + ; Load the 2 words + mov edi, DWORD PTR [edx] + mov esi, DWORD PTR 4[edx] + push ebx + mov ebx, DWORD PTR [ebp] + add edi, DWORD PTR 4[ebp] + add esi, DWORD PTR 8[ebp] + xor edi, esi + mov eax, DWORD PTR 12[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 16[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 20[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 24[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 28[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 32[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 36[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 40[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 44[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 48[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 52[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 56[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 60[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 64[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 68[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 72[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + cmp ebx, 8 + je $L000rc5_exit + xor edi, esi + mov eax, DWORD PTR 76[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 80[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 84[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 88[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 92[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 96[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 100[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 104[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + cmp ebx, 12 + je $L000rc5_exit + xor edi, esi + mov eax, DWORD PTR 108[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 112[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 116[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 120[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 124[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 128[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 132[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 136[ebp] + mov ecx, edi + rol esi, cl + add esi, eax +$L000rc5_exit: + mov DWORD PTR [edx],edi + mov DWORD PTR 4[edx],esi + pop ebx + pop edi + pop esi + pop ebp + ret +_RC5_32_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _RC5_32_decrypt + +_RC5_32_decrypt PROC NEAR + ; + push ebp + push esi + push edi + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 20[esp] + ; Load the 2 words + mov edi, DWORD PTR [edx] + mov esi, DWORD PTR 4[edx] + push ebx + mov ebx, DWORD PTR [ebp] + cmp ebx, 12 + je $L001rc5_dec_12 + cmp ebx, 8 + je $L002rc5_dec_8 + mov eax, DWORD PTR 136[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 132[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 128[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 124[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 120[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 116[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 112[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 108[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi +$L001rc5_dec_12: + mov eax, DWORD PTR 104[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 100[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 96[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 92[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 88[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 84[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 80[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 76[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi +$L002rc5_dec_8: + mov eax, DWORD PTR 72[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 68[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 64[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 60[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 56[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 52[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 48[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 44[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 40[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 36[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 32[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 28[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 24[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 20[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 16[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 12[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + sub esi, DWORD PTR 8[ebp] + sub edi, DWORD PTR 4[ebp] +L003rc5_exit: + mov DWORD PTR [edx],edi + mov DWORD PTR 4[edx],esi + pop ebx + pop edi + pop esi + pop ebp + ret +_RC5_32_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _RC5_32_cbc_encrypt + +_RC5_32_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L004decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L005encrypt_finish +L006encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L006encrypt_loop +$L005encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L007finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4] + jmp ebp +L009ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L010ej6: + mov dh, BYTE PTR 5[esi] +L011ej5: + mov dl, BYTE PTR 4[esi] +L012ej4: + mov ecx, DWORD PTR [esi] + jmp $L013ejend +L014ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L015ej2: + mov ch, BYTE PTR 1[esi] +L016ej1: + mov cl, BYTE PTR [esi] +$L013ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L007finish +$L004decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L017decrypt_finish +L018decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L018decrypt_loop +$L017decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L007finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L019dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L020dj6: + mov BYTE PTR 5[edi],dh +L021dj5: + mov BYTE PTR 4[edi],dl +L022dj4: + mov DWORD PTR [edi],ecx + jmp $L023djend +L024dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L025dj2: + mov BYTE PTR 1[esi],ch +L026dj1: + mov BYTE PTR [esi], cl +$L023djend: + jmp $L007finish +$L007finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L008cbc_enc_jmp_table: + DD 0 + DD L016ej1 + DD L015ej2 + DD L014ej3 + DD L012ej4 + DD L011ej5 + DD L010ej6 + DD L009ej7 +L027cbc_dec_jmp_table: + DD 0 + DD L026dj1 + DD L025dj2 + DD L024dj3 + DD L022dj4 + DD L021dj5 + DD L020dj6 + DD L019dj7 +_RC5_32_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/rc5/asm/r586unix.cpp b/src/lib/libcrypto/rc5/asm/r586unix.cpp new file mode 100644 index 0000000000..a25dd5a9a4 --- /dev/null +++ b/src/lib/libcrypto/rc5/asm/r586unix.cpp @@ -0,0 +1,628 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define RC5_32_encrypt _RC5_32_encrypt +#define RC5_32_decrypt _RC5_32_decrypt +#define RC5_32_cbc_encrypt _RC5_32_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rc5-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "rc5-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl RC5_32_encrypt + TYPE(RC5_32_encrypt,@function) +RC5_32_encrypt: + + pushl %ebp + pushl %esi + pushl %edi + movl 16(%esp), %edx + movl 20(%esp), %ebp + /* Load the 2 words */ + movl (%edx), %edi + movl 4(%edx), %esi + pushl %ebx + movl (%ebp), %ebx + addl 4(%ebp), %edi + addl 8(%ebp), %esi + xorl %esi, %edi + movl 12(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 16(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 20(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 24(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 28(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 32(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 36(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 40(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 44(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 48(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 52(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 56(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 60(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 64(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 68(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 72(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + cmpl $8, %ebx + je .L000rc5_exit + xorl %esi, %edi + movl 76(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 80(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 84(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 88(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 92(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 96(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 100(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 104(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + cmpl $12, %ebx + je .L000rc5_exit + xorl %esi, %edi + movl 108(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 112(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 116(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 120(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 124(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 128(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 132(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 136(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi +.L000rc5_exit: + movl %edi, (%edx) + movl %esi, 4(%edx) + popl %ebx + popl %edi + popl %esi + popl %ebp + ret +.RC5_32_encrypt_end: + SIZE(RC5_32_encrypt,.RC5_32_encrypt_end-RC5_32_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl RC5_32_decrypt + TYPE(RC5_32_decrypt,@function) +RC5_32_decrypt: + + pushl %ebp + pushl %esi + pushl %edi + movl 16(%esp), %edx + movl 20(%esp), %ebp + /* Load the 2 words */ + movl (%edx), %edi + movl 4(%edx), %esi + pushl %ebx + movl (%ebp), %ebx + cmpl $12, %ebx + je .L001rc5_dec_12 + cmpl $8, %ebx + je .L002rc5_dec_8 + movl 136(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 132(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 128(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 124(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 120(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 116(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 112(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 108(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi +.L001rc5_dec_12: + movl 104(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 100(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 96(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 92(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 88(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 84(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 80(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 76(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi +.L002rc5_dec_8: + movl 72(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 68(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 64(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 60(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 56(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 52(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 48(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 44(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 40(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 36(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 32(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 28(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 24(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 20(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 16(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 12(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + subl 8(%ebp), %esi + subl 4(%ebp), %edi +.L003rc5_exit: + movl %edi, (%edx) + movl %esi, 4(%edx) + popl %ebx + popl %edi + popl %esi + popl %ebp + ret +.RC5_32_decrypt_end: + SIZE(RC5_32_decrypt,.RC5_32_decrypt_end-RC5_32_decrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl RC5_32_cbc_encrypt + TYPE(RC5_32_cbc_encrypt,@function) +RC5_32_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L004decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L005encrypt_finish +.L006encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L006encrypt_loop +.L005encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L007finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L009ej7: + movb 6(%esi), %dh + sall $8, %edx +.L010ej6: + movb 5(%esi), %dh +.L011ej5: + movb 4(%esi), %dl +.L012ej4: + movl (%esi), %ecx + jmp .L013ejend +.L014ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L015ej2: + movb 1(%esi), %ch +.L016ej1: + movb (%esi), %cl +.L013ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L007finish +.align ALIGN +.L004decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L017decrypt_finish +.L018decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L018decrypt_loop +.L017decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L007finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L019dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L020dj6: + movb %dh, 5(%edi) +.L021dj5: + movb %dl, 4(%edi) +.L022dj4: + movl %ecx, (%edi) + jmp .L023djend +.L024dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L025dj2: + movb %ch, 1(%esi) +.L026dj1: + movb %cl, (%esi) +.L023djend: + jmp .L007finish +.align ALIGN +.L007finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L008cbc_enc_jmp_table: + .long 0 + .long .L016ej1 + .long .L015ej2 + .long .L014ej3 + .long .L012ej4 + .long .L011ej5 + .long .L010ej6 + .long .L009ej7 +.align ALIGN +.L027cbc_dec_jmp_table: + .long 0 + .long .L026dj1 + .long .L025dj2 + .long .L024dj3 + .long .L022dj4 + .long .L021dj5 + .long .L020dj6 + .long .L019dj7 +.RC5_32_cbc_encrypt_end: + SIZE(RC5_32_cbc_encrypt,.RC5_32_cbc_encrypt_end-RC5_32_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/rc5/asm/rc5-586.pl b/src/lib/libcrypto/rc5/asm/rc5-586.pl new file mode 100644 index 0000000000..172bd9ee1b --- /dev/null +++ b/src/lib/libcrypto/rc5/asm/rc5-586.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +push(@INC,"perlasm","../../perlasm"); +require "x86asm.pl"; +require "cbc.pl"; + +&asm_init($ARGV[0],"rc5-586.pl"); + +$RC5_MAX_ROUNDS=16; +$RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4; +$A="edi"; +$B="esi"; +$S="ebp"; +$tmp1="eax"; +$r="ebx"; +$tmpc="ecx"; +$tmp4="edx"; + +&RC5_32_encrypt("RC5_32_encrypt",1); +&RC5_32_encrypt("RC5_32_decrypt",0); +&cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1); +&asm_finish(); + +sub RC5_32_encrypt + { + local($name,$enc)=@_; + + &function_begin_B($name,""); + + &comment(""); + + &push("ebp"); + &push("esi"); + &push("edi"); + &mov($tmp4,&wparam(0)); + &mov($S,&wparam(1)); + + &comment("Load the 2 words"); + &mov($A,&DWP(0,$tmp4,"",0)); + &mov($B,&DWP(4,$tmp4,"",0)); + + &push($r); + &mov($r, &DWP(0,$S,"",0)); + + # encrypting part + + if ($enc) + { + &add($A, &DWP(4+0,$S,"",0)); + &add($B, &DWP(4+4,$S,"",0)); + + for ($i=0; $i<$RC5_MAX_ROUNDS; $i++) + { + &xor($A, $B); + &mov($tmp1, &DWP(12+$i*8,$S,"",0)); + &mov($tmpc, $B); + &rotl($A, &LB("ecx")); + &add($A, $tmp1); + + &xor($B, $A); + &mov($tmp1, &DWP(16+$i*8,$S,"",0)); + &mov($tmpc, $A); + &rotl($B, &LB("ecx")); + &add($B, $tmp1); + if (($i == 7) || ($i == 11)) + { + &cmp($r, $i+1); + &je(&label("rc5_exit")); + } + } + } + else + { + &cmp($r, 12); + &je(&label("rc5_dec_12")); + &cmp($r, 8); + &je(&label("rc5_dec_8")); + for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--) + { + &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8); + &mov($tmp1, &DWP($i*8+8,$S,"",0)); + &sub($B, $tmp1); + &mov($tmpc, $A); + &rotr($B, &LB("ecx")); + &xor($B, $A); + + &mov($tmp1, &DWP($i*8+4,$S,"",0)); + &sub($A, $tmp1); + &mov($tmpc, $B); + &rotr($A, &LB("ecx")); + &xor($A, $B); + } + &sub($B, &DWP(4+4,$S,"",0)); + &sub($A, &DWP(4+0,$S,"",0)); + } + + &set_label("rc5_exit"); + &mov(&DWP(0,$tmp4,"",0),$A); + &mov(&DWP(4,$tmp4,"",0),$B); + + &pop("ebx"); + &pop("edi"); + &pop("esi"); + &pop("ebp"); + &ret(); + &function_end_B($name); + } + + diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl new file mode 100644 index 0000000000..67d47ceb2c --- /dev/null +++ b/src/lib/libcrypto/ripemd/Makefile.ssl @@ -0,0 +1,104 @@ +# +# SSLeay/crypto/ripemd/Makefile +# + +DIR= ripemd +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +RIP_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rmdtest.c +APPS=rmd160.c + +LIB=$(TOP)/libcrypto.a +LIBSRC=rmd_dgst.c rmd_one.c +LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= ripemd.h +HEADER= rmd_locl.h rmdconst.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/rm86-elf.o: asm/rm86unix.cpp + $(CPP) -DELF asm/rm86unix.cpp | as -o asm/rm86-elf.o + +# solaris +asm/rm86-sol.o: asm/rm86unix.cpp + $(CC) -E -DSOL asm/rm86unix.cpp | sed 's/^#.*//' > asm/rm86-sol.s + as -o asm/rm86-sol.o asm/rm86-sol.s + rm -f asm/rm86-sol.s + +# a.out +asm/rm86-out.o: asm/rm86unix.cpp + $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o + +# bsdi +asm/rm86bsdi.o: asm/rm86unix.cpp + $(CPP) -DBSDI asm/rm86unix.cpp | as -o asm/rm86bsdi.o + +asm/rm86unix.cpp: + (cd asm; perl rmd-586.pl cpp >rm86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/ripemd/Makefile.uni b/src/lib/libcrypto/ripemd/Makefile.uni new file mode 100644 index 0000000000..54685712db --- /dev/null +++ b/src/lib/libcrypto/ripemd/Makefile.uni @@ -0,0 +1,109 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= md5 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +MD5_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md5test +APPS=md5 + +LIB=libmd5.a +LIBSRC=md5_dgst.c md5_one.c +LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= md5.h +HEADER= md5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/mx86-elf.o: asm/mx86unix.cpp + $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o + +# solaris +asm/mx86-sol.o: asm/mx86unix.cpp + $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s + as -o asm/mx86-sol.o asm/mx86-sol.s + rm -f asm/mx86-sol.s + +# a.out +asm/mx86-out.o: asm/mx86unix.cpp + $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o + +# bsdi +asm/mx86bsdi.o: asm/mx86unix.cpp + $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o + +asm/mx86unix.cpp: + (cd asm; perl md5-586.pl cpp >mx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-out: + $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-solaris: + $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-bdsi: + $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/ripemd/asm/rm-win32.asm b/src/lib/libcrypto/ripemd/asm/rm-win32.asm new file mode 100644 index 0000000000..bd38791c13 --- /dev/null +++ b/src/lib/libcrypto/ripemd/asm/rm-win32.asm @@ -0,0 +1,1972 @@ + ; Don't even think of reading this code + ; It was automatically generated by rmd-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE rmd-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _ripemd160_block_x86 + +_ripemd160_block_x86 PROC NEAR + push esi + mov ecx, DWORD PTR 16[esp] + push edi + mov esi, DWORD PTR 16[esp] + push ebp + add ecx, esi + push ebx + sub ecx, 64 + sub esp, 88 + mov DWORD PTR [esp],ecx + mov edi, DWORD PTR 108[esp] +L000start: + ; + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 4[esp],eax + mov DWORD PTR 8[esp],ebx + mov eax, DWORD PTR 8[esi] + mov ebx, DWORD PTR 12[esi] + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + mov eax, DWORD PTR 16[esi] + mov ebx, DWORD PTR 20[esi] + mov DWORD PTR 20[esp],eax + mov DWORD PTR 24[esp],ebx + mov eax, DWORD PTR 24[esi] + mov ebx, DWORD PTR 28[esi] + mov DWORD PTR 28[esp],eax + mov DWORD PTR 32[esp],ebx + mov eax, DWORD PTR 32[esi] + mov ebx, DWORD PTR 36[esi] + mov DWORD PTR 36[esp],eax + mov DWORD PTR 40[esp],ebx + mov eax, DWORD PTR 40[esi] + mov ebx, DWORD PTR 44[esi] + mov DWORD PTR 44[esp],eax + mov DWORD PTR 48[esp],ebx + mov eax, DWORD PTR 48[esi] + mov ebx, DWORD PTR 52[esi] + mov DWORD PTR 52[esp],eax + mov DWORD PTR 56[esp],ebx + mov eax, DWORD PTR 56[esi] + mov ebx, DWORD PTR 60[esi] + mov DWORD PTR 60[esp],eax + mov DWORD PTR 64[esp],ebx + add esi, 64 + mov eax, DWORD PTR [edi] + mov DWORD PTR 112[esp],esi + mov ebx, DWORD PTR 4[edi] + mov ecx, DWORD PTR 8[edi] + mov edx, DWORD PTR 12[edi] + mov ebp, DWORD PTR 16[edi] + ; 0 + mov esi, ecx + xor esi, edx + mov edi, DWORD PTR 4[esp] + xor esi, ebx + add eax, edi + rol ecx, 10 + add eax, esi + mov esi, ebx + rol eax, 11 + add eax, ebp + ; 1 + xor esi, ecx + mov edi, DWORD PTR 8[esp] + xor esi, eax + add ebp, esi + mov esi, eax + rol ebx, 10 + add ebp, edi + xor esi, ebx + rol ebp, 14 + add ebp, edx + ; 2 + mov edi, DWORD PTR 12[esp] + xor esi, ebp + add edx, edi + rol eax, 10 + add edx, esi + mov esi, ebp + rol edx, 15 + add edx, ecx + ; 3 + xor esi, eax + mov edi, DWORD PTR 16[esp] + xor esi, edx + add ecx, esi + mov esi, edx + rol ebp, 10 + add ecx, edi + xor esi, ebp + rol ecx, 12 + add ecx, ebx + ; 4 + mov edi, DWORD PTR 20[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 5 + add ebx, eax + ; 5 + xor esi, edx + mov edi, DWORD PTR 24[esp] + xor esi, ebx + add eax, esi + mov esi, ebx + rol ecx, 10 + add eax, edi + xor esi, ecx + rol eax, 8 + add eax, ebp + ; 6 + mov edi, DWORD PTR 28[esp] + xor esi, eax + add ebp, edi + rol ebx, 10 + add ebp, esi + mov esi, eax + rol ebp, 7 + add ebp, edx + ; 7 + xor esi, ebx + mov edi, DWORD PTR 32[esp] + xor esi, ebp + add edx, esi + mov esi, ebp + rol eax, 10 + add edx, edi + xor esi, eax + rol edx, 9 + add edx, ecx + ; 8 + mov edi, DWORD PTR 36[esp] + xor esi, edx + add ecx, edi + rol ebp, 10 + add ecx, esi + mov esi, edx + rol ecx, 11 + add ecx, ebx + ; 9 + xor esi, ebp + mov edi, DWORD PTR 40[esp] + xor esi, ecx + add ebx, esi + mov esi, ecx + rol edx, 10 + add ebx, edi + xor esi, edx + rol ebx, 13 + add ebx, eax + ; 10 + mov edi, DWORD PTR 44[esp] + xor esi, ebx + add eax, edi + rol ecx, 10 + add eax, esi + mov esi, ebx + rol eax, 14 + add eax, ebp + ; 11 + xor esi, ecx + mov edi, DWORD PTR 48[esp] + xor esi, eax + add ebp, esi + mov esi, eax + rol ebx, 10 + add ebp, edi + xor esi, ebx + rol ebp, 15 + add ebp, edx + ; 12 + mov edi, DWORD PTR 52[esp] + xor esi, ebp + add edx, edi + rol eax, 10 + add edx, esi + mov esi, ebp + rol edx, 6 + add edx, ecx + ; 13 + xor esi, eax + mov edi, DWORD PTR 56[esp] + xor esi, edx + add ecx, esi + mov esi, edx + rol ebp, 10 + add ecx, edi + xor esi, ebp + rol ecx, 7 + add ecx, ebx + ; 14 + mov edi, DWORD PTR 60[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 9 + add ebx, eax + ; 15 + xor esi, edx + mov edi, DWORD PTR 64[esp] + xor esi, ebx + add eax, esi + mov esi, -1 + rol ecx, 10 + add eax, edi + mov edi, DWORD PTR 32[esp] + rol eax, 8 + add eax, ebp + ; 16 + add ebp, edi + mov edi, ebx + sub esi, eax + and edi, eax + and esi, ecx + or edi, esi + mov esi, DWORD PTR 20[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, -1 + rol ebp, 7 + add ebp, edx + ; 17 + add edx, esi + mov esi, eax + sub edi, ebp + and esi, ebp + and edi, ebx + or esi, edi + mov edi, DWORD PTR 56[esp] + rol eax, 10 + lea edx, DWORD PTR 1518500249[esi*1+edx] + mov esi, -1 + rol edx, 6 + add edx, ecx + ; 18 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1518500249[edi*1+ecx] + mov edi, -1 + rol ecx, 8 + add ecx, ebx + ; 19 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 44[esp] + rol edx, 10 + lea ebx, DWORD PTR 1518500249[esi*1+ebx] + mov esi, -1 + rol ebx, 13 + add ebx, eax + ; 20 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 28[esp] + rol ecx, 10 + lea eax, DWORD PTR 1518500249[edi*1+eax] + mov edi, -1 + rol eax, 11 + add eax, ebp + ; 21 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, DWORD PTR 64[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + mov esi, -1 + rol ebp, 9 + add ebp, edx + ; 22 + add edx, edi + mov edi, eax + sub esi, ebp + and edi, ebp + and esi, ebx + or edi, esi + mov esi, DWORD PTR 16[esp] + rol eax, 10 + lea edx, DWORD PTR 1518500249[edi*1+edx] + mov edi, -1 + rol edx, 7 + add edx, ecx + ; 23 + add ecx, esi + mov esi, ebp + sub edi, edx + and esi, edx + and edi, eax + or esi, edi + mov edi, DWORD PTR 52[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1518500249[esi*1+ecx] + mov esi, -1 + rol ecx, 15 + add ecx, ebx + ; 24 + add ebx, edi + mov edi, edx + sub esi, ecx + and edi, ecx + and esi, ebp + or edi, esi + mov esi, DWORD PTR 4[esp] + rol edx, 10 + lea ebx, DWORD PTR 1518500249[edi*1+ebx] + mov edi, -1 + rol ebx, 7 + add ebx, eax + ; 25 + add eax, esi + mov esi, ecx + sub edi, ebx + and esi, ebx + and edi, edx + or esi, edi + mov edi, DWORD PTR 40[esp] + rol ecx, 10 + lea eax, DWORD PTR 1518500249[esi*1+eax] + mov esi, -1 + rol eax, 12 + add eax, ebp + ; 26 + add ebp, edi + mov edi, ebx + sub esi, eax + and edi, eax + and esi, ecx + or edi, esi + mov esi, DWORD PTR 24[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, -1 + rol ebp, 15 + add ebp, edx + ; 27 + add edx, esi + mov esi, eax + sub edi, ebp + and esi, ebp + and edi, ebx + or esi, edi + mov edi, DWORD PTR 12[esp] + rol eax, 10 + lea edx, DWORD PTR 1518500249[esi*1+edx] + mov esi, -1 + rol edx, 9 + add edx, ecx + ; 28 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 60[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1518500249[edi*1+ecx] + mov edi, -1 + rol ecx, 11 + add ecx, ebx + ; 29 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 48[esp] + rol edx, 10 + lea ebx, DWORD PTR 1518500249[esi*1+ebx] + mov esi, -1 + rol ebx, 7 + add ebx, eax + ; 30 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 36[esp] + rol ecx, 10 + lea eax, DWORD PTR 1518500249[edi*1+eax] + mov edi, -1 + rol eax, 13 + add eax, ebp + ; 31 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + sub edi, eax + rol ebp, 12 + add ebp, edx + ; 32 + mov esi, DWORD PTR 16[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[edi*1+edx] + sub esi, ebp + rol edx, 11 + add edx, ecx + ; 33 + mov edi, DWORD PTR 44[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1859775393[esi*1+ecx] + sub edi, edx + rol ecx, 13 + add ecx, ebx + ; 34 + mov esi, DWORD PTR 60[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1859775393[edi*1+ebx] + sub esi, ecx + rol ebx, 6 + add ebx, eax + ; 35 + mov edi, DWORD PTR 20[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1859775393[esi*1+eax] + sub edi, ebx + rol eax, 7 + add eax, ebp + ; 36 + mov esi, DWORD PTR 40[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1859775393[edi*1+ebp] + sub esi, eax + rol ebp, 14 + add ebp, edx + ; 37 + mov edi, DWORD PTR 64[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[esi*1+edx] + sub edi, ebp + rol edx, 9 + add edx, ecx + ; 38 + mov esi, DWORD PTR 36[esp] + or edi, edx + add ecx, esi + xor edi, eax + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1859775393[edi*1+ecx] + sub esi, edx + rol ecx, 13 + add ecx, ebx + ; 39 + mov edi, DWORD PTR 8[esp] + or esi, ecx + add ebx, edi + xor esi, ebp + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1859775393[esi*1+ebx] + sub edi, ecx + rol ebx, 15 + add ebx, eax + ; 40 + mov esi, DWORD PTR 12[esp] + or edi, ebx + add eax, esi + xor edi, edx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1859775393[edi*1+eax] + sub esi, ebx + rol eax, 14 + add eax, ebp + ; 41 + mov edi, DWORD PTR 32[esp] + or esi, eax + add ebp, edi + xor esi, ecx + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1859775393[esi*1+ebp] + sub edi, eax + rol ebp, 8 + add ebp, edx + ; 42 + mov esi, DWORD PTR 4[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[edi*1+edx] + sub esi, ebp + rol edx, 13 + add edx, ecx + ; 43 + mov edi, DWORD PTR 28[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1859775393[esi*1+ecx] + sub edi, edx + rol ecx, 6 + add ecx, ebx + ; 44 + mov esi, DWORD PTR 56[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1859775393[edi*1+ebx] + sub esi, ecx + rol ebx, 5 + add ebx, eax + ; 45 + mov edi, DWORD PTR 48[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1859775393[esi*1+eax] + sub edi, ebx + rol eax, 12 + add eax, ebp + ; 46 + mov esi, DWORD PTR 24[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1859775393[edi*1+ebp] + sub esi, eax + rol ebp, 7 + add ebp, edx + ; 47 + mov edi, DWORD PTR 52[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[esi*1+edx] + mov esi, eax + rol edx, 5 + add edx, ecx + ; 48 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 11 + add ecx, ebx + ; 49 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 40[esp] + rol edx, 10 + lea ebx, DWORD PTR 2400959708[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 12 + add ebx, eax + ; 50 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 48[esp] + rol ecx, 10 + lea eax, DWORD PTR 2400959708[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 14 + add eax, ebp + ; 51 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 44[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2400959708[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 15 + add ebp, edx + ; 52 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 4[esp] + rol eax, 10 + lea edx, DWORD PTR 2400959708[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 14 + add edx, ecx + ; 53 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 36[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 15 + add ecx, ebx + ; 54 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 52[esp] + rol edx, 10 + lea ebx, DWORD PTR 2400959708[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 9 + add ebx, eax + ; 55 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 20[esp] + rol ecx, 10 + lea eax, DWORD PTR 2400959708[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 8 + add eax, ebp + ; 56 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 56[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2400959708[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 9 + add ebp, edx + ; 57 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 16[esp] + rol eax, 10 + lea edx, DWORD PTR 2400959708[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 14 + add edx, ecx + ; 58 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 32[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 5 + add ecx, ebx + ; 59 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 64[esp] + rol edx, 10 + lea ebx, DWORD PTR 2400959708[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 6 + add ebx, eax + ; 60 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 60[esp] + rol ecx, 10 + lea eax, DWORD PTR 2400959708[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 8 + add eax, ebp + ; 61 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 24[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2400959708[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 6 + add ebp, edx + ; 62 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 28[esp] + rol eax, 10 + lea edx, DWORD PTR 2400959708[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 5 + add edx, ecx + ; 63 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 12[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + sub edi, ebp + rol ecx, 12 + add ecx, ebx + ; 64 + mov esi, DWORD PTR 20[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 2840853838[edi*1+ebx] + sub esi, edx + rol ebx, 9 + add ebx, eax + ; 65 + mov edi, DWORD PTR 4[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 2840853838[esi*1+eax] + sub edi, ecx + rol eax, 15 + add eax, ebp + ; 66 + mov esi, DWORD PTR 24[esp] + or edi, ebx + add ebp, esi + xor edi, eax + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 2840853838[edi*1+ebp] + sub esi, ebx + rol ebp, 5 + add ebp, edx + ; 67 + mov edi, DWORD PTR 40[esp] + or esi, eax + add edx, edi + xor esi, ebp + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 2840853838[esi*1+edx] + sub edi, eax + rol edx, 11 + add edx, ecx + ; 68 + mov esi, DWORD PTR 32[esp] + or edi, ebp + add ecx, esi + xor edi, edx + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 2840853838[edi*1+ecx] + sub esi, ebp + rol ecx, 6 + add ecx, ebx + ; 69 + mov edi, DWORD PTR 52[esp] + or esi, edx + add ebx, edi + xor esi, ecx + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 2840853838[esi*1+ebx] + sub edi, edx + rol ebx, 8 + add ebx, eax + ; 70 + mov esi, DWORD PTR 12[esp] + or edi, ecx + add eax, esi + xor edi, ebx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 2840853838[edi*1+eax] + sub esi, ecx + rol eax, 13 + add eax, ebp + ; 71 + mov edi, DWORD PTR 44[esp] + or esi, ebx + add ebp, edi + xor esi, eax + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 2840853838[esi*1+ebp] + sub edi, ebx + rol ebp, 12 + add ebp, edx + ; 72 + mov esi, DWORD PTR 60[esp] + or edi, eax + add edx, esi + xor edi, ebp + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 2840853838[edi*1+edx] + sub esi, eax + rol edx, 5 + add edx, ecx + ; 73 + mov edi, DWORD PTR 8[esp] + or esi, ebp + add ecx, edi + xor esi, edx + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 2840853838[esi*1+ecx] + sub edi, ebp + rol ecx, 12 + add ecx, ebx + ; 74 + mov esi, DWORD PTR 16[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 2840853838[edi*1+ebx] + sub esi, edx + rol ebx, 13 + add ebx, eax + ; 75 + mov edi, DWORD PTR 36[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 2840853838[esi*1+eax] + sub edi, ecx + rol eax, 14 + add eax, ebp + ; 76 + mov esi, DWORD PTR 48[esp] + or edi, ebx + add ebp, esi + xor edi, eax + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 2840853838[edi*1+ebp] + sub esi, ebx + rol ebp, 11 + add ebp, edx + ; 77 + mov edi, DWORD PTR 28[esp] + or esi, eax + add edx, edi + xor esi, ebp + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 2840853838[esi*1+edx] + sub edi, eax + rol edx, 8 + add edx, ecx + ; 78 + mov esi, DWORD PTR 64[esp] + or edi, ebp + add ecx, esi + xor edi, edx + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 2840853838[edi*1+ecx] + sub esi, ebp + rol ecx, 5 + add ecx, ebx + ; 79 + mov edi, DWORD PTR 56[esp] + or esi, edx + add ebx, edi + xor esi, ecx + mov edi, DWORD PTR 108[esp] + rol edx, 10 + lea ebx, DWORD PTR 2840853838[esi*1+ebx] + mov DWORD PTR 68[esp],eax + rol ebx, 6 + add ebx, eax + mov eax, DWORD PTR [edi] + mov DWORD PTR 72[esp],ebx + mov DWORD PTR 76[esp],ecx + mov ebx, DWORD PTR 4[edi] + mov DWORD PTR 80[esp],edx + mov ecx, DWORD PTR 8[edi] + mov DWORD PTR 84[esp],ebp + mov edx, DWORD PTR 12[edi] + mov ebp, DWORD PTR 16[edi] + ; 80 + mov edi, -1 + sub edi, edx + mov esi, DWORD PTR 24[esp] + or edi, ecx + add eax, esi + xor edi, ebx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[edi*1+eax] + sub esi, ecx + rol eax, 8 + add eax, ebp + ; 81 + mov edi, DWORD PTR 60[esp] + or esi, ebx + add ebp, edi + xor esi, eax + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1352829926[esi*1+ebp] + sub edi, ebx + rol ebp, 9 + add ebp, edx + ; 82 + mov esi, DWORD PTR 32[esp] + or edi, eax + add edx, esi + xor edi, ebp + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1352829926[edi*1+edx] + sub esi, eax + rol edx, 9 + add edx, ecx + ; 83 + mov edi, DWORD PTR 4[esp] + or esi, ebp + add ecx, edi + xor esi, edx + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1352829926[esi*1+ecx] + sub edi, ebp + rol ecx, 11 + add ecx, ebx + ; 84 + mov esi, DWORD PTR 40[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1352829926[edi*1+ebx] + sub esi, edx + rol ebx, 13 + add ebx, eax + ; 85 + mov edi, DWORD PTR 12[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[esi*1+eax] + sub edi, ecx + rol eax, 15 + add eax, ebp + ; 86 + mov esi, DWORD PTR 48[esp] + or edi, ebx + add ebp, esi + xor edi, eax + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1352829926[edi*1+ebp] + sub esi, ebx + rol ebp, 15 + add ebp, edx + ; 87 + mov edi, DWORD PTR 20[esp] + or esi, eax + add edx, edi + xor esi, ebp + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1352829926[esi*1+edx] + sub edi, eax + rol edx, 5 + add edx, ecx + ; 88 + mov esi, DWORD PTR 56[esp] + or edi, ebp + add ecx, esi + xor edi, edx + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1352829926[edi*1+ecx] + sub esi, ebp + rol ecx, 7 + add ecx, ebx + ; 89 + mov edi, DWORD PTR 28[esp] + or esi, edx + add ebx, edi + xor esi, ecx + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1352829926[esi*1+ebx] + sub edi, edx + rol ebx, 7 + add ebx, eax + ; 90 + mov esi, DWORD PTR 64[esp] + or edi, ecx + add eax, esi + xor edi, ebx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[edi*1+eax] + sub esi, ecx + rol eax, 8 + add eax, ebp + ; 91 + mov edi, DWORD PTR 36[esp] + or esi, ebx + add ebp, edi + xor esi, eax + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1352829926[esi*1+ebp] + sub edi, ebx + rol ebp, 11 + add ebp, edx + ; 92 + mov esi, DWORD PTR 8[esp] + or edi, eax + add edx, esi + xor edi, ebp + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1352829926[edi*1+edx] + sub esi, eax + rol edx, 14 + add edx, ecx + ; 93 + mov edi, DWORD PTR 44[esp] + or esi, ebp + add ecx, edi + xor esi, edx + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1352829926[esi*1+ecx] + sub edi, ebp + rol ecx, 14 + add ecx, ebx + ; 94 + mov esi, DWORD PTR 16[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1352829926[edi*1+ebx] + sub esi, edx + rol ebx, 12 + add ebx, eax + ; 95 + mov edi, DWORD PTR 52[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[esi*1+eax] + mov esi, ecx + rol eax, 6 + add eax, ebp + ; 96 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 28[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 9 + add ebp, edx + ; 97 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 48[esp] + rol eax, 10 + lea edx, DWORD PTR 1548603684[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 13 + add edx, ecx + ; 98 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 16[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1548603684[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 15 + add ecx, ebx + ; 99 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 32[esp] + rol edx, 10 + lea ebx, DWORD PTR 1548603684[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 7 + add ebx, eax + ; 100 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 4[esp] + rol ecx, 10 + lea eax, DWORD PTR 1548603684[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 12 + add eax, ebp + ; 101 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 56[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 8 + add ebp, edx + ; 102 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 24[esp] + rol eax, 10 + lea edx, DWORD PTR 1548603684[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 9 + add edx, ecx + ; 103 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 44[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1548603684[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 11 + add ecx, ebx + ; 104 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 60[esp] + rol edx, 10 + lea ebx, DWORD PTR 1548603684[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 7 + add ebx, eax + ; 105 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 64[esp] + rol ecx, 10 + lea eax, DWORD PTR 1548603684[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 7 + add eax, ebp + ; 106 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 36[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 12 + add ebp, edx + ; 107 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 52[esp] + rol eax, 10 + lea edx, DWORD PTR 1548603684[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 7 + add edx, ecx + ; 108 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 20[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1548603684[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 6 + add ecx, ebx + ; 109 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 40[esp] + rol edx, 10 + lea ebx, DWORD PTR 1548603684[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 15 + add ebx, eax + ; 110 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ecx, 10 + lea eax, DWORD PTR 1548603684[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 13 + add eax, ebp + ; 111 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 12[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + sub edi, eax + rol ebp, 11 + add ebp, edx + ; 112 + mov esi, DWORD PTR 64[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1836072691[edi*1+edx] + sub esi, ebp + rol edx, 9 + add edx, ecx + ; 113 + mov edi, DWORD PTR 24[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1836072691[esi*1+ecx] + sub edi, edx + rol ecx, 7 + add ecx, ebx + ; 114 + mov esi, DWORD PTR 8[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1836072691[edi*1+ebx] + sub esi, ecx + rol ebx, 15 + add ebx, eax + ; 115 + mov edi, DWORD PTR 16[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1836072691[esi*1+eax] + sub edi, ebx + rol eax, 11 + add eax, ebp + ; 116 + mov esi, DWORD PTR 32[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1836072691[edi*1+ebp] + sub esi, eax + rol ebp, 8 + add ebp, edx + ; 117 + mov edi, DWORD PTR 60[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1836072691[esi*1+edx] + sub edi, ebp + rol edx, 6 + add edx, ecx + ; 118 + mov esi, DWORD PTR 28[esp] + or edi, edx + add ecx, esi + xor edi, eax + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1836072691[edi*1+ecx] + sub esi, edx + rol ecx, 6 + add ecx, ebx + ; 119 + mov edi, DWORD PTR 40[esp] + or esi, ecx + add ebx, edi + xor esi, ebp + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1836072691[esi*1+ebx] + sub edi, ecx + rol ebx, 14 + add ebx, eax + ; 120 + mov esi, DWORD PTR 48[esp] + or edi, ebx + add eax, esi + xor edi, edx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1836072691[edi*1+eax] + sub esi, ebx + rol eax, 12 + add eax, ebp + ; 121 + mov edi, DWORD PTR 36[esp] + or esi, eax + add ebp, edi + xor esi, ecx + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1836072691[esi*1+ebp] + sub edi, eax + rol ebp, 13 + add ebp, edx + ; 122 + mov esi, DWORD PTR 52[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1836072691[edi*1+edx] + sub esi, ebp + rol edx, 5 + add edx, ecx + ; 123 + mov edi, DWORD PTR 12[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1836072691[esi*1+ecx] + sub edi, edx + rol ecx, 14 + add ecx, ebx + ; 124 + mov esi, DWORD PTR 44[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1836072691[edi*1+ebx] + sub esi, ecx + rol ebx, 13 + add ebx, eax + ; 125 + mov edi, DWORD PTR 4[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1836072691[esi*1+eax] + sub edi, ebx + rol eax, 13 + add eax, ebp + ; 126 + mov esi, DWORD PTR 20[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1836072691[edi*1+ebp] + sub esi, eax + rol ebp, 7 + add ebp, edx + ; 127 + mov edi, DWORD PTR 56[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, DWORD PTR 36[esp] + rol eax, 10 + lea edx, DWORD PTR 1836072691[esi*1+edx] + mov esi, -1 + rol edx, 5 + add edx, ecx + ; 128 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 28[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[edi*1+ecx] + mov edi, -1 + rol ecx, 15 + add ecx, ebx + ; 129 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 20[esp] + rol edx, 10 + lea ebx, DWORD PTR 2053994217[esi*1+ebx] + mov esi, -1 + rol ebx, 5 + add ebx, eax + ; 130 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ecx, 10 + lea eax, DWORD PTR 2053994217[edi*1+eax] + mov edi, -1 + rol eax, 8 + add eax, ebp + ; 131 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, DWORD PTR 16[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2053994217[esi*1+ebp] + mov esi, -1 + rol ebp, 11 + add ebp, edx + ; 132 + add edx, edi + mov edi, eax + sub esi, ebp + and edi, ebp + and esi, ebx + or edi, esi + mov esi, DWORD PTR 48[esp] + rol eax, 10 + lea edx, DWORD PTR 2053994217[edi*1+edx] + mov edi, -1 + rol edx, 14 + add edx, ecx + ; 133 + add ecx, esi + mov esi, ebp + sub edi, edx + and esi, edx + and edi, eax + or esi, edi + mov edi, DWORD PTR 64[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[esi*1+ecx] + mov esi, -1 + rol ecx, 14 + add ecx, ebx + ; 134 + add ebx, edi + mov edi, edx + sub esi, ecx + and edi, ecx + and esi, ebp + or edi, esi + mov esi, DWORD PTR 4[esp] + rol edx, 10 + lea ebx, DWORD PTR 2053994217[edi*1+ebx] + mov edi, -1 + rol ebx, 6 + add ebx, eax + ; 135 + add eax, esi + mov esi, ecx + sub edi, ebx + and esi, ebx + and edi, edx + or esi, edi + mov edi, DWORD PTR 24[esp] + rol ecx, 10 + lea eax, DWORD PTR 2053994217[esi*1+eax] + mov esi, -1 + rol eax, 14 + add eax, ebp + ; 136 + add ebp, edi + mov edi, ebx + sub esi, eax + and edi, eax + and esi, ecx + or edi, esi + mov esi, DWORD PTR 52[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2053994217[edi*1+ebp] + mov edi, -1 + rol ebp, 6 + add ebp, edx + ; 137 + add edx, esi + mov esi, eax + sub edi, ebp + and esi, ebp + and edi, ebx + or esi, edi + mov edi, DWORD PTR 12[esp] + rol eax, 10 + lea edx, DWORD PTR 2053994217[esi*1+edx] + mov esi, -1 + rol edx, 9 + add edx, ecx + ; 138 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 56[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[edi*1+ecx] + mov edi, -1 + rol ecx, 12 + add ecx, ebx + ; 139 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 40[esp] + rol edx, 10 + lea ebx, DWORD PTR 2053994217[esi*1+ebx] + mov esi, -1 + rol ebx, 9 + add ebx, eax + ; 140 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 32[esp] + rol ecx, 10 + lea eax, DWORD PTR 2053994217[edi*1+eax] + mov edi, -1 + rol eax, 12 + add eax, ebp + ; 141 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, DWORD PTR 44[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2053994217[esi*1+ebp] + mov esi, -1 + rol ebp, 5 + add ebp, edx + ; 142 + add edx, edi + mov edi, eax + sub esi, ebp + and edi, ebp + and esi, ebx + or edi, esi + mov esi, DWORD PTR 60[esp] + rol eax, 10 + lea edx, DWORD PTR 2053994217[edi*1+edx] + mov edi, -1 + rol edx, 15 + add edx, ecx + ; 143 + add ecx, esi + mov esi, ebp + sub edi, edx + and esi, edx + and edi, eax + or edi, esi + mov esi, edx + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[edi*1+ecx] + xor esi, ebp + rol ecx, 8 + add ecx, ebx + ; 144 + mov edi, DWORD PTR 52[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 8 + add ebx, eax + ; 145 + xor esi, edx + mov edi, DWORD PTR 64[esp] + xor esi, ebx + add eax, esi + mov esi, ebx + rol ecx, 10 + add eax, edi + xor esi, ecx + rol eax, 5 + add eax, ebp + ; 146 + mov edi, DWORD PTR 44[esp] + xor esi, eax + add ebp, edi + rol ebx, 10 + add ebp, esi + mov esi, eax + rol ebp, 12 + add ebp, edx + ; 147 + xor esi, ebx + mov edi, DWORD PTR 20[esp] + xor esi, ebp + add edx, esi + mov esi, ebp + rol eax, 10 + add edx, edi + xor esi, eax + rol edx, 9 + add edx, ecx + ; 148 + mov edi, DWORD PTR 8[esp] + xor esi, edx + add ecx, edi + rol ebp, 10 + add ecx, esi + mov esi, edx + rol ecx, 12 + add ecx, ebx + ; 149 + xor esi, ebp + mov edi, DWORD PTR 24[esp] + xor esi, ecx + add ebx, esi + mov esi, ecx + rol edx, 10 + add ebx, edi + xor esi, edx + rol ebx, 5 + add ebx, eax + ; 150 + mov edi, DWORD PTR 36[esp] + xor esi, ebx + add eax, edi + rol ecx, 10 + add eax, esi + mov esi, ebx + rol eax, 14 + add eax, ebp + ; 151 + xor esi, ecx + mov edi, DWORD PTR 32[esp] + xor esi, eax + add ebp, esi + mov esi, eax + rol ebx, 10 + add ebp, edi + xor esi, ebx + rol ebp, 6 + add ebp, edx + ; 152 + mov edi, DWORD PTR 28[esp] + xor esi, ebp + add edx, edi + rol eax, 10 + add edx, esi + mov esi, ebp + rol edx, 8 + add edx, ecx + ; 153 + xor esi, eax + mov edi, DWORD PTR 12[esp] + xor esi, edx + add ecx, esi + mov esi, edx + rol ebp, 10 + add ecx, edi + xor esi, ebp + rol ecx, 13 + add ecx, ebx + ; 154 + mov edi, DWORD PTR 56[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 6 + add ebx, eax + ; 155 + xor esi, edx + mov edi, DWORD PTR 60[esp] + xor esi, ebx + add eax, esi + mov esi, ebx + rol ecx, 10 + add eax, edi + xor esi, ecx + rol eax, 5 + add eax, ebp + ; 156 + mov edi, DWORD PTR 4[esp] + xor esi, eax + add ebp, edi + rol ebx, 10 + add ebp, esi + mov esi, eax + rol ebp, 15 + add ebp, edx + ; 157 + xor esi, ebx + mov edi, DWORD PTR 16[esp] + xor esi, ebp + add edx, esi + mov esi, ebp + rol eax, 10 + add edx, edi + xor esi, eax + rol edx, 13 + add edx, ecx + ; 158 + mov edi, DWORD PTR 40[esp] + xor esi, edx + add ecx, edi + rol ebp, 10 + add ecx, esi + mov esi, edx + rol ecx, 11 + add ecx, ebx + ; 159 + xor esi, ebp + mov edi, DWORD PTR 48[esp] + xor esi, ecx + add ebx, esi + rol edx, 10 + add ebx, edi + mov edi, DWORD PTR 108[esp] + rol ebx, 11 + add ebx, eax + mov esi, DWORD PTR 4[edi] + add edx, esi + mov esi, DWORD PTR 76[esp] + add edx, esi + mov esi, DWORD PTR 8[edi] + add ebp, esi + mov esi, DWORD PTR 80[esp] + add ebp, esi + mov esi, DWORD PTR 12[edi] + add eax, esi + mov esi, DWORD PTR 84[esp] + add eax, esi + mov esi, DWORD PTR 16[edi] + add ebx, esi + mov esi, DWORD PTR 68[esp] + add ebx, esi + mov esi, DWORD PTR [edi] + add ecx, esi + mov esi, DWORD PTR 72[esp] + add ecx, esi + mov DWORD PTR [edi],edx + mov DWORD PTR 4[edi],ebp + mov DWORD PTR 8[edi],eax + mov DWORD PTR 12[edi],ebx + mov DWORD PTR 16[edi],ecx + mov edi, DWORD PTR [esp] + mov esi, DWORD PTR 112[esp] + cmp edi, esi + mov edi, DWORD PTR 108[esp] + jge L000start + add esp, 88 + pop ebx + pop ebp + pop edi + pop esi + ret +_ripemd160_block_x86 ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/ripemd/asm/rm86unix.cpp b/src/lib/libcrypto/ripemd/asm/rm86unix.cpp new file mode 100644 index 0000000000..f90f6f2fd6 --- /dev/null +++ b/src/lib/libcrypto/ripemd/asm/rm86unix.cpp @@ -0,0 +1,2016 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define ripemd160_block_x86 _ripemd160_block_x86 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rmd-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "rmd-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl ripemd160_block_x86 + TYPE(ripemd160_block_x86,@function) +ripemd160_block_x86: + pushl %esi + movl 16(%esp), %ecx + pushl %edi + movl 16(%esp), %esi + pushl %ebp + addl %esi, %ecx + pushl %ebx + subl $64, %ecx + subl $88, %esp + movl %ecx, (%esp) + movl 108(%esp), %edi +.L000start: + + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 4(%esp) + movl %ebx, 8(%esp) + movl 8(%esi), %eax + movl 12(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + movl 16(%esi), %eax + movl 20(%esi), %ebx + movl %eax, 20(%esp) + movl %ebx, 24(%esp) + movl 24(%esi), %eax + movl 28(%esi), %ebx + movl %eax, 28(%esp) + movl %ebx, 32(%esp) + movl 32(%esi), %eax + movl 36(%esi), %ebx + movl %eax, 36(%esp) + movl %ebx, 40(%esp) + movl 40(%esi), %eax + movl 44(%esi), %ebx + movl %eax, 44(%esp) + movl %ebx, 48(%esp) + movl 48(%esi), %eax + movl 52(%esi), %ebx + movl %eax, 52(%esp) + movl %ebx, 56(%esp) + movl 56(%esi), %eax + movl 60(%esi), %ebx + movl %eax, 60(%esp) + movl %ebx, 64(%esp) + addl $64, %esi + movl (%edi), %eax + movl %esi, 112(%esp) + movl 4(%edi), %ebx + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl 16(%edi), %ebp + /* 0 */ + movl %ecx, %esi + xorl %edx, %esi + movl 4(%esp), %edi + xorl %ebx, %esi + addl %edi, %eax + roll $10, %ecx + addl %esi, %eax + movl %ebx, %esi + roll $11, %eax + addl %ebp, %eax + /* 1 */ + xorl %ecx, %esi + movl 8(%esp), %edi + xorl %eax, %esi + addl %esi, %ebp + movl %eax, %esi + roll $10, %ebx + addl %edi, %ebp + xorl %ebx, %esi + roll $14, %ebp + addl %edx, %ebp + /* 2 */ + movl 12(%esp), %edi + xorl %ebp, %esi + addl %edi, %edx + roll $10, %eax + addl %esi, %edx + movl %ebp, %esi + roll $15, %edx + addl %ecx, %edx + /* 3 */ + xorl %eax, %esi + movl 16(%esp), %edi + xorl %edx, %esi + addl %esi, %ecx + movl %edx, %esi + roll $10, %ebp + addl %edi, %ecx + xorl %ebp, %esi + roll $12, %ecx + addl %ebx, %ecx + /* 4 */ + movl 20(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $5, %ebx + addl %eax, %ebx + /* 5 */ + xorl %edx, %esi + movl 24(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl %ebx, %esi + roll $10, %ecx + addl %edi, %eax + xorl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 6 */ + movl 28(%esp), %edi + xorl %eax, %esi + addl %edi, %ebp + roll $10, %ebx + addl %esi, %ebp + movl %eax, %esi + roll $7, %ebp + addl %edx, %ebp + /* 7 */ + xorl %ebx, %esi + movl 32(%esp), %edi + xorl %ebp, %esi + addl %esi, %edx + movl %ebp, %esi + roll $10, %eax + addl %edi, %edx + xorl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 8 */ + movl 36(%esp), %edi + xorl %edx, %esi + addl %edi, %ecx + roll $10, %ebp + addl %esi, %ecx + movl %edx, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 9 */ + xorl %ebp, %esi + movl 40(%esp), %edi + xorl %ecx, %esi + addl %esi, %ebx + movl %ecx, %esi + roll $10, %edx + addl %edi, %ebx + xorl %edx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 10 */ + movl 44(%esp), %edi + xorl %ebx, %esi + addl %edi, %eax + roll $10, %ecx + addl %esi, %eax + movl %ebx, %esi + roll $14, %eax + addl %ebp, %eax + /* 11 */ + xorl %ecx, %esi + movl 48(%esp), %edi + xorl %eax, %esi + addl %esi, %ebp + movl %eax, %esi + roll $10, %ebx + addl %edi, %ebp + xorl %ebx, %esi + roll $15, %ebp + addl %edx, %ebp + /* 12 */ + movl 52(%esp), %edi + xorl %ebp, %esi + addl %edi, %edx + roll $10, %eax + addl %esi, %edx + movl %ebp, %esi + roll $6, %edx + addl %ecx, %edx + /* 13 */ + xorl %eax, %esi + movl 56(%esp), %edi + xorl %edx, %esi + addl %esi, %ecx + movl %edx, %esi + roll $10, %ebp + addl %edi, %ecx + xorl %ebp, %esi + roll $7, %ecx + addl %ebx, %ecx + /* 14 */ + movl 60(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $9, %ebx + addl %eax, %ebx + /* 15 */ + xorl %edx, %esi + movl 64(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl $-1, %esi + roll $10, %ecx + addl %edi, %eax + movl 32(%esp), %edi + roll $8, %eax + addl %ebp, %eax + /* 16 */ + addl %edi, %ebp + movl %ebx, %edi + subl %eax, %esi + andl %eax, %edi + andl %ecx, %esi + orl %esi, %edi + movl 20(%esp), %esi + roll $10, %ebx + leal 1518500249(%ebp,%edi,1),%ebp + movl $-1, %edi + roll $7, %ebp + addl %edx, %ebp + /* 17 */ + addl %esi, %edx + movl %eax, %esi + subl %ebp, %edi + andl %ebp, %esi + andl %ebx, %edi + orl %edi, %esi + movl 56(%esp), %edi + roll $10, %eax + leal 1518500249(%edx,%esi,1),%edx + movl $-1, %esi + roll $6, %edx + addl %ecx, %edx + /* 18 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ebp + leal 1518500249(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $8, %ecx + addl %ebx, %ecx + /* 19 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 44(%esp), %edi + roll $10, %edx + leal 1518500249(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $13, %ebx + addl %eax, %ebx + /* 20 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %ecx + leal 1518500249(%eax,%edi,1),%eax + movl $-1, %edi + roll $11, %eax + addl %ebp, %eax + /* 21 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl 64(%esp), %edi + roll $10, %ebx + leal 1518500249(%ebp,%esi,1),%ebp + movl $-1, %esi + roll $9, %ebp + addl %edx, %ebp + /* 22 */ + addl %edi, %edx + movl %eax, %edi + subl %ebp, %esi + andl %ebp, %edi + andl %ebx, %esi + orl %esi, %edi + movl 16(%esp), %esi + roll $10, %eax + leal 1518500249(%edx,%edi,1),%edx + movl $-1, %edi + roll $7, %edx + addl %ecx, %edx + /* 23 */ + addl %esi, %ecx + movl %ebp, %esi + subl %edx, %edi + andl %edx, %esi + andl %eax, %edi + orl %edi, %esi + movl 52(%esp), %edi + roll $10, %ebp + leal 1518500249(%ecx,%esi,1),%ecx + movl $-1, %esi + roll $15, %ecx + addl %ebx, %ecx + /* 24 */ + addl %edi, %ebx + movl %edx, %edi + subl %ecx, %esi + andl %ecx, %edi + andl %ebp, %esi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %edx + leal 1518500249(%ebx,%edi,1),%ebx + movl $-1, %edi + roll $7, %ebx + addl %eax, %ebx + /* 25 */ + addl %esi, %eax + movl %ecx, %esi + subl %ebx, %edi + andl %ebx, %esi + andl %edx, %edi + orl %edi, %esi + movl 40(%esp), %edi + roll $10, %ecx + leal 1518500249(%eax,%esi,1),%eax + movl $-1, %esi + roll $12, %eax + addl %ebp, %eax + /* 26 */ + addl %edi, %ebp + movl %ebx, %edi + subl %eax, %esi + andl %eax, %edi + andl %ecx, %esi + orl %esi, %edi + movl 24(%esp), %esi + roll $10, %ebx + leal 1518500249(%ebp,%edi,1),%ebp + movl $-1, %edi + roll $15, %ebp + addl %edx, %ebp + /* 27 */ + addl %esi, %edx + movl %eax, %esi + subl %ebp, %edi + andl %ebp, %esi + andl %ebx, %edi + orl %edi, %esi + movl 12(%esp), %edi + roll $10, %eax + leal 1518500249(%edx,%esi,1),%edx + movl $-1, %esi + roll $9, %edx + addl %ecx, %edx + /* 28 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %ebp + leal 1518500249(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $11, %ecx + addl %ebx, %ecx + /* 29 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 48(%esp), %edi + roll $10, %edx + leal 1518500249(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $7, %ebx + addl %eax, %ebx + /* 30 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 36(%esp), %esi + roll $10, %ecx + leal 1518500249(%eax,%edi,1),%eax + movl $-1, %edi + roll $13, %eax + addl %ebp, %eax + /* 31 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl $-1, %edi + roll $10, %ebx + leal 1518500249(%ebp,%esi,1),%ebp + subl %eax, %edi + roll $12, %ebp + addl %edx, %ebp + /* 32 */ + movl 16(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1859775393(%edx,%edi,1),%edx + subl %ebp, %esi + roll $11, %edx + addl %ecx, %edx + /* 33 */ + movl 44(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1859775393(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $13, %ecx + addl %ebx, %ecx + /* 34 */ + movl 60(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1859775393(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $6, %ebx + addl %eax, %ebx + /* 35 */ + movl 20(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1859775393(%eax,%esi,1),%eax + subl %ebx, %edi + roll $7, %eax + addl %ebp, %eax + /* 36 */ + movl 40(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1859775393(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $14, %ebp + addl %edx, %ebp + /* 37 */ + movl 64(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl $-1, %edi + roll $10, %eax + leal 1859775393(%edx,%esi,1),%edx + subl %ebp, %edi + roll $9, %edx + addl %ecx, %edx + /* 38 */ + movl 36(%esp), %esi + orl %edx, %edi + addl %esi, %ecx + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebp + leal 1859775393(%ecx,%edi,1),%ecx + subl %edx, %esi + roll $13, %ecx + addl %ebx, %ecx + /* 39 */ + movl 8(%esp), %edi + orl %ecx, %esi + addl %edi, %ebx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %edx + leal 1859775393(%ebx,%esi,1),%ebx + subl %ecx, %edi + roll $15, %ebx + addl %eax, %ebx + /* 40 */ + movl 12(%esp), %esi + orl %ebx, %edi + addl %esi, %eax + xorl %edx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1859775393(%eax,%edi,1),%eax + subl %ebx, %esi + roll $14, %eax + addl %ebp, %eax + /* 41 */ + movl 32(%esp), %edi + orl %eax, %esi + addl %edi, %ebp + xorl %ecx, %esi + movl $-1, %edi + roll $10, %ebx + leal 1859775393(%ebp,%esi,1),%ebp + subl %eax, %edi + roll $8, %ebp + addl %edx, %ebp + /* 42 */ + movl 4(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1859775393(%edx,%edi,1),%edx + subl %ebp, %esi + roll $13, %edx + addl %ecx, %edx + /* 43 */ + movl 28(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1859775393(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $6, %ecx + addl %ebx, %ecx + /* 44 */ + movl 56(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1859775393(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $5, %ebx + addl %eax, %ebx + /* 45 */ + movl 48(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1859775393(%eax,%esi,1),%eax + subl %ebx, %edi + roll $12, %eax + addl %ebp, %eax + /* 46 */ + movl 24(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1859775393(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $7, %ebp + addl %edx, %ebp + /* 47 */ + movl 52(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl $-1, %edi + roll $10, %eax + leal 1859775393(%edx,%esi,1),%edx + movl %eax, %esi + roll $5, %edx + addl %ecx, %edx + /* 48 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 49 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 40(%esp), %esi + roll $10, %edx + leal 2400959708(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $12, %ebx + addl %eax, %ebx + /* 50 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 48(%esp), %esi + roll $10, %ecx + leal 2400959708(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $14, %eax + addl %ebp, %eax + /* 51 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 44(%esp), %esi + roll $10, %ebx + leal 2400959708(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $15, %ebp + addl %edx, %ebp + /* 52 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %eax + leal 2400959708(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $14, %edx + addl %ecx, %edx + /* 53 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 36(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $15, %ecx + addl %ebx, %ecx + /* 54 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 52(%esp), %esi + roll $10, %edx + leal 2400959708(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $9, %ebx + addl %eax, %ebx + /* 55 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 20(%esp), %esi + roll $10, %ecx + leal 2400959708(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 56 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 56(%esp), %esi + roll $10, %ebx + leal 2400959708(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $9, %ebp + addl %edx, %ebp + /* 57 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 16(%esp), %esi + roll $10, %eax + leal 2400959708(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $14, %edx + addl %ecx, %edx + /* 58 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 32(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $5, %ecx + addl %ebx, %ecx + /* 59 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 64(%esp), %esi + roll $10, %edx + leal 2400959708(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $6, %ebx + addl %eax, %ebx + /* 60 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %ecx + leal 2400959708(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 61 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 24(%esp), %esi + roll $10, %ebx + leal 2400959708(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $6, %ebp + addl %edx, %ebp + /* 62 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %eax + leal 2400959708(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $5, %edx + addl %ecx, %edx + /* 63 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 12(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + subl %ebp, %edi + roll $12, %ecx + addl %ebx, %ecx + /* 64 */ + movl 20(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 2840853838(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $9, %ebx + addl %eax, %ebx + /* 65 */ + movl 4(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 2840853838(%eax,%esi,1),%eax + subl %ecx, %edi + roll $15, %eax + addl %ebp, %eax + /* 66 */ + movl 24(%esp), %esi + orl %ebx, %edi + addl %esi, %ebp + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebx + leal 2840853838(%ebp,%edi,1),%ebp + subl %ebx, %esi + roll $5, %ebp + addl %edx, %ebp + /* 67 */ + movl 40(%esp), %edi + orl %eax, %esi + addl %edi, %edx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %eax + leal 2840853838(%edx,%esi,1),%edx + subl %eax, %edi + roll $11, %edx + addl %ecx, %edx + /* 68 */ + movl 32(%esp), %esi + orl %ebp, %edi + addl %esi, %ecx + xorl %edx, %edi + movl $-1, %esi + roll $10, %ebp + leal 2840853838(%ecx,%edi,1),%ecx + subl %ebp, %esi + roll $6, %ecx + addl %ebx, %ecx + /* 69 */ + movl 52(%esp), %edi + orl %edx, %esi + addl %edi, %ebx + xorl %ecx, %esi + movl $-1, %edi + roll $10, %edx + leal 2840853838(%ebx,%esi,1),%ebx + subl %edx, %edi + roll $8, %ebx + addl %eax, %ebx + /* 70 */ + movl 12(%esp), %esi + orl %ecx, %edi + addl %esi, %eax + xorl %ebx, %edi + movl $-1, %esi + roll $10, %ecx + leal 2840853838(%eax,%edi,1),%eax + subl %ecx, %esi + roll $13, %eax + addl %ebp, %eax + /* 71 */ + movl 44(%esp), %edi + orl %ebx, %esi + addl %edi, %ebp + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebx + leal 2840853838(%ebp,%esi,1),%ebp + subl %ebx, %edi + roll $12, %ebp + addl %edx, %ebp + /* 72 */ + movl 60(%esp), %esi + orl %eax, %edi + addl %esi, %edx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %eax + leal 2840853838(%edx,%edi,1),%edx + subl %eax, %esi + roll $5, %edx + addl %ecx, %edx + /* 73 */ + movl 8(%esp), %edi + orl %ebp, %esi + addl %edi, %ecx + xorl %edx, %esi + movl $-1, %edi + roll $10, %ebp + leal 2840853838(%ecx,%esi,1),%ecx + subl %ebp, %edi + roll $12, %ecx + addl %ebx, %ecx + /* 74 */ + movl 16(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 2840853838(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 75 */ + movl 36(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 2840853838(%eax,%esi,1),%eax + subl %ecx, %edi + roll $14, %eax + addl %ebp, %eax + /* 76 */ + movl 48(%esp), %esi + orl %ebx, %edi + addl %esi, %ebp + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebx + leal 2840853838(%ebp,%edi,1),%ebp + subl %ebx, %esi + roll $11, %ebp + addl %edx, %ebp + /* 77 */ + movl 28(%esp), %edi + orl %eax, %esi + addl %edi, %edx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %eax + leal 2840853838(%edx,%esi,1),%edx + subl %eax, %edi + roll $8, %edx + addl %ecx, %edx + /* 78 */ + movl 64(%esp), %esi + orl %ebp, %edi + addl %esi, %ecx + xorl %edx, %edi + movl $-1, %esi + roll $10, %ebp + leal 2840853838(%ecx,%edi,1),%ecx + subl %ebp, %esi + roll $5, %ecx + addl %ebx, %ecx + /* 79 */ + movl 56(%esp), %edi + orl %edx, %esi + addl %edi, %ebx + xorl %ecx, %esi + movl 108(%esp), %edi + roll $10, %edx + leal 2840853838(%ebx,%esi,1),%ebx + movl %eax, 68(%esp) + roll $6, %ebx + addl %eax, %ebx + movl (%edi), %eax + movl %ebx, 72(%esp) + movl %ecx, 76(%esp) + movl 4(%edi), %ebx + movl %edx, 80(%esp) + movl 8(%edi), %ecx + movl %ebp, 84(%esp) + movl 12(%edi), %edx + movl 16(%edi), %ebp + /* 80 */ + movl $-1, %edi + subl %edx, %edi + movl 24(%esp), %esi + orl %ecx, %edi + addl %esi, %eax + xorl %ebx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1352829926(%eax,%edi,1),%eax + subl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 81 */ + movl 60(%esp), %edi + orl %ebx, %esi + addl %edi, %ebp + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebx + leal 1352829926(%ebp,%esi,1),%ebp + subl %ebx, %edi + roll $9, %ebp + addl %edx, %ebp + /* 82 */ + movl 32(%esp), %esi + orl %eax, %edi + addl %esi, %edx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %eax + leal 1352829926(%edx,%edi,1),%edx + subl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 83 */ + movl 4(%esp), %edi + orl %ebp, %esi + addl %edi, %ecx + xorl %edx, %esi + movl $-1, %edi + roll $10, %ebp + leal 1352829926(%ecx,%esi,1),%ecx + subl %ebp, %edi + roll $11, %ecx + addl %ebx, %ecx + /* 84 */ + movl 40(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 1352829926(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 85 */ + movl 12(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1352829926(%eax,%esi,1),%eax + subl %ecx, %edi + roll $15, %eax + addl %ebp, %eax + /* 86 */ + movl 48(%esp), %esi + orl %ebx, %edi + addl %esi, %ebp + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebx + leal 1352829926(%ebp,%edi,1),%ebp + subl %ebx, %esi + roll $15, %ebp + addl %edx, %ebp + /* 87 */ + movl 20(%esp), %edi + orl %eax, %esi + addl %edi, %edx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %eax + leal 1352829926(%edx,%esi,1),%edx + subl %eax, %edi + roll $5, %edx + addl %ecx, %edx + /* 88 */ + movl 56(%esp), %esi + orl %ebp, %edi + addl %esi, %ecx + xorl %edx, %edi + movl $-1, %esi + roll $10, %ebp + leal 1352829926(%ecx,%edi,1),%ecx + subl %ebp, %esi + roll $7, %ecx + addl %ebx, %ecx + /* 89 */ + movl 28(%esp), %edi + orl %edx, %esi + addl %edi, %ebx + xorl %ecx, %esi + movl $-1, %edi + roll $10, %edx + leal 1352829926(%ebx,%esi,1),%ebx + subl %edx, %edi + roll $7, %ebx + addl %eax, %ebx + /* 90 */ + movl 64(%esp), %esi + orl %ecx, %edi + addl %esi, %eax + xorl %ebx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1352829926(%eax,%edi,1),%eax + subl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 91 */ + movl 36(%esp), %edi + orl %ebx, %esi + addl %edi, %ebp + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebx + leal 1352829926(%ebp,%esi,1),%ebp + subl %ebx, %edi + roll $11, %ebp + addl %edx, %ebp + /* 92 */ + movl 8(%esp), %esi + orl %eax, %edi + addl %esi, %edx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %eax + leal 1352829926(%edx,%edi,1),%edx + subl %eax, %esi + roll $14, %edx + addl %ecx, %edx + /* 93 */ + movl 44(%esp), %edi + orl %ebp, %esi + addl %edi, %ecx + xorl %edx, %esi + movl $-1, %edi + roll $10, %ebp + leal 1352829926(%ecx,%esi,1),%ecx + subl %ebp, %edi + roll $14, %ecx + addl %ebx, %ecx + /* 94 */ + movl 16(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 1352829926(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $12, %ebx + addl %eax, %ebx + /* 95 */ + movl 52(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1352829926(%eax,%esi,1),%eax + movl %ecx, %esi + roll $6, %eax + addl %ebp, %eax + /* 96 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $9, %ebp + addl %edx, %ebp + /* 97 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 48(%esp), %esi + roll $10, %eax + leal 1548603684(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $13, %edx + addl %ecx, %edx + /* 98 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 16(%esp), %esi + roll $10, %ebp + leal 1548603684(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $15, %ecx + addl %ebx, %ecx + /* 99 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 32(%esp), %esi + roll $10, %edx + leal 1548603684(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $7, %ebx + addl %eax, %ebx + /* 100 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %ecx + leal 1548603684(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $12, %eax + addl %ebp, %eax + /* 101 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 56(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $8, %ebp + addl %edx, %ebp + /* 102 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 24(%esp), %esi + roll $10, %eax + leal 1548603684(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 103 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 44(%esp), %esi + roll $10, %ebp + leal 1548603684(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 104 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %edx + leal 1548603684(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $7, %ebx + addl %eax, %ebx + /* 105 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 64(%esp), %esi + roll $10, %ecx + leal 1548603684(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $7, %eax + addl %ebp, %eax + /* 106 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 36(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $12, %ebp + addl %edx, %ebp + /* 107 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 52(%esp), %esi + roll $10, %eax + leal 1548603684(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $7, %edx + addl %ecx, %edx + /* 108 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 20(%esp), %esi + roll $10, %ebp + leal 1548603684(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $6, %ecx + addl %ebx, %ecx + /* 109 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 40(%esp), %esi + roll $10, %edx + leal 1548603684(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $15, %ebx + addl %eax, %ebx + /* 110 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ecx + leal 1548603684(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $13, %eax + addl %ebp, %eax + /* 111 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 12(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + subl %eax, %edi + roll $11, %ebp + addl %edx, %ebp + /* 112 */ + movl 64(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1836072691(%edx,%edi,1),%edx + subl %ebp, %esi + roll $9, %edx + addl %ecx, %edx + /* 113 */ + movl 24(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1836072691(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $7, %ecx + addl %ebx, %ecx + /* 114 */ + movl 8(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1836072691(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $15, %ebx + addl %eax, %ebx + /* 115 */ + movl 16(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1836072691(%eax,%esi,1),%eax + subl %ebx, %edi + roll $11, %eax + addl %ebp, %eax + /* 116 */ + movl 32(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1836072691(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $8, %ebp + addl %edx, %ebp + /* 117 */ + movl 60(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl $-1, %edi + roll $10, %eax + leal 1836072691(%edx,%esi,1),%edx + subl %ebp, %edi + roll $6, %edx + addl %ecx, %edx + /* 118 */ + movl 28(%esp), %esi + orl %edx, %edi + addl %esi, %ecx + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebp + leal 1836072691(%ecx,%edi,1),%ecx + subl %edx, %esi + roll $6, %ecx + addl %ebx, %ecx + /* 119 */ + movl 40(%esp), %edi + orl %ecx, %esi + addl %edi, %ebx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %edx + leal 1836072691(%ebx,%esi,1),%ebx + subl %ecx, %edi + roll $14, %ebx + addl %eax, %ebx + /* 120 */ + movl 48(%esp), %esi + orl %ebx, %edi + addl %esi, %eax + xorl %edx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1836072691(%eax,%edi,1),%eax + subl %ebx, %esi + roll $12, %eax + addl %ebp, %eax + /* 121 */ + movl 36(%esp), %edi + orl %eax, %esi + addl %edi, %ebp + xorl %ecx, %esi + movl $-1, %edi + roll $10, %ebx + leal 1836072691(%ebp,%esi,1),%ebp + subl %eax, %edi + roll $13, %ebp + addl %edx, %ebp + /* 122 */ + movl 52(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1836072691(%edx,%edi,1),%edx + subl %ebp, %esi + roll $5, %edx + addl %ecx, %edx + /* 123 */ + movl 12(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1836072691(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $14, %ecx + addl %ebx, %ecx + /* 124 */ + movl 44(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1836072691(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 125 */ + movl 4(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1836072691(%eax,%esi,1),%eax + subl %ebx, %edi + roll $13, %eax + addl %ebp, %eax + /* 126 */ + movl 20(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1836072691(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $7, %ebp + addl %edx, %ebp + /* 127 */ + movl 56(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl 36(%esp), %edi + roll $10, %eax + leal 1836072691(%edx,%esi,1),%edx + movl $-1, %esi + roll $5, %edx + addl %ecx, %edx + /* 128 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %ebp + leal 2053994217(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $15, %ecx + addl %ebx, %ecx + /* 129 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 20(%esp), %edi + roll $10, %edx + leal 2053994217(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $5, %ebx + addl %eax, %ebx + /* 130 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ecx + leal 2053994217(%eax,%edi,1),%eax + movl $-1, %edi + roll $8, %eax + addl %ebp, %eax + /* 131 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl 16(%esp), %edi + roll $10, %ebx + leal 2053994217(%ebp,%esi,1),%ebp + movl $-1, %esi + roll $11, %ebp + addl %edx, %ebp + /* 132 */ + addl %edi, %edx + movl %eax, %edi + subl %ebp, %esi + andl %ebp, %edi + andl %ebx, %esi + orl %esi, %edi + movl 48(%esp), %esi + roll $10, %eax + leal 2053994217(%edx,%edi,1),%edx + movl $-1, %edi + roll $14, %edx + addl %ecx, %edx + /* 133 */ + addl %esi, %ecx + movl %ebp, %esi + subl %edx, %edi + andl %edx, %esi + andl %eax, %edi + orl %edi, %esi + movl 64(%esp), %edi + roll $10, %ebp + leal 2053994217(%ecx,%esi,1),%ecx + movl $-1, %esi + roll $14, %ecx + addl %ebx, %ecx + /* 134 */ + addl %edi, %ebx + movl %edx, %edi + subl %ecx, %esi + andl %ecx, %edi + andl %ebp, %esi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %edx + leal 2053994217(%ebx,%edi,1),%ebx + movl $-1, %edi + roll $6, %ebx + addl %eax, %ebx + /* 135 */ + addl %esi, %eax + movl %ecx, %esi + subl %ebx, %edi + andl %ebx, %esi + andl %edx, %edi + orl %edi, %esi + movl 24(%esp), %edi + roll $10, %ecx + leal 2053994217(%eax,%esi,1),%eax + movl $-1, %esi + roll $14, %eax + addl %ebp, %eax + /* 136 */ + addl %edi, %ebp + movl %ebx, %edi + subl %eax, %esi + andl %eax, %edi + andl %ecx, %esi + orl %esi, %edi + movl 52(%esp), %esi + roll $10, %ebx + leal 2053994217(%ebp,%edi,1),%ebp + movl $-1, %edi + roll $6, %ebp + addl %edx, %ebp + /* 137 */ + addl %esi, %edx + movl %eax, %esi + subl %ebp, %edi + andl %ebp, %esi + andl %ebx, %edi + orl %edi, %esi + movl 12(%esp), %edi + roll $10, %eax + leal 2053994217(%edx,%esi,1),%edx + movl $-1, %esi + roll $9, %edx + addl %ecx, %edx + /* 138 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 56(%esp), %esi + roll $10, %ebp + leal 2053994217(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $12, %ecx + addl %ebx, %ecx + /* 139 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 40(%esp), %edi + roll $10, %edx + leal 2053994217(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $9, %ebx + addl %eax, %ebx + /* 140 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 32(%esp), %esi + roll $10, %ecx + leal 2053994217(%eax,%edi,1),%eax + movl $-1, %edi + roll $12, %eax + addl %ebp, %eax + /* 141 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl 44(%esp), %edi + roll $10, %ebx + leal 2053994217(%ebp,%esi,1),%ebp + movl $-1, %esi + roll $5, %ebp + addl %edx, %ebp + /* 142 */ + addl %edi, %edx + movl %eax, %edi + subl %ebp, %esi + andl %ebp, %edi + andl %ebx, %esi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %eax + leal 2053994217(%edx,%edi,1),%edx + movl $-1, %edi + roll $15, %edx + addl %ecx, %edx + /* 143 */ + addl %esi, %ecx + movl %ebp, %esi + subl %edx, %edi + andl %edx, %esi + andl %eax, %edi + orl %esi, %edi + movl %edx, %esi + roll $10, %ebp + leal 2053994217(%ecx,%edi,1),%ecx + xorl %ebp, %esi + roll $8, %ecx + addl %ebx, %ecx + /* 144 */ + movl 52(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $8, %ebx + addl %eax, %ebx + /* 145 */ + xorl %edx, %esi + movl 64(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl %ebx, %esi + roll $10, %ecx + addl %edi, %eax + xorl %ecx, %esi + roll $5, %eax + addl %ebp, %eax + /* 146 */ + movl 44(%esp), %edi + xorl %eax, %esi + addl %edi, %ebp + roll $10, %ebx + addl %esi, %ebp + movl %eax, %esi + roll $12, %ebp + addl %edx, %ebp + /* 147 */ + xorl %ebx, %esi + movl 20(%esp), %edi + xorl %ebp, %esi + addl %esi, %edx + movl %ebp, %esi + roll $10, %eax + addl %edi, %edx + xorl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 148 */ + movl 8(%esp), %edi + xorl %edx, %esi + addl %edi, %ecx + roll $10, %ebp + addl %esi, %ecx + movl %edx, %esi + roll $12, %ecx + addl %ebx, %ecx + /* 149 */ + xorl %ebp, %esi + movl 24(%esp), %edi + xorl %ecx, %esi + addl %esi, %ebx + movl %ecx, %esi + roll $10, %edx + addl %edi, %ebx + xorl %edx, %esi + roll $5, %ebx + addl %eax, %ebx + /* 150 */ + movl 36(%esp), %edi + xorl %ebx, %esi + addl %edi, %eax + roll $10, %ecx + addl %esi, %eax + movl %ebx, %esi + roll $14, %eax + addl %ebp, %eax + /* 151 */ + xorl %ecx, %esi + movl 32(%esp), %edi + xorl %eax, %esi + addl %esi, %ebp + movl %eax, %esi + roll $10, %ebx + addl %edi, %ebp + xorl %ebx, %esi + roll $6, %ebp + addl %edx, %ebp + /* 152 */ + movl 28(%esp), %edi + xorl %ebp, %esi + addl %edi, %edx + roll $10, %eax + addl %esi, %edx + movl %ebp, %esi + roll $8, %edx + addl %ecx, %edx + /* 153 */ + xorl %eax, %esi + movl 12(%esp), %edi + xorl %edx, %esi + addl %esi, %ecx + movl %edx, %esi + roll $10, %ebp + addl %edi, %ecx + xorl %ebp, %esi + roll $13, %ecx + addl %ebx, %ecx + /* 154 */ + movl 56(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $6, %ebx + addl %eax, %ebx + /* 155 */ + xorl %edx, %esi + movl 60(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl %ebx, %esi + roll $10, %ecx + addl %edi, %eax + xorl %ecx, %esi + roll $5, %eax + addl %ebp, %eax + /* 156 */ + movl 4(%esp), %edi + xorl %eax, %esi + addl %edi, %ebp + roll $10, %ebx + addl %esi, %ebp + movl %eax, %esi + roll $15, %ebp + addl %edx, %ebp + /* 157 */ + xorl %ebx, %esi + movl 16(%esp), %edi + xorl %ebp, %esi + addl %esi, %edx + movl %ebp, %esi + roll $10, %eax + addl %edi, %edx + xorl %eax, %esi + roll $13, %edx + addl %ecx, %edx + /* 158 */ + movl 40(%esp), %edi + xorl %edx, %esi + addl %edi, %ecx + roll $10, %ebp + addl %esi, %ecx + movl %edx, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 159 */ + xorl %ebp, %esi + movl 48(%esp), %edi + xorl %ecx, %esi + addl %esi, %ebx + roll $10, %edx + addl %edi, %ebx + movl 108(%esp), %edi + roll $11, %ebx + addl %eax, %ebx + movl 4(%edi), %esi + addl %esi, %edx + movl 76(%esp), %esi + addl %esi, %edx + movl 8(%edi), %esi + addl %esi, %ebp + movl 80(%esp), %esi + addl %esi, %ebp + movl 12(%edi), %esi + addl %esi, %eax + movl 84(%esp), %esi + addl %esi, %eax + movl 16(%edi), %esi + addl %esi, %ebx + movl 68(%esp), %esi + addl %esi, %ebx + movl (%edi), %esi + addl %esi, %ecx + movl 72(%esp), %esi + addl %esi, %ecx + movl %edx, (%edi) + movl %ebp, 4(%edi) + movl %eax, 8(%edi) + movl %ebx, 12(%edi) + movl %ecx, 16(%edi) + movl (%esp), %edi + movl 112(%esp), %esi + cmpl %esi, %edi + movl 108(%esp), %edi + jge .L000start + addl $88, %esp + popl %ebx + popl %ebp + popl %edi + popl %esi + ret +.ripemd160_block_x86_end: + SIZE(ripemd160_block_x86,.ripemd160_block_x86_end-ripemd160_block_x86) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl new file mode 100644 index 0000000000..d52f2e609e --- /dev/null +++ b/src/lib/libcrypto/rsa/Makefile.ssl @@ -0,0 +1,86 @@ +# +# SSLeay/crypto/rsa/Makefile +# + +DIR= rsa +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=rsa +ERRC=rsa_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c $(ERRC).c \ + rsa_pk1.c rsa_ssl.c rsa_none.c +LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o $(ERRC).o \ + rsa_pk1.o rsa_ssl.o rsa_none.o + +SRC= $(LIBSRC) + +EXHEADER= rsa.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/rsa/rsa.err b/src/lib/libcrypto/rsa/rsa.err new file mode 100644 index 0000000000..5ded1b5fa2 --- /dev/null +++ b/src/lib/libcrypto/rsa/rsa.err @@ -0,0 +1,45 @@ +/* Error codes for the RSA functions. */ + +/* Function codes. */ +#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 100 +#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 101 +#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 102 +#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 103 +#define RSA_F_RSA_GENERATE_KEY 104 +#define RSA_F_RSA_NEW_METHOD 105 +#define RSA_F_RSA_PADDING_ADD_NONE 106 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 108 +#define RSA_F_RSA_PADDING_ADD_SSLV23 109 +#define RSA_F_RSA_PADDING_CHECK_NONE 110 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 112 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 113 +#define RSA_F_RSA_PRINT 114 +#define RSA_F_RSA_PRINT_FP 115 +#define RSA_F_RSA_SIGN 116 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 117 +#define RSA_F_RSA_VERIFY 118 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 119 + +/* Reason codes. */ +#define RSA_R_ALGORITHM_MISMATCH 100 +#define RSA_R_BAD_E_VALUE 101 +#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +#define RSA_R_BAD_PAD_BYTE_COUNT 103 +#define RSA_R_BAD_SIGNATURE 104 +#define RSA_R_BAD_ZERO_BYTE 105 +#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +#define RSA_R_DATA_TOO_LARGE 109 +#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +#define RSA_R_DATA_TOO_SMALL 111 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +#define RSA_R_UNKNOWN_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl new file mode 100644 index 0000000000..eeb545d140 --- /dev/null +++ b/src/lib/libcrypto/sha/Makefile.ssl @@ -0,0 +1,103 @@ +# +# SSLeay/crypto/sha/Makefile +# + +DIR= sha +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +SHA1_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=shatest.c sha1test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA1_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= sha.h +HEADER= sha_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/sx86-elf.o: asm/sx86unix.cpp + $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o + +# solaris +asm/sx86-sol.o: asm/sx86unix.cpp + $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s + as -o asm/sx86-sol.o asm/sx86-sol.s + rm -f asm/sx86-sol.s + +# a.out +asm/sx86-out.o: asm/sx86unix.cpp + $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o + +# bsdi +asm/sx86bsdi.o: asm/sx86unix.cpp + $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o + +asm/sx86unix.cpp: + (cd asm; perl sha1-586.pl cpp >sx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/sha/Makefile.uni b/src/lib/libcrypto/sha/Makefile.uni new file mode 100644 index 0000000000..f3236755b2 --- /dev/null +++ b/src/lib/libcrypto/sha/Makefile.uni @@ -0,0 +1,122 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= sha +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +SHA_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile + +TEST1=shatest +TEST2=sha1test +APP1=sha +APP2=sha1 + +TEST=$(TEST1) $(TEST2) +APPS=$(APP1) $(APP2) + +LIB=libsha.a +LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= sha.h +HEADER= sha_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/sx86-elf.o: asm/sx86unix.cpp + $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o + +# solaris +asm/sx86-sol.o: asm/sx86unix.cpp + $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s + as -o asm/sx86-sol.o asm/sx86-sol.s + rm -f asm/sx86-sol.s + +# a.out +asm/sx86-out.o: asm/sx86unix.cpp + $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o + +# bsdi +asm/sx86bsdi.o: asm/sx86unix.cpp + $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o + +asm/sx86unix.cpp: + (cd asm; perl sha1-586.pl cpp >sx86unix.cpp) + +test: $(TEST) + ./$(TEST1) + ./$(TEST2) + +$(TEST1): $(TEST1).c $(LIB) + $(CC) -o $(TEST1) $(CFLAGS) $(TEST1).c $(LIB) + +$(TEST2): $(TEST2).c $(LIB) + $(CC) -o $(TEST2) $(CFLAGS) $(TEST2).c $(LIB) + +$(APP1): $(APP1).c $(LIB) + $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB) + +$(APP2): $(APP2).c $(LIB) + $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) SHA_ASM_OBJ="" CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) SHA_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) SHA_ASM_OBJ="asm/sx86-elf.o" CFLAG="-DELF -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-out: + $(MAKE) SHA_ASM_OBJ="asm/sx86-out.o" CFLAG="-DOUT -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-solaris: + $(MAKE) SHA_ASM_OBJ="asm/sx86-sol.o" CFLAG="-DSOL -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-bdsi: + $(MAKE) SHA_ASM_OBJ="asm/sx86-bdsi.o" CFLAG="-DBDSI -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/sha/asm/s1-win32.asm b/src/lib/libcrypto/sha/asm/s1-win32.asm new file mode 100644 index 0000000000..61335666b9 --- /dev/null +++ b/src/lib/libcrypto/sha/asm/s1-win32.asm @@ -0,0 +1,1664 @@ + ; Don't even think of reading this code + ; It was automatically generated by sha1-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE sha1-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _sha1_block_x86 + +_sha1_block_x86 PROC NEAR + push esi + push ebp + mov eax, DWORD PTR 20[esp] + mov esi, DWORD PTR 16[esp] + add eax, esi + mov ebp, DWORD PTR 12[esp] + push ebx + sub eax, 64 + push edi + mov ebx, DWORD PTR 4[ebp] + sub esp, 72 + mov edx, DWORD PTR 12[ebp] + mov edi, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 8[ebp] + mov DWORD PTR 68[esp],eax + ; First we need to setup the X array + mov eax, DWORD PTR [esi] +L000start: + ; First, load the words onto the stack in network byte order + bswap eax + mov DWORD PTR [esp],eax + mov eax, DWORD PTR 4[esi] + bswap eax + mov DWORD PTR 4[esp],eax + mov eax, DWORD PTR 8[esi] + bswap eax + mov DWORD PTR 8[esp],eax + mov eax, DWORD PTR 12[esi] + bswap eax + mov DWORD PTR 12[esp],eax + mov eax, DWORD PTR 16[esi] + bswap eax + mov DWORD PTR 16[esp],eax + mov eax, DWORD PTR 20[esi] + bswap eax + mov DWORD PTR 20[esp],eax + mov eax, DWORD PTR 24[esi] + bswap eax + mov DWORD PTR 24[esp],eax + mov eax, DWORD PTR 28[esi] + bswap eax + mov DWORD PTR 28[esp],eax + mov eax, DWORD PTR 32[esi] + bswap eax + mov DWORD PTR 32[esp],eax + mov eax, DWORD PTR 36[esi] + bswap eax + mov DWORD PTR 36[esp],eax + mov eax, DWORD PTR 40[esi] + bswap eax + mov DWORD PTR 40[esp],eax + mov eax, DWORD PTR 44[esi] + bswap eax + mov DWORD PTR 44[esp],eax + mov eax, DWORD PTR 48[esi] + bswap eax + mov DWORD PTR 48[esp],eax + mov eax, DWORD PTR 52[esi] + bswap eax + mov DWORD PTR 52[esp],eax + mov eax, DWORD PTR 56[esi] + bswap eax + mov DWORD PTR 56[esp],eax + mov eax, DWORD PTR 60[esi] + bswap eax + mov DWORD PTR 60[esp],eax + ; We now have the X array on the stack + ; starting at sp-4 + mov DWORD PTR 64[esp],esi + ; + ; Start processing + mov eax, DWORD PTR [ebp] + ; 00_15 0 + mov esi, ecx + mov ebp, eax + xor esi, edx + rol ebp, 5 + and esi, ebx + add ebp, edi + ror ebx, 1 + mov edi, DWORD PTR [esp] + ror ebx, 1 + xor esi, edx + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, ebx + add esi, ebp + xor edi, ecx + mov ebp, esi + and edi, eax + rol ebp, 5 + add ebp, edx + mov edx, DWORD PTR 4[esp] + ror eax, 1 + xor edi, ecx + ror eax, 1 + lea ebp, DWORD PTR 1518500249[edx*1+ebp] + add edi, ebp + ; 00_15 2 + mov edx, eax + mov ebp, edi + xor edx, ebx + rol ebp, 5 + and edx, esi + add ebp, ecx + ror esi, 1 + mov ecx, DWORD PTR 8[esp] + ror esi, 1 + xor edx, ebx + lea ebp, DWORD PTR 1518500249[ecx*1+ebp] + mov ecx, esi + add edx, ebp + xor ecx, eax + mov ebp, edx + and ecx, edi + rol ebp, 5 + add ebp, ebx + mov ebx, DWORD PTR 12[esp] + ror edi, 1 + xor ecx, eax + ror edi, 1 + lea ebp, DWORD PTR 1518500249[ebx*1+ebp] + add ecx, ebp + ; 00_15 4 + mov ebx, edi + mov ebp, ecx + xor ebx, esi + rol ebp, 5 + and ebx, edx + add ebp, eax + ror edx, 1 + mov eax, DWORD PTR 16[esp] + ror edx, 1 + xor ebx, esi + lea ebp, DWORD PTR 1518500249[eax*1+ebp] + mov eax, edx + add ebx, ebp + xor eax, edi + mov ebp, ebx + and eax, ecx + rol ebp, 5 + add ebp, esi + mov esi, DWORD PTR 20[esp] + ror ecx, 1 + xor eax, edi + ror ecx, 1 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + add eax, ebp + ; 00_15 6 + mov esi, ecx + mov ebp, eax + xor esi, edx + rol ebp, 5 + and esi, ebx + add ebp, edi + ror ebx, 1 + mov edi, DWORD PTR 24[esp] + ror ebx, 1 + xor esi, edx + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, ebx + add esi, ebp + xor edi, ecx + mov ebp, esi + and edi, eax + rol ebp, 5 + add ebp, edx + mov edx, DWORD PTR 28[esp] + ror eax, 1 + xor edi, ecx + ror eax, 1 + lea ebp, DWORD PTR 1518500249[edx*1+ebp] + add edi, ebp + ; 00_15 8 + mov edx, eax + mov ebp, edi + xor edx, ebx + rol ebp, 5 + and edx, esi + add ebp, ecx + ror esi, 1 + mov ecx, DWORD PTR 32[esp] + ror esi, 1 + xor edx, ebx + lea ebp, DWORD PTR 1518500249[ecx*1+ebp] + mov ecx, esi + add edx, ebp + xor ecx, eax + mov ebp, edx + and ecx, edi + rol ebp, 5 + add ebp, ebx + mov ebx, DWORD PTR 36[esp] + ror edi, 1 + xor ecx, eax + ror edi, 1 + lea ebp, DWORD PTR 1518500249[ebx*1+ebp] + add ecx, ebp + ; 00_15 10 + mov ebx, edi + mov ebp, ecx + xor ebx, esi + rol ebp, 5 + and ebx, edx + add ebp, eax + ror edx, 1 + mov eax, DWORD PTR 40[esp] + ror edx, 1 + xor ebx, esi + lea ebp, DWORD PTR 1518500249[eax*1+ebp] + mov eax, edx + add ebx, ebp + xor eax, edi + mov ebp, ebx + and eax, ecx + rol ebp, 5 + add ebp, esi + mov esi, DWORD PTR 44[esp] + ror ecx, 1 + xor eax, edi + ror ecx, 1 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + add eax, ebp + ; 00_15 12 + mov esi, ecx + mov ebp, eax + xor esi, edx + rol ebp, 5 + and esi, ebx + add ebp, edi + ror ebx, 1 + mov edi, DWORD PTR 48[esp] + ror ebx, 1 + xor esi, edx + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, ebx + add esi, ebp + xor edi, ecx + mov ebp, esi + and edi, eax + rol ebp, 5 + add ebp, edx + mov edx, DWORD PTR 52[esp] + ror eax, 1 + xor edi, ecx + ror eax, 1 + lea ebp, DWORD PTR 1518500249[edx*1+ebp] + add edi, ebp + ; 00_15 14 + mov edx, eax + mov ebp, edi + xor edx, ebx + rol ebp, 5 + and edx, esi + add ebp, ecx + ror esi, 1 + mov ecx, DWORD PTR 56[esp] + ror esi, 1 + xor edx, ebx + lea ebp, DWORD PTR 1518500249[ecx*1+ebp] + mov ecx, esi + add edx, ebp + xor ecx, eax + mov ebp, edx + and ecx, edi + rol ebp, 5 + add ebp, ebx + mov ebx, DWORD PTR 60[esp] + ror edi, 1 + xor ecx, eax + ror edi, 1 + lea ebp, DWORD PTR 1518500249[ebx*1+ebp] + add ecx, ebp + ; 16_19 16 + nop + mov ebp, DWORD PTR [esp] + mov ebx, DWORD PTR 8[esp] + xor ebx, ebp + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 52[esp] + xor ebx, ebp + mov ebp, edi + rol ebx, 1 + xor ebp, esi + mov DWORD PTR [esp],ebx + and ebp, edx + lea ebx, DWORD PTR 1518500249[eax*1+ebx] + xor ebp, esi + mov eax, ecx + add ebx, ebp + rol eax, 5 + ror edx, 1 + add ebx, eax + mov eax, DWORD PTR 4[esp] + mov ebp, DWORD PTR 12[esp] + xor eax, ebp + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 56[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, edx + xor ebp, edi + mov DWORD PTR 4[esp],eax + and ebp, ecx + lea eax, DWORD PTR 1518500249[esi*1+eax] + xor ebp, edi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add eax, esi + ror ecx, 1 + add eax, ebp + ; 16_19 18 + mov ebp, DWORD PTR 8[esp] + mov esi, DWORD PTR 16[esp] + xor esi, ebp + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR 60[esp] + xor esi, ebp + mov ebp, ecx + rol esi, 1 + xor ebp, edx + mov DWORD PTR 8[esp],esi + and ebp, ebx + lea esi, DWORD PTR 1518500249[edi*1+esi] + xor ebp, edx + mov edi, eax + add esi, ebp + rol edi, 5 + ror ebx, 1 + add esi, edi + mov edi, DWORD PTR 12[esp] + mov ebp, DWORD PTR 20[esp] + xor edi, ebp + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR [esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, ebx + xor ebp, ecx + mov DWORD PTR 12[esp],edi + and ebp, eax + lea edi, DWORD PTR 1518500249[edx*1+edi] + xor ebp, ecx + mov edx, esi + rol edx, 5 + ror eax, 1 + add edi, edx + ror eax, 1 + add edi, ebp + ; 20_39 20 + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor edx, ebp + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 4[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 16[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 21 + mov ecx, DWORD PTR 20[esp] + mov ebp, DWORD PTR 28[esp] + xor ecx, ebp + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 8[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 20[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 22 + mov ebx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 12[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 24[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 1859775393[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 23 + mov eax, DWORD PTR 28[esp] + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 16[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 28[esp],eax + xor ebp, edi + lea eax, DWORD PTR 1859775393[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 24 + mov esi, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 20[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 32[esp],esi + xor ebp, edx + lea esi, DWORD PTR 1859775393[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 25 + mov edi, DWORD PTR 36[esp] + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 36[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 1859775393[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 26 + mov edx, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 8[esp] + xor edx, ebp + mov ebp, DWORD PTR 28[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 40[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 27 + mov ecx, DWORD PTR 44[esp] + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 12[esp] + xor ecx, ebp + mov ebp, DWORD PTR 32[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 44[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 28 + mov ebx, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 16[esp] + xor ebx, ebp + mov ebp, DWORD PTR 36[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 48[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 1859775393[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 29 + mov eax, DWORD PTR 52[esp] + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 20[esp] + xor eax, ebp + mov ebp, DWORD PTR 40[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 52[esp],eax + xor ebp, edi + lea eax, DWORD PTR 1859775393[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 30 + mov esi, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + xor esi, ebp + mov ebp, DWORD PTR 44[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 56[esp],esi + xor ebp, edx + lea esi, DWORD PTR 1859775393[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 31 + mov edi, DWORD PTR 60[esp] + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + xor edi, ebp + mov ebp, DWORD PTR 48[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 60[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 1859775393[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 32 + mov edx, DWORD PTR [esp] + mov ebp, DWORD PTR 8[esp] + xor edx, ebp + mov ebp, DWORD PTR 32[esp] + xor edx, ebp + mov ebp, DWORD PTR 52[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR [esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 33 + mov ecx, DWORD PTR 4[esp] + mov ebp, DWORD PTR 12[esp] + xor ecx, ebp + mov ebp, DWORD PTR 36[esp] + xor ecx, ebp + mov ebp, DWORD PTR 56[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 4[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 34 + mov ebx, DWORD PTR 8[esp] + mov ebp, DWORD PTR 16[esp] + xor ebx, ebp + mov ebp, DWORD PTR 40[esp] + xor ebx, ebp + mov ebp, DWORD PTR 60[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 8[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 1859775393[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 35 + mov eax, DWORD PTR 12[esp] + mov ebp, DWORD PTR 20[esp] + xor eax, ebp + mov ebp, DWORD PTR 44[esp] + xor eax, ebp + mov ebp, DWORD PTR [esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 12[esp],eax + xor ebp, edi + lea eax, DWORD PTR 1859775393[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 36 + mov esi, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor esi, ebp + mov ebp, DWORD PTR 48[esp] + xor esi, ebp + mov ebp, DWORD PTR 4[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 16[esp],esi + xor ebp, edx + lea esi, DWORD PTR 1859775393[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 37 + mov edi, DWORD PTR 20[esp] + mov ebp, DWORD PTR 28[esp] + xor edi, ebp + mov ebp, DWORD PTR 52[esp] + xor edi, ebp + mov ebp, DWORD PTR 8[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 20[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 1859775393[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 38 + mov edx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor edx, ebp + mov ebp, DWORD PTR 56[esp] + xor edx, ebp + mov ebp, DWORD PTR 12[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 24[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 39 + mov ecx, DWORD PTR 28[esp] + mov ebp, DWORD PTR 36[esp] + xor ecx, ebp + mov ebp, DWORD PTR 60[esp] + xor ecx, ebp + mov ebp, DWORD PTR 16[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 28[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 40_59 40 + mov ebx, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor ebx, ebp + mov ebp, DWORD PTR [esp] + xor ebx, ebp + mov ebp, DWORD PTR 20[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 32[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 36[esp] + add ebx, ebp + mov ebp, DWORD PTR 44[esp] + xor eax, ebp + mov ebp, DWORD PTR 4[esp] + xor eax, ebp + mov ebp, DWORD PTR 24[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 36[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 41 + ; 40_59 42 + mov esi, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor esi, ebp + mov ebp, DWORD PTR 8[esp] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + or ebp, ecx + mov DWORD PTR 40[esp],esi + and ebp, edx + lea esi, DWORD PTR 2400959708[edi*1+esi] + mov edi, ebx + ror ebx, 1 + and edi, ecx + or ebp, edi + mov edi, eax + rol edi, 5 + add ebp, edi + mov edi, DWORD PTR 44[esp] + add esi, ebp + mov ebp, DWORD PTR 52[esp] + xor edi, ebp + mov ebp, DWORD PTR 12[esp] + xor edi, ebp + mov ebp, DWORD PTR 32[esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, eax + mov DWORD PTR 44[esp],edi + or ebp, ebx + lea edi, DWORD PTR 2400959708[edx*1+edi] + mov edx, eax + and ebp, ecx + and edx, ebx + or ebp, edx + mov edx, esi + rol edx, 5 + ror eax, 1 + add ebp, edx + ror eax, 1 + add edi, ebp + ; 40_59 43 + ; 40_59 44 + mov edx, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor edx, ebp + mov ebp, DWORD PTR 16[esp] + xor edx, ebp + mov ebp, DWORD PTR 36[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + or ebp, eax + mov DWORD PTR 48[esp],edx + and ebp, ebx + lea edx, DWORD PTR 2400959708[ecx*1+edx] + mov ecx, esi + ror esi, 1 + and ecx, eax + or ebp, ecx + mov ecx, edi + rol ecx, 5 + add ebp, ecx + mov ecx, DWORD PTR 52[esp] + add edx, ebp + mov ebp, DWORD PTR 60[esp] + xor ecx, ebp + mov ebp, DWORD PTR 20[esp] + xor ecx, ebp + mov ebp, DWORD PTR 40[esp] + ror esi, 1 + xor ecx, ebp + rol ecx, 1 + mov ebp, edi + mov DWORD PTR 52[esp],ecx + or ebp, esi + lea ecx, DWORD PTR 2400959708[ebx*1+ecx] + mov ebx, edi + and ebp, eax + and ebx, esi + or ebp, ebx + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebp, ebx + ror edi, 1 + add ecx, ebp + ; 40_59 45 + ; 40_59 46 + mov ebx, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor ebx, ebp + mov ebp, DWORD PTR 24[esp] + xor ebx, ebp + mov ebp, DWORD PTR 44[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 56[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 60[esp] + add ebx, ebp + mov ebp, DWORD PTR 4[esp] + xor eax, ebp + mov ebp, DWORD PTR 28[esp] + xor eax, ebp + mov ebp, DWORD PTR 48[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 60[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 47 + ; 40_59 48 + mov esi, DWORD PTR [esp] + mov ebp, DWORD PTR 8[esp] + xor esi, ebp + mov ebp, DWORD PTR 32[esp] + xor esi, ebp + mov ebp, DWORD PTR 52[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + or ebp, ecx + mov DWORD PTR [esp],esi + and ebp, edx + lea esi, DWORD PTR 2400959708[edi*1+esi] + mov edi, ebx + ror ebx, 1 + and edi, ecx + or ebp, edi + mov edi, eax + rol edi, 5 + add ebp, edi + mov edi, DWORD PTR 4[esp] + add esi, ebp + mov ebp, DWORD PTR 12[esp] + xor edi, ebp + mov ebp, DWORD PTR 36[esp] + xor edi, ebp + mov ebp, DWORD PTR 56[esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, eax + mov DWORD PTR 4[esp],edi + or ebp, ebx + lea edi, DWORD PTR 2400959708[edx*1+edi] + mov edx, eax + and ebp, ecx + and edx, ebx + or ebp, edx + mov edx, esi + rol edx, 5 + ror eax, 1 + add ebp, edx + ror eax, 1 + add edi, ebp + ; 40_59 49 + ; 40_59 50 + mov edx, DWORD PTR 8[esp] + mov ebp, DWORD PTR 16[esp] + xor edx, ebp + mov ebp, DWORD PTR 40[esp] + xor edx, ebp + mov ebp, DWORD PTR 60[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + or ebp, eax + mov DWORD PTR 8[esp],edx + and ebp, ebx + lea edx, DWORD PTR 2400959708[ecx*1+edx] + mov ecx, esi + ror esi, 1 + and ecx, eax + or ebp, ecx + mov ecx, edi + rol ecx, 5 + add ebp, ecx + mov ecx, DWORD PTR 12[esp] + add edx, ebp + mov ebp, DWORD PTR 20[esp] + xor ecx, ebp + mov ebp, DWORD PTR 44[esp] + xor ecx, ebp + mov ebp, DWORD PTR [esp] + ror esi, 1 + xor ecx, ebp + rol ecx, 1 + mov ebp, edi + mov DWORD PTR 12[esp],ecx + or ebp, esi + lea ecx, DWORD PTR 2400959708[ebx*1+ecx] + mov ebx, edi + and ebp, eax + and ebx, esi + or ebp, ebx + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebp, ebx + ror edi, 1 + add ecx, ebp + ; 40_59 51 + ; 40_59 52 + mov ebx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor ebx, ebp + mov ebp, DWORD PTR 48[esp] + xor ebx, ebp + mov ebp, DWORD PTR 4[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 16[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 20[esp] + add ebx, ebp + mov ebp, DWORD PTR 28[esp] + xor eax, ebp + mov ebp, DWORD PTR 52[esp] + xor eax, ebp + mov ebp, DWORD PTR 8[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 20[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 53 + ; 40_59 54 + mov esi, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor esi, ebp + mov ebp, DWORD PTR 56[esp] + xor esi, ebp + mov ebp, DWORD PTR 12[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + or ebp, ecx + mov DWORD PTR 24[esp],esi + and ebp, edx + lea esi, DWORD PTR 2400959708[edi*1+esi] + mov edi, ebx + ror ebx, 1 + and edi, ecx + or ebp, edi + mov edi, eax + rol edi, 5 + add ebp, edi + mov edi, DWORD PTR 28[esp] + add esi, ebp + mov ebp, DWORD PTR 36[esp] + xor edi, ebp + mov ebp, DWORD PTR 60[esp] + xor edi, ebp + mov ebp, DWORD PTR 16[esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, eax + mov DWORD PTR 28[esp],edi + or ebp, ebx + lea edi, DWORD PTR 2400959708[edx*1+edi] + mov edx, eax + and ebp, ecx + and edx, ebx + or ebp, edx + mov edx, esi + rol edx, 5 + ror eax, 1 + add ebp, edx + ror eax, 1 + add edi, ebp + ; 40_59 55 + ; 40_59 56 + mov edx, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor edx, ebp + mov ebp, DWORD PTR [esp] + xor edx, ebp + mov ebp, DWORD PTR 20[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + or ebp, eax + mov DWORD PTR 32[esp],edx + and ebp, ebx + lea edx, DWORD PTR 2400959708[ecx*1+edx] + mov ecx, esi + ror esi, 1 + and ecx, eax + or ebp, ecx + mov ecx, edi + rol ecx, 5 + add ebp, ecx + mov ecx, DWORD PTR 36[esp] + add edx, ebp + mov ebp, DWORD PTR 44[esp] + xor ecx, ebp + mov ebp, DWORD PTR 4[esp] + xor ecx, ebp + mov ebp, DWORD PTR 24[esp] + ror esi, 1 + xor ecx, ebp + rol ecx, 1 + mov ebp, edi + mov DWORD PTR 36[esp],ecx + or ebp, esi + lea ecx, DWORD PTR 2400959708[ebx*1+ecx] + mov ebx, edi + and ebp, eax + and ebx, esi + or ebp, ebx + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebp, ebx + ror edi, 1 + add ecx, ebp + ; 40_59 57 + ; 40_59 58 + mov ebx, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor ebx, ebp + mov ebp, DWORD PTR 8[esp] + xor ebx, ebp + mov ebp, DWORD PTR 28[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 40[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 44[esp] + add ebx, ebp + mov ebp, DWORD PTR 52[esp] + xor eax, ebp + mov ebp, DWORD PTR 12[esp] + xor eax, ebp + mov ebp, DWORD PTR 32[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 44[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 59 + ; 20_39 60 + mov esi, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor esi, ebp + mov ebp, DWORD PTR 16[esp] + xor esi, ebp + mov ebp, DWORD PTR 36[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 48[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 61 + mov edi, DWORD PTR 52[esp] + mov ebp, DWORD PTR 60[esp] + xor edi, ebp + mov ebp, DWORD PTR 20[esp] + xor edi, ebp + mov ebp, DWORD PTR 40[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 52[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 62 + mov edx, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor edx, ebp + mov ebp, DWORD PTR 24[esp] + xor edx, ebp + mov ebp, DWORD PTR 44[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 56[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 3395469782[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 63 + mov ecx, DWORD PTR 60[esp] + mov ebp, DWORD PTR 4[esp] + xor ecx, ebp + mov ebp, DWORD PTR 28[esp] + xor ecx, ebp + mov ebp, DWORD PTR 48[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 60[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 3395469782[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 64 + mov ebx, DWORD PTR [esp] + mov ebp, DWORD PTR 8[esp] + xor ebx, ebp + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 52[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR [esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 3395469782[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 65 + mov eax, DWORD PTR 4[esp] + mov ebp, DWORD PTR 12[esp] + xor eax, ebp + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 56[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 4[esp],eax + xor ebp, edi + lea eax, DWORD PTR 3395469782[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 66 + mov esi, DWORD PTR 8[esp] + mov ebp, DWORD PTR 16[esp] + xor esi, ebp + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR 60[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 8[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 67 + mov edi, DWORD PTR 12[esp] + mov ebp, DWORD PTR 20[esp] + xor edi, ebp + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR [esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 12[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 68 + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor edx, ebp + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 4[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 16[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 3395469782[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 69 + mov ecx, DWORD PTR 20[esp] + mov ebp, DWORD PTR 28[esp] + xor ecx, ebp + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 8[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 20[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 3395469782[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 70 + mov ebx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 12[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 24[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 3395469782[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 71 + mov eax, DWORD PTR 28[esp] + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 16[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 28[esp],eax + xor ebp, edi + lea eax, DWORD PTR 3395469782[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 72 + mov esi, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 20[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 32[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 73 + mov edi, DWORD PTR 36[esp] + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 36[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 74 + mov edx, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 8[esp] + xor edx, ebp + mov ebp, DWORD PTR 28[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 40[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 3395469782[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 75 + mov ecx, DWORD PTR 44[esp] + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 12[esp] + xor ecx, ebp + mov ebp, DWORD PTR 32[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 44[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 3395469782[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 76 + mov ebx, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 16[esp] + xor ebx, ebp + mov ebp, DWORD PTR 36[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 48[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 3395469782[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 77 + mov eax, DWORD PTR 52[esp] + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 20[esp] + xor eax, ebp + mov ebp, DWORD PTR 40[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 52[esp],eax + xor ebp, edi + lea eax, DWORD PTR 3395469782[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 78 + mov esi, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + xor esi, ebp + mov ebp, DWORD PTR 44[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 56[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 79 + mov edi, DWORD PTR 60[esp] + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + xor edi, ebp + mov ebp, DWORD PTR 48[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 60[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + add edx, ebp + mov ebp, DWORD PTR 92[esp] + ror eax, 1 + add edi, edx + ror eax, 1 + ; End processing + ; + mov edx, DWORD PTR 12[ebp] + add edx, ebx + mov ebx, DWORD PTR 4[ebp] + add ebx, esi + mov esi, eax + mov eax, DWORD PTR [ebp] + mov DWORD PTR 12[ebp],edx + add eax, edi + mov edi, DWORD PTR 16[ebp] + add edi, ecx + mov ecx, DWORD PTR 8[ebp] + add ecx, esi + mov DWORD PTR [ebp],eax + mov esi, DWORD PTR 64[esp] + mov DWORD PTR 8[ebp],ecx + add esi, 64 + mov eax, DWORD PTR 68[esp] + mov DWORD PTR 16[ebp],edi + cmp eax, esi + mov DWORD PTR 4[ebp],ebx + jl $L001end + mov eax, DWORD PTR [esi] + jmp L000start +$L001end: + add esp, 72 + pop edi + pop ebx + pop ebp + pop esi + ret +_sha1_block_x86 ENDP +_TEXT ENDS +END diff --git a/src/lib/libcrypto/sha/asm/sx86unix.cpp b/src/lib/libcrypto/sha/asm/sx86unix.cpp new file mode 100644 index 0000000000..8366664a39 --- /dev/null +++ b/src/lib/libcrypto/sha/asm/sx86unix.cpp @@ -0,0 +1,1948 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define sha1_block_x86 _sha1_block_x86 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by sha1-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "sha1-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl sha1_block_x86 + TYPE(sha1_block_x86,@function) +sha1_block_x86: + pushl %esi + pushl %ebp + movl 20(%esp), %eax + movl 16(%esp), %esi + addl %esi, %eax + movl 12(%esp), %ebp + pushl %ebx + subl $64, %eax + pushl %edi + movl 4(%ebp), %ebx + subl $72, %esp + movl 12(%ebp), %edx + movl 16(%ebp), %edi + movl 8(%ebp), %ecx + movl %eax, 68(%esp) + /* First we need to setup the X array */ + movl (%esi), %eax +.L000start: + /* First, load the words onto the stack in network byte order */ +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, (%esp) + movl 4(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 4(%esp) + movl 8(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 8(%esp) + movl 12(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 12(%esp) + movl 16(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 16(%esp) + movl 20(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 20(%esp) + movl 24(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 24(%esp) + movl 28(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 28(%esp) + movl 32(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 32(%esp) + movl 36(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 36(%esp) + movl 40(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 40(%esp) + movl 44(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 44(%esp) + movl 48(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 48(%esp) + movl 52(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 52(%esp) + movl 56(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 56(%esp) + movl 60(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 60(%esp) + /* We now have the X array on the stack */ + /* starting at sp-4 */ + movl %esi, 64(%esp) + + /* Start processing */ + movl (%ebp), %eax + /* 00_15 0 */ + movl %ecx, %esi + movl %eax, %ebp + xorl %edx, %esi + roll $5, %ebp + andl %ebx, %esi + addl %edi, %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + movl (%esp), %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + movl %ebx, %edi + addl %ebp, %esi + xorl %ecx, %edi + movl %esi, %ebp + andl %eax, %edi + roll $5, %ebp + addl %edx, %ebp + movl 4(%esp), %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + xorl %ecx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + /* 00_15 2 */ + movl %eax, %edx + movl %edi, %ebp + xorl %ebx, %edx + roll $5, %ebp + andl %esi, %edx + addl %ecx, %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl 8(%esp), %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebx, %edx + leal 1518500249(%ebp,%ecx,1),%ebp + movl %esi, %ecx + addl %ebp, %edx + xorl %eax, %ecx + movl %edx, %ebp + andl %edi, %ecx + roll $5, %ebp + addl %ebx, %ebp + movl 12(%esp), %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + xorl %eax, %ecx +.byte 209 +.byte 207 /* rorl $1 %edi */ + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %ecx + /* 00_15 4 */ + movl %edi, %ebx + movl %ecx, %ebp + xorl %esi, %ebx + roll $5, %ebp + andl %edx, %ebx + addl %eax, %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + movl 16(%esp), %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %esi, %ebx + leal 1518500249(%ebp,%eax,1),%ebp + movl %edx, %eax + addl %ebp, %ebx + xorl %edi, %eax + movl %ebx, %ebp + andl %ecx, %eax + roll $5, %ebp + addl %esi, %ebp + movl 20(%esp), %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + xorl %edi, %eax +.byte 209 +.byte 201 /* rorl $1 %ecx */ + leal 1518500249(%ebp,%esi,1),%ebp + addl %ebp, %eax + /* 00_15 6 */ + movl %ecx, %esi + movl %eax, %ebp + xorl %edx, %esi + roll $5, %ebp + andl %ebx, %esi + addl %edi, %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + movl 24(%esp), %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + movl %ebx, %edi + addl %ebp, %esi + xorl %ecx, %edi + movl %esi, %ebp + andl %eax, %edi + roll $5, %ebp + addl %edx, %ebp + movl 28(%esp), %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + xorl %ecx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + /* 00_15 8 */ + movl %eax, %edx + movl %edi, %ebp + xorl %ebx, %edx + roll $5, %ebp + andl %esi, %edx + addl %ecx, %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl 32(%esp), %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebx, %edx + leal 1518500249(%ebp,%ecx,1),%ebp + movl %esi, %ecx + addl %ebp, %edx + xorl %eax, %ecx + movl %edx, %ebp + andl %edi, %ecx + roll $5, %ebp + addl %ebx, %ebp + movl 36(%esp), %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + xorl %eax, %ecx +.byte 209 +.byte 207 /* rorl $1 %edi */ + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %ecx + /* 00_15 10 */ + movl %edi, %ebx + movl %ecx, %ebp + xorl %esi, %ebx + roll $5, %ebp + andl %edx, %ebx + addl %eax, %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + movl 40(%esp), %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %esi, %ebx + leal 1518500249(%ebp,%eax,1),%ebp + movl %edx, %eax + addl %ebp, %ebx + xorl %edi, %eax + movl %ebx, %ebp + andl %ecx, %eax + roll $5, %ebp + addl %esi, %ebp + movl 44(%esp), %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + xorl %edi, %eax +.byte 209 +.byte 201 /* rorl $1 %ecx */ + leal 1518500249(%ebp,%esi,1),%ebp + addl %ebp, %eax + /* 00_15 12 */ + movl %ecx, %esi + movl %eax, %ebp + xorl %edx, %esi + roll $5, %ebp + andl %ebx, %esi + addl %edi, %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + movl 48(%esp), %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + movl %ebx, %edi + addl %ebp, %esi + xorl %ecx, %edi + movl %esi, %ebp + andl %eax, %edi + roll $5, %ebp + addl %edx, %ebp + movl 52(%esp), %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + xorl %ecx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + /* 00_15 14 */ + movl %eax, %edx + movl %edi, %ebp + xorl %ebx, %edx + roll $5, %ebp + andl %esi, %edx + addl %ecx, %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl 56(%esp), %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebx, %edx + leal 1518500249(%ebp,%ecx,1),%ebp + movl %esi, %ecx + addl %ebp, %edx + xorl %eax, %ecx + movl %edx, %ebp + andl %edi, %ecx + roll $5, %ebp + addl %ebx, %ebp + movl 60(%esp), %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + xorl %eax, %ecx +.byte 209 +.byte 207 /* rorl $1 %edi */ + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %ecx + /* 16_19 16 */ + nop + movl (%esp), %ebp + movl 8(%esp), %ebx + xorl %ebp, %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 52(%esp), %ebp + xorl %ebp, %ebx + movl %edi, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %esi, %ebp + movl %ebx, (%esp) + andl %edx, %ebp + leal 1518500249(%ebx,%eax,1),%ebx + xorl %esi, %ebp + movl %ecx, %eax + addl %ebp, %ebx + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + movl 4(%esp), %eax + movl 12(%esp), %ebp + xorl %ebp, %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 56(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %edx, %ebp + xorl %edi, %ebp + movl %eax, 4(%esp) + andl %ecx, %ebp + leal 1518500249(%eax,%esi,1),%eax + xorl %edi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 16_19 18 */ + movl 8(%esp), %ebp + movl 16(%esp), %esi + xorl %ebp, %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl 60(%esp), %ebp + xorl %ebp, %esi + movl %ecx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %edx, %ebp + movl %esi, 8(%esp) + andl %ebx, %ebp + leal 1518500249(%esi,%edi,1),%esi + xorl %edx, %ebp + movl %eax, %edi + addl %ebp, %esi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + movl 12(%esp), %edi + movl 20(%esp), %ebp + xorl %ebp, %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl (%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %ebx, %ebp + xorl %ecx, %ebp + movl %edi, 12(%esp) + andl %eax, %ebp + leal 1518500249(%edi,%edx,1),%edi + xorl %ecx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 20_39 20 */ + movl 16(%esp), %edx + movl 24(%esp), %ebp + xorl %ebp, %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 4(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 16(%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 21 */ + movl 20(%esp), %ecx + movl 28(%esp), %ebp + xorl %ebp, %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 8(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 20(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 22 */ + movl 24(%esp), %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 12(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 24(%esp) + xorl %esi, %ebp + leal 1859775393(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 23 */ + movl 28(%esp), %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 16(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 28(%esp) + xorl %edi, %ebp + leal 1859775393(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 24 */ + movl 32(%esp), %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 20(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 32(%esp) + xorl %edx, %ebp + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 25 */ + movl 36(%esp), %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 36(%esp) + xorl %ecx, %ebp + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 26 */ + movl 40(%esp), %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 8(%esp), %ebp + xorl %ebp, %edx + movl 28(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 40(%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 27 */ + movl 44(%esp), %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 12(%esp), %ebp + xorl %ebp, %ecx + movl 32(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 44(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 28 */ + movl 48(%esp), %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 16(%esp), %ebp + xorl %ebp, %ebx + movl 36(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 48(%esp) + xorl %esi, %ebp + leal 1859775393(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 29 */ + movl 52(%esp), %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 20(%esp), %ebp + xorl %ebp, %eax + movl 40(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 52(%esp) + xorl %edi, %ebp + leal 1859775393(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 30 */ + movl 56(%esp), %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + xorl %ebp, %esi + movl 44(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 56(%esp) + xorl %edx, %ebp + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 31 */ + movl 60(%esp), %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + xorl %ebp, %edi + movl 48(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 60(%esp) + xorl %ecx, %ebp + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 32 */ + movl (%esp), %edx + movl 8(%esp), %ebp + xorl %ebp, %edx + movl 32(%esp), %ebp + xorl %ebp, %edx + movl 52(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, (%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 33 */ + movl 4(%esp), %ecx + movl 12(%esp), %ebp + xorl %ebp, %ecx + movl 36(%esp), %ebp + xorl %ebp, %ecx + movl 56(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 4(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 34 */ + movl 8(%esp), %ebx + movl 16(%esp), %ebp + xorl %ebp, %ebx + movl 40(%esp), %ebp + xorl %ebp, %ebx + movl 60(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 8(%esp) + xorl %esi, %ebp + leal 1859775393(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 35 */ + movl 12(%esp), %eax + movl 20(%esp), %ebp + xorl %ebp, %eax + movl 44(%esp), %ebp + xorl %ebp, %eax + movl (%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 12(%esp) + xorl %edi, %ebp + leal 1859775393(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 36 */ + movl 16(%esp), %esi + movl 24(%esp), %ebp + xorl %ebp, %esi + movl 48(%esp), %ebp + xorl %ebp, %esi + movl 4(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 16(%esp) + xorl %edx, %ebp + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 37 */ + movl 20(%esp), %edi + movl 28(%esp), %ebp + xorl %ebp, %edi + movl 52(%esp), %ebp + xorl %ebp, %edi + movl 8(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 20(%esp) + xorl %ecx, %ebp + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 38 */ + movl 24(%esp), %edx + movl 32(%esp), %ebp + xorl %ebp, %edx + movl 56(%esp), %ebp + xorl %ebp, %edx + movl 12(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 24(%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 39 */ + movl 28(%esp), %ecx + movl 36(%esp), %ebp + xorl %ebp, %ecx + movl 60(%esp), %ebp + xorl %ebp, %ecx + movl 16(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 28(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 40_59 40 */ + movl 32(%esp), %ebx + movl 40(%esp), %ebp + xorl %ebp, %ebx + movl (%esp), %ebp + xorl %ebp, %ebx + movl 20(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 32(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 36(%esp), %eax + addl %ebp, %ebx + movl 44(%esp), %ebp + xorl %ebp, %eax + movl 4(%esp), %ebp + xorl %ebp, %eax + movl 24(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 36(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 41 */ + /* 40_59 42 */ + movl 40(%esp), %esi + movl 48(%esp), %ebp + xorl %ebp, %esi + movl 8(%esp), %ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + orl %ecx, %ebp + movl %esi, 40(%esp) + andl %edx, %ebp + leal 2400959708(%esi,%edi,1),%esi + movl %ebx, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + andl %ecx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + movl 44(%esp), %edi + addl %ebp, %esi + movl 52(%esp), %ebp + xorl %ebp, %edi + movl 12(%esp), %ebp + xorl %ebp, %edi + movl 32(%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %eax, %ebp + movl %edi, 44(%esp) + orl %ebx, %ebp + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + andl %ecx, %ebp + andl %ebx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 40_59 43 */ + /* 40_59 44 */ + movl 48(%esp), %edx + movl 56(%esp), %ebp + xorl %ebp, %edx + movl 16(%esp), %ebp + xorl %ebp, %edx + movl 36(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + orl %eax, %ebp + movl %edx, 48(%esp) + andl %ebx, %ebp + leal 2400959708(%edx,%ecx,1),%edx + movl %esi, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + andl %eax, %ecx + orl %ecx, %ebp + movl %edi, %ecx + roll $5, %ecx + addl %ecx, %ebp + movl 52(%esp), %ecx + addl %ebp, %edx + movl 60(%esp), %ebp + xorl %ebp, %ecx + movl 20(%esp), %ebp + xorl %ebp, %ecx + movl 40(%esp), %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebp, %ecx +.byte 209 +.byte 193 /* roll $1 %ecx */ + movl %edi, %ebp + movl %ecx, 52(%esp) + orl %esi, %ebp + leal 2400959708(%ecx,%ebx,1),%ecx + movl %edi, %ebx + andl %eax, %ebp + andl %esi, %ebx + orl %ebx, %ebp + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ebp +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ecx + /* 40_59 45 */ + /* 40_59 46 */ + movl 56(%esp), %ebx + movl (%esp), %ebp + xorl %ebp, %ebx + movl 24(%esp), %ebp + xorl %ebp, %ebx + movl 44(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 56(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 60(%esp), %eax + addl %ebp, %ebx + movl 4(%esp), %ebp + xorl %ebp, %eax + movl 28(%esp), %ebp + xorl %ebp, %eax + movl 48(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 60(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 47 */ + /* 40_59 48 */ + movl (%esp), %esi + movl 8(%esp), %ebp + xorl %ebp, %esi + movl 32(%esp), %ebp + xorl %ebp, %esi + movl 52(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + orl %ecx, %ebp + movl %esi, (%esp) + andl %edx, %ebp + leal 2400959708(%esi,%edi,1),%esi + movl %ebx, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + andl %ecx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + movl 4(%esp), %edi + addl %ebp, %esi + movl 12(%esp), %ebp + xorl %ebp, %edi + movl 36(%esp), %ebp + xorl %ebp, %edi + movl 56(%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %eax, %ebp + movl %edi, 4(%esp) + orl %ebx, %ebp + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + andl %ecx, %ebp + andl %ebx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 40_59 49 */ + /* 40_59 50 */ + movl 8(%esp), %edx + movl 16(%esp), %ebp + xorl %ebp, %edx + movl 40(%esp), %ebp + xorl %ebp, %edx + movl 60(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + orl %eax, %ebp + movl %edx, 8(%esp) + andl %ebx, %ebp + leal 2400959708(%edx,%ecx,1),%edx + movl %esi, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + andl %eax, %ecx + orl %ecx, %ebp + movl %edi, %ecx + roll $5, %ecx + addl %ecx, %ebp + movl 12(%esp), %ecx + addl %ebp, %edx + movl 20(%esp), %ebp + xorl %ebp, %ecx + movl 44(%esp), %ebp + xorl %ebp, %ecx + movl (%esp), %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebp, %ecx +.byte 209 +.byte 193 /* roll $1 %ecx */ + movl %edi, %ebp + movl %ecx, 12(%esp) + orl %esi, %ebp + leal 2400959708(%ecx,%ebx,1),%ecx + movl %edi, %ebx + andl %eax, %ebp + andl %esi, %ebx + orl %ebx, %ebp + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ebp +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ecx + /* 40_59 51 */ + /* 40_59 52 */ + movl 16(%esp), %ebx + movl 24(%esp), %ebp + xorl %ebp, %ebx + movl 48(%esp), %ebp + xorl %ebp, %ebx + movl 4(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 16(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 20(%esp), %eax + addl %ebp, %ebx + movl 28(%esp), %ebp + xorl %ebp, %eax + movl 52(%esp), %ebp + xorl %ebp, %eax + movl 8(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 20(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 53 */ + /* 40_59 54 */ + movl 24(%esp), %esi + movl 32(%esp), %ebp + xorl %ebp, %esi + movl 56(%esp), %ebp + xorl %ebp, %esi + movl 12(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + orl %ecx, %ebp + movl %esi, 24(%esp) + andl %edx, %ebp + leal 2400959708(%esi,%edi,1),%esi + movl %ebx, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + andl %ecx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + movl 28(%esp), %edi + addl %ebp, %esi + movl 36(%esp), %ebp + xorl %ebp, %edi + movl 60(%esp), %ebp + xorl %ebp, %edi + movl 16(%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %eax, %ebp + movl %edi, 28(%esp) + orl %ebx, %ebp + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + andl %ecx, %ebp + andl %ebx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 40_59 55 */ + /* 40_59 56 */ + movl 32(%esp), %edx + movl 40(%esp), %ebp + xorl %ebp, %edx + movl (%esp), %ebp + xorl %ebp, %edx + movl 20(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + orl %eax, %ebp + movl %edx, 32(%esp) + andl %ebx, %ebp + leal 2400959708(%edx,%ecx,1),%edx + movl %esi, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + andl %eax, %ecx + orl %ecx, %ebp + movl %edi, %ecx + roll $5, %ecx + addl %ecx, %ebp + movl 36(%esp), %ecx + addl %ebp, %edx + movl 44(%esp), %ebp + xorl %ebp, %ecx + movl 4(%esp), %ebp + xorl %ebp, %ecx + movl 24(%esp), %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebp, %ecx +.byte 209 +.byte 193 /* roll $1 %ecx */ + movl %edi, %ebp + movl %ecx, 36(%esp) + orl %esi, %ebp + leal 2400959708(%ecx,%ebx,1),%ecx + movl %edi, %ebx + andl %eax, %ebp + andl %esi, %ebx + orl %ebx, %ebp + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ebp +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ecx + /* 40_59 57 */ + /* 40_59 58 */ + movl 40(%esp), %ebx + movl 48(%esp), %ebp + xorl %ebp, %ebx + movl 8(%esp), %ebp + xorl %ebp, %ebx + movl 28(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 40(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 44(%esp), %eax + addl %ebp, %ebx + movl 52(%esp), %ebp + xorl %ebp, %eax + movl 12(%esp), %ebp + xorl %ebp, %eax + movl 32(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 44(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 59 */ + /* 20_39 60 */ + movl 48(%esp), %esi + movl 56(%esp), %ebp + xorl %ebp, %esi + movl 16(%esp), %ebp + xorl %ebp, %esi + movl 36(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 48(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 61 */ + movl 52(%esp), %edi + movl 60(%esp), %ebp + xorl %ebp, %edi + movl 20(%esp), %ebp + xorl %ebp, %edi + movl 40(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 52(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 62 */ + movl 56(%esp), %edx + movl (%esp), %ebp + xorl %ebp, %edx + movl 24(%esp), %ebp + xorl %ebp, %edx + movl 44(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 56(%esp) + xorl %ebx, %ebp + leal 3395469782(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 63 */ + movl 60(%esp), %ecx + movl 4(%esp), %ebp + xorl %ebp, %ecx + movl 28(%esp), %ebp + xorl %ebp, %ecx + movl 48(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 60(%esp) + xorl %eax, %ebp + leal 3395469782(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 64 */ + movl (%esp), %ebx + movl 8(%esp), %ebp + xorl %ebp, %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 52(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, (%esp) + xorl %esi, %ebp + leal 3395469782(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 65 */ + movl 4(%esp), %eax + movl 12(%esp), %ebp + xorl %ebp, %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 56(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 4(%esp) + xorl %edi, %ebp + leal 3395469782(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 66 */ + movl 8(%esp), %esi + movl 16(%esp), %ebp + xorl %ebp, %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl 60(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 8(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 67 */ + movl 12(%esp), %edi + movl 20(%esp), %ebp + xorl %ebp, %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl (%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 12(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 68 */ + movl 16(%esp), %edx + movl 24(%esp), %ebp + xorl %ebp, %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 4(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 16(%esp) + xorl %ebx, %ebp + leal 3395469782(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 69 */ + movl 20(%esp), %ecx + movl 28(%esp), %ebp + xorl %ebp, %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 8(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 20(%esp) + xorl %eax, %ebp + leal 3395469782(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 70 */ + movl 24(%esp), %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 12(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 24(%esp) + xorl %esi, %ebp + leal 3395469782(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 71 */ + movl 28(%esp), %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 16(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 28(%esp) + xorl %edi, %ebp + leal 3395469782(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 72 */ + movl 32(%esp), %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 20(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 32(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 73 */ + movl 36(%esp), %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 36(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 74 */ + movl 40(%esp), %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 8(%esp), %ebp + xorl %ebp, %edx + movl 28(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 40(%esp) + xorl %ebx, %ebp + leal 3395469782(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 75 */ + movl 44(%esp), %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 12(%esp), %ebp + xorl %ebp, %ecx + movl 32(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 44(%esp) + xorl %eax, %ebp + leal 3395469782(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 76 */ + movl 48(%esp), %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 16(%esp), %ebp + xorl %ebp, %ebx + movl 36(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 48(%esp) + xorl %esi, %ebp + leal 3395469782(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 77 */ + movl 52(%esp), %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 20(%esp), %ebp + xorl %ebp, %eax + movl 40(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 52(%esp) + xorl %edi, %ebp + leal 3395469782(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 78 */ + movl 56(%esp), %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + xorl %ebp, %esi + movl 44(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 56(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 79 */ + movl 60(%esp), %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + xorl %ebp, %edi + movl 48(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 60(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edx + movl 92(%esp), %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + /* End processing */ + + movl 12(%ebp), %edx + addl %ebx, %edx + movl 4(%ebp), %ebx + addl %esi, %ebx + movl %eax, %esi + movl (%ebp), %eax + movl %edx, 12(%ebp) + addl %edi, %eax + movl 16(%ebp), %edi + addl %ecx, %edi + movl 8(%ebp), %ecx + addl %esi, %ecx + movl %eax, (%ebp) + movl 64(%esp), %esi + movl %ecx, 8(%ebp) + addl $64, %esi + movl 68(%esp), %eax + movl %edi, 16(%ebp) + cmpl %esi, %eax + movl %ebx, 4(%ebp) + jl .L001end + movl (%esi), %eax + jmp .L000start +.L001end: + addl $72, %esp + popl %edi + popl %ebx + popl %ebp + popl %esi + ret +.sha1_block_x86_end: + SIZE(sha1_block_x86,.sha1_block_x86_end-sha1_block_x86) +.ident "desasm.pl" diff --git a/src/lib/libcrypto/sha/sha_sgst.c b/src/lib/libcrypto/sha/sha_sgst.c new file mode 100644 index 0000000000..8a16801328 --- /dev/null +++ b/src/lib/libcrypto/sha/sha_sgst.c @@ -0,0 +1,246 @@ +/* crypto/sha/sha_sgst.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include + +#ifdef undef +/* one or the other needs to be defined */ +#ifndef SHA_1 /* FIPE 180-1 */ +#define SHA_0 /* FIPS 180 */ +#endif +#endif + +#define ULONG unsigned long +#define UCHAR unsigned char +#define UINT unsigned int + +#ifdef NOCONST +#define const +#endif + +#undef c2nl +#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++))) )) + +#undef p_c2nl +#define p_c2nl(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + case 3: l|=((unsigned long)(*((c)++))); \ + } \ + } + +#undef c2nl_p +/* NOTE the pointer is not incremented at the end of this */ +#define c2nl_p(c,l,n) { \ + l=0; \ + (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<< 8; \ + case 2: l|=((unsigned long)(*(--(c))))<<16; \ + case 1: l|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +#undef p_c2nl_p +#define p_c2nl_p(c,l,sc,len) { \ + switch (sc) \ + { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + } \ + } + +#undef nl2c +#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#undef c2l +#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<<24)) + +#undef p_c2l +#define p_c2l(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++))); \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + case 3: l|=((unsigned long)(*((c)++)))<<24; \ + } \ + } + +#undef c2l_p +/* NOTE the pointer is not incremented at the end of this */ +#define c2l_p(c,l,n) { \ + l=0; \ + (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<<16; \ + case 2: l|=((unsigned long)(*(--(c))))<< 8; \ + case 1: l|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef p_c2l_p +#define p_c2l_p(c,l,sc,len) { \ + switch (sc) \ + { \ + case 0: l =((unsigned long)(*((c)++))); \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff)) + +#undef ROTATE +#if defined(WIN32) +#define ROTATE(a,n) _lrotl(a,n) +#else +#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) +#endif + +/* A nice byte order reversal from Wei Dai */ +#if defined(WIN32) +/* 5 instructions with rotate instruction, else 9 */ +#define Endian_Reverse32(a) \ + { \ + unsigned long l=(a); \ + (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \ + } +#else +/* 6 instructions with rotate instruction, else 8 */ +#define Endian_Reverse32(a) \ + { \ + unsigned long l=(a); \ + l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \ + (a)=ROTATE(l,16L); \ + } +#endif + +/* As pointed out by Wei Dai , F() below can be + * simplified to the code in F_00_19. Wei attributes these optimisations + * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. + * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) + * I've just become aware of another tweak to be made, again from Wei Dai, + * in F_40_59, (x&a)|(y&a) -> (x|y)&a + */ +#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) +#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) +#define F_60_79(b,c,d) F_20_39(b,c,d) + +#ifdef SHA_0 +#undef Xupdate +#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\ + (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]); +#endif +#ifdef SHA_1 +#undef Xupdate +#define Xupdate(a,i,ia,ib,ic,id) (a)=\ + (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\ + X[(i)&0x0f]=(a)=ROTATE((a),1); +#endif + +#define BODY_00_15(i,a,b,c,d,e,f,xa) \ + (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_32_39(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_40_59(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_60_79(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ + (b)=ROTATE((b),30); + diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl new file mode 100644 index 0000000000..0d232c08cf --- /dev/null +++ b/src/lib/libcrypto/stack/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/stack/Makefile +# + +DIR= stack +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=stack.c +LIBOBJ=stack.o + +SRC= $(LIBSRC) + +EXHEADER= stack.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl new file mode 100644 index 0000000000..76e511534f --- /dev/null +++ b/src/lib/libcrypto/txt_db/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/txt_db/Makefile +# + +DIR= txt_db +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=txt_db.c +LIBOBJ=txt_db.o + +SRC= $(LIBSRC) + +EXHEADER= txt_db.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/util/mklink.sh b/src/lib/libcrypto/util/mklink.sh new file mode 100644 index 0000000000..1e052ed6ee --- /dev/null +++ b/src/lib/libcrypto/util/mklink.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# A bit of an ugly shell script used to actually 'link' files. +# Used by 'make links' +# + +PATH=$PATH:.:util:../util:../../util +export PATH + +from=$1 +shift + +here=`pwd` +tmp=`dirname $from` +while [ "$tmp"x != "x" -a "$tmp"x != ".x" ] +do + t=`basename $here` + here=`dirname $here` + to="/$t$to" + tmp=`dirname $tmp` +done +to=..$to + +#echo from=$from +#echo to =$to +#exit 1 + +if [ "$*"x != "x" ]; then + for i in $* + do + /bin/rm -f $from/$i + point.sh $to/$i $from/$i + done +fi +exit 0; diff --git a/src/lib/libcrypto/util/ranlib.sh b/src/lib/libcrypto/util/ranlib.sh new file mode 100644 index 0000000000..543f712c6b --- /dev/null +++ b/src/lib/libcrypto/util/ranlib.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cwd=`pwd` +cd /tmp + +if [ -s /bin/ranlib ] ; then + RL=/bin/ranlib +else if [ -s /usr/bin/ranlib ] ; then + RL=/usr/bin/ranlib +fi +fi + +if [ "x$RL" != "x" ] +then + case "$1" in + /*) + $RL "$1" + ;; + *) + $RL "$cwd/$1" + ;; + esac +fi diff --git a/src/lib/libcrypto/util/sep_lib.sh b/src/lib/libcrypto/util/sep_lib.sh new file mode 100644 index 0000000000..2348db874e --- /dev/null +++ b/src/lib/libcrypto/util/sep_lib.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +cwd=`pwd` +/bin/rm -fr tmp/* + +cd crypto/des +make -f Makefile.uni tar +make -f Makefile.uni tar_lit +/bin/mv libdes.tgz $cwd/tmp +/bin/mv libdes-l.tgz $cwd/tmp +cd $cwd + +for name in md5 sha cast bf idea rc4 rc2 +do + echo doing $name + (cd crypto; tar cfh - $name)|(cd tmp; tar xf -) + cd tmp/$name + /bin/rm -f Makefile + /bin/rm -f Makefile.ssl + /bin/rm -f Makefile.ssl.orig + /bin/rm -f *.old + /bin/mv Makefile.uni Makefile + + cp $cwd/util/ranlib.sh . + chmod +x ranlib.sh + + if [ -d asm ]; then + mkdir asm/perlasm + cp $cwd/crypto/perlasm/*.pl asm/perlasm + fi + cd .. + tar cf - $name|gzip >$name.tgz +# /bin/rm -fr $name + cd $cwd +done + + diff --git a/src/lib/libcrypto/util/ssldir.pl b/src/lib/libcrypto/util/ssldir.pl new file mode 100644 index 0000000000..10584686da --- /dev/null +++ b/src/lib/libcrypto/util/ssldir.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +$#ARGV == 0 || die "usage: ssldir.pl /new/path\n"; +@files=('crypto/cryptlib.h', + 'Makefile.ssl', + 'tools/c_rehash', + 'util/mk1mf.pl', + ); + +%cryptlib=( + '\sX509_CERT_AREA\s',"#define X509_CERT_AREA\t\t".'"%s"', + '\sX509_CERT_DIR\s', "#define X509_CERT_DIR\t\t".'"%s/certs"', + '\sX509_CERT_FILE\s', "#define X509_CERT_FILE\t\t".'"%s/cert.pem"', + '\sX509_PRIVATE_DIR\s',"#define X509_PRIVATE_DIR\t".'"%s/private"', + ); + +%Makefile_ssl=( + '^INSTALLTOP=','INSTALLTOP=%s', + ); + +%c_rehash=( + '^DIR=', 'DIR=%s', + ); + +%mk1mf=( + '^$INSTALLTOP=','$INSTALLTOP="%s";', + ); + +&dofile("crypto/cryptlib.h",$ARGV[0],%cryptlib); +&dofile("Makefile.ssl",$ARGV[0],%Makefile_ssl); +&dofile("tools/c_rehash",$ARGV[0],%c_rehash); +&dofile("util/mk1mf.pl",$ARGV[0],%mk1mf); + +sub dofile + { + ($f,$p,%m)=@_; + + open(IN,"<$f") || die "unable to open $f:$!\n"; + @a=; + close(IN); + foreach $k (keys %m) + { + grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a); + } + ($ff=$f) =~ s/\..*$//; + open(OUT,">$ff.new") || die "unable to open $f:$!\n"; + print OUT @a; + close(OUT); + rename($f,"$ff.old") || die "unable to rename $f\n"; + rename("$ff.new",$f) || die "unable to rename $ff.new\n"; + } + diff --git a/src/lib/libcrypto/util/up_ver.pl b/src/lib/libcrypto/util/up_ver.pl new file mode 100644 index 0000000000..32c086b2aa --- /dev/null +++ b/src/lib/libcrypto/util/up_ver.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl +# +# Up the version numbers in the files. +# + +@files=( + "crypto/crypto.h", + "crypto/des/ecb_enc.c", + "crypto/idea/i_ecb.c", + "crypto/lhash/lhash.c", + "crypto/conf/conf.c", + "crypto/md2/md2_dgst.c", + "crypto/md5/md5_dgst.c", + "crypto/ripemd/rmd_dgst.c", + "crypto/pem/pem_lib.c", + "crypto/bn/bn_lib.c", + "crypto/dh/dh_lib.c", + "crypto/rc2/rc2_ecb.c", + "crypto/rc4/rc4_skey.c", + "crypto/rc5/rc5_ecb.c", + "crypto/bf/bf_ecb.c", + "crypto/cast/c_ecb.c", + "crypto/rsa/rsa_lib.c", + "crypto/dsa/dsa_lib.c", + "crypto/sha/sha1dgst.c", + "crypto/sha/sha_dgst.c", + "crypto/asn1/asn1_lib.c", + "crypto/x509/x509_vfy.c", + "crypto/evp/evp_enc.c", + "crypto/rand/md_rand.c", + "crypto/stack/stack.c", + "crypto/txt_db/txt_db.c", + "crypto/cversion.c", + "ssl/ssl_lib.c", + "ssl/s2_lib.c", + "ssl/s3_lib.c", + "ssl/t1_lib.c", + "README", + ); + +@month=('Jan','Feb','Mar','Apr','May','Jun', + 'Jul','Aug','Sep','Oct','Nov','Dec'); +@a=localtime(time()); +$time=sprintf("%02d-%s-%04d",$a[3],$month[$a[4]],$a[5]+1900); + +$ver=$ARGV[0]; +($ver ne "") || die "no version number specified\n"; +($a,$b,$c,$d)=unpack('axaxac',$ver); +$d=defined($d)?$d-96:0; +$xver=sprintf("%x%x%x%x",$a,$b,$c,$d); + +foreach $file (@files) + { + open(IN,"<$file") || die "unable to open $file:$!\n"; + open(OUT,">$file.new") || die "unable to open $file.new:$!\n"; + $found=0; + + print STDERR "$file:"; + + while () + { + if ((s/SSLeay \d\.\d.\d[^"]*(\"|\s)/SSLeay $ver $time\1/) || + s/^(\#define\s+SSLEAY_VERSION_NUMBER\s+0x)[0-9a-zA-Z]+(.*)$/$1$xver$2/) + { + print STDERR " Done"; + $found++; + print OUT; + while () { print OUT; } + last; + } + print OUT; + } + print STDERR "\n"; + close(IN); + close(OUT); + (!$found) && die "unable to update the version number in $file\n"; + rename($file,"$file.old") || die "unable to rename $file:$!\n"; + rename("$file.new",$file) || die "unable to rename $file.new:$!\n"; + } diff --git a/src/lib/libcrypto/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl new file mode 100644 index 0000000000..1c1ca2ffa0 --- /dev/null +++ b/src/lib/libcrypto/x509/Makefile.ssl @@ -0,0 +1,96 @@ +# +# SSLeay/crypto/x509/Makefile +# + +DIR= x509 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=x509 +ERRC=x509_err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \ + x509_obj.c x509_req.c x509_vfy.c \ + x509_set.c x509rset.c $(ERRC).c \ + x509name.c x509_v3.c x509_ext.c x509pack.c \ + x509type.c x509_lu.c x_all.c x509_txt.c \ + by_file.c by_dir.c \ + v3_net.c v3_x509.c +LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \ + x509_obj.o x509_req.o x509_vfy.o \ + x509_set.o x509rset.o $(ERRC).o \ + x509name.o x509_v3.o x509_ext.o x509pack.o \ + x509type.o x509_lu.o x_all.o x509_txt.o \ + by_file.o by_dir.o \ + v3_net.o v3_x509.o + +SRC= $(LIBSRC) + +EXHEADER= x509.h x509_vfy.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libcrypto/x509/attrib b/src/lib/libcrypto/x509/attrib new file mode 100644 index 0000000000..37f6cd755f --- /dev/null +++ b/src/lib/libcrypto/x509/attrib @@ -0,0 +1,38 @@ + +PKCS7 + STACK of X509_ATTRIBUTES + ASN1_OBJECT + STACK of ASN1_TYPE + +So it is + +p7.xa[].obj +p7.xa[].data[] + +get_obj_by_nid(STACK , nid) +get_num_by_nid(STACK , nid) +get_data_by_nid(STACK , nid, index) + +X509_ATTRIBUTE *X509_ATTRIBUTE_new(void ); +void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a); + +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **ex, + int nid, STACK *value); + +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **ex, + int nid, STACK *value); + +int X509_ATTRIBUTE_set_object(X509_ATTRIBUTE *ex,ASN1_OBJECT *obj); +int X509_ATTRIBUTE_add_data(X509_ATTRIBUTE *ex, int index, + ASN1_TYPE *value); + +ASN1_OBJECT * X509_ATTRIBUTE_get_object(X509_ATTRIBUTE *ex); +int X509_ATTRIBUTE_get_num(X509_ATTRIBUTE *ne); +ASN1_TYPE * X509_ATTRIBUTE_get_data(X509_ATTRIBUTE *ne,int index); + +ASN1_TYPE * X509_ATTRIBUTE_get_data_by_NID(X509_ATTRIBUTE *ne, + ASN1_OBJECT *obj); + +X509_ATTRUBUTE *PKCS7_get_s_att_by_NID(PKCS7 *p7,int nid); +X509_ATTRUBUTE *PKCS7_get_u_att_by_NID(PKCS7 *p7,int nid); + diff --git a/src/lib/libcrypto/x509/v3_net.c b/src/lib/libcrypto/x509/v3_net.c new file mode 100644 index 0000000000..0c2d276d13 --- /dev/null +++ b/src/lib/libcrypto/x509/v3_net.c @@ -0,0 +1,87 @@ +/* crypto/x509/v3_net.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "stack.h" +#include "cryptlib.h" +#include "asn1.h" +#include "objects.h" +#include "x509.h" + +#define NETSCAPE_X509_EXT_NUM 8 + +static X509_EXTENSION_METHOD netscape_x509_ext[NETSCAPE_X509_EXT_NUM]={ +{NID_netscape_ca_policy_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_ssl_server_name, V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_revocation_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_base_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_cert_type,V_ASN1_BIT_STRING,X509_EXT_PACK_STRING}, +{NID_netscape_ca_revocation_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_renewal_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_comment,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, + }; + +int X509v3_add_netscape_extensions() + { + int i; + + for (i=0; i +#include +#include "stack.h" +#include "cryptlib.h" +#include "bio.h" +#include "asn1.h" +#include "objects.h" +#include "x509.h" + +#if 0 +static int i2a_key_usage(BIO *bp, X509 *x); +static int a2i_key_usage(X509 *x, char *str, int len); +#endif + +int X509v3_get_key_usage(X509 *x); +int X509v3_set_key_usage(X509 *x,unsigned int use); +int i2a_X509v3_key_usage(BIO *bp, unsigned int use); +unsigned int a2i_X509v3_key_usage(char *p); + +#define STD_X509_EXT_NUM 9 + +#if 0 +static X509_OBJECTS std_x509_ext[STD_X509_EXT_NUM]={ +{NID_subject_key_identifier, NULL,NULL}, +{NID_key_usage, a2i_key_usage,i2a_key_usage}, /**/ +{NID_private_key_usage_period, NULL,NULL}, +{NID_subject_alt_name, NULL,NULL}, +{NID_issuer_alt_name, NULL,NULL}, +{NID_basic_constraints, NULL,NULL}, +{NID_crl_number, NULL,NULL}, +{NID_certificate_policies, NULL,NULL}, +{NID_authority_key_identifier, NULL,NULL}, + }; +#endif + +int X509v3_add_standard_extensions() + { + +#if 0 + for (i=0; i 0) + { + i=1; + data[0]=use&0xff; + } + if (use > 0xff) + { + i=2; + data[1]=(use>>8)&0xff; + } + return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1); + } + diff --git a/src/lib/libcrypto/x509/x509.doc b/src/lib/libcrypto/x509/x509.doc new file mode 100644 index 0000000000..73cfc9f034 --- /dev/null +++ b/src/lib/libcrypto/x509/x509.doc @@ -0,0 +1,27 @@ +X509_verify() +X509_sign() + +X509_get_version() +X509_get_serialNumber() +X509_get_issuer() +X509_get_subject() +X509_get_notBefore() +X509_get_notAfter() +X509_get_pubkey() + +X509_set_version() +X509_set_serialNumber() +X509_set_issuer() +X509_set_subject() +X509_set_notBefore() +X509_set_notAfter() +X509_set_pubkey() + +X509_get_extensions() +X509_set_extensions() + +X509_EXTENSIONS_clear() +X509_EXTENSIONS_retrieve() +X509_EXTENSIONS_add() +X509_EXTENSIONS_delete() + diff --git a/src/lib/libcrypto/x509/x509.err b/src/lib/libcrypto/x509/x509.err new file mode 100644 index 0000000000..8d0862d7d1 --- /dev/null +++ b/src/lib/libcrypto/x509/x509.err @@ -0,0 +1,46 @@ +/* Error codes for the X509 functions. */ + +/* Function codes. */ +#define X509_F_ADD_CERT_DIR 100 +#define X509_F_BY_FILE_CTRL 101 +#define X509_F_DIR_CTRL 102 +#define X509_F_GET_CERT_BY_SUBJECT 103 +#define X509_F_X509V3_ADD_EXT 104 +#define X509_F_X509V3_ADD_EXTENSION 105 +#define X509_F_X509V3_PACK_STRING 106 +#define X509_F_X509V3_UNPACK_STRING 107 +#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 +#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 +#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 +#define X509_F_X509_LOAD_CERT_FILE 111 +#define X509_F_X509_LOAD_CRL_FILE 112 +#define X509_F_X509_NAME_ADD_ENTRY 113 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 +#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 +#define X509_F_X509_NAME_ONELINE 116 +#define X509_F_X509_NAME_PRINT 117 +#define X509_F_X509_PRINT_FP 118 +#define X509_F_X509_PUBKEY_GET 119 +#define X509_F_X509_PUBKEY_SET 120 +#define X509_F_X509_REQ_PRINT 121 +#define X509_F_X509_REQ_PRINT_FP 122 +#define X509_F_X509_REQ_TO_X509 123 +#define X509_F_X509_STORE_ADD_CERT 124 +#define X509_F_X509_STORE_ADD_CRL 125 +#define X509_F_X509_TO_X509_REQ 126 +#define X509_F_X509_VERIFY_CERT 127 + +/* Reason codes. */ +#define X509_R_BAD_X509_FILETYPE 100 +#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +#define X509_R_ERR_ASN1_LIB 102 +#define X509_R_LOADING_CERT_DIR 103 +#define X509_R_LOADING_DEFAULTS 104 +#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +#define X509_R_SHOULD_RETRY 106 +#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +#define X509_R_UNKNOWN_NID 109 +#define X509_R_UNKNOWN_STRING_TYPE 110 +#define X509_R_UNSUPPORTED_ALGORITHM 111 +#define X509_R_WRONG_LOOKUP_TYPE 112 diff --git a/src/lib/libcrypto/x509/x509pack.c b/src/lib/libcrypto/x509/x509pack.c new file mode 100644 index 0000000000..846f125859 --- /dev/null +++ b/src/lib/libcrypto/x509/x509pack.c @@ -0,0 +1,157 @@ +/* crypto/x509/x509pack.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "stack.h" +#include "cryptlib.h" +#include "asn1.h" +#include "objects.h" +#include "evp.h" +#include "x509.h" + +ASN1_OCTET_STRING *X509v3_pack_string(ex,type,bytes,len) +ASN1_OCTET_STRING **ex; +int type; +unsigned char *bytes; +int len; + { + ASN1_OCTET_STRING *os; + ASN1_STRING str; + unsigned char *p; + int i; + + if ((ex == NULL) || (*ex == NULL)) + os=ASN1_OCTET_STRING_new(); + else + os= *ex; + + if (len < 0) len=strlen((char *)bytes); + str.length=len; + str.type=type; + str.data=bytes; + + /* str now holds the data, we just have to copy it into ->value */ + + switch (type) + { + case V_ASN1_BIT_STRING: + i=i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,NULL); + if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i)) + goto err; + p=(unsigned char *)os->data; + i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,&p); + break; + case V_ASN1_OCTET_STRING: + i=i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,NULL); + if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i)) + goto err; + p=(unsigned char *)os->data; + i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,&p); + break; + case V_ASN1_IA5STRING: + case V_ASN1_PRINTABLESTRING: + case V_ASN1_T61STRING: + i=i2d_ASN1_bytes(&str,NULL,type,V_ASN1_UNIVERSAL); + if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i)) + goto err; + p=(unsigned char *)os->data; + i=i2d_ASN1_bytes(&str,&p,type,V_ASN1_UNIVERSAL); + break; + default: + X509err(X509_F_X509V3_PACK_STRING,X509_R_UNKNOWN_STRING_TYPE); + goto err; + } + os->length=i; + + if ((ex != NULL) && (os != *ex)) + *ex=os; + return(os); +err: + return(NULL); + } + +ASN1_STRING *X509v3_unpack_string(ex,type,os) +ASN1_STRING **ex; +int type; +ASN1_OCTET_STRING *os; + { + unsigned char *p; + ASN1_STRING *ret=NULL; + + p=os->data; + switch (type) + { + case V_ASN1_BIT_STRING: + ret=(ASN1_STRING *)d2i_ASN1_BIT_STRING( + (ASN1_BIT_STRING **)ex,&p,os->length); + break; + case V_ASN1_OCTET_STRING: + ret=(ASN1_STRING *)d2i_ASN1_OCTET_STRING( + (ASN1_BIT_STRING **)ex,&p,os->length); + break; + case V_ASN1_IA5STRING: + case V_ASN1_PRINTABLESTRING: + case V_ASN1_T61STRING: + ret=(ASN1_STRING *)d2i_ASN1_PRINTABLE(ex,&p,os->length); + break; + default: + X509err(X509_F_X509V3_UNPACK_STRING,X509_R_UNKNOWN_STRING_TYPE); + } + return(ret); + } + diff --git a/src/lib/libcrypto/x509/x509v3.doc b/src/lib/libcrypto/x509/x509v3.doc new file mode 100644 index 0000000000..1e760a9469 --- /dev/null +++ b/src/lib/libcrypto/x509/x509v3.doc @@ -0,0 +1,24 @@ +The 'new' system. + +The X509_EXTENSION_METHOD includes extensions and attributes and/or names. +Basically everthing that can be added to an X509 with an OID identifying it. + +It operates via 2 methods per object id. +int a2i_XXX(X509 *x,char *str,int len); +int i2a_XXX(BIO *bp,X509 *x); + +The a2i_XXX function will add the object with a value converted from the +string into the X509. Len can be -1 in which case the length is calculated +via strlen(str). Applications can always use direct knowledge to load and +unload the relevent objects themselves. + +i2a_XXX will print to the passed BIO, a text representation of the +relevet object. Use a memory BIO if you want it printed to a buffer :-). + +X509_add_by_NID(X509 *x,int nid,char *str,int len); +X509_add_by_OBJ(X509 *x,ASN1_OBJECT *obj,char *str,int len); + +X509_print_by_name(BIO *bp,X509 *x); +X509_print_by_NID(BIO *bp,X509 *x); +X509_print_by_OBJ(BIO *bp,X509 *x); + diff --git a/src/lib/libcrypto/x509v3/format b/src/lib/libcrypto/x509v3/format new file mode 100644 index 0000000000..3307978121 --- /dev/null +++ b/src/lib/libcrypto/x509v3/format @@ -0,0 +1,92 @@ +AuthorityKeyIdentifier + { + keyIdentifier [0] OCTET_STRING OPTIONAL + authorityCertIssuer [1] GeneralNames OPTIONAL + authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL + } + +SubjectKeyIdentifier OCTET_STRING + +KeyUsage + { + BIT_STRING + digitalSignature 0 + nonRepudiation 1 + keyEncipherment 2 + dataEncipherment 3 + keyAgreement 4 + keyCertSign 5 + cRLSign 6 + encipherOnly 7 + decipherOnly 8 + } + +extKeyUsage + { + SEQUENCE of OBJECT_IDENTIFIER + } + +privateKeyUsagePeriod + { + notBefore [0] GeneralizedTime OPTIONAL + notAfter [1] GeneralizedTime OPTIONAL + } + +certificatePoliciesSyntax + SEQUENCE of PoliciesInformation + +PoliciesInformation XXX +policyMappings XXX +supportedAlgorithms XXX + +subjectAltName + GeneralNames sequence of GeneralName + +GeneralName + { + otherName [0] INSTANCE OF OTHER-NAME + rfc882Name [1] IA5String + dNSName [2] IA5String + x400Address [3] ORAddress + directoryName [4] Name + ediPartyName [5] + { + nameAssigner [0] DirectoryString OPTIONAL + partyName [1] DirectoryString + } + uniformResourceIdentifier [6] IA5String + iPAddress [7] OCTET_STRING + registeredID [8] OBJECT_IDENTIFIER + } + +issuerAltName + GeneralNames sequence of GeneralName + +subjectDirectoryAttribute SEQUENCE of Attribute + +basicConstraints + { + cA BOOLEAN default FALSE + pathLenConstraint INTEGER OPTIONAL + } + +nameConstraints + { + permittedSubtrees [0] sequence of GeneralSubtree OPTIONAL + excludedSubtrees [1] sequence of GeneralSubtree OPTIONAL + } + +GeneralSubtree + { + base GeneralName + minimum [0] BaseDistance DEFAULT 0 + maximum [1] BaseDistance OPTIONAL + } + +PolicyConstraints + { + requiredExplicitPolicy [0] SkipCerts OPTIONAL + inhibitPolicyMapping [1] SkipCerts OPTIONAL + } +SkipCerts == INTEGER + diff --git a/src/lib/libcrypto/x509v3/header b/src/lib/libcrypto/x509v3/header new file mode 100644 index 0000000000..3d791ca3dd --- /dev/null +++ b/src/lib/libcrypto/x509v3/header @@ -0,0 +1,6 @@ +int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size) +int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a) +int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp) +ASN1_INTEGER * d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,long length) + + diff --git a/src/lib/libcrypto/x509v3/v3_ku.c b/src/lib/libcrypto/x509v3/v3_ku.c new file mode 100644 index 0000000000..87c7402f43 --- /dev/null +++ b/src/lib/libcrypto/x509v3/v3_ku.c @@ -0,0 +1,318 @@ +/* crypto/x509v3/v3_ku.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include "stack.h" +#include "cryptlib.h" +#include "bio.h" +#include "asn1.h" +#include "objects.h" +#include "x509.h" + +X509_EXTENSION_METHOD X509v3_key_usage_method= + { + NID_key_usage, + ku_clear, + ex_get_bool, + ex_set_bool, + NULL, + NULL, + NULL, + NULL, + ku_a2i, + ku_i2a, + }; + +static void ku_clear(a) +X509_EXTENSION *a; + { + } + +static int ku_expand(a) +X509_EXTENSION *a; + { + ASN1_BIT_STRING *bs; + + if (a->argp == NULL) + { + bs=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,value); + if (bs == NULL) return(0); + a->argp=(char *)bs; + a->ex_free=ASN1_STRING_free; + } + return(1); + } + +static int ku_get_bool(a,num) +X509_EXTENSION *a; +int num; + { + int ret; + ASN1_BIT_STRING *bs; + + if ((a->argp == NULL) && !ku_expand(a)) + return(-1); + bs=(ASN1_BIT_STRING *)a->argp; + ret=ASN1_BIT_STRING_get_bit(bs,num); + return(ret); + } + +static int ku_set_bool(a,num,value) +X509_EXTENSION *a; +int num; +int value; + { + ASN1_BIT_STRING *a; + + if ((a->argp == NULL) && !ku_expand(a)) + return(0); + bs=(ASN1_BIT_STRING *)a->argp; + ret=ASN1_BIT_STRING_set_bit(bs,num,value); + } + +static int ku_a2i(bio,a,buf,len) +BIO *bio; +X509_EXTENSION *a; +char *buf; +int len; + { + get token + } + +static char ku_names[X509v3_N_KU_NUM]={ + X509v3_S_KU_digitalSignature, + X509v3_S_KU_nonRepudiation, + X509v3_S_KU_keyEncipherment, + X509v3_S_KU_dataEncipherment, + X509v3_S_KU_keyAgreement, + X509v3_S_KU_keyCertSign, + X509v3_S_KU_cRLSign, + X509v3_S_KU_encipherOnly, + X509v3_S_KU_decipherOnly, + }; + +static int ku_i2a(bio,a); +BIO *bio; +X509_EXTENSION *a; + { + int i,first=1; + char *c; + + for (i=0; i 0) + { + BIO_printf(bio,"%s%s",((first)?"":" "),ku_names[i]); + first=0; + } + } + } + +/***********************/ + +int X509v3_get_key_usage(x,ret) +STACK *x; +unsigned long *ret; + { + X509_EXTENSION *ext; + ASN1_STRING *st; + char *p; + int i; + + i=X509_get_ext_by_NID(x,NID_key_usage,-1); + if (i < 0) return(X509v3_KU_UNDEF); + ext=X509_get_ext(x,i); + st=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING, + X509_EXTENSION_get_data(X509_get_ext(x,i))); + + p=ASN1_STRING_data(st); + if (ASN1_STRING_length(st) == 1) + i=p[0]; + else if (ASN1_STRING_length(st) == 2) + i=p[0]|(p[1]<<8); + else + i=0; + return(i); + } + +static struct + { + char *name; + unsigned int value; + } key_usage_data[] ={ + {"digitalSignature", X509v3_KU_DIGITAL_SIGNATURE}, + {"nonRepudiation", X509v3_KU_NON_REPUDIATION}, + {"keyEncipherment", X509v3_KU_KEY_ENCIPHERMENT}, + {"dataEncipherment", X509v3_KU_DATA_ENCIPHERMENT}, + {"keyAgreement", X509v3_KU_KEY_AGREEMENT}, + {"keyCertSign", X509v3_KU_KEY_CERT_SIGN}, + {"cRLSign", X509v3_KU_CRL_SIGN}, + {"encipherOnly", X509v3_KU_ENCIPHER_ONLY}, + {"decipherOnly", X509v3_KU_DECIPHER_ONLY}, + {NULL,0}, + }; + +#if 0 +static int a2i_key_usage(x,str,len) +X509 *x; +char *str; +int len; + { + return(X509v3_set_key_usage(x,a2i_X509v3_key_usage(str))); + } + +static int i2a_key_usage(bp,x) +BIO *bp; +X509 *x; + { + return(i2a_X509v3_key_usage(bp,X509v3_get_key_usage(x))); + } +#endif + +int i2a_X509v3_key_usage(bp,use) +BIO *bp; +unsigned int use; + { + int i=0,first=1; + + for (;;) + { + if (use | key_usage_data[i].value) + { + BIO_printf(bp,"%s%s",((first)?"":" "), + key_usage_data[i].name); + first=0; + } + } + return(1); + } + +unsigned int a2i_X509v3_key_usage(p) +char *p; + { + unsigned int ret=0; + char *q,*s; + int i,n; + + q=p; + for (;;) + { + while ((*q != '\0') && isalnum(*q)) + q++; + if (*q == '\0') break; + s=q++; + while (isalnum(*q)) + q++; + n=q-s; + i=0; + for (;;) + { + if (strncmp(key_usage_data[i].name,s,n) == 0) + { + ret|=key_usage_data[i].value; + break; + } + i++; + if (key_usage_data[i].name == NULL) + return(X509v3_KU_UNDEF); + } + } + return(ret); + } + +int X509v3_set_key_usage(x,use) +X509 *x; +unsigned int use; + { + ASN1_OCTET_STRING *os; + X509_EXTENSION *ext; + int i; + unsigned char data[4]; + + i=X509_get_ext_by_NID(x,NID_key_usage,-1); + if (i < 0) + { + i=X509_get_ext_count(x)+1; + if ((ext=X509_EXTENSION_new()) == NULL) return(0); + if (!X509_add_ext(x,ext,i)) + { + X509_EXTENSION_free(ext); + return(0); + } + } + else + ext=X509_get_ext(x,i); + + /* fill in 'ext' */ + os=X509_EXTENSION_get_data(ext); + + i=0; + if (use > 0) + { + i=1; + data[0]=use&0xff; + } + if (use > 0xff) + { + i=2; + data[1]=(use>>8)&0xff; + } + return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1); + } + diff --git a/src/lib/libssl/Makefile b/src/lib/libssl/Makefile new file mode 100644 index 0000000000..d79795e0f3 --- /dev/null +++ b/src/lib/libssl/Makefile @@ -0,0 +1,12 @@ +.include + +ECHO= /bin/echo + +.if exists(${.OBJDIR}/src-patent) +SUBDIR= crypto-patent ssl-patent ssleay +.else +SUBDIR= crypto ssl ssleay +.endif + +.include + diff --git a/src/lib/libssl/Makefile.bsd-wrapper b/src/lib/libssl/Makefile.bsd-wrapper new file mode 100644 index 0000000000..20fc0cec1e --- /dev/null +++ b/src/lib/libssl/Makefile.bsd-wrapper @@ -0,0 +1,82 @@ +# Build wrapper for SSLeay. + +# Our lndir is hacked; specify a full path to avoid potential conflicts +# with the one installed with X11. +LNDIR= /usr/bin/lndir + + +# Figure out what flag we use to SSLeay's configure. This +# needs to be tested on all architectures. + +.if ${MACHINE_ARCH} == "i386" +SSLCONF= OpenBSD-x86 +.else +.if ${MACHINE_ARCH} == "alpha" +SSLCONF= OpenBSD-alpha +.else +.if ${MACHINE_ARCH} == "sparc" +SSLCONF= OpenBSD-bigendian +.else +##UNTESTED! +SSLCONF= OpenBSD-bigendian +.endif +.endif +.endif + + +.include + +#CLEANFILES = crypto/bf/bf_locl.h crypto/bn/bn.h crypto/des/des.h \ +# crypto/des/des_locl.h crypto/rc2/rc2.h crypto/md2/md2.h \ +# crypto/rc4/rc4.h crypto/rc4/rc4_locl.h crypto/idea/idea.h + +.if exists(src-patent) +SSL_SRC=src-patent +.else +SSL_SRC=src +.endif + +.BEGIN: + @if [ ${.CURDIR} != ${.OBJDIR} ]; then ${LNDIR} -s -e obj -e obj.${MACHINE_ARCH} -e Makefile.bsd-wrapper -e Makefile.ssl ${.CURDIR}; fi + +all: ${SSL_SRC}/crypto/md2/md2.h + (cd ${.OBJDIR}; ${MAKE}) + +includes: ${SSL_SRC}/crypto/md2/md2.h + (cd ${.OBJDIR}; ${MAKE} includes) + +install: + (cd ${.OBJDIR}; ${MAKE} install) + +${SSL_SRC}/crypto/md2/md2.h : ${SSL_SRC}/Makefile.ssl + (cd ${.OBJDIR}/${SSL_SRC}; /usr/bin/perl Configure ${SSLCONF}) + +${SSL_SRC}/Makefile.ssl: ${.CURDIR}/${SSL_SRC}/Makefile.ssl + (cp ${.CURDIR}/${SSL_SRC}/Makefile.ssl ${.OBJDIR}/${SSL_SRC}) + + +clean: + (cd ${.OBJDIR}; ${MAKE} clean) + +cleandir: + (cd ${.OBJDIR}; rm -f ${SSL_SRC}/crypto/md2/md2.h; ${MAKE} cleandir) + +test: + # Nothing here so far... + +depend: + # Nothing here so far... + +lint: + # Nothing here so far... + +tags: + # Nothing here so far... + +.include +.include + + + + + diff --git a/src/lib/libssl/README.OPENBSD b/src/lib/libssl/README.OPENBSD new file mode 100644 index 0000000000..7cc3d0d424 --- /dev/null +++ b/src/lib/libssl/README.OPENBSD @@ -0,0 +1,66 @@ + + This is an SSLeay-0.9.0b (the b means the PKCS#1 bug is fixed) tree. + + It has the following modifcations made to it. + + 0) util/perlpath.pl has been run to change perlpath to /usr/bin + util/ssldir.pl has been run to change the ssl dir to /usr/ssl + Null check added to crypto/err/err.c (mailed to Eric Young) + to avoid problems in error handling. Includes install into + /usr/include/ssl, certs and configs are expected to be in + /etc/ssl. + + 1) Changes for openbsd compilation to have been made to + config and Configure (these have been sent to Eric Young) + +NOTES: + + Many tests will fail miserably, since most of them start + with SSL v2, which requires RSA, and of course, they barf. + idea tests will also fail. This is to be expected. Do + "make -k test" if you want to see the output and draw + your own conclusions. + + Many parts of the utility programs may not work, although things + like client and server will provided you start them in a mode + that does not require RSA to operate. + + Unlike an ssl library built to remove the offending routines + (which removes many of the things like SSL23init which many + packages like web servers use) this library does contain + stubs for everything. The patent bits will simply fail. The + idea is that this may be used as is for limited functionality, + or where possible replaced with a full function library. When + porting an app it is important to remember to try to use the + tls1 version of stuff first where possible. I.E. if you're + going to SSL-ize OpenBSD telnet, for example, call the tls1 init + functions *NOT* sslv2init or sslv23init, or you'll be dependent + on RSA and have a version that will only work with a full + function library. Use the tls versions and you'll work with + both - a good thing. + + "crypto" and "ssl" are OpenBSD style build dirs for the + libraries of the same name. "ssleay" is the build dir for the + "ssleay" executable, used to control everything vagely ssleay + like, from testing to generating certificates, to playing + simple client server games. libraries expect to install headers + in "/usr/include/ssl", libraries in /usr/lib, ssleay in /usr/sbin + +TODO: + SSLeay contains just no library docs, it's all use the + force, read the source. This should be fixed sometime. + + DSS certificate generation is a black art. This + needs to be properly documented and a comprehensive procedure + written up, at least for how to generate a cert for + a host to be used by multiple servers. beck@ has talked + to Mark Shuttleworth of Thawte, and he has agreed that + if we can get DSS hosts certs up and running Thawte will + consider providing the service (for the usual fee of course) + of for-real signing of OpenBSD host certs for those who + want a real CA for things like telnet and ftp and the like. + + Apps beyond ssleay need testing - apps that use exclusively old style + sslv2 or sslv2/3 need to be converted/modified where possible to + try the tls1 stuff, so that we can handle doing things without + RSA. diff --git a/src/lib/libssl/crypto-patent/Makefile b/src/lib/libssl/crypto-patent/Makefile new file mode 100644 index 0000000000..b08ad38763 --- /dev/null +++ b/src/lib/libssl/crypto-patent/Makefile @@ -0,0 +1,170 @@ + +LIB= crypto + +SSLEAYDIST= src-patent + +LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto +SSLEAY_INC= ${.CURDIR}/../${SSLEAYDIST}/include + +.if ${MACHINE_ARCH} == "i386" +CFLAGS+= -DL_ENDIAN -DBN_ASM +.else +.if ${MACHINE_ARCH} == "alpha" +# no ENDIAN stuff defined for alpha +.else +CFLAGS+= -DB_ENDIAN +.endif +.endif + +CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE +CFLAGS+= -I${SSLEAY_INC} +CFLAGS+= -I${LCRYPTO_SRC} +SRCS+= cryptlib.c mem.c cversion.c ex_data.c cpt_err.c +CFLAGS+= -I${LCRYPTO_SRC}/md2 +SRCS+= md2_dgst.c md2_one.c +CFLAGS+= -I${LCRYPTO_SRC}/md5 +SRCS+= md5_dgst.c md5_one.c +CFLAGS+= -I${LCRYPTO_SRC}/sha +SRCS+= sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +CFLAGS+= -I${LCRYPTO_SRC}/mdc2 +SRCS+= mdc2dgst.c mdc2_one.c +CFLAGS+= -I${LCRYPTO_SRC}/hmac +SRCS+= hmac.c +CFLAGS+= -I${LCRYPTO_SRC}/ripemd +SRCS+= rmd_dgst.c rmd_one.c +CFLAGS+= -I${LCRYPTO_SRC}/des +SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ + ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \ + fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ + qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ + des_enc.c fcrypt_b.c read2pwd.c \ + fcrypt.c xcbc_enc.c \ + str2key.c cfb64ede.c ofb64ede.c supp.c +CFLAGS+= -I${LCRYPTO_SRC}/rc2 +SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c +SRCS+= rc2ofb64.c +CFLAGS+= -I${LCRYPTO_SRC}/rc4 +SRCS+= rc4_skey.c rc4_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/rc5 +SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c +SRCS+= rc5ofb64.c rc5_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/idea +SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c +SRCS+= i_skey.c +CFLAGS+= -I${LCRYPTO_SRC}/bf +SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c bf_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/cast +SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/bn +SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c +SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c +SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c +SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c +CFLAGS+= -I${LCRYPTO_SRC}/rsa +SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c +SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c +SRCS+= rsa_none.c +CFLAGS+= -I${LCRYPTO_SRC}/dsa +SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c +SRCS+= dsa_sign.c dsa_err.c +CFLAGS+= -I${LCRYPTO_SRC}/dh +SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c +CFLAGS+= -I${LCRYPTO_SRC}/buffer +SRCS+= buffer.c buf_err.c +CFLAGS+= -I${LCRYPTO_SRC}/bio +SRCS+= bio_lib.c bio_cb.c bio_err.c bss_mem.c +SRCS+= bss_null.c bss_fd.c bss_file.c bss_sock.c +SRCS+= bss_conn.c bf_null.c bf_buff.c +SRCS+= b_print.c b_dump.c b_sock.c bss_acpt.c +SRCS+= bf_nbio.c +CFLAGS+= -I${LCRYPTO_SRC}/stack +SRCS+= stack.c +CFLAGS+= -I${LCRYPTO_SRC}/lhash +SRCS+= lhash.c lh_stats.c +CFLAGS+= -I${LCRYPTO_SRC}/rand +SRCS+= md_rand.c randfile.c +CFLAGS+= -I${LCRYPTO_SRC}/err +SRCS+= err.c err_all.c err_prn.c +CFLAGS+= -I${LCRYPTO_SRC}/objects +SRCS+= obj_dat.c obj_lib.c obj_err.c +CFLAGS+= -I${LCRYPTO_SRC}/evp +SRCS+= encode.c digest.c evp_enc.c evp_key.c +SRCS+= e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c +SRCS+= e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c +SRCS+= e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c +SRCS+= e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c +SRCS+= e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c +SRCS+= e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c +SRCS+= e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c +SRCS+= e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c +SRCS+= m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c +SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c +SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c +SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c +SRCS+= evp_err.c e_null.c c_all.c evp_lib.c +CFLAGS+= -I${LCRYPTO_SRC}/pem +SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c +SRCS+= pem_all.c pem_err.c +CFLAGS+= -I${LCRYPTO_SRC}/asn1 +SRCS+= a_object.c a_bitstr.c a_utctm.c a_int.c +SRCS+= a_octet.c a_print.c a_type.c a_set.c +SRCS+= a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c +SRCS+= a_digest.c a_verify.c x_algor.c x_val.c +SRCS+= x_pubkey.c x_sig.c x_req.c x_attrib.c +SRCS+= x_name.c x_cinf.c x_x509.c x_crl.c +SRCS+= x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c +SRCS+= d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c +SRCS+= d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c +SRCS+= i2d_pu.c i2d_pr.c t_req.c t_x509.c +SRCS+= t_pkey.c p7_i_s.c p7_signi.c p7_signd.c +SRCS+= p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c +SRCS+= p7_s_e.c p7_enc.c p7_lib.c f_int.c +SRCS+= f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c +SRCS+= d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c +SRCS+= a_bool.c x_exten.c asn1_par.c asn1_lib.c +SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c +CFLAGS+= -I${LCRYPTO_SRC}/x509 +SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c +SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c +SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c +SRCS+= x509_ext.c x509pack.c x509type.c x509_lu.c +SRCS+= x_all.c x509_txt.c by_file.c by_dir.c +SRCS+= v3_net.c v3_x509.c +CFLAGS+= -I${LCRYPTO_SRC}/conf +SRCS+= conf.c conf_err.c +CFLAGS+= -I${LCRYPTO_SRC}/txt_db +SRCS+= txt_db.c +CFLAGS+= -I${LCRYPTO_SRC}/pkcs7 +SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c + +HDRS= asn1/asn1.h asn1/asn1_mac.h bf/blowfish.h bio/bio.h \ + bn/bn.h buffer/buffer.h cast/cast.h conf/conf.h des/des.h dh/dh.h \ + dsa/dsa.h err/err.h evp/evp.h hmac/hmac.h idea/idea.h lhash/lhash.h \ + md2/md2.h md5/md5.h mdc2/mdc2.h objects/objects.h pem/pem.h \ + pkcs7/pkcs7.h rand/rand.h rc2/rc2.h rc4/rc4.h rc5/rc5.h \ + ripemd/ripemd.h rsa/rsa.h sha/sha.h stack/stack.h txt_db/txt_db.h \ + x509/x509.h x509/x509_vfy.h crypto.h cryptall.h ../include/e_os.h + +.PATH: ${LCRYPTO_SRC}/md2 ${LCRYPTO_SRC}/md5 ${LCRYPTO_SRC}/sha ${LCRYPTO_SRC}/mdc2 \ + ${LCRYPTO_SRC}/hmac ${LCRYPTO_SRC}/ripemd ${LCRYPTO_SRC}/des ${LCRYPTO_SRC}/rc2 \ + ${LCRYPTO_SRC}/rc4 ${LCRYPTO_SRC}/rc5 ${LCRYPTO_SRC}/idea ${LCRYPTO_SRC}/bf \ + ${LCRYPTO_SRC}/cast ${LCRYPTO_SRC}/bn ${LCRYPTO_SRC}/rsa ${LCRYPTO_SRC}/dsa \ + ${LCRYPTO_SRC}/dh ${LCRYPTO_SRC}/buffer ${LCRYPTO_SRC}/bio ${LCRYPTO_SRC}/stack \ + ${LCRYPTO_SRC}/lhash ${LCRYPTO_SRC}/rand ${LCRYPTO_SRC}/err ${LCRYPTO_SRC}/objects \ + ${LCRYPTO_SRC}/evp ${LCRYPTO_SRC}/pem ${LCRYPTO_SRC}/asn1 ${LCRYPTO_SRC}/asn1 \ + ${LCRYPTO_SRC}/x509 ${LCRYPTO_SRC}/conf txt_db/txt_db.c ${LCRYPTO_SRC}/pkcs7 \ + ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC} + +includes: + @cd ${LCRYPTO_SRC}; for i in $(HDRS); do \ + j="cmp -s ${LCRYPTO_SRC}/$$i \ + ${DESTDIR}/usr/include/ssl/`basename $$i` || \ + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \ + ${LCRYPTO_SRC}/$$i ${DESTDIR}/usr/include/ssl"; \ + echo $$j; \ + eval "$$j"; \ + done + + +.include + diff --git a/src/lib/libssl/crypto-patent/shlib_version b/src/lib/libssl/crypto-patent/shlib_version new file mode 100644 index 0000000000..893819d18f --- /dev/null +++ b/src/lib/libssl/crypto-patent/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=1 diff --git a/src/lib/libssl/crypto/Makefile b/src/lib/libssl/crypto/Makefile new file mode 100644 index 0000000000..ec9e75dd4d --- /dev/null +++ b/src/lib/libssl/crypto/Makefile @@ -0,0 +1,170 @@ + +LIB= crypto + +SSLEAYDIST= src + +LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto +SSLEAY_INC= ${.CURDIR}/../${SSLEAYDIST}/include + +.if ${MACHINE_ARCH} == "i386" +CFLAGS+= -DL_ENDIAN -DBN_ASM +.else +.if ${MACHINE_ARCH} == "alpha" +# no ENDIAN stuff defined for alpha +.else +CFLAGS+= -DB_ENDIAN +.endif +.endif + +CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE +CFLAGS+= -I${SSLEAY_INC} +CFLAGS+= -I${LCRYPTO_SRC} +SRCS+= cryptlib.c mem.c cversion.c ex_data.c cpt_err.c +CFLAGS+= -I${LCRYPTO_SRC}/md2 +SRCS+= md2_dgst.c md2_one.c +CFLAGS+= -I${LCRYPTO_SRC}/md5 +SRCS+= md5_dgst.c md5_one.c +CFLAGS+= -I${LCRYPTO_SRC}/sha +SRCS+= sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +CFLAGS+= -I${LCRYPTO_SRC}/mdc2 +SRCS+= mdc2dgst.c mdc2_one.c +CFLAGS+= -I${LCRYPTO_SRC}/hmac +SRCS+= hmac.c +CFLAGS+= -I${LCRYPTO_SRC}/ripemd +SRCS+= rmd_dgst.c rmd_one.c +CFLAGS+= -I${LCRYPTO_SRC}/des +SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ + ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \ + fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ + qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ + des_enc.c fcrypt_b.c read2pwd.c \ + fcrypt.c xcbc_enc.c \ + str2key.c cfb64ede.c ofb64ede.c supp.c +CFLAGS+= -I${LCRYPTO_SRC}/rc2 +SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c +SRCS+= rc2ofb64.c +CFLAGS+= -I${LCRYPTO_SRC}/rc4 +SRCS+= rc4_skey.c rc4_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/rc5 +SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c +SRCS+= rc5ofb64.c rc5_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/idea +SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c +SRCS+= i_skey.c +CFLAGS+= -I${LCRYPTO_SRC}/bf +SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c bf_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/cast +SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c +CFLAGS+= -I${LCRYPTO_SRC}/bn +SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c +SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c +SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c +SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c +CFLAGS+= -I${LCRYPTO_SRC}/rsa +SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c +SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c +SRCS+= rsa_none.c +CFLAGS+= -I${LCRYPTO_SRC}/dsa +SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c +SRCS+= dsa_sign.c dsa_err.c +CFLAGS+= -I${LCRYPTO_SRC}/dh +SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c +CFLAGS+= -I${LCRYPTO_SRC}/buffer +SRCS+= buffer.c buf_err.c +CFLAGS+= -I${LCRYPTO_SRC}/bio +SRCS+= bio_lib.c bio_cb.c bio_err.c bss_mem.c +SRCS+= bss_null.c bss_fd.c bss_file.c bss_sock.c +SRCS+= bss_conn.c bf_null.c bf_buff.c +SRCS+= b_print.c b_dump.c b_sock.c bss_acpt.c +SRCS+= bf_nbio.c +CFLAGS+= -I${LCRYPTO_SRC}/stack +SRCS+= stack.c +CFLAGS+= -I${LCRYPTO_SRC}/lhash +SRCS+= lhash.c lh_stats.c +CFLAGS+= -I${LCRYPTO_SRC}/rand +SRCS+= md_rand.c randfile.c +CFLAGS+= -I${LCRYPTO_SRC}/err +SRCS+= err.c err_all.c err_prn.c +CFLAGS+= -I${LCRYPTO_SRC}/objects +SRCS+= obj_dat.c obj_lib.c obj_err.c +CFLAGS+= -I${LCRYPTO_SRC}/evp +SRCS+= encode.c digest.c evp_enc.c evp_key.c +SRCS+= e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c +SRCS+= e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c +SRCS+= e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c +SRCS+= e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c +SRCS+= e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c +SRCS+= e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c +SRCS+= e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c +SRCS+= e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c +SRCS+= m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c +SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c +SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c +SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c +SRCS+= evp_err.c e_null.c c_all.c evp_lib.c +CFLAGS+= -I${LCRYPTO_SRC}/pem +SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c +SRCS+= pem_all.c pem_err.c +CFLAGS+= -I${LCRYPTO_SRC}/asn1 +SRCS+= a_object.c a_bitstr.c a_utctm.c a_int.c +SRCS+= a_octet.c a_print.c a_type.c a_set.c +SRCS+= a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c +SRCS+= a_digest.c a_verify.c x_algor.c x_val.c +SRCS+= x_pubkey.c x_sig.c x_req.c x_attrib.c +SRCS+= x_name.c x_cinf.c x_x509.c x_crl.c +SRCS+= x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c +SRCS+= d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c +SRCS+= d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c +SRCS+= i2d_pu.c i2d_pr.c t_req.c t_x509.c +SRCS+= t_pkey.c p7_i_s.c p7_signi.c p7_signd.c +SRCS+= p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c +SRCS+= p7_s_e.c p7_enc.c p7_lib.c f_int.c +SRCS+= f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c +SRCS+= d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c +SRCS+= a_bool.c x_exten.c asn1_par.c asn1_lib.c +SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c +CFLAGS+= -I${LCRYPTO_SRC}/x509 +SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c +SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c +SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c +SRCS+= x509_ext.c x509pack.c x509type.c x509_lu.c +SRCS+= x_all.c x509_txt.c by_file.c by_dir.c +SRCS+= v3_net.c v3_x509.c +CFLAGS+= -I${LCRYPTO_SRC}/conf +SRCS+= conf.c conf_err.c +CFLAGS+= -I${LCRYPTO_SRC}/txt_db +SRCS+= txt_db.c +CFLAGS+= -I${LCRYPTO_SRC}/pkcs7 +SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c + +HDRS= asn1/asn1.h asn1/asn1_mac.h bf/blowfish.h bio/bio.h \ + bn/bn.h buffer/buffer.h cast/cast.h conf/conf.h des/des.h dh/dh.h \ + dsa/dsa.h err/err.h evp/evp.h hmac/hmac.h idea/idea.h lhash/lhash.h \ + md2/md2.h md5/md5.h mdc2/mdc2.h objects/objects.h pem/pem.h \ + pkcs7/pkcs7.h rand/rand.h rc2/rc2.h rc4/rc4.h rc5/rc5.h \ + ripemd/ripemd.h rsa/rsa.h sha/sha.h stack/stack.h txt_db/txt_db.h \ + x509/x509.h x509/x509_vfy.h crypto.h cryptall.h ../include/e_os.h + +.PATH: ${LCRYPTO_SRC}/md2 ${LCRYPTO_SRC}/md5 ${LCRYPTO_SRC}/sha ${LCRYPTO_SRC}/mdc2 \ + ${LCRYPTO_SRC}/hmac ${LCRYPTO_SRC}/ripemd ${LCRYPTO_SRC}/des ${LCRYPTO_SRC}/rc2 \ + ${LCRYPTO_SRC}/rc4 ${LCRYPTO_SRC}/rc5 ${LCRYPTO_SRC}/idea ${LCRYPTO_SRC}/bf \ + ${LCRYPTO_SRC}/cast ${LCRYPTO_SRC}/bn ${LCRYPTO_SRC}/rsa ${LCRYPTO_SRC}/dsa \ + ${LCRYPTO_SRC}/dh ${LCRYPTO_SRC}/buffer ${LCRYPTO_SRC}/bio ${LCRYPTO_SRC}/stack \ + ${LCRYPTO_SRC}/lhash ${LCRYPTO_SRC}/rand ${LCRYPTO_SRC}/err ${LCRYPTO_SRC}/objects \ + ${LCRYPTO_SRC}/evp ${LCRYPTO_SRC}/pem ${LCRYPTO_SRC}/asn1 ${LCRYPTO_SRC}/asn1 \ + ${LCRYPTO_SRC}/x509 ${LCRYPTO_SRC}/conf txt_db/txt_db.c ${LCRYPTO_SRC}/pkcs7 \ + ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC} + +includes: + @cd ${LCRYPTO_SRC}; for i in $(HDRS); do \ + j="cmp -s ${LCRYPTO_SRC}/$$i \ + ${DESTDIR}/usr/include/ssl/`basename $$i` || \ + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \ + ${LCRYPTO_SRC}/$$i ${DESTDIR}/usr/include/ssl"; \ + echo $$j; \ + eval "$$j"; \ + done + + +.include + diff --git a/src/lib/libssl/crypto/shlib_version b/src/lib/libssl/crypto/shlib_version new file mode 100644 index 0000000000..1edea46de9 --- /dev/null +++ b/src/lib/libssl/crypto/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=0 diff --git a/src/lib/libssl/src/COPYRIGHT b/src/lib/libssl/src/COPYRIGHT new file mode 100644 index 0000000000..4faa8c0a46 --- /dev/null +++ b/src/lib/libssl/src/COPYRIGHT @@ -0,0 +1,65 @@ +Copyright (C) 1997 Eric Young (eay@cryptsoft.com) +All rights reserved. + +This package is an SSL implementation written by Eric Young (eay@cryptsoft.com). +The implementation was written so as to conform with Netscapes SSL. + +This library is free for commercial and non-commercial use as long as +the following conditions are aheared to. The following conditions +apply to all code found in this distribution, be it the RC4, RSA, +lhash, DES, etc., code; not just the SSL code. The SSL documentation +included with this distribution is covered by the same copyright terms +except that the holder is Tim Hudson (tjh@cryptsoft.com). + +Please note that MD2, MD5 and IDEA are publically available standards +that contain sample implementations, I have re-coded them in my own +way but there is nothing special about those implementations. The DES +library is another mater :-). + +Copyright remains Eric Young's, and as such any Copyright notices in +the code are not to be removed. +If this package is used in a product, Eric Young should be given attribution +as the author of the parts of the library used. +This can be in the form of a textual message at program startup or +in documentation (online or textual) provided with the package. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + "This product includes cryptographic software written by + Eric Young (eay@cryptsoft.com)" + The word 'cryptographic' can be left out if the rouines from the library + being used are not cryptographic related :-). +4. If you include any Windows specific code (or a derivative thereof) from + the apps directory (application code) you must include an acknowledgement: + "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + +THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +The licence and distribution terms for any publically available version or +derivative of this code cannot be changed. i.e. this code cannot simply be +copied and put under another distribution licence +[including the GNU Public Licence.] + +The reason behind this being stated in this direct manner is past +experience in code simply being copied and the attribution removed +from it and then being distributed as part of other packages. This +implementation was a non-trivial and unpaid effort. + diff --git a/src/lib/libssl/src/HISTORY b/src/lib/libssl/src/HISTORY new file mode 100644 index 0000000000..7712100038 --- /dev/null +++ b/src/lib/libssl/src/HISTORY @@ -0,0 +1,316 @@ +16-Mar-98 + - Patch for Cray T90 from Wayne Schroeder + - Lots and lots of changes + +29-Jan-98 + - ASN1_BIT_STRING_set_bit()/ASN1_BIT_STRING_get_bit() from + Goetz Babin-Ebell . + - SSL_version() now returns SSL2_VERSION, SSL3_VERSION or + TLS1_VERSION. + +7-Jan-98 + - Finally reworked the cipher string to ciphers again, so it + works correctly + - All the app_data stuff is now ex_data with funcion calls to access. + The index is supplied by a function and 'methods' can be setup + for the types that are called on XXX_new/XXX_free. This lets + applications get notified on creation and destruction. Some of + the RSA methods could be implemented this way and I may do so. + - Oh yes, SSL under perl5 is working at the basic level. + +15-Dec-97 + - Warning - the gethostbyname cache is not fully thread safe, + but it should work well enough. + - Major internal reworking of the app_data stuff. More functions + but if you were accessing ->app_data directly, things will + stop working. + - The perlv5 stuff is working. Currently on message digests, + ciphers and the bignum library. + +9-Dec-97 + - Modified re-negotiation so that server initated re-neg + will cause a SSL_read() to return -1 should retry. + The danger otherwise was that the server and the + client could end up both trying to read when using non-blocking + sockets. + +4-Dec-97 + - Lots of small changes + - Fix for binaray mode in Windows for the FILE BIO, thanks to + Bob Denny + +17-Nov-97 + - Quite a few internal cleanups, (removal of errno, and using macros + defined in e_os.h). + - A bug in ca.c, pointed out by yasuyuki-ito@d-cruise.co.jp, where + the automactic naming out output files was being stuffed up. + +29-Oct-97 + - The Cast5 cipher has been added. MD5 and SHA-1 are now in assember + for x86. + +21-Oct-97 + - Fixed a bug in the BIO_gethostbyname() cache. + +15-Oct-97 + - cbc mode for blowfish/des/3des is now in assember. Blowfish asm + has also been improved. At this point in time, on the pentium, + md5 is %80 faster, the unoptimesed sha-1 is %79 faster, + des-cbc is %28 faster, des-ede3-cbc is %9 faster and blowfish-cbc + is %62 faster. + +12-Oct-97 + - MEM_BUF_grow() has been fixed so that it always sets the buf->length + to the value we are 'growing' to. Think of MEM_BUF_grow() as the + way to set the length value correctly. + +10-Oct-97 + - I now hash for certificate lookup on the raw DER encoded RDN (md5). + This breaks things again :-(. This is efficent since I cache + the DER encoding of the RDN. + - The text DN now puts in the numeric OID instead of UNKNOWN. + - req can now process arbitary OIDs in the config file. + - I've been implementing md5 in x86 asm, much faster :-). + - Started sha1 in x86 asm, needs more work. + - Quite a few speedups in the BN stuff. RSA public operation + has been made faster by caching the BN_MONT_CTX structure. + The calulating of the Ai where A*Ai === 1 mod m was rather + expensive. Basically a 40-50% speedup on public operations. + The RSA speedup is now 15% on pentiums and %20 on pentium + pro. + +30-Sep-97 + - After doing some profiling, I added x86 adm for bn_add_words(), + which just adds 2 arrays of longs together. A %10 speedup + for 512 and 1024 bit RSA on the pentium pro. + +29-Sep-97 + - Converted the x86 bignum assembler to us the perl scripts + for generation. + +23-Sep-97 + - If SSL_set_session() is passed a NULL session, it now clears the + current session-id. + +22-Sep-97 + - Added a '-ss_cert file' to apps/ca.c. This will sign selfsigned + certificates. + - Bug in crypto/evp/encode.c where by decoding of 65 base64 + encoded lines, one line at a time (via a memory BIO) would report + EOF after the first line was decoded. + - Fix in X509_find_by_issuer_and_serial() from + Dr Stephen Henson + +19-Sep-97 + - NO_FP_API and NO_STDIO added. + - Put in sh config command. It auto runs Configure with the correct + parameters. + +18-Sep-97 + - Fix x509.c so if a DSA cert has different parameters to its parent, + they are left in place. Not tested yet. + +16-Sep-97 + - ssl_create_cipher_list() had some bugs, fixes from + Patrick Eisenacher + - Fixed a bug in the Base64 BIO, where it would return 1 instead + of -1 when end of input was encountered but should retry. + Basically a Base64/Memory BIO interaction problem. + - Added a HMAC set of functions in preporarion for TLS work. + +15-Sep-97 + - Top level makefile tweak - Cameron Simpson + - Prime generation spead up %25 (512 bit prime, pentium pro linux) + by using montgomery multiplication in the prime number test. + +11-Sep-97 + - Ugly bug in ssl3_write_bytes(). Basically if application land + does a SSL_write(ssl,buf,len) where len > 16k, the SSLv3 write code + did not check the size and tried to copy the entire buffer. + This would tend to cause memory overwrites since SSLv3 has + a maximum packet size of 16k. If your program uses + buffers <= 16k, you would probably never see this problem. + - Fixed a new errors that were cause by malloc() not returning + 0 initialised memory.. + - SSL_OP_NETSCAPE_CA_DN_BUG was being switched on when using + SSL_CTX_set_options(ssl_ctx,SSL_OP_ALL); which was a bad thing + since this flags stops SSLeay being able to handle client + cert requests correctly. + +08-Sep-97 + - SSL_SESS_CACHE_NO_INTERNAL_LOOKUP option added. When switched + on, the SSL server routines will not use a SSL_SESSION that is + held in it's cache. This in intended to be used with the session-id + callbacks so that while the session-ids are still stored in the + cache, the decision to use them and how to look them up can be + done by the callbacks. The are the 'new', 'get' and 'remove' + callbacks. This can be used to determine the session-id + to use depending on information like which port/host the connection + is coming from. Since the are also SSL_SESSION_set_app_data() and + SSL_SESSION_get_app_data() functions, the application can hold + information against the session-id as well. + +03-Sep-97 + - Added lookup of CRLs to the by_dir method, + X509_load_crl_file() also added. Basically it means you can + lookup CRLs via the same system used to lookup certificates. + - Changed things so that the X509_NAME structure can contain + ASN.1 BIT_STRINGS which is required for the unique + identifier OID. + - Fixed some problems with the auto flushing of the session-id + cache. It was not occuring on the server side. + +02-Sep-97 + - Added SSL_CTX_sess_cache_size(SSL_CTX *ctx,unsigned long size) + which is the maximum number of entries allowed in the + session-id cache. This is enforced with a simple FIFO list. + The default size is 20*1024 entries which is rather large :-). + The Timeout code is still always operating. + +01-Sep-97 + - Added an argument to all the 'generate private key/prime` + callbacks. It is the last parameter so this should not + break existing code but it is needed for C++. + - Added the BIO_FLAGS_BASE64_NO_NL flag for the BIO_f_base64() + BIO. This lets the BIO read and write base64 encoded data + without inserting or looking for '\n' characters. The '-A' + flag turns this on when using apps/enc.c. + - RSA_NO_PADDING added to help BSAFE functionality. This is a + very dangerous thing to use, since RSA private key + operations without random padding bytes (as PKCS#1 adds) can + be attacked such that the private key can be revealed. + - ASN.1 bug and rc2-40-cbc and rc4-40 added by + Dr Stephen Henson + +31-Aug-97 (stuff added while I was away) + - Linux pthreads by Tim Hudson (tjh@cryptsoft.com). + - RSA_flags() added allowing bypass of pub/priv match check + in ssl/ssl_rsa.c - Tim Hudson. + - A few minor bugs. + +SSLeay 0.8.1 released. + +19-Jul-97 + - Server side initated dynamic renegotiation is broken. I will fix + it when I get back from holidays. + +15-Jul-97 + - Quite a few small changes. + - INVALID_SOCKET usage cleanups from Alex Kiernan + +09-Jul-97 + - Added 2 new values to the SSL info callback. + SSL_CB_START which is passed when the SSL protocol is started + and SSL_CB_DONE when it has finished sucsessfully. + +08-Jul-97 + - Fixed a few bugs problems in apps/req.c and crypto/asn1/x_pkey.c + that related to DSA public/private keys. + - Added all the relevent PEM and normal IO functions to support + reading and writing RSAPublic keys. + - Changed makefiles to use ${AR} instead of 'ar r' + +07-Jul-97 + - Error in ERR_remove_state() that would leave a dangling reference + to a free()ed location - thanks to Alex Kiernan + - s_client now prints the X509_NAMEs passed from the server + when requesting a client cert. + - Added a ssl->type, which is one of SSL_ST_CONNECT or + SSL_ST_ACCEPT. I had to add it so I could tell if I was + a connect or an accept after the handshake had finished. + - SSL_get_client_CA_list(SSL *s) now returns the CA names + passed by the server if called by a client side SSL. + +05-Jul-97 + - Bug in X509_NAME_get_text_by_OBJ(), looking starting at index + 0, not -1 :-( Fix from Tim Hudson (tjh@cryptsoft.com). + +04-Jul-97 + - Fixed some things in X509_NAME_add_entry(), thanks to + Matthew Donald . + - I had a look at the cipher section and though that it was a + bit confused, so I've changed it. + - I was not setting up the RC4-64-MD5 cipher correctly. It is + a MS special that appears in exported MS Money. + - Error in all my DH ciphers. Section 7.6.7.3 of the SSLv3 + spec. I was missing the two byte length header for the + ClientDiffieHellmanPublic value. This is a packet sent from + the client to the server. The SSL_OP_SSLEAY_080_CLIENT_DH_BUG + option will enable SSLeay server side SSLv3 accept either + the correct or my 080 packet format. + - Fixed a few typos in crypto/pem.org. + +02-Jul-97 + - Alias mapping for EVP_get_(digest|cipher)byname is now + performed before a lookup for actual cipher. This means + that an alias can be used to 're-direct' a cipher or a + digest. + - ASN1_read_bio() had a bug that only showed up when using a + memory BIO. When EOF is reached in the memory BIO, it is + reported as a -1 with BIO_should_retry() set to true. + +01-Jul-97 + - Fixed an error in X509_verify_cert() caused by my + miss-understanding how 'do { contine } while(0);' works. + Thanks to Emil Sit for educating me :-) + +30-Jun-97 + - Base64 decoding error. If the last data line did not end with + a '=', sometimes extra data would be returned. + - Another 'cut and paste' bug in x509.c related to setting up the + STDout BIO. + +27-Jun-97 + - apps/ciphers.c was not printing due to an editing error. + - Alex Kiernan send in a nice fix for + a library build error in util/mk1mf.pl + +26-Jun-97 + - Still did not have the auto 'experimental' code removal + script correct. + - A few header tweaks for Watcom 11.0 under Win32 from + Rolf Lindemann + - 0 length OCTET_STRING bug in asn1_parse + - A minor fix with an non-existent function in the MS .def files. + - A few changes to the PKCS7 stuff. + +25-Jun-97 + SSLeay 0.8.0 finally it gets released. + +24-Jun-97 + Added a SSL_OP_EPHEMERAL_RSA option which causes all SSLv3 RSA keys to + use a temporary RSA key. This is experimental and needs some more work. + Fixed a few Win16 build problems. + +23-Jun-97 + SSLv3 bug. I was not doing the 'lookup' of the CERT structure + correctly. I was taking the SSL->ctx->default_cert when I should + have been using SSL->cert. The bug was in ssl/s3_srvr.c + +20-Jun-97 + X509_ATTRIBUTES were being encoded wrongly by apps/reg.c and the + rest of the library. Even though I had the code required to do + it correctly, apps/req.c was doing the wrong thing. I have fixed + and tested everything. + + Missing a few #ifdef FIONBIO sections in crypto/bio/bss_acpt.c. + +19-Jun-97 + Fixed a bug in the SSLv2 server side first packet handling. When + using the non-blocking test BIO, the ssl->s2->first_packet flag + was being reset when a would-block failure occurred when reading + the first 5 bytes of the first packet. This caused the checking + logic to run at the wrong time and cause an error. + + Fixed a problem with specifying cipher. If RC4-MD5 were used, + only the SSLv3 version would be picked up. Now this will pick + up both SSLv2 and SSLv3 versions. This required changing the + SSL_CIPHER->mask values so that they only mask the ciphers, + digests, authentication, export type and key-exchange algorithms. + + I found that when a SSLv23 session is established, a reused + session, of type SSLv3 was attempting to write the SSLv2 + ciphers, which were invalid. The SSL_METHOD->put_cipher_by_char + method has been modified so it will only write out cipher which + that method knows about. + diff --git a/src/lib/libssl/src/HISTORY.066 b/src/lib/libssl/src/HISTORY.066 new file mode 100644 index 0000000000..f85224977a --- /dev/null +++ b/src/lib/libssl/src/HISTORY.066 @@ -0,0 +1,443 @@ +SSLeay 0.6.5 + +After quite some time (3 months), the new release. I have been very busy +for the last few months and so this is mostly bug fixes and improvments. + +The main additions are + +- assember for x86 DES. For all those gcc based systems, this is a big + improvement. From 117,000 DES operation a second on a pentium 100, + I now get 191,000. I have also reworked the C version so it + now gives 148,000 DESs per second. +- As mentioned above, the inner DES macros now have some more variant that + sometimes help, sometimes hinder performance. There are now 3 options + DES_PTR (ptr vs array lookup), DES_UNROLL (full vs partial loop unrolling) + and DES_RISC (a more register intensive version of the inner macro). + The crypto/des/des_opts.c program, when compiled and run, will give + an indication of the correct options to use. +- The BIO stuff has been improved. Read doc/bio.doc. There are now + modules for encryption and base64 encoding and a BIO_printf() function. +- The CA program will accept simple one line X509v3 extensions in the + ssleay.cnf file. Have a look at the example. Currently this just + puts the text into the certificate as an OCTET_STRING so currently + the more advanced X509v3 data types are not handled but this is enough + for the netscape extensions. +- There is the start of a nicer higher level interface to the X509 + strucutre. +- Quite a lot of bug fixes. +- CRYPTO_malloc_init() (or CRYPTO_set_mem_functions()) can be used + to define the malloc(), free() and realloc() routines to use + (look in crypto/crypto.h). This is mostly needed for Windows NT/95 when + using DLLs and mixing CRT libraries. + +In general, read the 'VERSION' file for changes and be aware that some of +the new stuff may not have been tested quite enough yet, so don't just plonk +in SSLeay 0.6.5 when 0.6.4 used to work and expect nothing to break. + +SSLeay 0.6.4 30/08/96 eay + +I've just finished some test builds on Windows NT, Windows 3.1, Solaris 2.3, +Solaris 2.5, Linux, IRIX, HPUX 10 and everthing seems to work :-). + +The main changes in this release + +- Thread safe. have a read of doc/threads.doc and play in the mt directory. + For anyone using 0.6.3 with threads, I found 2 major errors so consider + moving to 0.6.4. I have a test program that builds under NT and + solaris. +- The get session-id callback has changed. Have a read of doc/callback.doc. +- The X509_cert_verify callback (the SSL_verify callback) now + has another argument. Have a read of doc/callback.doc +- 'ca -preserve', sign without re-ordering the DN. Not tested much. +- VMS support. +- Compile time memory leak detection can now be built into SSLeay. + Read doc/memory.doc +- CONF routines now understand '\', '\n', '\r' etc. What this means is that + the SPKAC object mentioned in doc/ns-ca.doc can be on multiple lines. +- 'ssleay ciphers' added, lists the default cipher list for SSLeay. +- RC2 key setup is now compatable with Netscape. +- Modifed server side of SSL implementation, big performance difference when + using session-id reuse. + +0.6.3 + +Bug fixes and the addition of some nice stuff to the 'ca' program. +Have a read of doc/ns-ca.doc for how hit has been modified so +it can be driven from a CGI script. The CGI script is not provided, +but that is just being left as an excersize for the reader :-). + +0.6.2 + +This is most bug fixes and functionality improvements. + +Additions are +- More thread debugging patches, the thread stuff is still being + tested, but for those keep to play with stuff, have a look in + crypto/cryptlib.c. The application needs to define 1 (or optionaly + a second) callback that is used to implement locking. Compiling + with LOCK_DEBUG spits out lots of locking crud :-). + This is what I'm currently working on. +- SSL_CTX_set_default_passwd_cb() can be used to define the callback + function used in the SSL*_file() functions used to load keys. I was + always of the opinion that people should call + PEM_read_RSAPrivateKey() and pass the callback they want to use, but + it appears they just want to use the SSL_*_file() function() :-(. +- 'enc' now has a -kfile so a key can be read from a file. This is + mostly used so that the passwd does not appear when using 'ps', + which appears imposible to stop under solaris. +- X509v3 certificates now work correctly. I even have more examples + in my tests :-). There is now a X509_EXTENSION type that is used in + X509v3 certificates and CRLv2. +- Fixed that signature type error :-( +- Fixed quite a few potential memory leaks and problems when reusing + X509, CRL and REQ structures. +- EVP_set_pw_prompt() now sets the library wide default password + prompt. +- The 'pkcs7' command will now, given the -print_certs flag, output in + pem format, all certificates and CRL contained within. This is more + of a pre-emtive thing for the new verisign distribution method. I + should also note, that this also gives and example in code, of how + to do this :-), or for that matter, what is involved in going the + other way (list of certs and crl -> pkcs7). +- Added RSA's DESX to the DES library. It is also available via the + EVP_desx_cbc() method and via 'enc desx'. + +SSLeay 0.6.1 + +The main functional changes since 0.6.0 are as follows +- Bad news, the Microsoft 060 DLL's are not compatable, but the good news is + that from now on, I'll keep the .def numbers the same so they will be. +- RSA private key operations are about 2 times faster that 0.6.0 +- The SSL_CTX now has more fields so default values can be put against + it. When an SSL structure is created, these default values are used + but can be overwritten. There are defaults for cipher, certificate, + private key, verify mode and callback. This means SSL session + creation can now be + ssl=SSL_new() + SSL_set_fd(ssl,sock); + SSL_accept(ssl) + .... + All the other uglyness with having to keep a global copy of the + private key and certificate/verify mode in the server is now gone. +- ssl/ssltest.c - one process talking SSL to its self for testing. +- Storage of Session-id's can be controled via a session_cache_mode + flag. There is also now an automatic default flushing of + old session-id's. +- The X509_cert_verify() function now has another parameter, this + should not effect most people but it now means that the reason for + the failure to verify is now available via SSL_get_verify_result(ssl). + You don't have to use a global variable. +- SSL_get_app_data() and SSL_set_app_data() can be used to keep some + application data against the SSL structure. It is upto the application + to free the data. I don't use it, but it is available. +- SSL_CTX_set_cert_verify_callback() can be used to specify a + verify callback function that completly replaces my certificate + verification code. Xcert should be able to use this :-). + The callback is of the form int app_verify_callback(arg,ssl,cert). + This needs to be documented more. +- I have started playing with shared library builds, have a look in + the shlib directory. It is very simple. If you need a numbered + list of functions, have a look at misc/crypto.num and misc/ssl.num. +- There is some stuff to do locking to make the library thread safe. + I have only started this stuff and have not finished. If anyone is + keen to do so, please send me the patches when finished. + +So I have finally made most of the additions to the SSL interface that +I thought were needed. + +There will probably be a pause before I make any non-bug/documentation +related changes to SSLeay since I'm feeling like a bit of a break. + +eric - 12 Jul 1996 +I saw recently a comment by some-one that we now seem to be entering +the age of perpetual Beta software. +Pioneered by packages like linux but refined to an art form by +netscape. + +I too wish to join this trend with the anouncement of SSLeay 0.6.0 :-). + +There are quite a large number of sections that are 'works in +progress' in this package. I will also list the major changes and +what files you should read. + +BIO - this is the new IO structure being used everywhere in SSLeay. I +started out developing this because of microsoft, I wanted a mechanism +to callback to the application for all IO, so Windows 3.1 DLL +perversion could be hidden from me and the 15 different ways to write +to a file under NT would also not be dictated by me at library build +time. What the 'package' is is an API for a data structure containing +functions. IO interfaces can be written to conform to the +specification. This in not intended to hide the underlying data type +from the application, but to hide it from SSLeay :-). +I have only really finished testing the FILE * and socket/fd modules. +There are also 'filter' BIO's. Currently I have only implemented +message digests, and it is in use in the dgst application. This +functionality will allow base64/encrypto/buffering modules to be +'push' into a BIO without it affecting the semantics. I'm also +working on an SSL BIO which will hide the SSL_accept()/SLL_connet() +from an event loop which uses the interface. +It is also possible to 'attach' callbacks to a BIO so they get called +before and after each operation, alowing extensive debug output +to be generated (try running dgst with -d). + +Unfortunaly in the conversion from 0.5.x to 0.6.0, quite a few +functions that used to take FILE *, now take BIO *. +The wrappers are easy to write + +function_fp(fp,x) +FILE *fp; + { + BIO *b; + int ret; + + if ((b=BIO_new(BIO_s_file())) == NULL) error..... + BIO_set_fp(b,fp,BIO_NOCLOSE); + ret=function_bio(b,x); + BIO_free(b); + return(ret); + } +Remember, there are no functions that take FILE * in SSLeay when +compiled for Windows 3.1 DLL's. + +-- +I have added a general EVP_PKEY type that can hold a public/private +key. This is now what is used by the EVP_ functions and is passed +around internally. I still have not done the PKCS#8 stuff, but +X509_PKEY is defined and waiting :-) + +-- +For a full function name listings, have a look at ms/crypt32.def and +ms/ssl32.def. These are auto-generated but are complete. +Things like ASN1_INTEGER_get() have been added and are in here if you +look. I have renamed a few things, again, have a look through the +function list and you will probably find what you are after. I intend +to at least put a one line descrition for each one..... + +-- +Microsoft - thats what this release is about, read the MICROSOFT file. + +-- +Multi-threading support. I have started hunting through the code and +flaging where things need to be done. In a state of work but high on +the list. + +-- +For random numbers, edit e_os.h and set DEVRANDOM (it's near the top) +be be you random data device, otherwise 'RFILE' in e_os.h +will be used, in your home directory. It will be updated +periodically. The environment variable RANDFILE will override this +choice and read/write to that file instead. DEVRANDOM is used in +conjunction to the RFILE/RANDFILE. If you wish to 'seed' the random +number generator, pick on one of these files. + +-- + +The list of things to read and do + +dgst -d +s_client -state (this uses a callback placed in the SSL state loop and + will be used else-where to help debug/monitor what + is happening.) + +doc/why.doc +doc/bio.doc <- hmmm, needs lots of work. +doc/bss_file.doc <- one that is working :-) +doc/session.doc <- it has changed +doc/speed.doc + also play with ssleay version -a. I have now added a SSLeay() + function that returns a version number, eg 0600 for this release + which is primarily to be used to check DLL version against the + application. +util/* Quite a few will not interest people, but some may, like + mk1mf.pl, mkdef.pl, +util/do_ms.sh + +try +cc -Iinclude -Icrypto -c crypto/crypto.c +cc -Iinclude -Issl -c ssl/ssl.c +You have just built the SSLeay libraries as 2 object files :-) + +Have a general rummage around in the bin stall directory and look at +what is in there, like CA.sh and c_rehash + +There are lots more things but it is 12:30am on a Friday night and I'm +heading home :-). + +eric 22-Jun-1996 +This version has quite a few major bug fixes and improvements. It DOES NOT +do SSLv3 yet. + +The main things changed +- A Few days ago I added the s_mult application to ssleay which is + a demo of an SSL server running in an event loop type thing. + It supports non-blocking IO, I have finally gotten it right, SSL_accept() + can operate in non-blocking IO mode, look at the code to see how :-). + Have a read of doc/s_mult as well. This program leaks memory and + file descriptors everywhere but I have not cleaned it up yet. + This is a demo of how to do non-blocking IO. +- The SSL session management has been 'worked over' and there is now + quite an expansive set of functions to manipulate them. Have a read of + doc/session.doc for some-things I quickly whipped up about how it now works. + This assume you know the SSLv2 protocol :-) +- I can now read/write the netscape certificate format, use the + -inform/-outform 'net' options to the x509 command. I have not put support + for this type in the other demo programs, but it would be easy to add. +- asn1parse and 'enc' have been modified so that when reading base64 + encoded files (pem format), they do not require '-----BEGIN' header lines. + The 'enc' program had a buffering bug fixed, it can be used as a general + base64 -> binary -> base64 filter by doing 'enc -a -e' and 'enc -a -d' + respecivly. Leaving out the '-a' flag in this case makes the 'enc' command + into a form of 'cat'. +- The 'x509' and 'req' programs have been fixed and modified a little so + that they generate self-signed certificates correctly. The test + script actually generates a 'CA' certificate and then 'signs' a + 'user' certificate. Have a look at this shell script (test/sstest) + to see how things work, it tests most possible combinations of what can + be done. +- The 'SSL_set_pref_cipher()' function has been 'fixed' and the prefered name + of SSL_set_cipher_list() is now the correct API (stops confusion :-). + If this function is used in the client, only the specified ciphers can + be used, with preference given to the order the ciphers were listed. + For the server, if this is used, only the specified ciphers will be used + to accept connections. If this 'option' is not used, a default set of + ciphers will be used. The SSL_CTX_set_cipher_list(SSL_CTX *ctx) sets this + list for all ciphers started against the SSL_CTX. So the order is + SSL cipher_list, if not present, SSL_CTX cipher list, if not + present, then the library default. + What this means is that normally ciphers like + NULL-MD5 will never be used. The only way this cipher can be used + for both ends to specify to use it. + To enable or disable ciphers in the library at build time, modify the + first field for the cipher in the ssl_ciphers array in ssl/ssl_lib.c. + This file also contains the 'pref_cipher' list which is the default + cipher preference order. +- I'm not currently sure if the 'rsa -inform net' and the 'rsa -outform net' + options work. They should, and they enable loading and writing the + netscape rsa private key format. I will be re-working this section of + SSLeay for the next version. What is currently in place is a quick and + dirty hack. +- I've re-written parts of the bignum library. This gives speedups + for all platforms. I now provide assembler for use under Windows NT. + I have not tested the Windows 3.1 assembler but it is quite simple code. + This gives RSAprivate_key operation encryption times of 0.047s (512bit key) + and 0.230s (1024bit key) on a pentium 100 which I consider reasonable. + Basically the times available under linux/solaris x86 can be achieve under + Windows NT. I still don't know how these times compare to RSA's BSAFE + library but I have been emailing with people and with their help, I should + be able to get my library's quite a bit faster still (more algorithm changes). + The object file crypto/bn/asm/x86-32.obj should be used when linking + under NT. +- 'make makefile.one' in the top directory will generate a single makefile + called 'makefile.one' This makefile contains no perl references and + will build the SSLeay library into the 'tmp' and 'out' directories. + util/mk1mf.pl >makefile.one is how this makefile is + generated. The mk1mf.pl command take several option to generate the + makefile for use with cc, gcc, Visual C++ and Borland C++. This is + still under development. I have only build .lib's for NT and MSDOS + I will be working on this more. I still need to play with the + correct compiler setups for these compilers and add some more stuff but + basically if you just want to compile the library + on a 'non-unix' platform, this is a very very good file to start with :-). + Have a look in the 'microsoft' directory for my current makefiles. + I have not yet modified things to link with sockets under Windows NT. + You guys should be able to do this since this is actually outside of the + SSLeay scope :-). I will be doing it for myself soon. + util/mk1mf.pl takes quite a few options including no-rc, rsaref and no-sock + to build without RC2/RC4, to require RSAref for linking, and to + build with no socket code. + +- Oh yes, the cipher that was reported to be compatible with RSA's RC2 cipher + that was posted to sci.crypt has been added to the library and SSL. + I take the view that if RC2 is going to be included in a standard, + I'll include the cipher to make my package complete. + There are NO_RC2, NO_RC4 and NO_IDEA macros to remove these ciphers + at compile time. I have not tested this recently but it should all work + and if you are in the USA and don't want RSA threatening to sue you, + you could probably remove the RC4/RC2 code inside these sections. + I may in the future include a perl script that does this code + removal automatically for those in the USA :-). +- I have removed all references to sed in the makefiles. So basically, + the development environment requires perl and sh. The build environment + does not (use the makefile.one makefile). + The Configure script still requires perl, this will probably stay that way + since I have perl for Windows NT :-). + +eric (03-May-1996) + +PS Have a look in the VERSION file for more details on the changes and + bug fixes. +I have fixed a few bugs, added alpha and x86 assembler and generally cleaned +things up. This version will be quite stable, mostly because I'm on +holidays until 10-March-1996. For any problems in the interum, send email +to Tim Hudson . + +SSLeay 0.5.0 + +12-12-95 +This is going out before it should really be released. + +I leave for 11 weeks holidays on the 22-12-95 and so I either sit on +this for 11 weeks or get things out. It is still going to change a +lot in the next week so if you do grab this version, please test and +give me feed back ASAP, inculuding questions on how to do things with +the library. This will prompt me to write documentation so I don't +have to answer the same question again :-). + +This 'pre' release version is for people who are interested in the +library. The applications will have to be changed to use +the new version of the SSL interface. I intend to finish more +documentation before I leave but until then, look at the programs in +the apps directory. As far as code goes, it is much much nicer than +the old version. + +The current library works, has no memory leaks (as far as I can tell) +and is far more bug free that 0.4.5d. There are no global variable of +consequence (I believe) and I will produce some documentation that +tell where to look for those people that do want to do multi-threaded +stuff. + +There should be more documentation. Have a look in the +doc directory. I'll be adding more before I leave, it is a start +by mostly documents the crypto library. Tim Hudson will update +the web page ASAP. The spelling and grammar are crap but +it is better than nothing :-) + +Reasons to start playing with version 0.5.0 +- All the programs in the apps directory build into one ssleay binary. +- There is a new version of the 'req' program that generates certificate + requests, there is even documentation for this one :-) +- There is a demo certification authorithy program. Currently it will + look at the simple database and update it. It will generate CRL from + the data base. You need to edit the database by hand to revoke a + certificate, it is my aim to use perl5/Tk but I don't have time to do + this right now. It will generate the certificates but the management + scripts still need to be written. This is not a hard task. +- Things have been cleaned up alot. +- Have a look at the enc and dgst programs in the apps directory. +- It supports v3 of x509 certiticates. + + +Major things missing. +- I have been working on (and thinging about) the distributed x509 + hierachy problem. I have not had time to put my solution in place. + It will have to wait until I come back. +- I have not put in CRL checking in the certificate verification but + it would not be hard to do. I was waiting until I could generate my + own CRL (which has only been in the last week) and I don't have time + to put it in correctly. +- Montgomery multiplication need to be implemented. I know the + algorithm, just ran out of time. +- PKCS#7. I can load and write the DER version. I need to re-work + things to support BER (if that means nothing, read the ASN1 spec :-). +- Testing of the higher level digital envelope routines. I have not + played with the *_seal() and *_open() type functions. They are + written but need testing. The *_sign() and *_verify() functions are + rock solid. +- PEM. Doing this and PKCS#7 have been dependant on the distributed + x509 heirachy problem. I started implementing my ideas, got + distracted writing a CA program and then ran out of time. I provide + the functionality of RSAref at least. +- Re work the asm. code for the x86. I've changed by low level bignum + interface again, so I really need to tweak the x86 stuff. gcc is + good enough for the other boxes. + diff --git a/src/lib/libssl/src/MICROSOFT b/src/lib/libssl/src/MICROSOFT new file mode 100644 index 0000000000..54176f0472 --- /dev/null +++ b/src/lib/libssl/src/MICROSOFT @@ -0,0 +1,146 @@ +The Microsoft World. + +The good news, to build SSLeay for the Microsft World + +Windows 3.1 DLL's +perl Configure VC-WIN16 +nmake -f ms\w31dll.mak + +Windows NT/95 DLL's +perl Configure VC-WIN32 +nmake -f ms\ntdll.mak + +Now the bad news +All builds were done using Microsofts Visual C++ 1.52c and [45].x. +If you are a borland person, you are probably going to have to help me +finish the stuff in util/pl/BC*pl + +All builds were made under Windows NT - this means long filenames, so +you may have problems under Windows 3.1 but probably not under 95. + +Because file pointers don't work in DLL's under Windows 3.1 (well at +least stdin/stdout don't and I don't like having to differentiate +between these and other file pointers), I now use the BIO file-pointer +module, which needs to be linked into your application. You can either +use the memory buffer BIO for IO, or compile bss_file.c into your +application, it is in the apps directory and is just a copy of +crypto/buffer/bss_file.c with #define APPS_WIN16 added. +I have not yet automated the makefile to automatically copy it into 'out' +for a win 3.1 build.... + +All callbacks passed into SSLeay for Windows 3.1 need to be of type +_far _loadds. + +I don't support building with the pascal calling convention. + +The DLL and static builds are large memory model. + +To build static libraries for NT/95 or win 3.1 + +perl util/mk1mf.pl VC-WIN32 > mf-stat.nt +perl util/mk1mf.pl VC-WIN16 > mf-stat.w31 +for DLL's +perl util/mk1mf.pl dll VC-WIN32 > mf-dll.nt +perl util/mk1mf.pl dll VC-WIN16 > mf-dll.w31 + +Again you will notice that if you dont have perl, you cannot do this. + +Now the next importaint issue. Running Configure! +I have small assember code files for critical big number library operation +in crypto/bn/asm. There is, asm code, object files and uuencode +object files. They are +x86nt32.asm - 32bit flat memory model assember - suitable Win32 +x86w16.asm - 16bit assember - used in the msdos build. +x86w32.asm - 32bit assember, win 3.1 segments, used for win16 build. + +If you feel compelled to build the 16bit maths routines in the windows 3.1 +build, +perl Configure VC-W31-16 +perl util/mk1mf.pl dll VC-W31-16 > mf-dll.w31 + +If you hate assember and don't want anything to do with it, +perl util/mk1mf.pl no-asm VC-WIN16 > mf-dll.w31 +will work for any of the makefile generations. + +There are more options to mk1mf.pl but these all leave the temporary +files in 'tmp' and the output files in 'out' by default. + +The NT build is done for console mode. + +The Windows 3.1 version of SSLeay uses quickwin, the interface is ugly +but it is better than nothing. If you want ugly, try doing anything +that involves getting a password. I decided to be ugly instead of +echoing characters. For Windows 3.1 I would just sugest using the +msdos version of the ssleay application for command line work. +The QuickWin build is primarily for testing. + +For both NT and Windows 3.1, I have not written the code so that +s_client, s_server can take input from the keyboard. You can happily +start applications up in separate windows, watch them handshake, and then sit +there for-ever. I have not had the time to get this working, and I've +been able to test things from a unix box to the NT box :-). +Try running ssleay s_server on the windows box +(with either -cert ../apps/server.pem -www) +and run ssleay s_time from another window. +This often stuffs up on Windows 3.1, but I'm not worried since this is +probably a problem with my demo applications, not the libraries. + +After a build of one of the version of microsoft SSLeay, +'cd ms' and then run 'test'. This should check everything out and +even does a trial run of generating certificates. +'test.bat' requires that perl be install, you be in the ms directory +(not the test directory, thats for unix so stay out :-) and that the +build output directory be ../out + +On a last note, you will probably get division by zero errors and +stuff after a build. This is due to your own inability to follow +instructions :-). + +The reasons for the problem is probably one of the following. + +1) You did not run Configure. This is critical for windows 3.1 when + using assember. The values in crypto/bn/bn.h must match the + ones requred for the assember code. (remember that if you + edit crypto/bn/bn.h by hand, it will be clobered the next time + you run Configure by the contents of crypto/bn/bn.org). + SSLeay version -o will list the compile options. + For VC-WIN32 you need bn(64,32) or bn(32,32) + For VC-W31-32/VC-WIN16 you need bn(32,32) + For VC-W31-16 you need bn(32,16) or bn(16,16) + For VC-MSDOS you need bn(32,16) or bn(16,16). + + The first number will be 2 times bigger than the second if + BN_LLONG is defined in bn.h and the size of the second number + depends on the 'bits' defined at the start of bn.h. Have a + look, it's all reasonably clear. + If you want to start messing with 8 bit builds and things like + that, build without the assember by re-generating a makefile + via 'perl util/mk1mf.pl no-asm'. +2) You tried to build under MS-DOS or Windows 3.1 using the /G3 + option. Don't. It is buggy (thats why you just got that + error) and unless you want to work out which optimising flag + to turn off, I'm not going to help you :-). I also noticed + that code often ran slower when compiled with /G3. +3) Under NT/95, malloc goes stupid. You are probably linking with + the wrong library, there are problems if you mix the threaded + and non-threaded libraries (due to the DLL being staticly + linked with one and the applicaion using another. + +Well hopefully thats most of the MS issues handled, see you in ssl-users :-). + +eric 30-Aug-1996 + +SSLeay 0.6.5 +For Windows 95/NT, add CRYPTO_malloc_init() to your program before any +calls to the SSLeay libraries. This function will insert callbacks so that +the SSLeay libraries will use the same malloc(), free() and realloc() as +your application so 'problem 3)' mentioned above will go away. + +There is now DES assember for Windows NT/95. The file is +crypto/des/asm/win32.asm and replaces crypto/des/des_enc.c in the build. + +There is also Blowfish assember for Windows NT/95. The file is +crypto/bf/asm/win32.asm and replaces crypto/bf/bf_enc.c in the build. + +eric 25-Jun-1997 + diff --git a/src/lib/libssl/src/MINFO b/src/lib/libssl/src/MINFO new file mode 100644 index 0000000000..0509f33648 --- /dev/null +++ b/src/lib/libssl/src/MINFO @@ -0,0 +1,968 @@ +RELATIVE_DIRECTORY=. +AR=ar r +BASENAME=SSLeay +BF_ENC=bf_enc.o +BN_MULW=bn_mulw.o +CAST_ENC=c_enc.o +CC=cc +CFLAG=-O -DNOPROTO +DES_ENC=des_enc.o fcrypt_b.o +DIRS=crypto ssl rsaref apps test tools +EDIRS=times doc bugs util include certs ms shlib mt demos perl dep +EXHEADER=e_os.h +EX_LIBS= +GENERAL=Makefile +HEADER=e_os.h +INSTALLTOP=/usr/local/ssl +LIBS=libcrypto.a libssl.a +MAKE=make -f Makefile.ssl +MAKEFILE=Makefile.ssl +MAN1=1 +MAN3=3 +MD5_ASM_OBJ= +MISC=COPYRIGHT Configure HISTORY.066 INSTALL Makefile.ssl Makefile README TODO HISTORY README.066 README.080 README.090 VERSION PROBLEMS MINFO makefile.one e_os.h MICROSOFT makevms.com config PATENTS +NAME=SSLeay-0.9.0 +ONEDIRS=out tmp +PEX_LIBS=-L. -L.. -L../.. -L../../.. +RC4_ENC=rc4_enc.o +RC5_ENC=rc5_enc.o +RMD160_ASM_OBJ= +SDIRS=md2 md5 sha mdc2 hmac ripemd des rc2 rc4 rc5 idea bf cast bn rsa dsa dh buffer bio stack lhash rand err objects evp pem asn1 x509 conf txt_db pkcs7 +SHA1_ASM_OBJ= +SHELL=/bin/sh +TARFILE=SSLeay-0.9.0.tar +TOP=. +VERSION=0.9.0 +WDIRS=windows +WTARFILE=SSLeay-0.9.0-win.tar +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto +ALL=Makefile README cryptlib.c mem.c cversion.c ex_data.c cpt_err.c cryptlib.h date.h crypto.h cryptall.h +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I. -I../include -g -DCFLAGS=" \"cc -g\" " +DIR=crypto +ERR=crypto +ERRC=cpt_err +EXHEADER=crypto.h cryptall.h +EX_LIBS= +GENERAL=Makefile README +HEADER=cryptlib.h date.h crypto.h cryptall.h +INCLUDE=-I. -I../include +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../libcrypto.a +LIBOBJ=cryptlib.o mem.o cversion.o ex_data.o cpt_err.o +LIBS= +LIBSRC=cryptlib.c mem.c cversion.c ex_data.c cpt_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +PEX_LIBS= +RM=/bin/rm -f +SDIRS=md2 md5 sha mdc2 hmac ripemd des rc2 rc4 rc5 idea bf cast bn rsa dsa dh buffer bio stack lhash rand err objects evp pem x509 asn1 conf txt_db pkcs7 +SRC=cryptlib.c mem.c cversion.c ex_data.c cpt_err.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/md2 +ALL=Makefile md2_dgst.c md5_one.c md2.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=md +EXHEADER=md2.h +GENERAL=Makefile +HEADER=md2.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=md2_dgst.o md2_one.o +LIBSRC=md2_dgst.c md5_one.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=md2_dgst.c md5_one.c +TEST=md2test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/md5 +ALL=Makefile md5_dgst.c md5_one.c md5_locl.h md5.h +APPS=md5.c +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=md5 +EXHEADER=md5.h +GENERAL=Makefile +HEADER=md5_locl.h md5.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=md5_dgst.o md5_one.o +LIBSRC=md5_dgst.c md5_one.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +MD5_ASM_OBJ= +SRC=md5_dgst.c md5_one.c +TEST=md5test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/sha +ALL=Makefile sha_dgst.c sha1dgst.c sha_one.c sha1_one.c sha_locl.h sha.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=sha +EXHEADER=sha.h +GENERAL=Makefile +HEADER=sha_locl.h sha.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o +LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SHA1_ASM_OBJ= +SRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +TEST=shatest.c sha1test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/mdc2 +ALL=Makefile mdc2dgst.c mdc2_one.c mdc2.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=mdc2 +EXHEADER=mdc2.h +GENERAL=Makefile +HEADER=mdc2.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=mdc2dgst.o mdc2_one.o +LIBSRC=mdc2dgst.c mdc2_one.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=mdc2dgst.c mdc2_one.c +TEST=mdc2test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/hmac +ALL=Makefile hmac.c hmac.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=hmac +EXHEADER=hmac.h +GENERAL=Makefile +HEADER=hmac.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=hmac.o +LIBSRC=hmac.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=hmac.c +TEST=hmactest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/ripemd +ALL=Makefile rmd_dgst.c rmd_one.c rmd_locl.h rmdconst.h ripemd.h +APPS=rmd160.c +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=ripemd +EXHEADER=ripemd.h +GENERAL=Makefile +HEADER=rmd_locl.h rmdconst.h ripemd.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=rmd_dgst.o rmd_one.o +LIBSRC=rmd_dgst.c rmd_one.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +RIP_ASM_OBJ= +SRC=rmd_dgst.c rmd_one.c +TEST=rmdtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/des +ALL=Makefile des.org des_locl.org cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c read2pwd.c fcrypt.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c supp.c des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h des.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DES_ENC=des_enc.o fcrypt_b.o +DIR=des +EXHEADER=des.h +GENERAL=Makefile des.org des_locl.org +HEADER=des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h des.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=set_key.o ecb_enc.o cbc_enc.o ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o enc_read.o enc_writ.o ofb64enc.o ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o des_enc.o fcrypt_b.o read2pwd.o fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o +LIBSRC=cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c read2pwd.c fcrypt.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c supp.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c read2pwd.c fcrypt.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c supp.c +TEST=destest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rc2 +ALL=Makefile rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c rc2_locl.h rc2.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=rc2 +EXHEADER=rc2.h +GENERAL=Makefile +HEADER=rc2_locl.h rc2.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o +LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +TEST=rc2test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rc4 +ALL=Makefile rc4_skey.c rc4_enc.c rc4.h rc4_locl.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=rc4 +EXHEADER=rc4.h +GENERAL=Makefile +HEADER=rc4.h rc4_locl.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=rc4_skey.o rc4_enc.o +LIBSRC=rc4_skey.c rc4_enc.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +RC4_ENC=rc4_enc.o +SRC=rc4_skey.c rc4_enc.c +TEST=rc4test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rc5 +ALL=Makefile rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c rc5_locl.h rc5.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=rc5 +EXHEADER=rc5.h +GENERAL=Makefile +HEADER=rc5_locl.h rc5.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=rc5_skey.o rc5_ecb.o rc5_enc.o rc5cfb64.o rc5ofb64.o +LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +RC5_ENC=rc5_enc.o +SRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c +TEST=rc5test.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/idea +ALL=Makefile i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c idea_lcl.h idea.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=idea +EXHEADER=idea.h +GENERAL=Makefile +HEADER=idea_lcl.h idea.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o +LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c +TEST=ideatest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/bf +ALL=Makefile bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c bf_pi.h bf_locl.h blowfish.h +APPS= +AR=ar r +BF_ENC=bf_enc.o +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=bf +EXHEADER=blowfish.h +GENERAL=Makefile +HEADER=bf_pi.h bf_locl.h blowfish.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=bf_skey.o bf_ecb.o bf_enc.o bf_cfb64.o bf_ofb64.o +LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c +TEST=bftest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/cast +ALL=Makefile c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c cast_s.h cast_lcl.h cast.h +APPS= +AR=ar r +CAST_ENC=c_enc.o +CC=cc +CFLAG=-g +CFLAGS= -g +CPP=cc -E +DIR=cast +EXHEADER=cast.h +GENERAL=Makefile +HEADER=cast_s.h cast_lcl.h cast.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=c_skey.o c_ecb.o c_enc.o c_cfb64.o c_ofb64.o +LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +TEST=casttest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/bn +ALL=Makefile bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c bn_mpi.c bn_lcl.h bn_prime.h bn.h +APPS= +AR=ar r +BN_MULW=bn_mulw.o +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=bn +ERR=bn +ERRC=bn_err +EXHEADER=bn.h +GENERAL=Makefile +HEADER=bn_lcl.h bn_prime.h bn.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o bn_mulw.o bn_recp.o bn_mont.o bn_mpi.o +LIBSRC=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c bn_mpi.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c bn_mpi.c +TEST=bntest.c exptest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rsa +ALL=Makefile rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c rsa.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=rsa +ERR=rsa +ERRC=rsa_err +EXHEADER=rsa.h +GENERAL=Makefile +HEADER=rsa.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o rsa_pk1.o rsa_ssl.o rsa_none.o +LIBSRC=rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/dsa +ALL=Makefile dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c dsa_err.c dsa.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=dsa +ERR=dsa +ERRC=dsa_err +EXHEADER=dsa.h +GENERAL=Makefile +HEADER=dsa.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o dsa_err.o +LIBSRC=dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c dsa_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c dsa_err.c +TEST=dsatest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/dh +ALL=Makefile dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=dh +ERR=dh +ERRC=dh_err +EXHEADER=dh.h +GENERAL=Makefile +HEADER=dh.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o +LIBSRC=dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c +TEST=dhtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/buffer +ALL=Makefile buffer.c buf_err.c buffer.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=buffer +ERR=buffer +ERRC=buf_err +EXHEADER=buffer.h +GENERAL=Makefile +HEADER=buffer.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=buffer.o buf_err.o +LIBSRC=buffer.c buf_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=buffer.c buf_err.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/bio +ALL=Makefile bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c bio.h bss_file.c +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=bio +ERR=bio +ERRC=bio_err +EXHEADER=bio.h bss_file.c +GENERAL=Makefile +HEADER=bio.h bss_file.c +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=bio_lib.o bio_cb.o bio_err.o bss_mem.o bss_null.o bss_fd.o bss_file.o bss_sock.o bss_conn.o bf_null.o bf_buff.o b_print.o b_dump.o b_sock.o bss_acpt.o bf_nbio.o +LIBSRC=bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/stack +ALL=Makefile stack.c stack.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=stack +EXHEADER=stack.h +GENERAL=Makefile +HEADER=stack.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=stack.o +LIBSRC=stack.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=stack.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/lhash +ALL=Makefile lhash.c lh_stats.c lhash.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=lhash +EXHEADER=lhash.h +GENERAL=Makefile +HEADER=lhash.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=lhash.o lh_stats.o +LIBSRC=lhash.c lh_stats.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=lhash.c lh_stats.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/rand +ALL=Makefile md_rand.c randfile.c rand.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=rand +EXHEADER=rand.h +GENERAL=Makefile +HEADER=rand.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=md_rand.o randfile.o +LIBSRC=md_rand.c randfile.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=md_rand.c randfile.c +TEST=randtest.c +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/err +ALL=Makefile err.c err_all.c err_prn.c err.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=err +EXHEADER=err.h +GENERAL=Makefile +HEADER=err.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=err.o err_all.o err_prn.o +LIBSRC=err.c err_all.c err_prn.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=err.c err_all.c err_prn.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/objects +ALL=Makefile README obj_dat.c obj_lib.c obj_err.c objects.h obj_dat.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=objects +ERR=objects +ERRC=obj_err +EXHEADER=objects.h +GENERAL=Makefile README +HEADER=objects.h obj_dat.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=obj_dat.o obj_lib.o obj_err.o +LIBSRC=obj_dat.c obj_lib.c obj_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=obj_dat.c obj_lib.c obj_err.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/evp +ALL=Makefile encode.c digest.c evp_enc.c evp_key.c e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c evp_lib.c evp.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=evp +ERR=evp +ERRC=evp_err +EXHEADER=evp.h +GENERAL=Makefile +HEADER=evp.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=encode.o digest.o evp_enc.o evp_key.o e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o m_ripemd.o p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o c_all.o evp_lib.o +LIBSRC=encode.c digest.c evp_enc.c evp_key.c e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c evp_lib.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=encode.c digest.c evp_enc.c evp_key.c e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c evp_lib.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/pem +ALL=Makefile pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c pem.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +CTX_SIZE=ctx_size +DIR=pem +ERR=pem +ERRC=pem_err +EXHEADER=pem.h +GENERAL=Makefile +HEADER=pem.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o +LIBSRC=pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/asn1 +ALL=Makefile README a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c asn1.h asn1_mac.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=asn1 +ERR=asn1 +ERRC=asn1_err +EXHEADER=asn1.h asn1_mac.h +GENERAL=Makefile README +HEADER=asn1.h asn1_mac.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_sign.o a_digest.o a_verify.o x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o t_req.o t_x509.o t_pkey.o p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o a_hdr.o x_pkey.o a_bool.o x_exten.o asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o evp_asn1.o +LIBSRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/x509 +ALL=Makefile README x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509_vfy.c x509_set.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509pack.c x509type.c x509_lu.c x_all.c x509_txt.c by_file.c by_dir.c v3_net.c v3_x509.c x509.h x509_vfy.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=x509 +ERR=x509 +ERRC=x509_err +EXHEADER=x509.h x509_vfy.h +GENERAL=Makefile README +HEADER=x509.h x509_vfy.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=x509_def.o x509_d2.o x509_r2x.o x509_cmp.o x509_obj.o x509_req.o x509_vfy.o x509_set.o x509rset.o x509_err.o x509name.o x509_v3.o x509_ext.o x509pack.o x509type.o x509_lu.o x_all.o x509_txt.o by_file.o by_dir.o v3_net.o v3_x509.o +LIBSRC=x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509_vfy.c x509_set.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509pack.c x509type.c x509_lu.c x_all.c x509_txt.c by_file.c by_dir.c v3_net.c v3_x509.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509_vfy.c x509_set.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509pack.c x509type.c x509_lu.c x_all.c x509_txt.c by_file.c by_dir.c v3_net.c v3_x509.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/conf +ALL=Makefile conf.c conf_err.c conf_lcl.h conf.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=conf +ERR=conf +ERRC=conf_err +EXHEADER=conf.h +GENERAL=Makefile +HEADER=conf_lcl.h conf.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=conf.o conf_err.o +LIBSRC=conf.c conf_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=conf.c conf_err.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/txt_db +ALL=Makefile txt_db.c txt_db.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS= -g +DIR=txt_db +EXHEADER=txt_db.h +GENERAL=Makefile +HEADER=txt_db.h +INCLUDES= +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=txt_db.o +LIBSRC=txt_db.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=txt_db.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=crypto/pkcs7 +ALL=Makefile README pk7_lib.c pkcs7err.c pk7_doit.c pkcs7.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=pkcs7 +ERR=pkcs7 +ERRC=pkcs7err +EXHEADER=pkcs7.h +GENERAL=Makefile README +HEADER=pkcs7.h +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +LIB=../../libcrypto.a +LIBOBJ=pk7_lib.o pkcs7err.o pk7_doit.o +LIBSRC=pk7_lib.c pkcs7err.c pk7_doit.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=pk7_lib.c pkcs7err.c pk7_doit.c +TEST= +TOP=../.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=ssl +ALL=Makefile README s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c ssl.h ssl2.h ssl3.h ssl23.h tls1.h ssl_locl.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I../crypto -I../include -g +DIR=ssl +ERR=ssl +ERRC=ssl_err +EXHEADER=ssl.h ssl2.h ssl3.h ssl23.h tls1.h +GENERAL=Makefile README +HEADER=ssl.h ssl2.h ssl3.h ssl23.h tls1.h ssl_locl.h +INCLUDES=-I../crypto -I../include +INSTALLTOP=/usr/local/ssl +LIB=../libssl.a +LIBOBJ=s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o ssl_ciph.o ssl_stat.o ssl_rsa.o ssl_asn1.o ssl_txt.o ssl_algs.o bio_ssl.o ssl_err.o +LIBSRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c +TEST=ssltest.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=rsaref +ALL=Makefile rsaref.c rsar_err.c rsaref.h +APPS= +AR=ar r +CC=cc +CFLAG=-g +CFLAGS=-I../crypto -I../include -g +DIR=rsaref +ERR=rsaref +ERRC=rsar_err +EXHEADER= +GENERAL=Makefile +HEADER= rsaref.h +INCLUDES=-I../crypto -I../include +INSTALLTOP=/usr/local/ssl +LIB=../libRSAglue.a +LIBOBJ=rsaref.o rsar_err.o +LIBSRC=rsaref.c rsar_err.c +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +SRC=rsaref.c rsar_err.c +TEST= +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=apps +ALL=Makefile verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c dsa.c dsaparam.c x509.c genrsa.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c ciphers.c apps.h progs.h s_apps.h testdsa.h testrsa.h +A_OBJ=apps.o +A_SRC=apps.c +CC=cc +CFLAG=-g -static +CFLAGS=-DMONOLITH -I../include -g -static +DIR=apps +DLIBCRYPTO=../libcrypto.a +DLIBSSL=../libssl.a +EXE=ssleay +EXHEADER= +EX_LIBS= +E_EXE=verify asn1pars req dgst dh enc gendh errstr ca crl rsa dsa dsaparam x509 genrsa s_server s_client speed s_time version pkcs7 crl2pkcs7 sess_id ciphers +E_OBJ=verify.o asn1pars.o req.o dgst.o dh.o enc.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o dsa.o dsaparam.o x509.o genrsa.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o version.o sess_id.o ciphers.o +E_SRC=verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c dsa.c dsaparam.c x509.c genrsa.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c ciphers.c +GENERAL=Makefile +HEADER=apps.h progs.h s_apps.h testdsa.h testrsa.h +INCLUDES=-I../include +INSTALLTOP=/usr/local/ssl +LIBCRYPTO=-L.. -lcrypto +LIBSSL=-L.. -lssl +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +PEX_LIBS= +PROGS=ssleay.c +RM=/bin/rm -f +SCRIPTS=CA.sh der_chop +SRC=verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c dsa.c dsaparam.c x509.c genrsa.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c ciphers.c +SSLEAY=ssleay +S_OBJ=s_cb.o s_socket.o +S_SRC=s_cb.c s_socket.c +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=test +ALL=Makefile.ssl bntest.c ideatest.c md2test.c md5test.c hmactest.c rc2test.c rc4test.c rc5test.c destest.c shatest.c sha1test.c mdc2test.c rmdtest.c randtest.c dhtest.c casttest.c bftest.c ssltest.c dsatest.c exptest.c +BFTEST=bftest +BNTEST=bntest +CASTTEST=casttest +CC=cc +CFLAG=-g +CFLAGS=-I../include -g +DESTEST=destest +DHTEST=dhtest +DIR=test +DLIBCRYPTO=../libcrypto.a +DLIBSSL=../libssl.a +DSATEST=dsatest +EXE=bntest ideatest md2test md5test hmactest rc2test rc4test rc5test destest shatest sha1test mdc2test rmdtest randtest dhtest bftest casttest ssltest exptest dsatest +EXHEADER= +EXPTEST=exptest +EX_LIBS= +GENERAL=Makefile.ssl +HEADER= +HMACTEST=hmactest +IDEATEST=ideatest +INCLUDES=-I../include +INSTALLTOP=/usr/local/ssl +LIBCRYPTO=-L.. -lcrypto +LIBSSL=-L.. -lssl +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -fMakefile.ssl +MAKEFILE=Makefile.ssl +MD2TEST=md2test +MD5TEST=md5test +MDC2TEST=mdc2test +METHTEST=methtest +OBJ=bntest.o ideatest.o md2test.o md5test.o hmactest.o rc2test.o rc4test.o rc5test.o destest.o shatest.o sha1test.o mdc2test.o rmdtest.o randtest.o dhtest.o casttest.o bftest.o ssltest.o dsatest.o exptest.o +PEX_LIBS= +RANDTEST=randtest +RC2TEST=rc2test +RC4TEST=rc4test +RC5TEST=rc5test +RMDTEST=rmdtest +SHA1TEST=sha1test +SHATEST=shatest +SRC=bntest.c ideatest.c md2test.c md5test.c hmactest.c rc2test.c rc4test.c rc5test.c destest.c shatest.c sha1test.c mdc2test.c rmdtest.c randtest.c dhtest.c casttest.c bftest.c ssltest.c dsatest.c exptest.c +SSLTEST=ssltest +TOP=.. +RELATIVE_DIRECTORY= +RELATIVE_DIRECTORY=tools +APPS=c_hash c_info c_issuer c_name c_rehash +CC=cc +CFLAG=-g +CFLAGS=-I.. -I../../include -g +DIR=tools +GENERAL=Makefile.ssl +INCLUDES=-I.. -I../../include +INSTALLTOP=/usr/local/ssl +MAKE=make -f Makefile.ssl +MAKEDEPEND=makedepend -f Makefile.ssl +MAKEFILE=Makefile.ssl +TEST= +TOP=.. +RELATIVE_DIRECTORY= diff --git a/src/lib/libssl/src/Makefile.ssl b/src/lib/libssl/src/Makefile.ssl new file mode 100644 index 0000000000..da7f885985 --- /dev/null +++ b/src/lib/libssl/src/Makefile.ssl @@ -0,0 +1,331 @@ +# +# Makefile for all the SSL related library routines and utilities +VERSION = 0.9.0a +# +# make install will install: +# libraries into $INSTALLTOP/lib +# headers into $INSTALLTOP/include +# utilities into $INSTALLTOP/bin +# +# By default INSTALLTOP is set to /usr/local/ssl +# If you want things install elsewere, consider running +# perl util/ssldir.pl /new/path +# +# Interesting Mailing Lists: +# ssl-bugs@mincom.oz.au +# ssl-users@mincom.oz.au +# +# To join the Mailing Lists: +# ssl-bugs-request@mincom.oz.au +# ssl-users-request@mincom.oz.au +# +# If you must get hold of people directly (we much prefer the above +# lists to be used if the question is of general interest!): +# Eric Young +# Tim Hudson +# or both +# +# The primary distribution of SSLeay is from +# ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL +# +# NOCONST - Define for C compilers that don't like the const key word. +# NOPROTO - Define in if your compiler does not support prototypes. +# RSAref - Define if we are to link with RSAref. +# NO_IDEA - Define to build without the IDEA algorithm +# NO_RC4 - Define to build without the RC4 algorithm +# NO_RC2 - Define to build without the RC2 algorithm +# THREADS - Define when building with threads, you will probably also need any +# system defines as well, i.e. _REENTERANT for Solaris 2.[34] +# TERMIO - Define the termio terminal subsystem, needed if sgtty is missing. +# TERMIOS - Define the termios terminal subsystem, Silicon Graphics. +# LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3). +# DEVRANDOM - Give this the value of the 'random device' if your OS supports +# one. 32 bytes will be read from this when the random +# number generator is initalised. +# SSL_ALLOW_ADH - define if you want the server to be able to use the +# SSLv3 anon-DH ciphers. +# SSL_ALLOW_ENULL - define if you want the server to be able to use the +# NULL encryption ciphers. +# +# LOCK_DEBUG - turns on lots of lock debug output :-) +# REF_CHECK - turn on some xyz_free() assertions. +# REF_PRINT - prints some stuff on structure free. +# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff +# MFUNC - Make all Malloc/Free/Realloc calls call +# CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to +# call application defined callbacks via CRYPTO_set_mem_functions() +# MD5_ASM needs to be defined to use the x86 assembler for MD5 +# SHA1_ASM needs to be defined to use the x86 assembler for SHA1 +# RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160 + + +CC= gcc +#CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DMD5_ASM -DSHA1_ASM -DRMD160_ASM +CFLAG= -DNO_IDEA -DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM +PEX_LIBS= -L. -L.. -L../.. -L../../.. +EX_LIBS= +AR=ar r + +# Set BN_MULW to bn_mulw.o if you want to use the C version +BN_MULW= asm/bn86-out.o +#BN_MULW= bn_mulw.o +#BN_MULW= asm/bn86-elf.o # elf, linux-elf +#BN_MULW= asm/bn86-sol.o # solaris +#BN_MULW= asm/bn86-out.o # a.out, FreeBSD +#BN_MULW= asm/bn86bsdi.o # bsdi +#BN_MULW= asm/alpha.o # DEC Alpha +#BN_MULW= asm/pa-risc2.o # HP-UX PA-RISC +#BN_MULW= asm/r3000.o # SGI MIPS cpu +#BN_MULW= asm/sparc.o # Sun solaris/SunOS +#BN_MULW= asm/bn-win32.o # Windows 95/NT +#BN_MULW= asm/x86w16.o # 16 bit code for Windows 3.1/DOS +#BN_MULW= asm/x86w32.o # 32 bit code for Windows 3.1 + +# Set DES_ENC to des_enc.o if you want to use the C version +#There are 4 x86 assember options. +DES_ENC= asm/dx86-out.o asm/yx86-out.o +#DES_ENC= des_enc.o fcrypt_b.o # C +#DES_ENC= asm/dx86-elf.o asm/yx86-elf.o # elf +#DES_ENC= asm/dx86-sol.o asm/yx86-sol.o # solaris +#DES_ENC= asm/dx86-out.o asm/yx86-out.o # a.out, FreeBSD +#DES_ENC= asm/dx86bsdi.o asm/yx86bsdi.o # bsdi + +# Set BF_ENC to bf_enc.o if you want to use the C version +#There are 4 x86 assember options. +BF_ENC= asm/bx86-out.o +#BF_ENC= bf_enc.o +#BF_ENC= asm/bx86-elf.o # elf +#BF_ENC= asm/bx86-sol.o # solaris +#BF_ENC= asm/bx86-out.o # a.out, FreeBSD +#BF_ENC= asm/bx86bsdi.o # bsdi + +# Set CAST_ENC to c_enc.o if you want to use the C version +#There are 4 x86 assember options. +CAST_ENC= asm/cx86-out.o +#CAST_ENC= c_enc.o +#CAST_ENC= asm/cx86-elf.o # elf +#CAST_ENC= asm/cx86-sol.o # solaris +#CAST_ENC= asm/cx86-out.o # a.out, FreeBSD +#CAST_ENC= asm/cx86bsdi.o # bsdi + +# Set RC4_ENC to rc4_enc.o if you want to use the C version +#There are 4 x86 assember options. +RC4_ENC= asm/rx86-out.o +#RC4_ENC= rc4_enc.o +#RC4_ENC= asm/rx86-elf.o # elf +#RC4_ENC= asm/rx86-sol.o # solaris +#RC4_ENC= asm/rx86-out.o # a.out, FreeBSD +#RC4_ENC= asm/rx86bsdi.o # bsdi + +# Set RC5_ENC to rc5_enc.o if you want to use the C version +#There are 4 x86 assember options. +RC5_ENC= asm/r586-out.o +#RC5_ENC= rc5_enc.o +#RC5_ENC= asm/r586-elf.o # elf +#RC5_ENC= asm/r586-sol.o # solaris +#RC5_ENC= asm/r586-out.o # a.out, FreeBSD +#RC5_ENC= asm/r586bsdi.o # bsdi + +# Also need MD5_ASM defined +MD5_ASM_OBJ= asm/mx86-out.o +#MD5_ASM_OBJ= asm/mx86-elf.o # elf +#MD5_ASM_OBJ= asm/mx86-sol.o # solaris +#MD5_ASM_OBJ= asm/mx86-out.o # a.out, FreeBSD +#MD5_ASM_OBJ= asm/mx86bsdi.o # bsdi + +# Also need SHA1_ASM defined +SHA1_ASM_OBJ= asm/sx86-out.o +#SHA1_ASM_OBJ= asm/sx86-elf.o # elf +#SHA1_ASM_OBJ= asm/sx86-sol.o # solaris +#SHA1_ASM_OBJ= asm/sx86-out.o # a.out, FreeBSD +#SHA1_ASM_OBJ= asm/sx86bsdi.o # bsdi + +# Also need RMD160_ASM defined +RMD160_ASM_OBJ= asm/rm86-out.o +#RMD160_ASM_OBJ= asm/rm86-elf.o # elf +#RMD160_ASM_OBJ= asm/rm86-sol.o # solaris +#RMD160_ASM_OBJ= asm/rm86-out.o # a.out, FreeBSD +#RMD160_ASM_OBJ= asm/rm86bsdi.o # bsdi + +DIRS= crypto ssl rsaref apps test tools +# dirs in crypto to build +SDIRS= \ + md2 md5 sha mdc2 hmac ripemd \ + des rc2 rc4 rc5 idea bf cast \ + bn rsa dsa dh \ + buffer bio stack lhash rand err objects \ + evp pem asn1 x509 conf txt_db pkcs7 + +# If you change the INSTALLTOP, make sure to also change the values +# in crypto/location.h +INSTALLTOP=/usr/ssl + +MAKEFILE= Makefile.ssl +MAKE= make -f Makefile.ssl + +MAN1=1 +MAN3=3 +SHELL=/bin/sh + +TOP= . +ONEDIRS=out tmp +EDIRS= times doc bugs util include certs ms shlib mt demos perl dep +MISC= COPYRIGHT Configure HISTORY.066 INSTALL Makefile.ssl Makefile \ + README TODO HISTORY README.066 README.080 README.090 \ + VERSION PROBLEMS MINFO makefile.one e_os.h \ + MICROSOFT makevms.com config PATENTS +WDIRS= windows +LIBS= libcrypto.a libssl.a + +GENERAL= Makefile +BASENAME= SSLeay +NAME= $(BASENAME)-$(VERSION) +TARFILE= $(NAME).tar +WTARFILE= $(NAME)-win.tar +EXHEADER= e_os.h +HEADER= e_os.h + +all: + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making $$i..."; \ + $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' SDIRS='${SDIRS}' AR='${AR}' all ); \ + done; + +sub_all: + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making $$i..."; \ + $(MAKE) CC='${CC}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' all ); \ + done; + +clean: + /bin/rm -f shlib/*.o *.o core a.out fluff *.map + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "cleaning $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' clean ); \ + /bin/rm -f $(LIBS); \ + done; + /bin/rm -f *.a *.o speed.* *.map *.so .pure core + /bin/rm -f $(TARFILE) + @for i in $(ONEDIRS) ;\ + do \ + /bin/rm -fr $$i/*; \ + done + +makefile.one: files + perl util/mk1mf.pl >makefile.one; \ + sh util/do_ms.sh + +files: MINFO + perl $(TOP)/util/files.pl Makefile.ssl > $(TOP)/MINFO + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making 'files' in $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' files ); \ + done; + +links: + /bin/rm -f Makefile; + ./util/point.sh Makefile.ssl Makefile; + $(TOP)/util/mklink.sh include $(EXHEADER) ; + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making links in $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' links ); \ + done; + # @(cd apps; sh ./mklinks) + @( SSLEAY="`pwd`/apps/ssleay"; export SSLEAY; sh tools/c_rehash certs ) + +dclean: + /bin/rm -f *.bak + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "undoing makedepend in $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' dclean ); \ + done; + +rehash: + @(PATH="`pwd`/apps:${PATH}"; sh tools/c_rehash certs) + +test: tests + +tests: + (cd test; echo "testing $$i..."; \ + $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' tests ); + @apps/ssleay version -a + +depend: + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making dependancies $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' depend ); \ + done; + +lint: + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making lint $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' lint ); \ + done; + +tags: + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making tags $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' tags ); \ + done; + +errors: + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "making errors in $$i..."; \ + $(MAKE) SDIRS='${SDIRS}' errors ); \ + done; + +tar: + @(cd ..;\ + mv $(BASENAME) $(NAME); \ + export STUFF; \ + for i in $(MISC) $(DIRS) $(EDIRS) $(ONEDIRS) ;\ + do \ + STUFF="$$STUFF $(NAME)/$$i"; \ + done; \ + tar cf $(NAME)/$(TARFILE) $$STUFF; \ + mv $(NAME) $(BASENAME) ) + gzip -f $(TARFILE) + +dist: + perl Configure dist + perl util/up_ver.pl ${VERSION} + @$(MAKE) dist_pem_h + @$(MAKE) SDIRS='${SDIRS}' clean + @$(MAKE) SDIRS='${SDIRS}' dclean + @(cd apps; sh ./rmlinks) + @$(MAKE) makefile.one + @$(MAKE) tar + +dist_pem_h: + (cd crypto/pem; $(MAKE) SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean) + +install: all + @-mkdir -p $(INSTALLTOP)/bin 2>/dev/null + @-mkdir -p $(INSTALLTOP)/lib 2>/dev/null + @-mkdir -p $(INSTALLTOP)/include 2>/dev/null + @-mkdir -p $(INSTALLTOP)/certs 2>/dev/null + @-mkdir -p $(INSTALLTOP)/private 2>/dev/null + @for i in $(DIRS) ;\ + do \ + (cd $$i; echo "installing $$i..."; \ + $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' install ); \ + done + @for i in $(LIBS) ;\ + do \ + ( echo installing $$i; \ + cp $$i $(INSTALLTOP)/lib; \ + sh util/ranlib.sh $(INSTALLTOP)/lib/$$i; \ + chmod 644 $(INSTALLTOP)/lib/$$i ); \ + done + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/PATENTS b/src/lib/libssl/src/PATENTS new file mode 100644 index 0000000000..61423d03c8 --- /dev/null +++ b/src/lib/libssl/src/PATENTS @@ -0,0 +1,9 @@ +RSA Data Security holds software patents on the RSA and RC5 algorithms. +If there ciphers are used used inside the USA (and Japan?), you must contact +RSA Data Security for licencing conditions. + +The IDEA algorithm is patented by XXXX and they should be contacted if that +algorithm is to be used. + +RC4 is a trademark of RSA Data Security, so use of this label should perhaps +only me used with RSA Data Security's permission. diff --git a/src/lib/libssl/src/README.066 b/src/lib/libssl/src/README.066 new file mode 100644 index 0000000000..d8e086d0b4 --- /dev/null +++ b/src/lib/libssl/src/README.066 @@ -0,0 +1,27 @@ + +SSLeay 0.6.6 13-Jan-1997 + +The main additions are + +- assember for x86 DES improvments. + From 191,000 per second on a pentium 100, I now get 281,000. The inner + loop and the IP/FP modifications are from + Svend Olaf Mikkelsen . Many thanks for his + contribution. +- The 'DES macros' introduced in 0.6.5 now have 3 types. + DES_PTR1, DES_PTR2 and 'normal'. As per before, des_opts reports which + is best and there is a summery of mine in crypto/des/options.txt +- A few bug fixes. +- Added blowfish. It is not used by SSL but all the other stuff that + deals with ciphers can use it in either ecb, cbc, cfb64 or ofb64 modes. + There are 3 options for optimising Blowfish. BF_PTR, BF_PTR2 and 'normal'. + BF_PTR2 is pentium/x86 specific. The correct option is setup in + the 'Configure' script. +- There is now a 'get client certificate' callback which can be + 'non-blocking'. If more details are required, let me know. It will + documented more in SSLv3 when I finish it. +- Bug fixes from 0.6.5 including the infamous 'ca' bug. The 'make test' + now tests the ca program. +- Lots of little things modified and tweaked. + +eric diff --git a/src/lib/libssl/src/README.080 b/src/lib/libssl/src/README.080 new file mode 100644 index 0000000000..155ce1c712 --- /dev/null +++ b/src/lib/libssl/src/README.080 @@ -0,0 +1,147 @@ +This version of SSLeay has quite a lot of things different from the +previous version. + +Basically check all callback parameters, I will be producing documentation +about how to use things in th future. Currently I'm just getting 080 out +the door. Please not that there are several ways to do everything, and +most of the applications in the apps directory are hybrids, some using old +methods and some using new methods. + +Have a look in demos/bio for some very simple programs and +apps/s_client.c and apps/s_server.c for some more advanced versions. +Notes are definitly needed but they are a week or so away. + +Anyway, some quick nots from Tim Hudson (tjh@cryptsoft.com) +--- +Quick porting notes for moving from SSLeay-0.6.x to SSLeay-0.8.x to +get those people that want to move to using the new code base off to +a quick start. + +Note that Eric has tidied up a lot of the areas of the API that were +less than desirable and renamed quite a few things (as he had to break +the API in lots of places anyrate). There are a whole pile of additional +functions for making dealing with (and creating) certificates a lot +cleaner. + +01-Jul-97 +Tim Hudson +tjh@cryptsoft.com + +---8<--- + +To maintain code that uses both SSLeay-0.6.x and SSLeay-0.8.x you could +use something like the following (assuming you #include "crypto.h" which +is something that you really should be doing). + +#if SSLEAY_VERSION_NUMBER >= 0x0800 +#define SSLEAY8 +#endif + +buffer.h -> splits into buffer.h and bio.h so you need to include bio.h + too if you are working with BIO internal stuff (as distinct + from simply using the interface in an opaque manner) + +#include "bio.h" - required along with "buffer.h" if you write + your own BIO routines as the buffer and bio + stuff that was intermixed has been separated + out + +envelope.h -> evp.h (which should have been done ages ago) + +Initialisation ... don't forget these or you end up with code that +is missing the bits required to do useful things (like ciphers): + +SSLeay_add_ssl_algorithms() +(probably also want SSL_load_error_strings() too but you should have + already had that call in place) + +SSL_CTX_new() - requires an extra method parameter + SSL_CTX_new(SSLv23_method()) + SSL_CTX_new(SSLv2_method()) + SSL_CTX_new(SSLv3_method()) + + OR to only have the server or the client code + SSL_CTX_new(SSLv23_server_method()) + SSL_CTX_new(SSLv2_server_method()) + SSL_CTX_new(SSLv3_server_method()) + or + SSL_CTX_new(SSLv23_client_method()) + SSL_CTX_new(SSLv2_client_method()) + SSL_CTX_new(SSLv3_client_method()) + +SSL_set_default_verify_paths() ... renamed to the more appropriate +SSL_CTX_set_default_verify_paths() + +If you want to use client certificates then you have to add in a bit +of extra stuff in that a SSLv3 server sends a list of those CAs that +it will accept certificates from ... so you have to provide a list to +SSLeay otherwise certain browsers will not send client certs. + +SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(s_cert_file)); + + +X509_NAME_oneline(X) -> X509_NAME_oneline(X,NULL,0) + or provide a buffer and size to copy the + result into + +X509_add_cert -> X509_STORE_add_cert (and you might want to read the + notes on X509_NAME structure changes too) + + +VERIFICATION CODE +================= + +The codes have all be renamed from VERIFY_ERR_* to X509_V_ERR_* to +more accurately reflect things. + +The verification callback args are now packaged differently so that +extra fields for verification can be added easily in future without +having to break things by adding extra parameters each release :-) + +X509_cert_verify_error_string -> X509_verify_cert_error_string + + +BIO INTERNALS +============= + +Eric has fixed things so that extra flags can be introduced in +the BIO layer in future without having to play with all the BIO +modules by adding in some macros. + +The ugly stuff using + b->flags ~= (BIO_FLAGS_RW|BIO_FLAGS_SHOULD_RETRY) +becomes + BIO_clear_retry_flags(b) + + b->flags |= (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY) +becomes + BIO_set_retry_read(b) + +Also ... BIO_get_retry_flags(b), BIO_set_flags(b) + + + +OTHER THINGS +============ + +X509_NAME has been altered so that it isn't just a STACK ... the STACK +is now in the "entries" field ... and there are a pile of nice functions +for getting at the details in a much cleaner manner. + +SSL_CTX has been altered ... "cert" is no longer a direct member of this +structure ... things are now down under "cert_store" (see x509_vfy.h) and +things are no longer in a CERTIFICATE_CTX but instead in a X509_STORE. +If your code "knows" about this level of detail then it will need some +surgery. + +If you depending on the incorrect spelling of a number of the error codes +then you will have to change your code as these have been fixed. + +ENV_CIPHER "type" got renamed to "nid" and as that is what it actually +has been all along so this makes things clearer. +ify_cert_error_string(ctx->error)); + +SSL_R_NO_CIPHER_WE_TRUST -> SSL_R_NO_CIPHER_LIST + and SSL_R_REUSE_CIPHER_LIST_NOT_ZERO + + diff --git a/src/lib/libssl/src/README.090 b/src/lib/libssl/src/README.090 new file mode 100644 index 0000000000..634870d5f1 --- /dev/null +++ b/src/lib/libssl/src/README.090 @@ -0,0 +1,71 @@ +10-Apr-1998 +I said the next version would go out at easter, and so it shall. +I expect a 0.9.1 will follow with portability fixes in the next few weeks. + +This is a quick, meet the deadline. Look to ssl-users for comments on what +is new etc. + +The state of play +- TLSv1 - I need to do some explaining about how the methods interact. + The bad news is that SSLeay 0.8.x application will not roll back to + SSLv3, I suffed up. 0.8.x is rather pedantic about the '3.0' version + number. Look at the 'no-tls' options in applications in the apps directory. +- The perl5 stuff is very rough. The SSL part does not work due to + reference count hassles in the BIO stuff. I just have not had time to + look at it. The cipher, digest and bignum stuff works though. I just + need to clean up the API. +- Lots of x86 assember. I now have it for des, 3des, rc4, rc5, blowfish, + cast, md5, sha1 and ripemd160. It has been tested on win32, linux (elf) + and FreeBSD (a.out). +- As mentioned above, cast, rc5 and ripemd160 have been added. +- A simple HMAC set of functions. +- EX_DATA strucutre, which can be used by applications or other libraries + to tack arbitarty data against strucutures that include it. + You will probably have to see examples to see how to use it, and I will + elaberate on the ssl-users mailing list +- RSA blinding. If you fear timing attacks on RSA, you can turn on + blinding which defeats it. +- From Tim Hudson, try running 'sh config' instead of 'perl Configure'. + I makes an educated guess as to what you are and then runs 'perl Configure' +- The error stuff has been modified so arbitary strings can be taged + against an error message. It is used in a few places to elaberate on + parameters that caused the error. + +Areas of work +- The 16bit big-num assember needs a routine added. The WIN16 and + WIN32 stuff is ok, but MS-DOS or 286 builds need the update. +- Most of the bignum assember will not work. There will be a function + missing, bn_add_words(). I need people to send me the C compiler output + for platforms I don't already have. Currently, the assember is correct for + x86, win32, win16(386+), linux elf, FreeBSD a.out and sparc. +- PKCS7, I have delusions of s/MIME. I need to do a BIO interface. +- perl5, it needs finishing +- X509v3 extension. I have some ideas, I just need to + implement them :-) +- Public key methods. I need to clean up the library internally so + public key methods are loaded is a similar way to symetric ciphers + and digests. I also need to seperate out the digests from public + key methods. This stuff is needed to support sortware patents, smaller + code size and hardware tokens. + +Anyway, this release gets out the bug fixes and TLS, but be warned, until +all those old SSLeay 0.8.x based server get upgraded, you will need to +connect with SSLv3 if TLSv1 fails. + +eric (about to go bushwalking for the 4 day easter break :-) + +PS Common problems +- For Win32 build, use /MD to specify your libraries, or build SSLeay with + the same flags as your application. Visual C stuffs up the malloc routines + if memory allocated by one memory model is freed by another. FILE pointers + are a major cause of these problem. +- If you are trying to use non-blocking IO and it is not working, + try 'ssleay s_client -help' and see if the -nbio option is listed. + For unixware, it has the non-block IO define in 'differnt' header file + and SSLeay will silently build without non-blocking IO calls (but for + unixware, the special header has been included). +- -DL_ENDIAN. For the message digests, some code needs to be turned off + in the C code when assember is used. For x86, this means the L_ENDIAN + needs to defined when x86 -DSHA1_ASM is defined. The reasons this is + not automagically done is because non-x86 assember could be bigendian. + For pure C code builds, the B_ENDIAN/L_ENDIAN flags are optional. diff --git a/src/lib/libssl/src/TODO b/src/lib/libssl/src/TODO new file mode 100644 index 0000000000..1c3da41cdf --- /dev/null +++ b/src/lib/libssl/src/TODO @@ -0,0 +1,28 @@ +- The loading of the netscape RC4 encrypted key is a crock of pig pellets. + It will be reworked along with a nice general mechanism for encrypting + ASN.1 stuff. [ Jun 96 ] I've cleaned up private keys internally but + still have not done PKCS#8 support. + +- Winsock support in s_client/s_server for windows nt/3.1 is a crock. + I will probably not get this fixed for a while, it is just there so + I could test things. + +- Be able to generate DSS certificates. + +- Add CRL to the X509 verification stuff, this will probably be added with + SSLv3. + ++ X509 callback. I need to callback the application to retrieve certificates + and CRL. + +*<- designates the things I'm activly working on. ++<- designates that which I have next in the queue. + +==== + +X509v3 extensions +verify certificate chains +X509 cert lookup methods +RSA/DSA/DH methods mostly for smart cards +dsa cert generation + diff --git a/src/lib/libssl/src/VERSION b/src/lib/libssl/src/VERSION new file mode 100644 index 0000000000..5555e9a3af --- /dev/null +++ b/src/lib/libssl/src/VERSION @@ -0,0 +1,24 @@ +SSLeay 0.8.1 + - Mostly bug fixes. There is an Ephemeral DH cipher problem which + is fixed. + +SSLeay 0.8.0 + - New release, for those that are wondering what happend to + 0.7.x, call it our internal development version :-) + - There have been lots of changes, mostly the addition of SSLv3. + - There have been many additions from people and amongst + others, C2Net has assisted greatly. + +SSLeay 0.6.6 + SSLeay 0.8.0 is not upward compatable with SSLeay 0.6.6, so + if your application requires 0.6.6, use it. There have been + lots of bug fixes to 0.8.x that have not been applied to 0.6.6 + so use 0.8.0+ in preference. + +PORTING 0.6.6 to 0.8.0 + I'll be documenting this over the next few weeks but as + pressures have been increasing for making SSLv3 support + available I'm shipping it without this documentation as I + basically have not had time to write it (too busy earning a + living :-) + diff --git a/src/lib/libssl/src/apps/Makefile.ssl b/src/lib/libssl/src/apps/Makefile.ssl new file mode 100644 index 0000000000..1cace40ab7 --- /dev/null +++ b/src/lib/libssl/src/apps/Makefile.ssl @@ -0,0 +1,144 @@ +# +# SSLeay/apps/Makefile.ssl +# + +DIR= apps +TOP= .. +CC= cc +INCLUDES= -I../include +CFLAG= -g -static +INSTALLTOP= /usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +RM= /bin/rm -f + +PEX_LIBS= +EX_LIBS= + +CFLAGS= -DMONOLITH $(INCLUDES) $(CFLAG) + +GENERAL=Makefile + +DLIBCRYPTO=../libcrypto.a +DLIBSSL=../libssl.a +LIBCRYPTO=-L.. -lcrypto +LIBSSL=-L.. -lssl + +SSLEAY= ssleay + +SCRIPTS=CA.sh der_chop + +EXE= $(SSLEAY) + +E_EXE= verify asn1pars req dgst dh enc gendh errstr ca crl \ + rsa dsa dsaparam \ + x509 genrsa s_server s_client speed \ + s_time version pkcs7 crl2pkcs7 sess_id ciphers + +PROGS= $(SSLEAY).c + +A_OBJ=apps.o +A_SRC=apps.c +S_OBJ= s_cb.o s_socket.o +S_SRC= s_cb.c s_socket.c + +E_OBJ= verify.o asn1pars.o req.o dgst.o dh.o enc.o gendh.o errstr.o ca.o \ + pkcs7.o crl2p7.o crl.o \ + rsa.o dsa.o dsaparam.o \ + x509.o genrsa.o s_server.o s_client.o speed.o \ + s_time.o $(A_OBJ) $(S_OBJ) version.o sess_id.o \ + ciphers.o + +# pem_mail.o + +E_SRC= verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c \ + pkcs7.c crl2p7.c crl.c \ + rsa.c dsa.c dsaparam.c \ + x509.c genrsa.c s_server.c s_client.c speed.c \ + s_time.c $(A_SRC) $(S_SRC) version.c sess_id.c \ + ciphers.c + +# pem_mail.c + +SRC=$(E_SRC) + +EXHEADER= +HEADER= apps.h progs.h s_apps.h \ + testdsa.h testrsa.h \ + $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + @(cd ..; $(MAKE) DIRS=$(DIR) all) + +all: exe + +exe: $(EXE) + +req: sreq.o $(A_OBJ) $(DLIBCRYPTO) + $(CC) -o req $(CFLAG) sreq.o $(A_OBJ) $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +sreq.o: req.c + $(CC) -c $(INCLUDES) $(CFLAG) -o sreq.o req.c + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +install: mklinks + @for i in $(EXE) $(SCRIPTS) mklinks; \ + do \ + (echo installing $$i; \ + cp $$i $(INSTALLTOP)/bin/$$i; \ + chmod 755 $(INSTALLTOP)/bin/$$i ); \ + done; \ + cp ssleay.cnf $(INSTALLTOP)/lib + chmod 644 $(INSTALLTOP)/lib/ssleay.cnf + cd $(INSTALLTOP)/bin; \ + /bin/sh ./mklinks; \ + /bin/rm -f ./mklinks + +tags: + ctags $(SRC) + +tests: + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +errors: + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) + /bin/rm -f req + +$(DLIBSSL): + (cd ../ssl; $(MAKE)) + +$(DLIBCRYPTO): + (cd ../crypto; $(MAKE)) + +$(SSLEAY): progs.h $(E_OBJ) $(SSLEAY).o $(DLIBCRYPTO) $(DLIBSSL) + $(RM) $(SSLEAY) + $(CC) -o $(SSLEAY) $(CFLAGS) $(SSLEAY).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) + +progs.h: + perl ./g_ssleay.pl $(E_EXE) >progs.h + $(RM) $(SSLEAY).o + +mklinks: + perl ./g_ssleay.pl $(E_EXE) >progs.h + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/apps/der_chop b/src/lib/libssl/src/apps/der_chop new file mode 100644 index 0000000000..4639330c10 --- /dev/null +++ b/src/lib/libssl/src/apps/der_chop @@ -0,0 +1,305 @@ +#!/usr/local/bin/perl +# +# der_chop ... this is one total hack that Eric is really not proud of +# so don't look at it and don't ask for support +# +# The "documentation" for this (i.e. all the comments) are my fault --tjh +# +# This program takes the "raw" output of derparse/asn1parse and +# converts it into tokens and then runs regular expression matches +# to try to figure out what to grab to get the things that are needed +# and it is possible that this will do the wrong thing as it is a *hack* +# +# SSLeay 0.5.2+ should have direct read support for x509 (via -inform NET) +# [I know ... promises promises :-)] +# +# To convert a Netscape Certificate: +# der_chop < ServerCert.der > cert.pem +# To convert a Netscape Key (and encrypt it again to protect it) +# rsa -inform NET -in ServerKey.der -des > key.pem +# +# 23-Apr-96 eay Added the extra ASN.1 string types, I still think this +# is an evil hack. If nothing else the parsing should +# be relative, not absolute. +# 19-Apr-96 tjh hacked (with eay) into 0.5.x format +# +# Tim Hudson +# tjh@cryptsoft.com +# + + +require 'getopts.pl'; + +$debug=0; + +# this was the 0.4.x way of doing things ... +$cmd="derparse"; +$x509_cmd="x509"; +$crl_cmd="crl"; +$rc4_cmd="rc4"; +$md2_cmd="md2"; +$md4_cmd="md4"; +$rsa_cmd="rsa -des -inform der "; + +# this was the 0.5.x way of doing things ... +$cmd="ssleay asn1parse"; +$x509_cmd="ssleay x509"; +$crl_cmd="ssleay crl"; +$rc4_cmd="ssleay rc4"; +$md2_cmd="ssleay md2"; +$md4_cmd="ssleay md4"; +$rsa_cmd="ssleay rsa -des -inform der "; + +&Getopts('vd:') || die "usage:$0 [-v] [-d num] file"; +$depth=($opt_d =~ /^\d+$/)?$opt_d:0; + +&init_der(); + +if ($#ARGV != -1) + { + foreach $file (@ARGV) + { + print STDERR "doing $file\n"; + &dofile($file); + } + } +else + { + $file="/tmp/a$$.DER"; + open(OUT,">$file") || die "unable to open $file:$!\n"; + for (;;) + { + $i=sysread(STDIN,$b,1024*10); + last if ($i <= 0); + $i=syswrite(OUT,$b,$i); + } + &dofile($file); + unlink($file); + } + +sub dofile + { + local($file)=@_; + local(@p); + + $b=&load_file($file); + @p=&load_file_parse($file); + + foreach $_ (@p) + { + ($off,$d,$hl,$len)=&parse_line($_); + $d-=$depth; + next if ($d != 0); + next if ($len == 0); + + $o=substr($b,$off,$len+$hl); + ($str,@data)=&der_str($o); + print "$str\n" if ($opt_v); + if ($str =~ /^$crl/) + { + open(OUT,"|$crl_cmd -inform d -hash -issuer") || + die "unable to run $crl_cmd:$!\n"; + print OUT $o; + close(OUT); + } + elsif ($str =~ /^$x509/) + { + open(OUT,"|$x509_cmd -inform d -hash -subject -issuer") + || die "unable to run $x509_cmd:$!\n"; + print OUT $o; + close(OUT); + } + elsif ($str =~ /^$rsa/) + { + ($type)=($data[3] =~ /OBJECT_IDENTIFIER :(.*)\s*$/); + next unless ($type eq "rsaEncryption"); + ($off,$d,$hl,$len)=&parse_line($data[5]); + $os=substr($o,$off+$hl,$len); + open(OUT,"|$rsa_cmd") + || die "unable to run $rsa_cmd:$!\n"; + print OUT $os; + close(OUT); + } + elsif ($str =~ /^0G-1D-1G/) + { + ($off,$d,$hl,$len)=&parse_line($data[1]); + $os=substr($o,$off+$hl,$len); + print STDERR "<$os>\n" if $opt_v; + &do_certificate($o,@data) + if (($os eq "certificate") && + ($str =! /^0G-1D-1G-2G-3F-3E-2D/)); + &do_private_key($o,@data) + if (($os eq "private-key") && + ($str =! /^0G-1D-1G-2G-3F-3E-2D/)); + } + } + } + +sub der_str + { + local($str)=@_; + local(*OUT,*IN,@a,$t,$d,$ret); + local($file)="/tmp/b$$.DER"; + local(@ret); + + open(OUT,">$file"); + print OUT $str; + close(OUT); + open(IN,"$cmd -inform 'd' -in $file |") || + die "unable to run $cmd:$!\n"; + $ret=""; + while () + { + chop; + push(@ret,$_); + + print STDERR "$_\n" if ($debug); + + @a=split(/\s*:\s*/); + ($d)=($a[1] =~ /d=\s*(\d+)/); + $a[2] =~ s/\s+$//; + $t=$DER_s2i{$a[2]}; + $ret.="$d$t-"; + } + close(IN); + unlink($file); + chop $ret; + $ret =~ s/(-3H(-4G-5F-5[IJKMQRS])+)+/-NAME/g; + $ret =~ s/(-3G-4B-4L)+/-RCERT/g; + return($ret,@ret); + } + +sub init_der + { + $crl= "0G-1G-2G-3F-3E-2G-NAME-2L-2L-2G-RCERT-1G-2F-2E-1C"; + $x509="0G-1G-2B-2G-3F-3E-2G-NAME-2G-3L-3L-2G-NAME-2G-3G-4F-4E-3C-1G-2F-2E-1C"; + $rsa= "0G-1B-1G-2F-2E-1D"; + + %DER_i2s=( + # SSLeay 0.4.x has this list + "A","EOC", + "B","INTEGER", + "C","BIT STRING", + "D","OCTET STRING", + "E","NULL", + "F","OBJECT", + "G","SEQUENCE", + "H","SET", + "I","PRINTABLESTRING", + "J","T61STRING", + "K","IA5STRING", + "L","UTCTIME", + "M","NUMERICSTRING", + "N","VIDEOTEXSTRING", + "O","GENERALIZEDTIME", + "P","GRAPHICSTRING", + "Q","ISO64STRING", + "R","GENERALSTRING", + "S","UNIVERSALSTRING", + + # SSLeay 0.5.x changed some things ... and I'm + # leaving in the old stuff but adding in these + # to handle the new as well --tjh + # - Well I've just taken them out and added the extra new + # ones :-) - eay + ); + + foreach (keys %DER_i2s) + { $DER_s2i{$DER_i2s{$_}}=$_; } + } + +sub parse_line + { + local($_)=@_; + + return(/\s*(\d+):d=\s*(\d+)\s+hl=\s*(\d+)\s+l=\s*(\d+|inf)\s/); + } + +# 0:d=0 hl=4 l=377 cons: univ: SEQUENCE +# 4:d=1 hl=2 l= 11 prim: univ: OCTET_STRING +# 17:d=1 hl=4 l=360 cons: univ: SEQUENCE +# 21:d=2 hl=2 l= 12 cons: univ: SEQUENCE +# 23:d=3 hl=2 l= 8 prim: univ: OBJECT_IDENTIFIER :rc4 +# 33:d=3 hl=2 l= 0 prim: univ: NULL +# 35:d=2 hl=4 l=342 prim: univ: OCTET_STRING +sub do_private_key + { + local($data,@struct)=@_; + local($file)="/tmp/b$$.DER"; + local($off,$d,$hl,$len,$_,$b,@p,$s); + + ($type)=($struct[4] =~ /OBJECT_IDENTIFIER :(.*)\s*$/); + if ($type eq "rc4") + { + ($off,$d,$hl,$len)=&parse_line($struct[6]); + open(OUT,"|$rc4_cmd >$file") || + die "unable to run $rc4_cmd:$!\n"; + print OUT substr($data,$off+$hl,$len); + close(OUT); + + $b=&load_file($file); + unlink($file); + + ($s,@p)=&der_str($b); + die "unknown rsa key type\n$s\n" + if ($s ne '0G-1B-1G-2F-2E-1D'); + local($off,$d,$hl,$len)=&parse_line($p[5]); + $b=substr($b,$off+$hl,$len); + ($s,@p)=&der_str($b); + open(OUT,"|$rsa_cmd") || die "unable to run $rsa_cmd:$!\n"; + print OUT $b; + close(OUT); + } + else + { + print "'$type' is unknown\n"; + exit(1); + } + } + +sub do_certificate + { + local($data,@struct)=@_; + local($file)="/tmp/b$$.DER"; + local($off,$d,$hl,$len,$_,$b,@p,$s); + + ($off,$d,$hl,$len)=&parse_line($struct[2]); + $b=substr($data,$off,$len+$hl); + + open(OUT,"|$x509_cmd -inform d") || die "unable to run $x509_cmd:$!\n"; + print OUT $b; + close(OUT); + } + +sub load_file + { + local($file)=@_; + local(*IN,$r,$b,$i); + + $r=""; + open(IN,"<$file") || die "unable to open $file:$!\n"; + for (;;) + { + $i=sysread(IN,$b,10240); + last if ($i <= 0); + $r.=$b; + } + close(IN); + return($r); + } + +sub load_file_parse + { + local($file)=@_; + local(*IN,$r,@ret,$_,$i,$n,$b); + + open(IN,"$cmd -inform d -in $file|") + || die "unable to run der_parse\n"; + while () + { + chop; + push(@ret,$_); + } + return($r,@ret); + } + diff --git a/src/lib/libssl/src/apps/eay.c b/src/lib/libssl/src/apps/eay.c new file mode 100644 index 0000000000..37d5dcbd30 --- /dev/null +++ b/src/lib/libssl/src/apps/eay.c @@ -0,0 +1,130 @@ +/* apps/eay.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include + +#define MONOLITH +#define USE_SOCKETS +#include "../e_os.h" + +#include "bio.h" +#include "stack.h" +#include "lhash.h" + +#include "err.h" + +#include "bn.h" + +#include "evp.h" + +#include "rand.h" +#include "conf.h" +#include "txt_db.h" + +#include "err.h" + +#include "x509.h" +#include "pkcs7.h" +#include "pem.h" +#include "asn1.h" +#include "objects.h" + +#define MONOLITH + +#include "ssleay.c" +#include "apps.c" +#include "asn1pars.c" +#ifndef NO_RSA +#include "ca.c" +#include "genrsa.c" +#include "req.c" +#include "rsa.c" +#endif +#ifndef NO_DH +#include "gendh.c" +#include "dh.c" +#endif +#include "crl.c" +#include "crl2p7.c" +#include "dgst.c" +#include "enc.c" +#include "errstr.c" +#if !defined(NO_SSL2) || !defined(NO_SSL3) +#ifndef NO_SOCK +#include "s_cb.c" +#include "s_client.c" +#include "s_server.c" +#include "s_socket.c" +#include "s_time.c" +#endif +#endif +#include "speed.c" +#include "verify.c" +#include "version.c" +#include "x509.c" +#include "ciphers.c" +#include "sess_id.c" +#include "pkcs7.c" +#ifndef NO_DSA +#include "dsaparam.c" +#include "dsa.c" +#include "gendsa.c" +#endif + diff --git a/src/lib/libssl/src/apps/ext.v3 b/src/lib/libssl/src/apps/ext.v3 new file mode 100644 index 0000000000..87ee8e6173 --- /dev/null +++ b/src/lib/libssl/src/apps/ext.v3 @@ -0,0 +1,2 @@ +2.99999.3 SET.ex3 SET x509v3 extension 3 + diff --git a/src/lib/libssl/src/apps/g_ssleay.pl b/src/lib/libssl/src/apps/g_ssleay.pl new file mode 100644 index 0000000000..bd5621dcab --- /dev/null +++ b/src/lib/libssl/src/apps/g_ssleay.pl @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +$mkprog='mklinks'; +$rmprog='rmlinks'; + +print "#ifndef NOPROTO\n"; + +grep(s/^asn1pars$/asn1parse/,@ARGV); + +foreach (@ARGV) + { printf "extern int %s_main(int argc,char *argv[]);\n",$_; } +print "#else\n"; +foreach (@ARGV) + { printf "extern int %s_main();\n",$_; } +print "#endif\n"; + + +print <<'EOF'; + +#ifdef SSLEAY_SRC + +#define FUNC_TYPE_GENERAL 1 +#define FUNC_TYPE_MD 2 +#define FUNC_TYPE_CIPHER 3 + +typedef struct { + int type; + char *name; + int (*func)(); + } FUNCTION; + +FUNCTION functions[] = { +EOF + +foreach (@ARGV) + { + push(@files,$_); + $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n"; + if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/)) + { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))\n${str}#endif\n"; } + elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) || + ($_ =~ /^req$/) || ($_ =~ /^ca$/) || ($_ =~ /^x509$/)) + { print "#ifndef NO_RSA\n${str}#endif\n"; } + elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/)) + { print "#ifndef NO_DSA\n${str}#endif\n"; } + elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/)) + { print "#ifndef NO_DH\n${str}#endif\n"; } + else + { print $str; } + } + +foreach ("md2","md5","sha","sha1","mdc2") + { + push(@files,$_); + printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_; + } + +foreach ( + "base64", + "des", "des3", "desx", "idea", "rc4", "rc2","bf","cast","rc5", + "des-ecb", "des-ede", "des-ede3", + "des-cbc", "des-ede-cbc","des-ede3-cbc", + "des-cfb", "des-ede-cfb","des-ede3-cfb", + "des-ofb", "des-ede-ofb","des-ede3-ofb", + "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb", + "rc2-cbc", "rc2-ecb", "rc2-cfb", "rc2-ofb", + "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb", + "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb", + "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb") + { + push(@files,$_); + + $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_); + if ($_ =~ /des/) { $t="#ifndef NO_DES\n${t}#endif\n"; } + elsif ($_ =~ /idea/) { $t="#ifndef NO_IDEA\n${t}#endif\n"; } + elsif ($_ =~ /rc4/) { $t="#ifndef NO_RC4\n${t}#endif\n"; } + elsif ($_ =~ /rc2/) { $t="#ifndef NO_RC2\n${t}#endif\n"; } + elsif ($_ =~ /bf/) { $t="#ifndef NO_BLOWFISH\n${t}#endif\n"; } + elsif ($_ =~ /cast/) { $t="#ifndef NO_CAST\n${t}#endif\n"; } + elsif ($_ =~ /rc5/) { $t="#ifndef NO_RC5\n${t}#endif\n"; } + print $t; + } + +print "\t{0,NULL,NULL}\n\t};\n"; +print "#endif\n\n"; + +open(OUT,">$mkprog") || die "unable to open '$prog':$!\n"; +print OUT "#!/bin/sh\nfor i in "; +foreach (@files) + { print OUT $_." "; } +print OUT <<'EOF'; + +do +echo making symlink for $i +/bin/rm -f $i +ln -s ssleay $i +done +EOF +close(OUT); +chmod(0755,$mkprog); + +open(OUT,">$rmprog") || die "unable to open '$prog':$!\n"; +print OUT "#!/bin/sh\nfor i in "; +foreach (@files) + { print OUT $_." "; } +print OUT <<'EOF'; + +do +echo removing $i +/bin/rm -f $i +done +EOF +close(OUT); +chmod(0755,$rmprog); diff --git a/src/lib/libssl/src/apps/mklinks b/src/lib/libssl/src/apps/mklinks new file mode 100644 index 0000000000..55a56b399e --- /dev/null +++ b/src/lib/libssl/src/apps/mklinks @@ -0,0 +1,7 @@ +#!/bin/sh +for i in verify asn1parse req dgst dh enc gendh errstr ca crl rsa dsa dsaparam x509 genrsa s_server s_client speed s_time version pkcs7 crl2pkcs7 sess_id ciphers md2 md5 sha sha1 mdc2 base64 des des3 desx idea rc4 rc2 bf cast rc5 des-ecb des-ede des-ede3 des-cbc des-ede-cbc des-ede3-cbc des-cfb des-ede-cfb des-ede3-cfb des-ofb des-ede-ofb des-ede3-ofb idea-cbc idea-ecb idea-cfb idea-ofb rc2-cbc rc2-ecb rc2-cfb rc2-ofb bf-cbc bf-ecb bf-cfb bf-ofb cast5-cbc cast5-ecb cast5-cfb cast5-ofb cast-cbc rc5-cbc rc5-ecb rc5-cfb rc5-ofb +do +echo making symlink for $i +/bin/rm -f $i +ln -s ssleay $i +done diff --git a/src/lib/libssl/src/apps/pem_mail.c b/src/lib/libssl/src/apps/pem_mail.c new file mode 100644 index 0000000000..64e04acb52 --- /dev/null +++ b/src/lib/libssl/src/apps/pem_mail.c @@ -0,0 +1,170 @@ +/* apps/pem_mail.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "rsa.h" +#include "evp.h" +#include "objects.h" +#include "x509.h" +#include "err.h" +#include "pem.h" +#include "apps.h" + +#undef PROG +#define PROG pem_mail_main + +static char *usage[]={ +"usage: pem_mail args\n", +"\n", +" -in arg - input file - default stdin\n", +" -out arg - output file - default stdout\n", +" -cert arg - the certificate to use\n", +" -key arg - the private key to use\n", +" -MIC - sign the message\n", +" -enc arg - encrypt with one of cbc-des\n", +NULL +}; + + +typedef struct lines_St + { + char *line; + struct lines_st *next; + } LINES; + +int main(argc, argv) +int argc; +char **argv; + { + FILE *in; + RSA *rsa=NULL; + EVP_MD_CTX ctx; + unsigned int mic=0,i,n; + unsigned char buf[1024*15]; + char *prog,*infile=NULL,*outfile=NULL,*key=NULL; + int badops=0; + + apps_startup(); + + prog=argv[0]; + argc--; + argv++; + while (argc >= 1) + { + if (strcmp(*argv,"-key") == 0) + { + if (--argc < 1) goto bad; + key= *(++argv); + } + else if (strcmp(*argv,"-in") == 0) + { + if (--argc < 1) goto bad; + infile= *(++argv); + } + else if (strcmp(*argv,"-out") == 0) + { + if (--argc < 1) goto bad; + outfile= *(++argv); + } + else if (strcmp(*argv,"-mic") == 0) + mic=1; + else + { + BIO_printf(bio_err,"unknown option %s\n",*argv); + badops=1; + break; + } + argc--; + argv++; + } + + if (badops) + { +bad: + BIO_printf(bio_err,"%s [options] outfile\n",prog); + BIO_printf(bio_err,"where options are\n"); + EXIT(1); + } + + if (key == NULL) + { BIO_printf(bio_err,"you need to specify a key\n"); EXIT(1); } + in=fopen(key,"r"); + if (in == NULL) { perror(key); EXIT(1); } + rsa=PEM_read_RSAPrivateKey(in,NULL,NULL); + if (rsa == NULL) + { + BIO_printf(bio_err,"unable to load Private Key\n"); + ERR_print_errors(bio_err); + EXIT(1); + } + fclose(in); + + PEM_SignInit(&ctx,EVP_md5()); + for (;;) + { + i=fread(buf,1,1024*10,stdin); + if (i <= 0) break; + PEM_SignUpdate(&ctx,buf,i); + } + if (!PEM_SignFinal(&ctx,buf,&n,rsa)) goto err; + BIO_printf(bio_err,"%s\n",buf); + EXIT(0); +err: + ERR_print_errors(bio_err); + EXIT(1); + } diff --git a/src/lib/libssl/src/apps/rmlinks b/src/lib/libssl/src/apps/rmlinks new file mode 100644 index 0000000000..7c4f8983ba --- /dev/null +++ b/src/lib/libssl/src/apps/rmlinks @@ -0,0 +1,6 @@ +#!/bin/sh +for i in verify asn1parse req dgst dh enc gendh errstr ca crl rsa dsa dsaparam x509 genrsa s_server s_client speed s_time version pkcs7 crl2pkcs7 sess_id ciphers md2 md5 sha sha1 mdc2 base64 des des3 desx idea rc4 rc2 bf cast rc5 des-ecb des-ede des-ede3 des-cbc des-ede-cbc des-ede3-cbc des-cfb des-ede-cfb des-ede3-cfb des-ofb des-ede-ofb des-ede3-ofb idea-cbc idea-ecb idea-cfb idea-ofb rc2-cbc rc2-ecb rc2-cfb rc2-ofb bf-cbc bf-ecb bf-cfb bf-ofb cast5-cbc cast5-ecb cast5-cfb cast5-ofb cast-cbc rc5-cbc rc5-ecb rc5-cfb rc5-ofb +do +echo removing $i +/bin/rm -f $i +done diff --git a/src/lib/libssl/src/apps/ssleay.c b/src/lib/libssl/src/apps/ssleay.c new file mode 100644 index 0000000000..eac411b854 --- /dev/null +++ b/src/lib/libssl/src/apps/ssleay.c @@ -0,0 +1,342 @@ +/* apps/ssleay.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef DEBUG +#undef DEBUG +#endif + +#include +#include +#include +#include "bio.h" +#include "crypto.h" +#include "lhash.h" +#include "conf.h" +#include "x509.h" +#include "pem.h" +#include "ssl.h" +#define SSLEAY /* turn off a few special case MONOLITH macros */ +#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ +#define SSLEAY_SRC +#include "apps.h" +#include "s_apps.h" +#include "err.h" + +/* +#ifdef WINDOWS +#include "bss_file.c" +#endif +*/ + +#ifndef NOPROTO +static unsigned long MS_CALLBACK hash(FUNCTION *a); +static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); +static LHASH *prog_init(void ); +static int do_cmd(LHASH *prog,int argc,char *argv[]); +#else +static unsigned long MS_CALLBACK hash(); +static int MS_CALLBACK cmp(); +static LHASH *prog_init(); +static int do_cmd(); +#endif + +LHASH *config=NULL; +char *default_config_file=NULL; + +#ifdef DEBUG +static void sig_stop(i) +int i; + { + char *a=NULL; + + *a='\0'; + } +#endif + +/* Make sure there is only one when MONOLITH is defined */ +#ifdef MONOLITH +BIO *bio_err=NULL; +#endif + +int main(Argc,Argv) +int Argc; +char *Argv[]; + { + ARGS arg; +#define PROG_NAME_SIZE 16 + char pname[PROG_NAME_SIZE]; + FUNCTION f,*fp; + MS_STATIC char *prompt,buf[1024],config_name[256]; + int n,i,ret=0; + int argc; + char **argv,*p; + LHASH *prog=NULL; + long errline; + + arg.data=NULL; + arg.count=0; + + /* SSLeay_add_ssl_algorithms(); is called in apps_startup() */ + apps_startup(); + +#if defined(DEBUG) && !defined(WINDOWS) && !defined(MSDOS) +#ifdef SIGBUS + signal(SIGBUS,sig_stop); +#endif +#ifdef SIGSEGV + signal(SIGSEGV,sig_stop); +#endif +#endif + + if (bio_err == NULL) + if ((bio_err=BIO_new(BIO_s_file())) != NULL) + BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); + + CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); + + ERR_load_crypto_strings(); + + /* Lets load up our environment a little */ + p=getenv("SSLEAY_CONF"); + if (p == NULL) + { + strcpy(config_name,X509_get_default_cert_area()); + strcat(config_name,"/lib/"); + strcat(config_name,SSLEAY_CONF); + p=config_name; + } + + default_config_file=p; + + config=CONF_load(config,p,&errline); + if (config == NULL) ERR_clear_error(); + + prog=prog_init(); + + /* first check the program name */ + program_name(Argv[0],pname,PROG_NAME_SIZE); + + f.name=pname; + fp=(FUNCTION *)lh_retrieve(prog,(char *)&f); + if (fp != NULL) + { + Argv[0]=pname; + ret=fp->func(Argc,Argv); + goto end; + } + + /* ok, now check that there are not arguments, if there are, + * run with them, shifting the ssleay off the front */ + if (Argc != 1) + { + Argc--; + Argv++; + ret=do_cmd(prog,Argc,Argv); + if (ret < 0) ret=0; + goto end; + } + + /* ok, lets enter the old 'SSLeay>' mode */ + + for (;;) + { + ret=0; + p=buf; + n=1024; + i=0; + for (;;) + { + p[0]='\0'; + if (i++) + prompt=">"; + else prompt="SSLeay>"; + fputs(prompt,stdout); + fflush(stdout); + fgets(p,n,stdin); + if (p[0] == '\0') goto end; + i=strlen(p); + if (i <= 1) break; + if (p[i-2] != '\\') break; + i-=2; + p+=i; + n-=i; + } + if (!chopup_args(&arg,buf,&argc,&argv)) break; + + ret=do_cmd(prog,argc,argv); + if (ret < 0) + { + ret=0; + goto end; + } + if (ret != 0) + BIO_printf(bio_err,"error in %s\n",argv[0]); + BIO_flush(bio_err); + } + BIO_printf(bio_err,"bad exit\n"); + ret=1; +end: + if (config != NULL) + { + CONF_free(config); + config=NULL; + } + if (prog != NULL) lh_free(prog); + if (arg.data != NULL) Free(arg.data); + ERR_remove_state(0); + + EVP_cleanup(); + + CRYPTO_mem_leaks(bio_err); + if (bio_err != NULL) + { + BIO_free(bio_err); + bio_err=NULL; + } + EXIT(ret); + } + +static int do_cmd(prog,argc,argv) +LHASH *prog; +int argc; +char *argv[]; + { + FUNCTION f,*fp; + int i,ret=1,tp,nl; + + if ((argc <= 0) || (argv[0] == NULL)) + { ret=0; goto end; } + f.name=argv[0]; + fp=(FUNCTION *)lh_retrieve(prog,(char *)&f); + if (fp != NULL) + { + ret=fp->func(argc,argv); + } + else if ((strcmp(argv[0],"quit") == 0) || + (strcmp(argv[0],"q") == 0) || + (strcmp(argv[0],"exit") == 0) || + (strcmp(argv[0],"bye") == 0)) + { + ret= -1; + goto end; + } + else + { + BIO_printf(bio_err,"'%s' is a bad command, valid commands are", + argv[0]); + i=0; + fp=functions; + tp=0; + for (fp=functions; fp->name != NULL; fp++) + { + nl=0; + if (((i++) % 5) == 0) + { + BIO_printf(bio_err,"\n"); + nl=1; + } + if (fp->type != tp) + { + tp=fp->type; + if (!nl) BIO_printf(bio_err,"\n"); + if (tp == FUNC_TYPE_MD) + { + i=1; + BIO_printf(bio_err, + "Message Digest commands - see the dgst command for more details\n"); + } + else if (tp == FUNC_TYPE_CIPHER) + { + i=1; + BIO_printf(bio_err,"Cipher commands - see the enc command for more details\n"); + } + } + BIO_printf(bio_err,"%-15s",fp->name); + } + BIO_printf(bio_err,"\nquit\n"); + ret=0; + } +end: + return(ret); + } + +static LHASH *prog_init() + { + LHASH *ret; + FUNCTION *f; + + if ((ret=lh_new(hash,cmp)) == NULL) return(NULL); + + for (f=functions; f->name != NULL; f++) + lh_insert(ret,(char *)f); + return(ret); + } + +static int MS_CALLBACK cmp(a,b) +FUNCTION *a,*b; + { + return(strncmp(a->name,b->name,8)); + } + +static unsigned long MS_CALLBACK hash(a) +FUNCTION *a; + { + return(lh_strhash(a->name)); + } + +#undef SSLEAY diff --git a/src/lib/libssl/src/apps/ssleay.cnf b/src/lib/libssl/src/apps/ssleay.cnf new file mode 100644 index 0000000000..0b3bfa64f8 --- /dev/null +++ b/src/lib/libssl/src/apps/ssleay.cnf @@ -0,0 +1,116 @@ +# +# SSLeay example configuration file. +# This is mostly being used for generation of certificate requests. +# + +RANDFILE = $ENV::HOME/.rnd + +#################################################################### +[ ca ] +default_ca = CA_default # The default ca section + +#################################################################### +[ CA_default ] + +dir = ./demoCA # Where everything is kept +certs = $dir/certs # Where the issued certs are kept +crl_dir = $dir/crl # Where the issued crl are kept +database = $dir/index.txt # database index file. +new_certs_dir = $dir/newcerts # default place for new certs. + +certificate = $dir/cacert.pem # The CA certificate +serial = $dir/serial # The current serial number +crl = $dir/crl.pem # The current CRL +private_key = $dir/private/cakey.pem# The private key +RANDFILE = $dir/private/.rand # private random number file + +x509_extensions = x509v3_extensions # The extentions to add to the cert +default_days = 365 # how long to certify for +default_crl_days= 30 # how long before next CRL +default_md = md5 # which md to use. +preserve = no # keep passed DN ordering + +# A few difference way of specifying how similar the request should look +# For type CA, the listed attributes must be the same, and the optional +# and supplied fields are just that :-) +policy = policy_match + +# For the CA policy +[ policy_match ] +countryName = match +stateOrProvinceName = match +organizationName = match +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +# For the 'anything' policy +# At this point in time, you must list all acceptable 'object' +# types. +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +#################################################################### +[ req ] +default_bits = 1024 +default_keyfile = privkey.pem +distinguished_name = req_distinguished_name +attributes = req_attributes + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +countryName_default = AU +countryName_min = 2 +countryName_max = 2 + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State + +localityName = Locality Name (eg, city) + +0.organizationName = Organization Name (eg, company) +0.organizationName_default = Internet Widgits Pty Ltd + +# we can do this but it is not needed normally :-) +#1.organizationName = Second Organization Name (eg, company) +#1.organizationName_default = CryptSoft Pty Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +#organizationalUnitName_default = + +commonName = Common Name (eg, YOUR name) +commonName_max = 64 + +emailAddress = Email Address +emailAddress_max = 40 + +[ req_attributes ] +challengePassword = A challenge password +challengePassword_min = 4 +challengePassword_max = 20 + +unstructuredName = An optional company name + +[ x509v3_extensions ] + +nsCaRevocationUrl = http://www.cryptsoft.com/ca-crl.pem +nsComment = "This is a comment" + +# under ASN.1, the 0 bit would be encoded as 80 +nsCertType = 0x40 + +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName +#nsCertSequence +#nsCertExt +#nsDataType + diff --git a/src/lib/libssl/src/apps/tkca b/src/lib/libssl/src/apps/tkca new file mode 100644 index 0000000000..bdaf21606a --- /dev/null +++ b/src/lib/libssl/src/apps/tkca @@ -0,0 +1,66 @@ +#!/usr/local/bin/perl5 +# +# This is only something I'm playing with, it does not work :-) +# + +use Tk; + +my $main=MainWindow->new(); +my $f=$main->Frame(-relief => "ridge", -borderwidth => 2); +$f->pack(-fill => 'x'); + +my $ff=$f->Frame; +$ff->pack(-fill => 'x'); +my $l=$ff->Label(-text => "TkCA - SSLeay", + -relief => "ridge", -borderwidth => 2); +$l->pack(-fill => 'x', -ipady => 5); + +my $l=$ff->Button(-text => "Certify"); +$l->pack(-fill => 'x', -ipady => 5); + +my $l=$ff->Button(-text => "Review"); +$l->pack(-fill => 'x', -ipady => 5); + +my $l=$ff->Button(-text => "Revoke"); +$l->pack(-fill => 'x', -ipady => 5); + +my $l=$ff->Button(-text => "Generate CRL"); +$l->pack(-fill => 'x', -ipady => 5); + +my($db)=&load_db("demoCA/index.txt"); + +MainLoop; + +sub load_db + { + my(%ret); + my($file)=@_; + my(*IN); + my(%db_serial,%db_name,@f,@db_s); + + $ret{'serial'}=\%db_serial; + $ret{'name'}=\%db_name; + + open(IN,"<$file") || die "unable to open $file:$!\n"; + while () + { + chop; + s/([^\\])\t/\1\t\t/g; + my(@f)=split(/\t\t/); + die "wrong number of fields in $file, line $.\n" + if ($#f != 5); + + my(%f); + $f{'type'}=$f[0]; + $f{'exp'}=$f[1]; + $f{'rev'}=$f[2]; + $f{'serial'}=$f[3]; + $f{'file'}=$f[4]; + $f{'name'}=$f[5]; + die "serial number $f{'serial'} appears twice (line $.)\n" + if (defined($db{$f{'serial'}})) + $db_serial{$f{'serial'}}=\%f; + $db_name{$f{'name'}}.=$f{'serial'}." "; + } + return \%ret; + } diff --git a/src/lib/libssl/src/certs/ICE-CA.pem b/src/lib/libssl/src/certs/ICE-CA.pem new file mode 100644 index 0000000000..75652366c2 --- /dev/null +++ b/src/lib/libssl/src/certs/ICE-CA.pem @@ -0,0 +1,59 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 1 (0x1) + Signature Algorithm: md5WithRSAEncryption + Issuer: O=European ICE-TEL project, OU=V3-Certification Authority + Validity + Not Before: Apr 2 17:35:53 1997 GMT + Not After : Apr 2 17:35:53 1998 GMT + Subject: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt + Subject Public Key Info: + Public Key Algorithm: rsa + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:82:75:ba:f6:d1:60:b5:f9:15:b3:6a:dd:29:8f: + 8b:a4:6f:1a:88:e0:50:43:40:0b:79:41:d5:d3:16: + 44:7d:74:65:17:42:06:52:0b:e9:50:c8:10:cd:24: + e2:ae:8d:22:30:73:e6:b4:b7:93:1f:e5:6e:a2:ae: + 49:11:a5:c9:45 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Authority Key Identifier: + 0.........z.."p......e.. + X509v3 Subject Key Identifier: + ..~r..:..B.44fu......3 + X509v3 Key Usage: critical + .... + X509v3 Certificate Policies: critical + 0.0...*... + X509v3 Subject Alternative Name: + 0!..secude-support@darmstadt.gmd.de + X509v3 Issuer Alternative Name: + 0I..ice-tel-ca@darmstadt.gmd.de.*http://www.darmstadt.gmd.de/ice-tel/euroca + X509v3 Basic Constraints: critical + 0.... + X509v3 CRL Distribution Points: + 0200...,.*http://www.darmstadt.gmd.de/ice-tel/euroca + Signature Algorithm: md5WithRSAEncryption + 17:a2:88:b7:99:5a:05:41:e4:13:34:67:e6:1f:3e:26:ec:4b: + 69:f9:3e:28:22:be:9d:1c:ab:41:6f:0c:00:85:fe:45:74:f6: + 98:f0:ce:9b:65:53:4a:50:42:c7:d4:92:bd:d7:a2:a8:3d:98: + 88:73:cd:60:28:79:a3:fc:48:7a +-----BEGIN CERTIFICATE----- +MIICzDCCAnagAwIBAgIBATANBgkqhkiG9w0BAQQFADBIMSEwHwYDVQQKExhFdXJv +cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g +QXV0aG9yaXR5MB4XDTk3MDQwMjE3MzU1M1oXDTk4MDQwMjE3MzU1M1owXDEhMB8G +A1UEChMYRXVyb3BlYW4gSUNFLVRFTCBwcm9qZWN0MSMwIQYDVQQLExpWMy1DZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eTESMBAGA1UEBxMJRGFybXN0YWR0MFkwCgYEVQgB +AQICAgADSwAwSAJBAIJ1uvbRYLX5FbNq3SmPi6RvGojgUENAC3lB1dMWRH10ZRdC +BlIL6VDIEM0k4q6NIjBz5rS3kx/lbqKuSRGlyUUCAwEAAaOCATgwggE0MB8GA1Ud +IwQYMBaAFIr3yNUOx3ro1yJw4AuJ1bbsZbzPMB0GA1UdDgQWBBR+cvL4OoacQog0 +NGZ1w9T80aIRMzAOBgNVHQ8BAf8EBAMCAfYwFAYDVR0gAQH/BAowCDAGBgQqAwQF +MCoGA1UdEQQjMCGBH3NlY3VkZS1zdXBwb3J0QGRhcm1zdGFkdC5nbWQuZGUwUgYD +VR0SBEswSYEbaWNlLXRlbC1jYUBkYXJtc3RhZHQuZ21kLmRlhipodHRwOi8vd3d3 +LmRhcm1zdGFkdC5nbWQuZGUvaWNlLXRlbC9ldXJvY2EwDwYDVR0TAQH/BAUwAwEB +/zA7BgNVHR8ENDAyMDCgLqAshipodHRwOi8vd3d3LmRhcm1zdGFkdC5nbWQuZGUv +aWNlLXRlbC9ldXJvY2EwDQYJKoZIhvcNAQEEBQADQQAXooi3mVoFQeQTNGfmHz4m +7Etp+T4oIr6dHKtBbwwAhf5FdPaY8M6bZVNKUELH1JK916KoPZiIc81gKHmj/Eh6 +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/ICE-root.pem b/src/lib/libssl/src/certs/ICE-root.pem new file mode 100644 index 0000000000..fa991599c9 --- /dev/null +++ b/src/lib/libssl/src/certs/ICE-root.pem @@ -0,0 +1,48 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: md5WithRSAEncryption + Issuer: O=European ICE-TEL project, OU=V3-Certification Authority + Validity + Not Before: Apr 2 17:33:36 1997 GMT + Not After : Apr 2 17:33:36 1998 GMT + Subject: O=European ICE-TEL project, OU=V3-Certification Authority + Subject Public Key Info: + Public Key Algorithm: rsa + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:80:3e:eb:ae:47:a9:fe:10:54:0b:81:8b:9c:2b: + 82:ab:3a:61:36:65:8b:f3:73:9f:ac:ac:7a:15:a7: + 13:8f:b4:c4:ba:a3:0f:bc:a5:58:8d:cc:b1:93:31: + 9e:81:9e:8c:19:61:86:fa:52:73:54:d1:97:76:22: + e7:c7:9f:41:cd + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + ........z.."p......e.. + X509v3 Key Usage: critical + .... + X509v3 Subject Alternative Name: + 0I.*http://www.darmstadt.gmd.de/ice-tel/euroca..ice-tel-ca@darmstadt.gmd.de + X509v3 Basic Constraints: critical + 0.... + Signature Algorithm: md5WithRSAEncryption + 76:69:61:db:b7:cf:8b:06:9e:d8:8c:96:53:d2:4d:a8:23:a6: + 03:44:e8:8f:24:a5:c0:84:a8:4b:77:d4:2d:2b:7d:37:91:67: + f2:2c:ce:02:31:4c:6b:cc:ce:f2:68:a6:11:11:ab:7d:88:b8: + 7e:22:9f:25:06:60:bd:79:30:3d +-----BEGIN CERTIFICATE----- +MIICFjCCAcCgAwIBAgIBADANBgkqhkiG9w0BAQQFADBIMSEwHwYDVQQKExhFdXJv +cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g +QXV0aG9yaXR5MB4XDTk3MDQwMjE3MzMzNloXDTk4MDQwMjE3MzMzNlowSDEhMB8G +A1UEChMYRXVyb3BlYW4gSUNFLVRFTCBwcm9qZWN0MSMwIQYDVQQLExpWMy1DZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eTBZMAoGBFUIAQECAgIAA0sAMEgCQQCAPuuuR6n+ +EFQLgYucK4KrOmE2ZYvzc5+srHoVpxOPtMS6ow+8pViNzLGTMZ6BnowZYYb6UnNU +0Zd2IufHn0HNAgMBAAGjgZcwgZQwHQYDVR0OBBYEFIr3yNUOx3ro1yJw4AuJ1bbs +ZbzPMA4GA1UdDwEB/wQEAwIB9jBSBgNVHREESzBJhipodHRwOi8vd3d3LmRhcm1z +dGFkdC5nbWQuZGUvaWNlLXRlbC9ldXJvY2GBG2ljZS10ZWwtY2FAZGFybXN0YWR0 +LmdtZC5kZTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBBAUAA0EAdmlh27fP +iwae2IyWU9JNqCOmA0TojySlwISoS3fULSt9N5Fn8izOAjFMa8zO8mimERGrfYi4 +fiKfJQZgvXkwPQ== +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/ICE-user.pem b/src/lib/libssl/src/certs/ICE-user.pem new file mode 100644 index 0000000000..28065fd37d --- /dev/null +++ b/src/lib/libssl/src/certs/ICE-user.pem @@ -0,0 +1,63 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 1 (0x1) + Signature Algorithm: md5WithRSAEncryption + Issuer: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt + Validity + Not Before: Apr 2 17:35:59 1997 GMT + Not After : Apr 2 17:35:59 1998 GMT + Subject: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt, CN=USER + Subject Public Key Info: + Public Key Algorithm: rsa + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:a8:a8:53:63:49:1b:93:c3:c3:0b:6c:88:11:55: + de:7e:6a:e2:f9:52:a0:dc:69:25:c4:c8:bf:55:e1: + 31:a8:ce:e4:a9:29:85:99:8a:15:9a:de:f6:2f:e1: + b4:50:5f:5e:04:75:a6:f4:76:dc:3c:0e:39:dc:3a: + be:3e:a4:61:8b + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Authority Key Identifier: + 0...~r..:..B.44fu......3 + X509v3 Subject Key Identifier: + ...... .*...1.*....... + X509v3 Key Usage: critical + .... + X509v3 Certificate Policies: critical + 0.0...*...0....... + X509v3 Subject Alternative Name: + 0:..user@darmstadt.gmd.de.!http://www.darmstadt.gmd.de/~user + X509v3 Issuer Alternative Name: + 0....gmdca@gmd.de..http://www.gmd.de..saturn.darmstadt.gmd.de.\1!0...U. +..European ICE-TEL project1#0!..U....V3-Certification Authority1.0...U....Darmstadt..141.12.62.26 + X509v3 Basic Constraints: critical + 0. + X509v3 CRL Distribution Points: + 0.0.......gmdca@gmd.de + Signature Algorithm: md5WithRSAEncryption + 69:0c:e1:b7:a7:f2:d8:fb:e8:69:c0:13:cd:37:ad:21:06:22: + 4d:e8:c6:db:f1:04:0b:b7:e0:b3:d6:0c:81:03:ce:c3:6a:3e: + c7:e7:24:24:a4:92:64:c2:83:83:06:42:53:0e:6f:09:1e:84: + 9a:f7:6f:63:9b:94:99:83:d6:a4 +-----BEGIN CERTIFICATE----- +MIIDTzCCAvmgAwIBAgIBATANBgkqhkiG9w0BAQQFADBcMSEwHwYDVQQKExhFdXJv +cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g +QXV0aG9yaXR5MRIwEAYDVQQHEwlEYXJtc3RhZHQwHhcNOTcwNDAyMTczNTU5WhcN +OTgwNDAyMTczNTU5WjBrMSEwHwYDVQQKExhFdXJvcGVhbiBJQ0UtVEVMIHByb2pl +Y3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24gQXV0aG9yaXR5MRIwEAYDVQQH +EwlEYXJtc3RhZHQxDTALBgNVBAMTBFVTRVIwWTAKBgRVCAEBAgICAANLADBIAkEA +qKhTY0kbk8PDC2yIEVXefmri+VKg3GklxMi/VeExqM7kqSmFmYoVmt72L+G0UF9e +BHWm9HbcPA453Dq+PqRhiwIDAQABo4IBmDCCAZQwHwYDVR0jBBgwFoAUfnLy+DqG +nEKINDRmdcPU/NGiETMwHQYDVR0OBBYEFJfc4B8gjSoRmLUx4Sq/ucIYiMrPMA4G +A1UdDwEB/wQEAwIB8DAcBgNVHSABAf8EEjAQMAYGBCoDBAUwBgYECQgHBjBDBgNV +HREEPDA6gRV1c2VyQGRhcm1zdGFkdC5nbWQuZGWGIWh0dHA6Ly93d3cuZGFybXN0 +YWR0LmdtZC5kZS9+dXNlcjCBsQYDVR0SBIGpMIGmgQxnbWRjYUBnbWQuZGWGEWh0 +dHA6Ly93d3cuZ21kLmRlghdzYXR1cm4uZGFybXN0YWR0LmdtZC5kZaRcMSEwHwYD +VQQKExhFdXJvcGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRp +ZmljYXRpb24gQXV0aG9yaXR5MRIwEAYDVQQHEwlEYXJtc3RhZHSHDDE0MS4xMi42 +Mi4yNjAMBgNVHRMBAf8EAjAAMB0GA1UdHwQWMBQwEqAQoA6BDGdtZGNhQGdtZC5k +ZTANBgkqhkiG9w0BAQQFAANBAGkM4ben8tj76GnAE803rSEGIk3oxtvxBAu34LPW +DIEDzsNqPsfnJCSkkmTCg4MGQlMObwkehJr3b2OblJmD1qQ= +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/ICE.crl b/src/lib/libssl/src/certs/ICE.crl new file mode 100644 index 0000000000..21939e8cc4 --- /dev/null +++ b/src/lib/libssl/src/certs/ICE.crl @@ -0,0 +1,9 @@ +-----BEGIN X509 CRL----- +MIIBNDCBnjANBgkqhkiG9w0BAQIFADBFMSEwHwYDVQQKExhFdXJvcGVhbiBJQ0Ut +VEVMIFByb2plY3QxIDAeBgNVBAsTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5Fw05 +NzA2MDkxNDQyNDNaFw05NzA3MDkxNDQyNDNaMCgwEgIBChcNOTcwMzAzMTQ0MjU0 +WjASAgEJFw05NjEwMDIxMjI5MjdaMA0GCSqGSIb3DQEBAgUAA4GBAH4vgWo2Tej/ +i7kbiw4Imd30If91iosjClNpBFwvwUDBclPEeMuYimHbLOk4H8Nofc0fw11+U/IO +KSNouUDcqG7B64oY7c4SXKn+i1MWOb5OJiWeodX3TehHjBlyWzoNMWCnYA8XqFP1 +mOKp8Jla1BibEZf14+/HqCi2hnZUiEXh +-----END X509 CRL----- diff --git a/src/lib/libssl/src/certs/ca-cert.pem b/src/lib/libssl/src/certs/ca-cert.pem new file mode 100644 index 0000000000..6dd974d70d --- /dev/null +++ b/src/lib/libssl/src/certs/ca-cert.pem @@ -0,0 +1,31 @@ +issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit) +subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit) +-----BEGIN CERTIFICATE----- +MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV +BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD +VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw +OTEzNTc0M1owWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY +BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgxMDI0 +IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgybTsZ +DCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/dFXSv +1F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUecQU2 +mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAM7achv3v +hLQJcv/65eGEpBXM40ZDVoFQFFJWaY5p883HTqLB1x4FdzsXHH0QKBTcKpWwqyu4 +YDm3fb8oDugw72bCzfyZK/zVZPR/hVlqI/fvU109Qoc+7oPvIXWky71HfcK6ZBCA +q30KIqGM/uoM60INq97qjDmCJapagcNBGQs= +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425 +gxSK4jqhhT62UPpqDBEwvQ+fYkVv3RV0r9ReuZGv12NoS4fXsQgqO17lHA7Od0Kd +2yNwJjKh44MxPKDt2o8iQMyZE0zlHnEFNpsP4COLTDNC6ljEEu5bk8uPsQIDAQAB +AoGAVZmpFZsDZfr0l2S9tLLwpjRWNOlKATQkno6q2WesT0eGLQufTciY+c8ypfU6 +hyio8r5iUl/VhhdjhAtKx1mRpiotftHo/eYf8rtsrnprOnWG0bWjLjtIoMbcxGn2 +J3bN6LJmbJMjDs0eJ3KnTu646F3nDUw2oGAwmpzKXA1KAP0CQQDRvQhxk2D3Pehs +HvG665u2pB5ipYQngEFlZO7RHJZzJOZEWSLuuMqaF/7pTfA5jiBvWqCgJeCRRInL +21ru4dlPAkEAx9jj7BgKn5TYnMoBSSe0afjsV9oApVpN1Nacb1YDtCwy+scp3++s +nFxlv98wxIlSdpwMUn+AUWfjiWR7Tu/G/wJBAJ/KjwZIrFVxewP0x2ILYsTRYLzz +MS4PDsO7FB+I0i7DbBOifXS2oNSpd3I0CNMwrxFnUHzynpbOStVfN3ZL5w0CQQCa +pwFahxBRhkJKsxhjoFJBX9yl75JoY4Wvm5Tbo9ih6UJaRx3kqfkN14L2BKYcsZgb +KY9vmDOYy6iNfjDeWTfJAkBkfPUb8oTJ/nSP5zN6sqGxSY4krc4xLxpRmxoJ8HL2 +XfhqXkTzbU13RX9JJ/NZ8vQN9Vm2NhxRGJocQkmcdVtJ +-----END RSA PRIVATE KEY----- diff --git a/src/lib/libssl/src/certs/dsa-ca.pem b/src/lib/libssl/src/certs/dsa-ca.pem new file mode 100644 index 0000000000..9eb08f3ddd --- /dev/null +++ b/src/lib/libssl/src/certs/dsa-ca.pem @@ -0,0 +1,43 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0 + +svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0 +Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl +Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/ +par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr +zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO +uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5 +rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx +1QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4 +HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827 +MVqOsYxGCb+kez0FoDSTgw== +-----END DSA PRIVATE KEY----- +-----BEGIN CERTIFICATE REQUEST----- +MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx +ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew +ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW +sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m +rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk +cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo +bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR +CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB +F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH +vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq +AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u +3enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v +AhQfeF5BoMMDbX/kidUVpQ6gadPlZA== +-----END CERTIFICATE REQUEST----- +-----BEGIN CERTIFICATE----- +MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK +U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww +CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw +CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu +ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE +AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi +ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh +MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD +MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa +C1Q= +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/certs/dsa-pca.pem b/src/lib/libssl/src/certs/dsa-pca.pem new file mode 100644 index 0000000000..e3641ad47e --- /dev/null +++ b/src/lib/libssl/src/certs/dsa-pca.pem @@ -0,0 +1,49 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4 + +GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS +mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt +of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr +FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX +RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd +qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1 +diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn +V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h +hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf +dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7 +-----END DSA PRIVATE KEY----- +-----BEGIN CERTIFICATE REQUEST----- +MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx +ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB +MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G +lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O +Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR +5HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl +aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6 +kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als +QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe +6NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ +yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0 +z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB +nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w== +-----END CERTIFICATE REQUEST----- +-----BEGIN CERTIFICATE----- +MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK +U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww +CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw +CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu +ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww +ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ +R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5 +JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps +BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze +mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO +VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C +uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk +umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A +29nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D +AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n +5rKUjNBhSg== +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/certs/factory.pem b/src/lib/libssl/src/certs/factory.pem new file mode 100644 index 0000000000..8e28b391b2 --- /dev/null +++ b/src/lib/libssl/src/certs/factory.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICTTCCAbagAwIBAgIBADANBgkqhkiG9w0BAQQFADBMMQswCQYDVQQGEwJHQjEM +MAoGA1UEChMDVUNMMRgwFgYDVQQLEw9JQ0UtVEVMIFByb2plY3QxFTATBgNVBAMT +DFRydXN0RmFjdG9yeTAeFw05NzA0MjIxNDM5MTRaFw05ODA0MjIxNDM5MTRaMEwx +CzAJBgNVBAYTAkdCMQwwCgYDVQQKEwNVQ0wxGDAWBgNVBAsTD0lDRS1URUwgUHJv +amVjdDEVMBMGA1UEAxMMVHJ1c3RGYWN0b3J5MIGcMAoGBFUIAQECAgQAA4GNADCB +iQKBgQCEieR8NcXkUW1f0G6aC6u0i8q/98JqS6RxK5YmHIGKCkuTWAUjzLfUa4dt +U9igGCjTuxaDqlzEim+t/02pmiBZT9HaX++35MjQPUWmsChcYU5WyzGErXi+rQaw +zlwS73zM8qiPj/97lXYycWhgL0VaiDSPxRXEUdWoaGruom4mNQIDAQABo0IwQDAd +BgNVHQ4EFgQUHal1LZr7oVg5z6lYzrhTgZRCmcUwDgYDVR0PAQH/BAQDAgH2MA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAfaggfl6FZoioecjv0dq8 +/DXo/u11iMZvXn08gjX/zl2b4wtPbShOSY5FhkSm8GeySasz+/Nwb/uzfnIhokWi +lfPZHtlCWtXbIy/TN51eJyq04ceDCQDWvLC2enVg9KB+GJ34b5c5VaPRzq8MBxsA +S7ELuYGtmYgYm9NZOIr7yU0= +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/nortelCA.pem b/src/lib/libssl/src/certs/nortelCA.pem new file mode 100644 index 0000000000..207f34ab3a --- /dev/null +++ b/src/lib/libssl/src/certs/nortelCA.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICajCCAdMCBDGA0QUwDQYJKoZIhvcNAQEEBQAwfTELMAkGA1UEBhMCQ2ExDzAN +BgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmlsaXR5IEFjY2VwdGVkMR8w +HQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRwwGgYDVQQDExNFbnRydXN0 +IERlbW8gV2ViIENBMB4XDTk2MDQyNjEzMzUwMVoXDTA2MDQyNjEzMzUwMVowfTEL +MAkGA1UEBhMCQ2ExDzANBgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmls +aXR5IEFjY2VwdGVkMR8wHQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRww +GgYDVQQDExNFbnRydXN0IERlbW8gV2ViIENBMIGdMA0GCSqGSIb3DQEBAQUAA4GL +ADCBhwKBgQCaroS7O1DA0hm4IefNYU1cx/nqOmzEnk291d1XqznDeF4wEgakbkCc +zTKxK791yNpXG5RmngqH7cygDRTHZJ6mfCRn0wGC+AI00F2vYTGqPGRQL1N3lZT0 +YDKFC0SQeMMjFIZ1aeQigroFQnHo0VB3zWIMpNkka8PY9lxHZAmWwQIBAzANBgkq +hkiG9w0BAQQFAAOBgQBAx0UMVA1s54lMQyXjMX5kj99FJN5itb8bK1Rk+cegPQPF +cWO9SEWyEjjBjIkjjzAwBkaEszFsNGxemxtXvwjIm1xEUMTVlPEWTs2qnDvAUA9W +YqhWbhH0toGT36236QAsqCZ76rbTRVSSX2BHyJwJMG2tCRv7kRJ//NIgxj3H4w== +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/certs/pca-cert.pem b/src/lib/libssl/src/certs/pca-cert.pem new file mode 100644 index 0000000000..140e9a6b43 --- /dev/null +++ b/src/lib/libssl/src/certs/pca-cert.pem @@ -0,0 +1,31 @@ +issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit) +subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit) +-----BEGIN CERTIFICATE----- +MIICJzCCAZACAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV +BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD +VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTczN1oXDTAxMDYw +OTEzNTczN1owXDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY +BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYDVQQDExNUZXN0IFBDQSAoMTAy +NCBiaXQpMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCdoWk/3+WcMlfjIrkg +40ketmnQaEogQe1LLcuOJV6rKfUSAsPgwgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp +22Jp85PmemiDzyUIStwk72qhp1imbANZvlmlCFKiQrjUyuDfu4TABmn+kkt3vR1Y +BEOGt+IFye1UBVSATVdRJ2UVhwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABNA1u/S +Cg/LJZWb7GliiKJsvuhxlE4E5JxQF2zMub/CSNbF97//tYSyj96sxeFQxZXbcjm9 +xt6mr/xNLA4szNQMJ4P+L7b5e/jC5DSqlwS+CUYJgaFs/SP+qJoCSu1bR3IM9XWO +cRBpDmcBbYLkSyB92WURvsZ1LtjEcn+cdQVI +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCdoWk/3+WcMlfjIrkg40ketmnQaEogQe1LLcuOJV6rKfUSAsPg +wgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp22Jp85PmemiDzyUIStwk72qhp1imbANZ +vlmlCFKiQrjUyuDfu4TABmn+kkt3vR1YBEOGt+IFye1UBVSATVdRJ2UVhwIDAQAB +AoGAba4fTtuap5l7/8ZsbE7Z1O32KJY4ZcOZukLOLUUhXxXduT+FTgGWujc0/rgc +z9qYCLlNZHOouMYTgtSfYvuMuLZ11VIt0GYH+nRioLShE59Yy+zCRyC+gPigS1kz +xvo14AsOIPYV14Tk/SsHyq6E0eTk7VzaIE197giiINUERPECQQDSKmtPTh/lRKw7 +HSZSM0I1mFWn/1zqrAbontRQY5w98QWIOe5qmzYyFbPXYT3d9BzlsMyhgiRNoBbD +yvohSHXJAkEAwAHx6ezAZeWWzD5yXD36nyjpkVCw7Tk7TSmOceLJMWt1QcrCfqlS +xA5jjpQ6Z8suU5DdtWAryM2sAir1WisYzwJAd6Zcx56jvAQ3xcPXsE6scBTVFzrj +7FqZ6E+cclPzfLQ+QQsyOBE7bpI6e/FJppY26XGZXo3YGzV8IGXrt40oOQJALETG +h86EFXo3qGOFbmsDy4pdP5nBERCu8X1xUCSfintiD4c2DInxgS5oGclnJeMcjTvL +QjQoJCX3UJCi/OUO1QJBAKgcDHWjMvt+l1pjJBsSEZ0HX9AAIIVx0RQmbFGS+F2Q +hhu5l77WnnZOQ9vvhV5u7NPCUF9nhU3jh60qWWO8mkc= +-----END RSA PRIVATE KEY----- diff --git a/src/lib/libssl/src/certs/rsa-cca.pem b/src/lib/libssl/src/certs/rsa-cca.pem new file mode 100644 index 0000000000..69f5c1c84c --- /dev/null +++ b/src/lib/libssl/src/certs/rsa-cca.pem @@ -0,0 +1,19 @@ +subject=/C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority +issuer= /C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority +notBefore=941104185834Z +notAfter =991103185834Z +-----BEGIN X509 CERTIFICATE----- + +MIICIzCCAZACBQJBAAAWMA0GCSqGSIb3DQEBAgUAMFwxCzAJBgNVBAYTAlVTMSAw +HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVy +Y2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDQxODU4MzRaFw05 +OTExMDMxODU4MzRaMFwxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0YSBT +ZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVyY2lhbCBDZXJ0aWZpY2F0aW9u +IEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCk+4Fie84QJ93o +975sbsZwmdu41QUDaSiCnHJ/lj+O7Kwpkj+KFPhCdr69XQO5kNTQvAayUTNfxMK/ +touPmbZiImDd298ggrTKoi8tUO2UMt7gVY3UaOLgTNLNBRYulWZcYVI4HlGogqHE +7yXpCuaLK44xZtn42f29O2nZ6wIDAQABMA0GCSqGSIb3DQEBAgUAA34AdrW2EP4j +9/dZYkuwX5zBaLxJu7NJbyFHXSudVMQAKD+YufKKg5tgf+tQx6sFEC097TgCwaVI +0v5loMC86qYjFmZsGySp8+x5NRhPJsjjr1BKx6cxa9B8GJ1Qv6km+iYrRpwUqbtb +MJhCKLVLU7tDCZJAuqiqWqTGtotXTcU= +-----END X509 CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/rsa-ssca.pem b/src/lib/libssl/src/certs/rsa-ssca.pem new file mode 100644 index 0000000000..c9403212d1 --- /dev/null +++ b/src/lib/libssl/src/certs/rsa-ssca.pem @@ -0,0 +1,19 @@ +subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority +issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority +notBefore=941109235417Z +notAfter =991231235417Z +-----BEGIN X509 CERTIFICATE----- + +MIICKTCCAZYCBQJBAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw +HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl +IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDkyMzU0MTda +Fw05OTEyMzEyMzU0MTdaMF8xCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0 +YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJlIFNlcnZlciBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCSznrB +roM+WqqJg1esJQF2DK2ujiw3zus1eGRUA+WEQFHJv48I4oqCCNIWhjdV6bEhAq12 +aIGaBaJLyUslZiJWbIgHj/eBWW2EB2VwE3F2Ppt3TONQiVaYSLkdpykaEy5KEVmc +HhXVSVQsczppgrGXOZxtcGdI5d0t1sgeewIDAQABMA0GCSqGSIb3DQEBAgUAA34A +iNHReSHO4ovo+MF9NFM/YYPZtgs4F7boviGNjwC4i1N+RGceIr2XJ+CchcxK9oU7 +suK+ktPlDemvXA4MRpX/oRxePug2WHpzpgr4IhFrwwk4fia7c+8AvQKk8xQNMD9h +cHsg/jKjn7P0Z1LctO6EjJY2IN6BCINxIYoPnqk= +-----END X509 CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/timCA.pem b/src/lib/libssl/src/certs/timCA.pem new file mode 100644 index 0000000000..9c8d5bf9c6 --- /dev/null +++ b/src/lib/libssl/src/certs/timCA.pem @@ -0,0 +1,16 @@ +Tims test GCI CA + +-----BEGIN CERTIFICATE----- +MIIB8DCCAZoCAQAwDQYJKoZIhvcNAQEEBQAwgYIxCzAJBgNVBAYTAkFVMRMwEQYD +VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5 +cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBD +cnlwdFNvZnQgRGV2IENBMB4XDTk3MDMyMjEzMzQwNFoXDTk4MDMyMjEzMzQwNFow +gYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhC +cmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2Rl +dmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQgRGV2IENBMFwwDQYJKoZIhvcN +AQEBBQADSwAwSAJBAOAOAqogG5QwAmLhzyO4CoRnx/wVy4NZP4dxJy83O1EnL0rw +OdsamJKvPOLHgSXo3gDu9uVyvCf/QJmZAmC5ml8CAwEAATANBgkqhkiG9w0BAQQF +AANBADRRS/GVdd7rAqRW6SdmgLJduOU2yq3avBu99kRqbp9A/dLu6r6jU+eP4oOA +TfdbFZtAAD2Hx9jUtY3tfdrJOb8= +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/certs/tjhCA.pem b/src/lib/libssl/src/certs/tjhCA.pem new file mode 100644 index 0000000000..67bee1b200 --- /dev/null +++ b/src/lib/libssl/src/certs/tjhCA.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICVjCCAgACAQAwDQYJKoZIhvcNAQEEBQAwgbUxCzAJBgNVBAYTAkFVMRMwEQYD +VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5 +cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsTI1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9O +IEFVVEhPUklUSUVTMTQwMgYDVQQDEytaRVJPIFZBTFVFIENBIC0gREVNT05TVFJB +VElPTiBQVVJQT1NFUyBPTkxZMB4XDTk3MDQwMzEzMjI1NFoXDTk4MDQwMzEzMjI1 +NFowgbUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH +EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsT +I1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9OIEFVVEhPUklUSUVTMTQwMgYDVQQDEyta +RVJPIFZBTFVFIENBIC0gREVNT05TVFJBVElPTiBQVVJQT1NFUyBPTkxZMFwwDQYJ +KoZIhvcNAQEBBQADSwAwSAJBAOZ7T7yqP/tyspcko3yPY1y0Cm2EmwNvzW4QgVXR +Fjs3HmJ4xtSpXdo6mwcGezL3Abt/aQXaxv9PU8xt+Jr0OFUCAwEAATANBgkqhkiG +9w0BAQQFAANBAOQpYmGgyCqCy1OljgJhCqQOu627oVlHzK1L+t9vBaMfn40AVUR4 +WzQVWO31KTgi5vTK1U+3h46fgUWqQ0h+6rU= +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/certs/vsign2.pem b/src/lib/libssl/src/certs/vsign2.pem new file mode 100644 index 0000000000..2386e149d0 --- /dev/null +++ b/src/lib/libssl/src/certs/vsign2.pem @@ -0,0 +1,31 @@ + subject=/L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber + issuer= /L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber + +-----BEGIN CERTIFICATE----- +MIIEkzCCA/ygAwIBAgIRANDTUpSRL3nTFeMrMayFSPAwDQYJKoZIhvcNAQECBQAw +YjERMA8GA1UEBxMISW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQw +MgYDVQQLEytWZXJpU2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3Jp +YmVyMB4XDTk2MDYwNDAwMDAwMFoXDTk4MDYwNDIzNTk1OVowYjERMA8GA1UEBxMI +SW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJp +U2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyMIGfMA0GCSqG +SIb3DQEBAQUAA4GNADCBiQKBgQC6A+2czKGRcYMfm8gdnk+0de99TDDzsqo0v5nb +RsbUmMcdRQ7nsMbRWe0SAb/9QoLTZ/cJ0iOBqdrkz7UpqqKarVoTSdlSMVM92tWp +3bJncZHQD1t4xd6lQVdI1/T6R+5J0T1ukOdsI9Jmf+F28S6g3R3L1SFwiHKeZKZv +z+793wIDAQABo4ICRzCCAkMwggIpBgNVHQMBAf8EggIdMIICGTCCAhUwggIRBgtg +hkgBhvhFAQcBATCCAgAWggGrVGhpcyBjZXJ0aWZpY2F0ZSBpbmNvcnBvcmF0ZXMg +YnkgcmVmZXJlbmNlLCBhbmQgaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRv +LCB0aGUgVmVyaVNpZ24gQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1lbnQg +KENQUyksIGF2YWlsYWJsZSBhdDogaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL0NQ +Uy0xLjA7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBv +ciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1v +dW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMw +IENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBS +ZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJ +TElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMC8w +LRYraHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTLTEuMDAU +BglghkgBhvhCAQEBAf8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEApRJRkNBqLLgs +53IR/d18ODdLOWMTZ+QOOxBrq460iBEdUwgF8vmPRX1ku7UiDeNzaLlurE6eFqHq +2zPyK5j60zfTLVJMWKcQWwTJLjHtXrW8pxhNtFc6Fdvy5ZkHnC/9NIl7/t4U6WqB +p4y+p7SdMIkEwIZfds0VbnQyX5MRUJY= +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/certs/vsign4.pem b/src/lib/libssl/src/certs/vsign4.pem new file mode 100644 index 0000000000..b5bcef4d0d --- /dev/null +++ b/src/lib/libssl/src/certs/vsign4.pem @@ -0,0 +1,16 @@ + subject=/C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority + issuer= /C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority +-----BEGIN CERTIFICATE----- +MIICMTCCAZoCBQKmAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa +Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln +biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0LJ1 +9njQrlpQ9OlQqZ+M1++RlHDo0iSQdomF1t+s5gEXMoDwnZNHvJplnR+Xrr/phnVj +IIm9gFidBAydqMEk6QvlMXi9/C0MN2qeeIDpRnX57aP7E3vIwUzSo+/1PLBij0pd +O92VZ48TucE81qcmm+zDO3rZTbxtm+gVAePwR6kCAwEAATANBgkqhkiG9w0BAQIF +AAOBgQBT3dPwnCR+QKri/AAa19oM/DJhuBUNlvP6Vxt/M3yv6ZiaYch6s7f/sdyZ +g9ysEvxwyR84Qu1E9oAuW2szaayc01znX1oYx7EteQSWQZGZQbE8DbqEOcY7l/Am +yY7uvcxClf8exwI/VAx49byqYHwCaejcrOICdmHEPgPq0ook0Q== +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/crypto/Makefile.ssl b/src/lib/libssl/src/crypto/Makefile.ssl new file mode 100644 index 0000000000..efdbba38ac --- /dev/null +++ b/src/lib/libssl/src/crypto/Makefile.ssl @@ -0,0 +1,161 @@ +# +# SSLeay/crypto/Makefile +# + +DIR= crypto +TOP= .. +CC= cc +INCLUDE= -I. -I../include +INCLUDES= -I.. -I../../include +CFLAG= -g +INSTALLTOP= /usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +RM= /bin/rm -f +AR= ar r + +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl + +PEX_LIBS= +EX_LIBS= + +CFLAGS= $(INCLUDE) $(CFLAG) -DCFLAGS=" \"$(CC) $(CFLAG)\" " + +ERR=crypto +ERRC=cpt_err + +LIBS= + +SDIRS= md2 md5 sha mdc2 hmac ripemd \ + des rc2 rc4 rc5 idea bf cast \ + bn rsa dsa dh \ + buffer bio stack lhash rand err objects \ + evp pem x509 \ + asn1 conf txt_db pkcs7 + +GENERAL=Makefile README + +LIB= $(TOP)/libcrypto.a +LIBSRC= cryptlib.c mem.c cversion.c ex_data.c $(ERRC).c +LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= crypto.h cryptall.h +HEADER= cryptlib.h date.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + @(cd ..; $(MAKE) DIRS=$(DIR) all) + +all: date.h lib subdirs + +date.h: ../Makefile.ssl ../VERSION + echo "#define DATE \"`date`\"" >date.h + +subdirs: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making all in $$i..."; \ + $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' all ); \ + done; + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making 'files' in $$i..."; \ + $(MAKE) files ); \ + done; + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../include $(HEADER) ; + $(TOP)/util/mklink.sh ../test $(TEST) ; + $(TOP)/util/mklink.sh ../apps $(APPS) ; + $(TOP)/util/point.sh Makefile.ssl Makefile; + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making links in $$i..."; \ + $(MAKE) links ); \ + done; + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +libs: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making libs in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \ + done; + +tests: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making tests in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \ + done; + +install: + @for i in $(EXHEADER) ;\ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making install in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \ + done; + +lint: + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making lint in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \ + done; + +depend: + $(MAKEDEPEND) $(INCLUDE) $(PROGS) $(LIBSRC) + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making depend in $$i..."; \ + $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' MAKEDEPEND='${MAKEDEPEND}' depend ); \ + done; + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making clean in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \ + done; + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making dclean in $$i..."; \ + $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \ + done; + +errors: + perl ./err/err_code.pl -conf err/ssleay.ec *.c */*.c ../ssl/*.c ../rsaref/*.c + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl err/err_genc.pl -s $(ERR).h $(ERRC).c + @for i in $(SDIRS) ;\ + do \ + (cd $$i; echo "making errors in $$i..."; \ + $(MAKE) errors ); \ + done; + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/asn1/Makefile.ssl b/src/lib/libssl/src/crypto/asn1/Makefile.ssl new file mode 100644 index 0000000000..30751bd156 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/Makefile.ssl @@ -0,0 +1,120 @@ +# +# SSLeay/crypto/asn1/Makefile +# + +DIR= asn1 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=asn1 +ERRC=asn1_err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c \ + a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \ + a_sign.c a_digest.c a_verify.c \ + x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \ + x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c \ + d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \ + d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \ + d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\ + t_req.c t_x509.c t_pkey.c \ + p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \ + p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ + f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \ + a_hdr.c x_pkey.c a_bool.c x_exten.c \ + asn1_par.c asn1_lib.c $(ERRC).c a_meth.c a_bytes.c \ + evp_asn1.c +LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o \ + a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \ + a_sign.o a_digest.o a_verify.o \ + x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \ + x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o \ + d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \ + d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \ + d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \ + t_req.o t_x509.o t_pkey.o \ + p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \ + p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ + f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \ + a_hdr.o x_pkey.o a_bool.o x_exten.o \ + asn1_par.o asn1_lib.o $(ERRC).o a_meth.o a_bytes.o \ + evp_asn1.o + +SRC= $(LIBSRC) + +EXHEADER= asn1.h asn1_mac.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +test: test.c + cc -g -I../../include -c test.c + cc -g -I../../include -o test test.o -L../.. -lcrypto + +pk: pk.c + cc -g -I../../include -c pk.c + cc -g -I../../include -o pk pk.o -L../.. -lcrypto + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/asn1/a_bmp.c b/src/lib/libssl/src/crypto/asn1/a_bmp.c new file mode 100644 index 0000000000..774502b1fc --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/a_bmp.c @@ -0,0 +1,90 @@ +/* crypto/asn1/a_bmp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1.h" + +/* ASN1err(ASN1_F_D2I_ASN1_INTEGER,ASN1_R_EXPECTING_AN_INTEGER); + */ + +int i2d_ASN1_BMPSTRING(a, pp) +ASN1_BMPSTRING *a; +unsigned char **pp; + { + return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, + V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL)); + } + +ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(a, pp, length) +ASN1_BMPSTRING **a; +unsigned char **pp; +long length; + { + ASN1_BMPSTRING *ret=NULL; + + ret=(ASN1_BMPSTRING *)d2i_ASN1_bytes((ASN1_STRING **)a, + pp,length,V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL); + if (ret == NULL) + { + ASN1err(ASN1_F_D2I_ASN1_BMPSTRING,ASN1_R_ERROR_STACK); + return(NULL); + } + return(ret); + } + diff --git a/src/lib/libssl/src/crypto/asn1/asn1.err b/src/lib/libssl/src/crypto/asn1/asn1.err new file mode 100644 index 0000000000..c8b7011488 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/asn1.err @@ -0,0 +1,182 @@ +/* Error codes for the ASN1 functions. */ + +/* Function codes. */ +#define ASN1_F_A2D_ASN1_OBJECT 100 +#define ASN1_F_A2I_ASN1_INTEGER 101 +#define ASN1_F_A2I_ASN1_STRING 102 +#define ASN1_F_ASN1_COLLATE_PRIMATIVE 103 +#define ASN1_F_ASN1_D2I_BIO 104 +#define ASN1_F_ASN1_D2I_FP 105 +#define ASN1_F_ASN1_DUP 106 +#define ASN1_F_ASN1_GET_OBJECT 107 +#define ASN1_F_ASN1_HEADER_NEW 108 +#define ASN1_F_ASN1_I2D_BIO 109 +#define ASN1_F_ASN1_I2D_FP 110 +#define ASN1_F_ASN1_INTEGER_SET 111 +#define ASN1_F_ASN1_INTEGER_TO_BN 112 +#define ASN1_F_ASN1_OBJECT_NEW 113 +#define ASN1_F_ASN1_SIGN 114 +#define ASN1_F_ASN1_STRING_NEW 115 +#define ASN1_F_ASN1_STRING_TYPE_NEW 116 +#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117 +#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118 +#define ASN1_F_ASN1_TYPE_NEW 119 +#define ASN1_F_ASN1_UTCTIME_NEW 120 +#define ASN1_F_ASN1_VERIFY 121 +#define ASN1_F_BN_TO_ASN1_INTEGER 122 +#define ASN1_F_D2I_ASN1_BIT_STRING 123 +#define ASN1_F_D2I_ASN1_BMPSTRING 124 +#define ASN1_F_D2I_ASN1_BOOLEAN 125 +#define ASN1_F_D2I_ASN1_BYTES 126 +#define ASN1_F_D2I_ASN1_HEADER 127 +#define ASN1_F_D2I_ASN1_INTEGER 128 +#define ASN1_F_D2I_ASN1_OBJECT 129 +#define ASN1_F_D2I_ASN1_OCTET_STRING 130 +#define ASN1_F_D2I_ASN1_PRINT_TYPE 131 +#define ASN1_F_D2I_ASN1_SET 132 +#define ASN1_F_D2I_ASN1_TYPE 133 +#define ASN1_F_D2I_ASN1_TYPE_BYTES 134 +#define ASN1_F_D2I_ASN1_UTCTIME 135 +#define ASN1_F_D2I_DHPARAMS 136 +#define ASN1_F_D2I_DSAPARAMS 137 +#define ASN1_F_D2I_DSAPRIVATEKEY 138 +#define ASN1_F_D2I_DSAPUBLICKEY 139 +#define ASN1_F_D2I_NETSCAPE_PKEY 140 +#define ASN1_F_D2I_NETSCAPE_RSA 141 +#define ASN1_F_D2I_NETSCAPE_RSA_2 142 +#define ASN1_F_D2I_NETSCAPE_SPKAC 143 +#define ASN1_F_D2I_NETSCAPE_SPKI 144 +#define ASN1_F_D2I_PKCS7 145 +#define ASN1_F_D2I_PKCS7_DIGEST 146 +#define ASN1_F_D2I_PKCS7_ENCRYPT 147 +#define ASN1_F_D2I_PKCS7_ENC_CONTENT 148 +#define ASN1_F_D2I_PKCS7_ENVELOPE 149 +#define ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL 150 +#define ASN1_F_D2I_PKCS7_RECIP_INFO 151 +#define ASN1_F_D2I_PKCS7_SIGNED 152 +#define ASN1_F_D2I_PKCS7_SIGNER_INFO 153 +#define ASN1_F_D2I_PKCS7_SIGN_ENVELOPE 154 +#define ASN1_F_D2I_PRIVATEKEY 155 +#define ASN1_F_D2I_PUBLICKEY 156 +#define ASN1_F_D2I_RSAPRIVATEKEY 157 +#define ASN1_F_D2I_RSAPUBLICKEY 158 +#define ASN1_F_D2I_X509 159 +#define ASN1_F_D2I_X509_ALGOR 160 +#define ASN1_F_D2I_X509_ATTRIBUTE 161 +#define ASN1_F_D2I_X509_CINF 162 +#define ASN1_F_D2I_X509_CRL 163 +#define ASN1_F_D2I_X509_CRL_INFO 164 +#define ASN1_F_D2I_X509_EXTENSION 165 +#define ASN1_F_D2I_X509_KEY 166 +#define ASN1_F_D2I_X509_NAME 167 +#define ASN1_F_D2I_X509_NAME_ENTRY 168 +#define ASN1_F_D2I_X509_PKEY 169 +#define ASN1_F_D2I_X509_PUBKEY 170 +#define ASN1_F_D2I_X509_REQ 171 +#define ASN1_F_D2I_X509_REQ_INFO 172 +#define ASN1_F_D2I_X509_REVOKED 173 +#define ASN1_F_D2I_X509_SIG 174 +#define ASN1_F_D2I_X509_VAL 175 +#define ASN1_F_I2D_ASN1_HEADER 176 +#define ASN1_F_I2D_DHPARAMS 177 +#define ASN1_F_I2D_DSAPARAMS 178 +#define ASN1_F_I2D_DSAPRIVATEKEY 179 +#define ASN1_F_I2D_DSAPUBLICKEY 180 +#define ASN1_F_I2D_NETSCAPE_RSA 181 +#define ASN1_F_I2D_PKCS7 182 +#define ASN1_F_I2D_PRIVATEKEY 183 +#define ASN1_F_I2D_PUBLICKEY 184 +#define ASN1_F_I2D_RSAPRIVATEKEY 185 +#define ASN1_F_I2D_RSAPUBLICKEY 186 +#define ASN1_F_I2D_X509_ATTRIBUTE 187 +#define ASN1_F_I2T_ASN1_OBJECT 188 +#define ASN1_F_NETSCAPE_PKEY_NEW 189 +#define ASN1_F_NETSCAPE_SPKAC_NEW 190 +#define ASN1_F_NETSCAPE_SPKI_NEW 191 +#define ASN1_F_PKCS7_DIGEST_NEW 192 +#define ASN1_F_PKCS7_ENCRYPT_NEW 193 +#define ASN1_F_PKCS7_ENC_CONTENT_NEW 194 +#define ASN1_F_PKCS7_ENVELOPE_NEW 195 +#define ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW 196 +#define ASN1_F_PKCS7_NEW 197 +#define ASN1_F_PKCS7_RECIP_INFO_NEW 198 +#define ASN1_F_PKCS7_SIGNED_NEW 199 +#define ASN1_F_PKCS7_SIGNER_INFO_NEW 200 +#define ASN1_F_PKCS7_SIGN_ENVELOPE_NEW 201 +#define ASN1_F_X509_ALGOR_NEW 202 +#define ASN1_F_X509_ATTRIBUTE_NEW 203 +#define ASN1_F_X509_CINF_NEW 204 +#define ASN1_F_X509_CRL_INFO_NEW 205 +#define ASN1_F_X509_CRL_NEW 206 +#define ASN1_F_X509_DHPARAMS_NEW 207 +#define ASN1_F_X509_EXTENSION_NEW 208 +#define ASN1_F_X509_INFO_NEW 209 +#define ASN1_F_X509_KEY_NEW 210 +#define ASN1_F_X509_NAME_ENTRY_NEW 211 +#define ASN1_F_X509_NAME_NEW 212 +#define ASN1_F_X509_NEW 213 +#define ASN1_F_X509_PKEY_NEW 214 +#define ASN1_F_X509_PUBKEY_NEW 215 +#define ASN1_F_X509_REQ_INFO_NEW 216 +#define ASN1_F_X509_REQ_NEW 217 +#define ASN1_F_X509_REVOKED_NEW 218 +#define ASN1_F_X509_SIG_NEW 219 +#define ASN1_F_X509_VAL_FREE 220 +#define ASN1_F_X509_VAL_NEW 221 + +/* Reason codes. */ +#define ASN1_R_BAD_CLASS 100 +#define ASN1_R_BAD_GET_OBJECT 101 +#define ASN1_R_BAD_OBJECT_HEADER 102 +#define ASN1_R_BAD_PASSWORD_READ 103 +#define ASN1_R_BAD_PKCS7_CONTENT 104 +#define ASN1_R_BAD_PKCS7_TYPE 105 +#define ASN1_R_BAD_TAG 106 +#define ASN1_R_BAD_TYPE 107 +#define ASN1_R_BN_LIB 108 +#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 109 +#define ASN1_R_BUFFER_TOO_SMALL 110 +#define ASN1_R_DATA_IS_WRONG 111 +#define ASN1_R_DECODING_ERROR 112 +#define ASN1_R_ERROR_STACK 113 +#define ASN1_R_EXPECTING_AN_INTEGER 114 +#define ASN1_R_EXPECTING_AN_OBJECT 115 +#define ASN1_R_EXPECTING_AN_OCTET_STRING 116 +#define ASN1_R_EXPECTING_A_BIT_STRING 117 +#define ASN1_R_EXPECTING_A_BOOLEAN 118 +#define ASN1_R_EXPECTING_A_SEQUENCE 119 +#define ASN1_R_EXPECTING_A_UTCTIME 120 +#define ASN1_R_FIRST_NUM_TOO_LARGE 121 +#define ASN1_R_HEADER_TOO_LONG 122 +#define ASN1_R_INVALID_DIGIT 123 +#define ASN1_R_INVALID_SEPARATOR 124 +#define ASN1_R_INVALID_TIME_FORMAT 125 +#define ASN1_R_IV_TOO_LARGE 126 +#define ASN1_R_LENGTH_ERROR 127 +#define ASN1_R_LENGTH_MISMATCH 128 +#define ASN1_R_MISSING_EOS 129 +#define ASN1_R_MISSING_SECOND_NUMBER 130 +#define ASN1_R_NON_HEX_CHARACTERS 131 +#define ASN1_R_NOT_ENOUGH_DATA 132 +#define ASN1_R_ODD_NUMBER_OF_CHARS 133 +#define ASN1_R_PARSING 134 +#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 135 +#define ASN1_R_SECOND_NUMBER_TOO_LARGE 136 +#define ASN1_R_SHORT_LINE 137 +#define ASN1_R_STRING_TOO_SHORT 138 +#define ASN1_R_TAG_VALUE_TOO_HIGH 139 +#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 140 +#define ASN1_R_TOO_LONG 141 +#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 142 +#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 143 +#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 144 +#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 145 +#define ASN1_R_UNKNOWN_OBJECT_TYPE 146 +#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 147 +#define ASN1_R_UNSUPPORTED_CIPHER 148 +#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 149 +#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 150 +#define ASN1_R_UTCTIME_TOO_LONG 151 +#define ASN1_R_WRONG_PRINTABLE_TYPE 152 +#define ASN1_R_WRONG_TAG 153 +#define ASN1_R_WRONG_TYPE 154 diff --git a/src/lib/libssl/src/crypto/asn1/d2i_dhp.c b/src/lib/libssl/src/crypto/asn1/d2i_dhp.c new file mode 100644 index 0000000000..616a308100 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/d2i_dhp.c @@ -0,0 +1,108 @@ +/* crypto/asn1/d2i_dhp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dh.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DHPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +DH *d2i_DHparams(a,pp,length) +DH **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_ERROR_STACK; + ASN1_INTEGER *bs=NULL; + long v=0; + M_ASN1_D2I_vars(a,DH *,DH_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; + + if (!M_ASN1_D2I_end_sequence()) + { + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + for (i=0; ilength; i++) + v=(v<<8)|(bs->data[i]); + ret->length=(int)v; + } + + ASN1_BIT_STRING_free(bs); + + M_ASN1_D2I_Finish_2(a); + +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DHPARAMS,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret); + if (bs != NULL) ASN1_BIT_STRING_free(bs); + return(NULL); + } + diff --git a/src/lib/libssl/src/crypto/asn1/d2i_dsap.c b/src/lib/libssl/src/crypto/asn1/d2i_dsap.c new file mode 100644 index 0000000000..2c8ac7bbcf --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/d2i_dsap.c @@ -0,0 +1,101 @@ +/* crypto/asn1/d2i_dsap.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DSAPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +DSA *d2i_DSAparams(a,pp,length) +DSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_ERROR_STACK; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,DSA *,DSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; + + ASN1_BIT_STRING_free(bs); + + M_ASN1_D2I_Finish_2(a); + +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DSAPARAMS,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); + if (bs != NULL) ASN1_BIT_STRING_free(bs); + return(NULL); + } + diff --git a/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c new file mode 100644 index 0000000000..0c53aa94bf --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c @@ -0,0 +1,129 @@ +/* crypto/asn1/d2i_r_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_PARSING); + */ + +static ASN1_METHOD method={ + (int (*)()) i2d_RSAPrivateKey, + (char *(*)())d2i_RSAPrivateKey, + (char *(*)())RSA_new, + (void (*)()) RSA_free}; + +ASN1_METHOD *RSAPrivateKey_asn1_meth() + { + return(&method); + } + +RSA *d2i_RSAPrivateKey(a,pp,length) +RSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,RSA *,RSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if (bs->length == 0) + ret->version=0; + else ret->version=bs->data[0]; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->d=BN_bin2bn(bs->data,bs->length,ret->d)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->dmp1=BN_bin2bn(bs->data,bs->length,ret->dmp1)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->dmq1=BN_bin2bn(bs->data,bs->length,ret->dmq1)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL) + goto err_bn; + + ASN1_INTEGER_free(bs); + + M_ASN1_D2I_Finish_2(a); +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c new file mode 100644 index 0000000000..778b792b1e --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c @@ -0,0 +1,100 @@ +/* crypto/asn1/d2i_r_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +RSA *d2i_RSAPublicKey(a,pp,length) +RSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,RSA *,RSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn; + + ASN1_INTEGER_free(bs); + bs=NULL; + + M_ASN1_D2I_Finish_2(a); + +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c new file mode 100644 index 0000000000..32ff8ba4b3 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c @@ -0,0 +1,113 @@ +/* crypto/asn1/d2i_s_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Origional version from Steven Schoch */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_PARSING); + */ + +DSA *d2i_DSAPrivateKey(a,pp,length) +DSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,DSA *,DSA_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if (bs->length == 0) + ret->version=0; + else ret->version=bs->data[0]; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key)) + == NULL) goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key)) + == NULL) goto err_bn; + + ASN1_INTEGER_free(bs); + + M_ASN1_D2I_Finish_2(a); +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c new file mode 100644 index 0000000000..1002f41cd8 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c @@ -0,0 +1,124 @@ +/* crypto/asn1/d2i_s_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Origional version from Steven Schoch */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +DSA *d2i_DSAPublicKey(a,pp,length) +DSA **a; +unsigned char **pp; +long length; + { + int i=ASN1_R_PARSING; + ASN1_INTEGER *bs=NULL; + M_ASN1_D2I_vars(a,DSA *,DSA_new); + + M_ASN1_D2I_Init(); + if ((length != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) + == (V_ASN1_UNIVERSAL|(V_ASN1_INTEGER)))) + { + c.slen=length; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key)) + == NULL) + goto err_bn; + ret->write_params=0; + } + else + { + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key)) + == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) + goto err_bn; + M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); + if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) + goto err_bn; + + ret->write_params=1; + } + + ASN1_INTEGER_free(bs); + bs=NULL; + M_ASN1_D2I_Finish_2(a); +err_bn: + i=ERR_R_BN_LIB; +err: + ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i); + if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret); + if (bs != NULL) ASN1_INTEGER_free(bs); + return(NULL); + } + diff --git a/src/lib/libssl/src/crypto/asn1/f.c b/src/lib/libssl/src/crypto/asn1/f.c new file mode 100644 index 0000000000..2ab3a262ac --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/f.c @@ -0,0 +1,80 @@ +/* crypto/asn1/f.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#include +#include "asn1.h" +#include "err.h" + +main() + { + ASN1_TYPE *at; + char buf[512]; + int n; + long l; + + at=ASN1_TYPE_new(); + + n=ASN1_TYPE_set_int_octetstring(at,98736,"01234567",8); + printf("%d\n",n); + n=ASN1_TYPE_get_int_octetstring(at,&l,buf,8); + buf[8]='\0'; + printf("%ld %d %d\n",l,n,buf[8]); + buf[8]='\0'; + printf("%s\n",buf); + ERR_load_crypto_strings(); + ERR_print_errors_fp(stderr); + } diff --git a/src/lib/libssl/src/crypto/asn1/i2d_dhp.c b/src/lib/libssl/src/crypto/asn1/i2d_dhp.c new file mode 100644 index 0000000000..a454025ce3 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/i2d_dhp.c @@ -0,0 +1,128 @@ +/* crypto/asn1/i2d_dhp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "asn1_mac.h" +#include "dh.h" + +/* + * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_DHPARAMS_NEW,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_DHparams(a,pp) +DH *a; +unsigned char **pp; + { + BIGNUM *num[3]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0; + int t,ret= -1; + unsigned char *p; + + if (a == NULL) return(0); + num[0]=a->p; + num[1]=a->g; + if (a->length != 0) + { + if ((num[2]=BN_new()) == NULL) goto err; + if (!BN_set_word(num[2],a->length)) goto err; + } + else + num[2]=NULL; + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DHPARAMS,ERR_R_MALLOC_FAILURE); + goto err; + } + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + ret=t; +err: + if (num[2] != NULL) BN_free(num[2]); + *pp=p; + return(ret); + } diff --git a/src/lib/libssl/src/crypto/asn1/i2d_dsap.c b/src/lib/libssl/src/crypto/asn1/i2d_dsap.c new file mode 100644 index 0000000000..94ecff1525 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/i2d_dsap.c @@ -0,0 +1,121 @@ +/* crypto/asn1/i2d_dsap.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "asn1_mac.h" +#include "dsa.h" + +/* + * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_DSAparams(a,pp) +DSA *a; +unsigned char **pp; + { + BIGNUM *num[3]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0; + int t,ret= -1; + unsigned char *p; + + if (a == NULL) return(0); + num[0]=a->p; + num[1]=a->q; + num[2]=a->g; + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DSAPARAMS,ERR_R_MALLOC_FAILURE); + goto err; + } + + for (i=0; i<3; i++) + { + if (num[i] == NULL) continue; + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + ret=t; +err: + *pp=p; + return(ret); + } + diff --git a/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c new file mode 100644 index 0000000000..aadbb92d8e --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c @@ -0,0 +1,132 @@ +/* crypto/asn1/i2d_r_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_RSAPrivateKey(a,pp) +RSA *a; +unsigned char **pp; + { + BIGNUM *num[9]; + unsigned char data[1]; + ASN1_INTEGER bs; + unsigned int j,i,tot,t,len,max=0; + unsigned char *p; + + if (a == NULL) return(0); + + num[1]=a->n; + num[2]=a->e; + num[3]=a->d; + num[4]=a->p; + num[5]=a->q; + num[6]=a->dmp1; + num[7]=a->dmq1; + num[8]=a->iqmp; + + bs.length=1; + bs.data=data; + bs.type=V_ASN1_INTEGER; + data[0]=a->version&0x7f; + + tot=i2d_ASN1_INTEGER(&(bs),NULL); + for (i=1; i<9; i++) + { + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + i2d_ASN1_INTEGER(&bs,&p); + + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=1; i<9; i++) + { + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + *pp=p; + return(t); + } + diff --git a/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c new file mode 100644 index 0000000000..3c54f6709d --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c @@ -0,0 +1,118 @@ +/* crypto/asn1/i2d_r_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "rsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_RSAPublicKey(a,pp) +RSA *a; +unsigned char **pp; + { + BIGNUM *num[2]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0,t; + unsigned char *p; + + if (a == NULL) return(0); + + num[0]=a->n; + num[1]=a->e; + + for (i=0; i<2; i++) + { + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=0; i<2; i++) + { + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + *pp=p; + return(t); + } + diff --git a/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c new file mode 100644 index 0000000000..6e95305548 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c @@ -0,0 +1,128 @@ +/* crypto/asn1/i2d_s_pr.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_DSAPrivateKey(a,pp) +DSA *a; +unsigned char **pp; + { + BIGNUM *num[6]; + unsigned char data[1]; + ASN1_INTEGER bs; + unsigned int j,i,tot,t,len,max=0; + unsigned char *p; + + if (a == NULL) return(0); + + num[1]=a->p; + num[2]=a->q; + num[3]=a->g; + num[4]=a->pub_key; + num[5]=a->priv_key; + + bs.length=1; + bs.data=data; + bs.type=V_ASN1_INTEGER; + data[0]=a->version&0x7f; + + tot=i2d_ASN1_INTEGER(&(bs),NULL); + for (i=1; i<6; i++) + { + j=BN_num_bits(num[i]); + len=((j == 0)?0:((j/8)+1)); + if (len > max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + + p= *pp; + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + i2d_ASN1_INTEGER(&bs,&p); + + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=1; i<6; i++) + { + bs.length=BN_bn2bin(num[i],bs.data); + i2d_ASN1_INTEGER(&bs,&p); + } + Free((char *)bs.data); + *pp=p; + return(t); + } + diff --git a/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c new file mode 100644 index 0000000000..5cf2877069 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c @@ -0,0 +1,133 @@ +/* crypto/asn1/i2d_s_pu.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn.h" +#include "dsa.h" +#include "objects.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE); + */ + +int i2d_DSAPublicKey(a,pp) +DSA *a; +unsigned char **pp; + { + BIGNUM *num[4]; + ASN1_INTEGER bs; + unsigned int j,i,tot=0,len,max=0,t=0,all,n=1; + unsigned char *p; + + if (a == NULL) return(0); + + all=a->write_params; + + num[0]=a->pub_key; + if (all) + { + num[1]=a->p; + num[2]=a->q; + num[3]=a->g; + n=4; + } + + for (i=0; i max) max=len; + len=ASN1_object_size(0,len, + (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER); + tot+=len; + } + + if (all) + { + t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE); + if (pp == NULL) return(t); + } + else + { + if (pp == NULL) return(tot); + } + + p= *pp; + if (all) + ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + + bs.type=V_ASN1_INTEGER; + bs.data=(unsigned char *)Malloc(max+4); + if (bs.data == NULL) + { + ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ERR_R_MALLOC_FAILURE); + return(-1); + } + + for (i=0; i +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_DIGEST_NEW,ASN1_R_MISSING_EOS); + * ASN1err(ASN1_F_D2I_PKCS7_DIGEST,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_DIGEST(a,pp) +PKCS7_DIGEST *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->md,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->contents,i2d_PKCS7); + M_ASN1_I2D_len(a->digest,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->md,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->contents,i2d_PKCS7); + M_ASN1_I2D_put(a->digest,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_finish(); + } + +PKCS7_DIGEST *d2i_PKCS7_DIGEST(a,pp,length) +PKCS7_DIGEST **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_DIGEST *,PKCS7_DIGEST_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->md,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->contents,d2i_PKCS7); + M_ASN1_D2I_get(ret->digest,d2i_ASN1_OCTET_STRING); + + M_ASN1_D2I_Finish(a,PKCS7_DIGEST_free,ASN1_F_D2I_PKCS7_DIGEST); + } + +PKCS7_DIGEST *PKCS7_DIGEST_new() + { + PKCS7_DIGEST *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_DIGEST); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->md,X509_ALGOR_new); + M_ASN1_New(ret->contents,PKCS7_new); + M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW); + } + +void PKCS7_DIGEST_free(a) +PKCS7_DIGEST *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + X509_ALGOR_free(a->md); + PKCS7_free(a->contents); + ASN1_OCTET_STRING_free(a->digest); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_enc.c b/src/lib/libssl/src/crypto/asn1/p7_enc.c new file mode 100644 index 0000000000..874dd78389 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_enc.c @@ -0,0 +1,120 @@ +/* crypto/asn1/p7_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ENCRYPT_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ENCRYPT,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ENCRYPT(a,pp) +PKCS7_ENCRYPT *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_finish(); + } + +PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(a,pp,length) +PKCS7_ENCRYPT **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ENCRYPT *,PKCS7_ENCRYPT_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT); + + M_ASN1_D2I_Finish(a,PKCS7_ENCRYPT_free,ASN1_F_D2I_PKCS7_ENCRYPT); + } + +PKCS7_ENCRYPT *PKCS7_ENCRYPT_new() + { + PKCS7_ENCRYPT *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW); + } + +void PKCS7_ENCRYPT_free(a) +PKCS7_ENCRYPT *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + PKCS7_ENC_CONTENT_free(a->enc_data); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_enc_c.c b/src/lib/libssl/src/crypto/asn1/p7_enc_c.c new file mode 100644 index 0000000000..2860d3e925 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_enc_c.c @@ -0,0 +1,127 @@ +/* crypto/asn1/p7_enc_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ENC_CONTENT_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ENC_CONTENT,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ENC_CONTENT(a,pp) +PKCS7_ENC_CONTENT *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->content_type,i2d_ASN1_OBJECT); + M_ASN1_I2D_len(a->algorithm,i2d_X509_ALGOR); + M_ASN1_I2D_len_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->content_type,i2d_ASN1_OBJECT); + M_ASN1_I2D_put(a->algorithm,i2d_X509_ALGOR); + M_ASN1_I2D_put_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING,0); + + M_ASN1_I2D_finish(); + } + +PKCS7_ENC_CONTENT *d2i_PKCS7_ENC_CONTENT(a,pp,length) +PKCS7_ENC_CONTENT **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ENC_CONTENT *,PKCS7_ENC_CONTENT_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->content_type,d2i_ASN1_OBJECT); + M_ASN1_D2I_get(ret->algorithm,d2i_X509_ALGOR); + M_ASN1_D2I_get_IMP_opt(ret->enc_data,d2i_ASN1_OCTET_STRING,0, + V_ASN1_OCTET_STRING); + + M_ASN1_D2I_Finish(a,PKCS7_ENC_CONTENT_free, + ASN1_F_D2I_PKCS7_ENC_CONTENT); + } + +PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new() + { + PKCS7_ENC_CONTENT *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT); + M_ASN1_New(ret->content_type,ASN1_OBJECT_new); + M_ASN1_New(ret->algorithm,X509_ALGOR_new); + ret->enc_data=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ENC_CONTENT_NEW); + } + +void PKCS7_ENC_CONTENT_free(a) +PKCS7_ENC_CONTENT *a; + { + if (a == NULL) return; + ASN1_OBJECT_free(a->content_type); + X509_ALGOR_free(a->algorithm); + ASN1_OCTET_STRING_free(a->enc_data); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_evp.c b/src/lib/libssl/src/crypto/asn1/p7_evp.c new file mode 100644 index 0000000000..4db0a7fe62 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_evp.c @@ -0,0 +1,125 @@ +/* crypto/asn1/p7_evp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ENVELOPE,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ENVELOPE(a,pp) +PKCS7_ENVELOPE *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT); + + M_ASN1_I2D_finish(); + } + +PKCS7_ENVELOPE *d2i_PKCS7_ENVELOPE(a,pp,length) +PKCS7_ENVELOPE **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ENVELOPE *,PKCS7_ENVELOPE_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO); + M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT); + + M_ASN1_D2I_Finish(a,PKCS7_ENVELOPE_free,ASN1_F_D2I_PKCS7_ENVELOPE); + } + +PKCS7_ENVELOPE *PKCS7_ENVELOPE_new() + { + PKCS7_ENVELOPE *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->recipientinfo,sk_new_null); + M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ENVELOPE_NEW); + } + +void PKCS7_ENVELOPE_free(a) +PKCS7_ENVELOPE *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); + PKCS7_ENC_CONTENT_free(a->enc_data); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_i_s.c b/src/lib/libssl/src/crypto/asn1/p7_i_s.c new file mode 100644 index 0000000000..9b00c556d9 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_i_s.c @@ -0,0 +1,120 @@ +/* crypto/asn1/p7_i_s.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_ISSUER_AND_SERIAL(a,pp) +PKCS7_ISSUER_AND_SERIAL *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->issuer,i2d_X509_NAME); + M_ASN1_I2D_len(a->serial,i2d_ASN1_INTEGER); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->issuer,i2d_X509_NAME); + M_ASN1_I2D_put(a->serial,i2d_ASN1_INTEGER); + + M_ASN1_I2D_finish(); + } + +PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(a,pp,length) +PKCS7_ISSUER_AND_SERIAL **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_ISSUER_AND_SERIAL *,PKCS7_ISSUER_AND_SERIAL_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); + M_ASN1_D2I_get(ret->serial,d2i_ASN1_INTEGER); + M_ASN1_D2I_Finish(a,PKCS7_ISSUER_AND_SERIAL_free, + ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL); + } + +PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new() + { + PKCS7_ISSUER_AND_SERIAL *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL); + M_ASN1_New(ret->issuer,X509_NAME_new); + M_ASN1_New(ret->serial,ASN1_INTEGER_new); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW); + } + +void PKCS7_ISSUER_AND_SERIAL_free(a) +PKCS7_ISSUER_AND_SERIAL *a; + { + if (a == NULL) return; + X509_NAME_free(a->issuer); + ASN1_INTEGER_free(a->serial); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_lib.c b/src/lib/libssl/src/crypto/asn1/p7_lib.c new file mode 100644 index 0000000000..2134e0974a --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_lib.c @@ -0,0 +1,299 @@ +/* crypto/asn1/p7_lib.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "objects.h" + +/* ASN1err(ASN1_F_D2I_PKCS7,ASN1_R_BAD_PKCS7_CONTENT); + * ASN1err(ASN1_F_I2D_PKCS7,ASN1_R_BAD_PKCS7_TYPE); + * ASN1err(ASN1_F_PKCS7_NEW,ASN1_R_BAD_PKCS7_TYPE); + */ + +int i2d_PKCS7(a,pp) +PKCS7 *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + if (a->asn1 != NULL) + { + if (pp == NULL) + return((int)a->length); + memcpy(*pp,a->asn1,(int)a->length); + *pp+=a->length; + return((int)a->length); + } + + ret+=4; /* sequence, BER header plus '0 0' end padding */ + M_ASN1_I2D_len(a->type,i2d_ASN1_OBJECT); + if (a->d.ptr != NULL) + { + ret+=4; /* explicit tag [ 0 ] BER plus '0 0' */ + switch (OBJ_obj2nid(a->type)) + { + case NID_pkcs7_data: + M_ASN1_I2D_len(a->d.data,i2d_ASN1_OCTET_STRING); + break; + case NID_pkcs7_signed: + M_ASN1_I2D_len(a->d.sign,i2d_PKCS7_SIGNED); + break; + case NID_pkcs7_enveloped: + M_ASN1_I2D_len(a->d.enveloped,i2d_PKCS7_ENVELOPE); + break; + case NID_pkcs7_signedAndEnveloped: + M_ASN1_I2D_len(a->d.signed_and_enveloped, + i2d_PKCS7_SIGN_ENVELOPE); + break; + case NID_pkcs7_digest: + M_ASN1_I2D_len(a->d.digest,i2d_PKCS7_DIGEST); + break; + case NID_pkcs7_encrypted: + M_ASN1_I2D_len(a->d.encrypted,i2d_PKCS7_ENCRYPT); + break; + default: + break; + } + } + r=ret; + if (pp == NULL) return(r); + p= *pp; + M_ASN1_I2D_INF_seq_start(V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + M_ASN1_I2D_put(a->type,i2d_ASN1_OBJECT); + + if (a->d.ptr != NULL) + { + M_ASN1_I2D_INF_seq_start(0,V_ASN1_CONTEXT_SPECIFIC); + switch (OBJ_obj2nid(a->type)) + { + case NID_pkcs7_data: + M_ASN1_I2D_put(a->d.data,i2d_ASN1_OCTET_STRING); + break; + case NID_pkcs7_signed: + M_ASN1_I2D_put(a->d.sign,i2d_PKCS7_SIGNED); + break; + case NID_pkcs7_enveloped: + M_ASN1_I2D_put(a->d.enveloped,i2d_PKCS7_ENVELOPE); + break; + case NID_pkcs7_signedAndEnveloped: + M_ASN1_I2D_put(a->d.signed_and_enveloped, + i2d_PKCS7_SIGN_ENVELOPE); + break; + case NID_pkcs7_digest: + M_ASN1_I2D_put(a->d.digest,i2d_PKCS7_DIGEST); + break; + case NID_pkcs7_encrypted: + M_ASN1_I2D_put(a->d.encrypted,i2d_PKCS7_ENCRYPT); + break; + default: + break; + } + M_ASN1_I2D_INF_seq_end(); + } + M_ASN1_I2D_INF_seq_end(); + M_ASN1_I2D_finish(); + } + +PKCS7 *d2i_PKCS7(a,pp,length) +PKCS7 **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new); + + if ((a != NULL) && ((*a) != NULL)) + { + if ((*a)->asn1 != NULL) + { + Free((char *)(*a)->asn1); + (*a)->asn1=NULL; + } + (*a)->length=0; + } + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->type,d2i_ASN1_OBJECT); + if (!M_ASN1_D2I_end_sequence()) + { + int Tinf,Ttag,Tclass; + long Tlen; + + if (M_ASN1_next != (V_ASN1_CONSTRUCTED| + V_ASN1_CONTEXT_SPECIFIC|0)) + { + c.error=ASN1_R_BAD_PKCS7_CONTENT; + goto err; + } + + ret->detached=0; + + c.q=c.p; + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass, + (c.inf & 1)?(length+ *pp-c.q):c.slen); + if (Tinf & 0x80) goto err; + c.slen-=(c.p-c.q); + + switch (OBJ_obj2nid(ret->type)) + { + case NID_pkcs7_data: + M_ASN1_D2I_get(ret->d.data,d2i_ASN1_OCTET_STRING); + break; + case NID_pkcs7_signed: + M_ASN1_D2I_get(ret->d.sign,d2i_PKCS7_SIGNED); + if (ret->d.sign->contents->d.ptr == NULL) + ret->detached=1; + break; + case NID_pkcs7_enveloped: + M_ASN1_D2I_get(ret->d.enveloped,d2i_PKCS7_ENVELOPE); + break; + case NID_pkcs7_signedAndEnveloped: + M_ASN1_D2I_get(ret->d.signed_and_enveloped, + d2i_PKCS7_SIGN_ENVELOPE); + break; + case NID_pkcs7_digest: + M_ASN1_D2I_get(ret->d.digest,d2i_PKCS7_DIGEST); + break; + case NID_pkcs7_encrypted: + M_ASN1_D2I_get(ret->d.encrypted,d2i_PKCS7_ENCRYPT); + break; + default: + c.error=ASN1_R_BAD_PKCS7_TYPE; + goto err; + break; + } + if (Tinf == (1|V_ASN1_CONSTRUCTED)) + { + if (!ASN1_check_infinite_end(&c.p,c.slen)) + { + c.error=ASN1_R_MISSING_EOS; + goto err; + } + } + } + else + ret->detached=1; + + M_ASN1_D2I_Finish(a,PKCS7_free,ASN1_F_D2I_PKCS7); + } + +PKCS7 *PKCS7_new() + { + PKCS7 *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7); + ret->type=ASN1_OBJECT_new(); + ret->asn1=NULL; + ret->length=0; + ret->detached=0; + ret->d.ptr=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_NEW); + } + +void PKCS7_free(a) +PKCS7 *a; + { + if (a == NULL) return; + + PKCS7_content_free(a); + if (a->type != NULL) + { + ASN1_OBJECT_free(a->type); + } + Free((char *)(char *)a); + } + +void PKCS7_content_free(a) +PKCS7 *a; + { + if (a->asn1 != NULL) Free((char *)a->asn1); + + if (a->d.ptr != NULL) + { + if (a->type == NULL) return; + + switch (OBJ_obj2nid(a->type)) + { + case NID_pkcs7_data: + ASN1_OCTET_STRING_free(a->d.data); + break; + case NID_pkcs7_signed: + PKCS7_SIGNED_free(a->d.sign); + break; + case NID_pkcs7_enveloped: + PKCS7_ENVELOPE_free(a->d.enveloped); + break; + case NID_pkcs7_signedAndEnveloped: + PKCS7_SIGN_ENVELOPE_free(a->d.signed_and_enveloped); + break; + case NID_pkcs7_digest: + PKCS7_DIGEST_free(a->d.digest); + break; + case NID_pkcs7_encrypted: + PKCS7_ENCRYPT_free(a->d.encrypted); + break; + default: + /* MEMORY LEAK */ + break; + } + } + a->d.ptr=NULL; + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_recip.c b/src/lib/libssl/src/crypto/asn1/p7_recip.c new file mode 100644 index 0000000000..f02233f5a8 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_recip.c @@ -0,0 +1,132 @@ +/* crypto/asn1/p7_recip.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_RECIP_INFO_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_RECIP_INFO,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_RECIP_INFO(a,pp) +PKCS7_RECIP_INFO *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_len(a->key_enc_algor,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->enc_key,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_put(a->key_enc_algor,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->enc_key,i2d_ASN1_OCTET_STRING); + + M_ASN1_I2D_finish(); + } + +PKCS7_RECIP_INFO *d2i_PKCS7_RECIP_INFO(a,pp,length) +PKCS7_RECIP_INFO **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_RECIP_INFO *,PKCS7_RECIP_INFO_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_D2I_get(ret->key_enc_algor,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->enc_key,d2i_ASN1_OCTET_STRING); + + M_ASN1_D2I_Finish(a,PKCS7_RECIP_INFO_free,ASN1_F_D2I_PKCS7_RECIP_INFO); + } + +PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new() + { + PKCS7_RECIP_INFO *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); + M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new); + M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new); + ret->cert=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW); + } + +void PKCS7_RECIP_INFO_free(a) +PKCS7_RECIP_INFO *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); + X509_ALGOR_free(a->key_enc_algor); + ASN1_OCTET_STRING_free(a->enc_key); + if (a->cert != NULL) X509_free(a->cert); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_s_e.c b/src/lib/libssl/src/crypto/asn1/p7_s_e.c new file mode 100644 index 0000000000..d344211456 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_s_e.c @@ -0,0 +1,146 @@ +/* crypto/asn1/p7_s_e.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_SIGN_ENVELOPE(a,pp) +PKCS7_SIGN_ENVELOPE *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT); + M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO); + M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT); + M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_finish(); + } + +PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(a,pp,length) +PKCS7_SIGN_ENVELOPE **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_SIGN_ENVELOPE *,PKCS7_SIGN_ENVELOPE_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO); + M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT); + M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0); + M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1); + M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO); + + M_ASN1_D2I_Finish(a,PKCS7_SIGN_ENVELOPE_free, + ASN1_F_D2I_PKCS7_SIGN_ENVELOPE); + } + +PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new() + { + PKCS7_SIGN_ENVELOPE *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->recipientinfo,sk_new_null); + M_ASN1_New(ret->md_algs,sk_new_null); + M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new); + ret->cert=NULL; + ret->crl=NULL; + M_ASN1_New(ret->signer_info,sk_new_null); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW); + } + +void PKCS7_SIGN_ENVELOPE_free(a) +PKCS7_SIGN_ENVELOPE *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free); + sk_pop_free(a->md_algs,X509_ALGOR_free); + PKCS7_ENC_CONTENT_free(a->enc_data); + sk_pop_free(a->cert,X509_free); + sk_pop_free(a->crl,X509_CRL_free); + sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_signd.c b/src/lib/libssl/src/crypto/asn1/p7_signd.c new file mode 100644 index 0000000000..40f9a44fa8 --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_signd.c @@ -0,0 +1,140 @@ +/* crypto/asn1/p7_signd.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_SIGNED_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_SIGNED,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_SIGNED(a,pp) +PKCS7_SIGNED *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->contents,i2d_PKCS7); + M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->contents,i2d_PKCS7); + M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0); + M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1); + M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO); + + M_ASN1_I2D_finish(); + } + +PKCS7_SIGNED *d2i_PKCS7_SIGNED(a,pp,length) +PKCS7_SIGNED **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_SIGNED *,PKCS7_SIGNED_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->contents,d2i_PKCS7); + M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0); + M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1); + M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO); + + M_ASN1_D2I_Finish(a,PKCS7_SIGNED_free,ASN1_F_D2I_PKCS7_SIGNED); + } + +PKCS7_SIGNED *PKCS7_SIGNED_new() + { + PKCS7_SIGNED *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_SIGNED); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->md_algs,sk_new_null); + M_ASN1_New(ret->contents,PKCS7_new); + ret->cert=NULL; + ret->crl=NULL; + M_ASN1_New(ret->signer_info,sk_new_null); + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_SIGNED_NEW); + } + +void PKCS7_SIGNED_free(a) +PKCS7_SIGNED *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + sk_pop_free(a->md_algs,X509_ALGOR_free); + PKCS7_free(a->contents); + sk_pop_free(a->cert,X509_free); + sk_pop_free(a->crl,X509_CRL_free); + sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/p7_signi.c b/src/lib/libssl/src/crypto/asn1/p7_signi.c new file mode 100644 index 0000000000..0da92169fc --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/p7_signi.c @@ -0,0 +1,149 @@ +/* crypto/asn1/p7_signi.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "x509.h" + +/* + * ASN1err(ASN1_F_PKCS7_SIGNER_INFO_NEW,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_D2I_PKCS7_SIGNER_INFO,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_PKCS7_SIGNER_INFO(a,pp) +PKCS7_SIGNER_INFO *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_len(a->digest_alg,i2d_X509_ALGOR); + M_ASN1_I2D_len_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0); + M_ASN1_I2D_len(a->digest_enc_alg,i2d_X509_ALGOR); + M_ASN1_I2D_len(a->enc_digest,i2d_ASN1_OCTET_STRING); + M_ASN1_I2D_len_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_I2D_put(a->digest_alg,i2d_X509_ALGOR); + M_ASN1_I2D_put_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0); + M_ASN1_I2D_put(a->digest_enc_alg,i2d_X509_ALGOR); + M_ASN1_I2D_put(a->enc_digest,i2d_ASN1_OCTET_STRING); + M_ASN1_I2D_put_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1); + + M_ASN1_I2D_finish(); + } + +PKCS7_SIGNER_INFO *d2i_PKCS7_SIGNER_INFO(a,pp,length) +PKCS7_SIGNER_INFO **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,PKCS7_SIGNER_INFO *,PKCS7_SIGNER_INFO_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL); + M_ASN1_D2I_get(ret->digest_alg,d2i_X509_ALGOR); + M_ASN1_D2I_get_IMP_set_opt(ret->auth_attr,d2i_X509_ATTRIBUTE,0); + M_ASN1_D2I_get(ret->digest_enc_alg,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->enc_digest,d2i_ASN1_OCTET_STRING); + M_ASN1_D2I_get_IMP_set_opt(ret->unauth_attr,d2i_X509_ATTRIBUTE,1); + + M_ASN1_D2I_Finish(a,PKCS7_SIGNER_INFO_free, + ASN1_F_D2I_PKCS7_SIGNER_INFO); + } + +PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new() + { + PKCS7_SIGNER_INFO *ret=NULL; + + M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO); + M_ASN1_New(ret->version,ASN1_INTEGER_new); + M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new); + M_ASN1_New(ret->digest_alg,X509_ALGOR_new); + ret->auth_attr=NULL; + M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new); + M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new); + ret->unauth_attr=NULL; + ret->pkey=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_PKCS7_SIGNER_INFO_NEW); + } + +void PKCS7_SIGNER_INFO_free(a) +PKCS7_SIGNER_INFO *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial); + X509_ALGOR_free(a->digest_alg); + sk_pop_free(a->auth_attr,X509_ATTRIBUTE_free); + X509_ALGOR_free(a->digest_enc_alg); + ASN1_OCTET_STRING_free(a->enc_digest); + sk_pop_free(a->unauth_attr,X509_ATTRIBUTE_free); + if (a->pkey != NULL) + EVP_PKEY_free(a->pkey); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/pkcs8.c b/src/lib/libssl/src/crypto/asn1/pkcs8.c new file mode 100644 index 0000000000..03fdadd51a --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/pkcs8.c @@ -0,0 +1,142 @@ +/* crypto/asn1/pkcs8.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" +#include "objects.h" + +/* + * ASN1err(ASN1_F_D2I_X509_KEY,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_KEY_NEW,ASN1_R_BAD_GET_OBJECT); + */ + +int i2d_X509_KEY(a,pp) +X509 *a; +unsigned char **pp; + { + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF); + M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR); + M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF); + M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR); + M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING); + + M_ASN1_I2D_finish(); + } + +X509 *d2i_X509_KEY(a,pp,length) +X509 **a; +unsigned char **pp; +long length; + { + M_ASN1_D2I_vars(a,X509 *,X509_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF); + M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING); + M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509); + } + +X509 *X509_KEY_new() + { + X509_KEY *ret=NULL; + + M_ASN1_New_Malloc(ret,X509_KEY); + ret->references=1; + ret->type=NID + M_ASN1_New(ret->cert_info,X509_CINF_new); + M_ASN1_New(ret->sig_alg,X509_ALGOR_new); + M_ASN1_New(ret->signature,ASN1_BIT_STRING_new); + return(ret); + M_ASN1_New_Error(ASN1_F_X509_NEW); + } + +void X509_KEY_free(a) +X509 *a; + { + int i; + + if (a == NULL) return; + + i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY); +#ifdef REF_PRINT + REF_PRINT("X509_KEY",a); +#endif + if (i > 0) return; +#ifdef REF_CHECK + if (i < 0) + { + fprintf(stderr,"X509_KEY_free, bad reference count\n"); + abort(); + } +#endif + + X509_CINF_free(a->cert_info); + X509_ALGOR_free(a->sig_alg); + ASN1_BIT_STRING_free(a->signature); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/asn1/x_cinf.c b/src/lib/libssl/src/crypto/asn1/x_cinf.c new file mode 100644 index 0000000000..4fc2cc9f6e --- /dev/null +++ b/src/lib/libssl/src/crypto/asn1/x_cinf.c @@ -0,0 +1,197 @@ +/* crypto/asn1/x_cinf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "asn1_mac.h" + +/* + * ASN1err(ASN1_F_D2I_X509_CINF,ASN1_R_LENGTH_MISMATCH); + * ASN1err(ASN1_F_X509_CINF_NEW,ASN1_R_LENGTH_MISMATCH); + */ + +int i2d_X509_CINF(a,pp) +X509_CINF *a; +unsigned char **pp; + { + int v1=0,v2=0; + M_ASN1_I2D_vars(a); + + M_ASN1_I2D_len_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1); + M_ASN1_I2D_len(a->serialNumber, i2d_ASN1_INTEGER); + M_ASN1_I2D_len(a->signature, i2d_X509_ALGOR); + M_ASN1_I2D_len(a->issuer, i2d_X509_NAME); + M_ASN1_I2D_len(a->validity, i2d_X509_VAL); + M_ASN1_I2D_len(a->subject, i2d_X509_NAME); + M_ASN1_I2D_len(a->key, i2d_X509_PUBKEY); + M_ASN1_I2D_len_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING); + M_ASN1_I2D_len_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING); + M_ASN1_I2D_len_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2); + + M_ASN1_I2D_seq_total(); + + M_ASN1_I2D_put_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1); + M_ASN1_I2D_put(a->serialNumber, i2d_ASN1_INTEGER); + M_ASN1_I2D_put(a->signature, i2d_X509_ALGOR); + M_ASN1_I2D_put(a->issuer, i2d_X509_NAME); + M_ASN1_I2D_put(a->validity, i2d_X509_VAL); + M_ASN1_I2D_put(a->subject, i2d_X509_NAME); + M_ASN1_I2D_put(a->key, i2d_X509_PUBKEY); + M_ASN1_I2D_put_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING,1); + M_ASN1_I2D_put_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING,2); + M_ASN1_I2D_put_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2); + + M_ASN1_I2D_finish(); + } + +X509_CINF *d2i_X509_CINF(a,pp,length) +X509_CINF **a; +unsigned char **pp; +long length; + { + int ver=0; + M_ASN1_D2I_vars(a,X509_CINF *,X509_CINF_new); + + M_ASN1_D2I_Init(); + M_ASN1_D2I_start_sequence(); + /* we have the optional version field */ + if (M_ASN1_next == (V_ASN1_CONTEXT_SPECIFIC | V_ASN1_CONSTRUCTED | 0)) + { + M_ASN1_D2I_get_EXP_opt(ret->version,d2i_ASN1_INTEGER,0); + if (ret->version->data != NULL) + ver=ret->version->data[0]; + } + else + { + if (ret->version != NULL) + { + ASN1_INTEGER_free(ret->version); + ret->version=NULL; + } + } + M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER); + M_ASN1_D2I_get(ret->signature,d2i_X509_ALGOR); + M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME); + M_ASN1_D2I_get(ret->validity,d2i_X509_VAL); + M_ASN1_D2I_get(ret->subject,d2i_X509_NAME); + M_ASN1_D2I_get(ret->key,d2i_X509_PUBKEY); + if (ver >= 1) /* version 2 extensions */ + { + if (ret->issuerUID != NULL) + { + ASN1_BIT_STRING_free(ret->issuerUID); + ret->issuerUID=NULL; + } + if (ret->subjectUID != NULL) + { + ASN1_BIT_STRING_free(ret->subjectUID); + ret->issuerUID=NULL; + } + M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1, + V_ASN1_BIT_STRING); + M_ASN1_D2I_get_IMP_opt(ret->subjectUID,d2i_ASN1_BIT_STRING, 2, + V_ASN1_BIT_STRING); + } + if (ver >= 2) /* version 3 extensions */ + { + if (ret->extensions != NULL) + while (sk_num(ret->extensions)) + X509_EXTENSION_free((X509_EXTENSION *) + sk_pop(ret->extensions)); + M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,3, + V_ASN1_SEQUENCE); + } + M_ASN1_D2I_Finish(a,X509_CINF_free,ASN1_F_D2I_X509_CINF); + } + +X509_CINF *X509_CINF_new() + { + X509_CINF *ret=NULL; + + M_ASN1_New_Malloc(ret,X509_CINF); + ret->version=NULL; + M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new); + M_ASN1_New(ret->signature,X509_ALGOR_new); + M_ASN1_New(ret->issuer,X509_NAME_new); + M_ASN1_New(ret->validity,X509_VAL_new); + M_ASN1_New(ret->subject,X509_NAME_new); + M_ASN1_New(ret->key,X509_PUBKEY_new); + ret->issuerUID=NULL; + ret->subjectUID=NULL; + ret->extensions=NULL; + return(ret); + M_ASN1_New_Error(ASN1_F_X509_CINF_NEW); + } + +void X509_CINF_free(a) +X509_CINF *a; + { + if (a == NULL) return; + ASN1_INTEGER_free(a->version); + ASN1_INTEGER_free(a->serialNumber); + X509_ALGOR_free(a->signature); + X509_NAME_free(a->issuer); + X509_VAL_free(a->validity); + X509_NAME_free(a->subject); + X509_PUBKEY_free(a->key); + ASN1_BIT_STRING_free(a->issuerUID); + ASN1_BIT_STRING_free(a->subjectUID); + sk_pop_free(a->extensions,X509_EXTENSION_free); + Free((char *)a); + } + diff --git a/src/lib/libssl/src/crypto/bf/Makefile.ssl b/src/lib/libssl/src/crypto/bf/Makefile.ssl new file mode 100644 index 0000000000..236671f238 --- /dev/null +++ b/src/lib/libssl/src/crypto/bf/Makefile.ssl @@ -0,0 +1,107 @@ +# +# SSLeay/crypto/blowfish/Makefile +# + +DIR= bf +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +BF_ENC= bf_enc.o +# or use +#DES_ENC= bx86-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=bftest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c +LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= blowfish.h +HEADER= bf_pi.h bf_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/bx86-elf.o: asm/bx86unix.cpp + $(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o + +# solaris +asm/bx86-sol.o: asm/bx86unix.cpp + $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s + as -o asm/bx86-sol.o asm/bx86-sol.s + rm -f asm/bx86-sol.s + +# a.out +asm/bx86-out.o: asm/bx86unix.cpp + $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o + +# bsdi +asm/bx86bsdi.o: asm/bx86unix.cpp + $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o + +asm/bx86unix.cpp: + (cd asm; perl bf-586.pl cpp >bx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/bf/Makefile.uni b/src/lib/libssl/src/crypto/bf/Makefile.uni new file mode 100644 index 0000000000..9ba5b0c854 --- /dev/null +++ b/src/lib/libssl/src/crypto/bf/Makefile.uni @@ -0,0 +1,169 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= bf +TOP= . +# use BF_PTR2 for intel boxes, +# BF_PTR for sparc and MIPS/SGI +# use nothing for Alpha and HP. + +# There are 3 possible performance options, experiment :-) +#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI +#OPTS= -DBF_PTR2 # use for pentium +OPTS= # use for pentium pro, Alpha and HP + +MAKE=make -f Makefile +#CC=cc +#CFLAG= -O + +CC=gcc +#CFLAG= -O4 -funroll-loops -fomit-frame-pointer +CFLAG= -O3 -fomit-frame-pointer + +CFLAGS=$(OPTS) $(CFLAG) +CPP=$(CC) -E +AS=as + +# Assember version of bf_encrypt(). +BF_ENC=bf_enc.o # normal C version +#BF_ENC=asm/bx86-elf.o # elf format x86 +#BF_ENC=asm/bx86-out.o # a.out format x86 +#BF_ENC=asm/bx86-sol.o # solaris format x86 +#BF_ENC=asm/bx86bsdi.o # bsdi format x86 + +LIBDIR=/usr/local/lib +BINDIR=/usr/local/bin +INCDIR=/usr/local/include +MANDIR=/usr/local/man +MAN1=1 +MAN3=3 +SHELL=/bin/sh +LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o +LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c + +GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \ + COPYRIGHT blowfish.doc INSTALL + +TESTING= bftest bfspeed bf_opts +TESTING_SRC=bftest.c bfspeed.c bf_opts.c +HEADERS=bf_locl.h blowfish.h bf_pi.h + +ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS) + +BLIB= libblowfish.a + +all: $(BLIB) $(TESTING) + +cc: + $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all + +gcc: + $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all + +x86-elf: + $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all + +x86-out: + $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all + +x86-solaris: + $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all + +x86-bsdi: + $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all + +# elf +asm/bx86-elf.o: asm/bx86unix.cpp + $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o + +# solaris +asm/bx86-sol.o: asm/bx86unix.cpp + $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s + as -o asm/bx86-sol.o asm/bx86-sol.s + rm -f asm/bx86-sol.s + +# a.out +asm/bx86-out.o: asm/bx86unix.cpp + $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o + +# bsdi +asm/bx86bsdi.o: asm/bx86unix.cpp + $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o + +asm/bx86unix.cpp: + (cd asm; perl bf-586.pl cpp >bx86unix.cpp) + +test: all + ./bftest + +$(BLIB): $(LIBOBJ) + /bin/rm -f $(BLIB) + ar cr $(BLIB) $(LIBOBJ) + -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \ + else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \ + else exit 0; fi; fi + +bftest: bftest.o $(BLIB) + $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB) + +bfspeed: bfspeed.o $(BLIB) + $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB) + +bf_opts: bf_opts.o $(BLIB) + $(CC) $(CFLAGS) -o bf_opts bf_opts.o $(BLIB) + +tags: + ctags $(TESTING_SRC) $(LIBBF) + +tar: + tar chf libbf.tar $(ALL) + +shar: + shar $(ALL) >libbf.shar + +depend: + makedepend $(LIBBF) $(TESTING_SRC) + +clean: + /bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o + +dclean: + sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new + mv -f Makefile.new Makefile + +# Eric is probably going to choke when he next looks at this --tjh +install: $(BLIB) + if test $(INSTALLTOP); then \ + echo SSL style install; \ + cp $(BLIB) $(INSTALLTOP)/lib; \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ + fi; fi; \ + chmod 644 $(INSTALLTOP)/lib/$(BLIB); \ + cp blowfish.h $(INSTALLTOP)/include; \ + chmod 644 $(INSTALLTOP)/include/blowfish.h; \ + else \ + echo Standalone install; \ + cp $(BLIB) $(LIBDIR)/$(BLIB); \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(LIBDIR)/$(BLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(LIBDIR)/$(BLIB); \ + fi; \ + fi; \ + chmod 644 $(LIBDIR)/$(BLIB); \ + cp blowfish.h $(INCDIR)/blowfish.h; \ + chmod 644 $(INCDIR)/blowfish.h; \ + fi + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/bf/asm/b-win32.asm b/src/lib/libssl/src/crypto/bf/asm/b-win32.asm new file mode 100644 index 0000000000..138c99d0aa --- /dev/null +++ b/src/lib/libssl/src/crypto/bf/asm/b-win32.asm @@ -0,0 +1,906 @@ + ; Don't even think of reading this code + ; It was automatically generated by bf-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE bf-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _BF_encrypt + +_BF_encrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + mov ebx, DWORD PTR [ebp] + xor ecx, ecx + xor edi, ebx + ; + ; Round 0 + mov edx, DWORD PTR 4[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 1 + mov edx, DWORD PTR 8[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 2 + mov edx, DWORD PTR 12[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 3 + mov edx, DWORD PTR 16[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 4 + mov edx, DWORD PTR 20[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 5 + mov edx, DWORD PTR 24[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 6 + mov edx, DWORD PTR 28[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 7 + mov edx, DWORD PTR 32[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 8 + mov edx, DWORD PTR 36[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 9 + mov edx, DWORD PTR 40[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 10 + mov edx, DWORD PTR 44[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 11 + mov edx, DWORD PTR 48[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 12 + mov edx, DWORD PTR 52[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 13 + mov edx, DWORD PTR 56[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 14 + mov edx, DWORD PTR 60[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 15 + mov edx, DWORD PTR 64[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + ; Load parameter 0 (16) enc=1 + mov eax, DWORD PTR 20[esp] + xor edi, ebx + mov edx, DWORD PTR 68[ebp] + xor esi, edx + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_BF_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _BF_decrypt + +_BF_decrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + mov ebx, DWORD PTR 68[ebp] + xor ecx, ecx + xor edi, ebx + ; + ; Round 16 + mov edx, DWORD PTR 64[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 15 + mov edx, DWORD PTR 60[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 14 + mov edx, DWORD PTR 56[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 13 + mov edx, DWORD PTR 52[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 12 + mov edx, DWORD PTR 48[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 11 + mov edx, DWORD PTR 44[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 10 + mov edx, DWORD PTR 40[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 9 + mov edx, DWORD PTR 36[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 8 + mov edx, DWORD PTR 32[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 7 + mov edx, DWORD PTR 28[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 6 + mov edx, DWORD PTR 24[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 5 + mov edx, DWORD PTR 20[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 4 + mov edx, DWORD PTR 16[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 3 + mov edx, DWORD PTR 12[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor edi, ebx + ; + ; Round 2 + mov edx, DWORD PTR 8[ebp] + mov ebx, edi + xor esi, edx + shr ebx, 16 + mov edx, edi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + xor eax, eax + xor esi, ebx + ; + ; Round 1 + mov edx, DWORD PTR 4[ebp] + mov ebx, esi + xor edi, edx + shr ebx, 16 + mov edx, esi + mov al, bh + and ebx, 255 + mov cl, dh + and edx, 255 + mov eax, DWORD PTR 72[eax*4+ebp] + mov ebx, DWORD PTR 1096[ebx*4+ebp] + add ebx, eax + mov eax, DWORD PTR 2120[ecx*4+ebp] + xor ebx, eax + mov edx, DWORD PTR 3144[edx*4+ebp] + add ebx, edx + ; Load parameter 0 (1) enc=0 + mov eax, DWORD PTR 20[esp] + xor edi, ebx + mov edx, DWORD PTR [ebp] + xor esi, edx + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_BF_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _BF_cbc_encrypt + +_BF_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L000decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L001encrypt_finish +L002encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L002encrypt_loop +$L001encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4] + jmp ebp +L005ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L006ej6: + mov dh, BYTE PTR 5[esi] +L007ej5: + mov dl, BYTE PTR 4[esi] +L008ej4: + mov ecx, DWORD PTR [esi] + jmp $L009ejend +L010ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L011ej2: + mov ch, BYTE PTR 1[esi] +L012ej1: + mov cl, BYTE PTR [esi] +$L009ejend: + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L003finish +$L000decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L013decrypt_finish +L014decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L014decrypt_loop +$L013decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _BF_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L015dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L016dj6: + mov BYTE PTR 5[edi],dh +L017dj5: + mov BYTE PTR 4[edi],dl +L018dj4: + mov DWORD PTR [edi],ecx + jmp $L019djend +L020dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L021dj2: + mov BYTE PTR 1[esi],ch +L022dj1: + mov BYTE PTR [esi], cl +$L019djend: + jmp $L003finish +$L003finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L004cbc_enc_jmp_table: + DD 0 + DD L012ej1 + DD L011ej2 + DD L010ej3 + DD L008ej4 + DD L007ej5 + DD L006ej6 + DD L005ej7 +L023cbc_dec_jmp_table: + DD 0 + DD L022dj1 + DD L021dj2 + DD L020dj3 + DD L018dj4 + DD L017dj5 + DD L016dj6 + DD L015dj7 +_BF_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp b/src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp new file mode 100644 index 0000000000..cdaa269378 --- /dev/null +++ b/src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp @@ -0,0 +1,976 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define BF_encrypt _BF_encrypt +#define BF_decrypt _BF_decrypt +#define BF_cbc_encrypt _BF_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by bf-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "bf-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl BF_encrypt + TYPE(BF_encrypt,@function) +BF_encrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + movl (%ebp), %ebx + xorl %ecx, %ecx + xorl %ebx, %edi + + /* Round 0 */ + movl 4(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 1 */ + movl 8(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 2 */ + movl 12(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 3 */ + movl 16(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 4 */ + movl 20(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 5 */ + movl 24(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 6 */ + movl 28(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 7 */ + movl 32(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 8 */ + movl 36(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 9 */ + movl 40(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 10 */ + movl 44(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 11 */ + movl 48(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 12 */ + movl 52(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 13 */ + movl 56(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 14 */ + movl 60(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 15 */ + movl 64(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + /* Load parameter 0 (16) enc=1 */ + movl 20(%esp), %eax + xorl %ebx, %edi + movl 68(%ebp), %edx + xorl %edx, %esi + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.BF_encrypt_end: + SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt) +.ident "BF_encrypt" +.text + .align ALIGN +.globl BF_decrypt + TYPE(BF_decrypt,@function) +BF_decrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + movl 68(%ebp), %ebx + xorl %ecx, %ecx + xorl %ebx, %edi + + /* Round 16 */ + movl 64(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 15 */ + movl 60(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 14 */ + movl 56(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 13 */ + movl 52(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 12 */ + movl 48(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 11 */ + movl 44(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 10 */ + movl 40(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 9 */ + movl 36(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 8 */ + movl 32(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 7 */ + movl 28(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 6 */ + movl 24(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 5 */ + movl 20(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 4 */ + movl 16(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 3 */ + movl 12(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %edi + + /* Round 2 */ + movl 8(%ebp), %edx + movl %edi, %ebx + xorl %edx, %esi + shrl $16, %ebx + movl %edi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + xorl %eax, %eax + xorl %ebx, %esi + + /* Round 1 */ + movl 4(%ebp), %edx + movl %esi, %ebx + xorl %edx, %edi + shrl $16, %ebx + movl %esi, %edx + movb %bh, %al + andl $255, %ebx + movb %dh, %cl + andl $255, %edx + movl 72(%ebp,%eax,4),%eax + movl 1096(%ebp,%ebx,4),%ebx + addl %eax, %ebx + movl 2120(%ebp,%ecx,4),%eax + xorl %eax, %ebx + movl 3144(%ebp,%edx,4),%edx + addl %edx, %ebx + /* Load parameter 0 (1) enc=0 */ + movl 20(%esp), %eax + xorl %ebx, %edi + movl (%ebp), %edx + xorl %edx, %esi + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.BF_decrypt_end: + SIZE(BF_decrypt,.BF_decrypt_end-BF_decrypt) +.ident "BF_decrypt" +.text + .align ALIGN +.globl BF_cbc_encrypt + TYPE(BF_cbc_encrypt,@function) +BF_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L000decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L001encrypt_finish +.L002encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L002encrypt_loop +.L001encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L005ej7: + movb 6(%esi), %dh + sall $8, %edx +.L006ej6: + movb 5(%esi), %dh +.L007ej5: + movb 4(%esi), %dl +.L008ej4: + movl (%esi), %ecx + jmp .L009ejend +.L010ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L011ej2: + movb 1(%esi), %ch +.L012ej1: + movb (%esi), %cl +.L009ejend: + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L003finish +.align ALIGN +.L000decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L013decrypt_finish +.L014decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L014decrypt_loop +.L013decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call BF_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L015dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L016dj6: + movb %dh, 5(%edi) +.L017dj5: + movb %dl, 4(%edi) +.L018dj4: + movl %ecx, (%edi) + jmp .L019djend +.L020dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L021dj2: + movb %ch, 1(%esi) +.L022dj1: + movb %cl, (%esi) +.L019djend: + jmp .L003finish +.align ALIGN +.L003finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L004cbc_enc_jmp_table: + .long 0 + .long .L012ej1 + .long .L011ej2 + .long .L010ej3 + .long .L008ej4 + .long .L007ej5 + .long .L006ej6 + .long .L005ej7 +.align ALIGN +.L023cbc_dec_jmp_table: + .long 0 + .long .L022dj1 + .long .L021dj2 + .long .L020dj3 + .long .L018dj4 + .long .L017dj5 + .long .L016dj6 + .long .L015dj7 +.BF_cbc_encrypt_end: + SIZE(BF_cbc_encrypt,.BF_cbc_encrypt_end-BF_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/bf/bf_locl.org b/src/lib/libssl/src/crypto/bf/bf_locl.org new file mode 100644 index 0000000000..a5663de8ca --- /dev/null +++ b/src/lib/libssl/src/crypto/bf/bf_locl.org @@ -0,0 +1,242 @@ +/* crypto/bf/bf_locl.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify bf_locl.org since bf_locl.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define BF_PTR +#elif defined( __ultrix ) /* Older MIPS */ +# define BF_PTR +#elif defined( __osf1__ ) /* Alpha */ + /* None */ +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* None */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ + /* Unknown */ +#elif defined( __sgi ) /* Newer MIPS */ +# define BF_PTR +#elif defined( i386 ) /* x86 boxes, should be gcc */ +#elif defined( _MSC_VER ) /* x86 boxes, Visual C */ +#endif /* Systems-specific speed defines */ + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* This is actually a big endian algorithm, the most significate byte + * is used to lookup array 0 */ + +/* use BF_PTR2 for intel boxes, + * BF_PTR for sparc and MIPS/SGI + * use nothing for Alpha and HP. + */ +#if !defined(BF_PTR) && !defined(BF_PTR2) +#undef BF_PTR +#endif + +#define BF_M 0x3fc +#define BF_0 22L +#define BF_1 14L +#define BF_2 6L +#define BF_3 2L /* left shift */ + +#if defined(BF_PTR2) + +/* This is basically a special pentium verson */ +#define BF_ENC(LL,R,S,P) \ + { \ + BF_LONG t,u,v; \ + u=R>>BF_0; \ + v=R>>BF_1; \ + u&=BF_M; \ + v&=BF_M; \ + t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ + u=R>>BF_2; \ + t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ + v=R<>BF_0)&BF_M))+ \ + *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ + *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ + *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24L) ] + \ + S[0x0100+((int)(R>>16L)&0xff)])^ \ + S[0x0200+((int)(R>> 8L)&0xff)])+ \ + S[0x0300+((int)(R )&0xff)])&0xffffffffL; +#endif diff --git a/src/lib/libssl/src/crypto/bio/Makefile.ssl b/src/lib/libssl/src/crypto/bio/Makefile.ssl new file mode 100644 index 0000000000..42e11e1c94 --- /dev/null +++ b/src/lib/libssl/src/crypto/bio/Makefile.ssl @@ -0,0 +1,92 @@ +# +# SSLeay/crypto/bio/Makefile +# + +DIR= bio +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=bio +ERRC=bio_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= bio_lib.c bio_cb.c $(ERRC).c \ + bss_mem.c bss_null.c bss_fd.c \ + bss_file.c bss_sock.c bss_conn.c \ + bf_null.c bf_buff.c b_print.c b_dump.c \ + b_sock.c bss_acpt.c bf_nbio.c +LIBOBJ= bio_lib.o bio_cb.o $(ERRC).o \ + bss_mem.o bss_null.o bss_fd.o \ + bss_file.o bss_sock.o bss_conn.o \ + bf_null.o bf_buff.o b_print.o b_dump.o \ + b_sock.o bss_acpt.o bf_nbio.o + +SRC= $(LIBSRC) + +EXHEADER= bio.h bss_file.c +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) bss_file.c ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/bio/bio.err b/src/lib/libssl/src/crypto/bio/bio.err new file mode 100644 index 0000000000..6e2f2b63ca --- /dev/null +++ b/src/lib/libssl/src/crypto/bio/bio.err @@ -0,0 +1,46 @@ +/* Error codes for the BIO functions. */ + +/* Function codes. */ +#define BIO_F_ACPT_STATE 100 +#define BIO_F_BIO_ACCEPT 101 +#define BIO_F_BIO_CTRL 102 +#define BIO_F_BIO_GETS 103 +#define BIO_F_BIO_GET_ACCEPT_SOCKET 104 +#define BIO_F_BIO_GET_HOST_IP 105 +#define BIO_F_BIO_GET_PORT 106 +#define BIO_F_BIO_NEW 107 +#define BIO_F_BIO_NEW_FILE 108 +#define BIO_F_BIO_PUTS 109 +#define BIO_F_BIO_READ 110 +#define BIO_F_BIO_SOCK_INIT 111 +#define BIO_F_BIO_WRITE 112 +#define BIO_F_BUFFER_CTRL 113 +#define BIO_F_CONN_STATE 114 +#define BIO_F_FILE_CTRL 115 +#define BIO_F_MEM_WRITE 116 +#define BIO_F_SSL_NEW 117 +#define BIO_F_WSASTARTUP 118 + +/* Reason codes. */ +#define BIO_R_ACCEPT_ERROR 100 +#define BIO_R_BAD_FOPEN_MODE 101 +#define BIO_R_BAD_HOSTNAME_LOOKUP 102 +#define BIO_R_CONNECT_ERROR 103 +#define BIO_R_ERROR_SETTING_NBIO 104 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 +#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +#define BIO_R_INVALID_IP_ADDRESS 108 +#define BIO_R_KEEPALIVE 109 +#define BIO_R_NBIO_CONNECT_ERROR 110 +#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 +#define BIO_R_NO_HOSTHNAME_SPECIFIED 112 +#define BIO_R_NO_PORT_DEFINED 113 +#define BIO_R_NO_PORT_SPECIFIED 114 +#define BIO_R_NULL_PARAMETER 115 +#define BIO_R_UNABLE_TO_BIND_SOCKET 116 +#define BIO_R_UNABLE_TO_CREATE_SOCKET 117 +#define BIO_R_UNABLE_TO_LISTEN_SOCKET 118 +#define BIO_R_UNINITALISED 119 +#define BIO_R_UNSUPPORTED_METHOD 120 +#define BIO_R_WSASTARTUP 121 diff --git a/src/lib/libssl/src/crypto/bn/Makefile.ssl b/src/lib/libssl/src/crypto/bn/Makefile.ssl new file mode 100644 index 0000000000..9809d26cbc --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/Makefile.ssl @@ -0,0 +1,133 @@ +# +# SSLeay/crypto/bn/Makefile +# + +DIR= bn +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +BN_MULW= bn_mulw.o +# or use +#BN_MULW= bn86-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=bn +ERRC=bn_err +GENERAL=Makefile +TEST=bntest.c exptest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c \ + bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c \ + bn_gcd.c bn_prime.c $(ERRC).c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c \ + bn_mpi.c + +LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o \ + bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o \ + bn_gcd.o bn_prime.o $(ERRC).o bn_sqr.o $(BN_MULW) bn_recp.o bn_mont.o \ + bn_mpi.o + + +SRC= $(LIBSRC) + +EXHEADER= bn.h +HEADER= bn_lcl.h bn_prime.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +knuth: bn_knuth.c + cc -pg -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a + +knuth.fast: bn_knuth.c + cc -pg -fast -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a + + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/bn86-elf.o: asm/bn86unix.cpp + $(CPP) -DELF asm/bn86unix.cpp | as -o asm/bn86-elf.o + +# solaris +asm/bn86-sol.o: asm/bn86unix.cpp + $(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s + as -o asm/bn86-sol.o asm/bn86-sol.s + rm -f asm/bn86-sol.s + +# a.out +asm/bn86-out.o: asm/bn86unix.cpp + $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o + +# bsdi +asm/bn86bsdi.o: asm/bn86unix.cpp + $(CPP) -DBSDI asm/bn86unix.cpp | as -o asm/bn86bsdi.o + +asm/bn86unix.cpp: + (cd asm; perl bn-586.pl cpp >bn86unix.cpp ) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +exptest: + /bin/rm -f exptest + gcc -I../../include -g2 -ggdb -o exptest exptest.c ../../libcrypto.a + +div: + /bin/rm -f a.out + gcc -I.. -g div.c ../../libcrypto.a + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_mulw.s + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # special case .org + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/bn/asm/bn-win32.asm b/src/lib/libssl/src/crypto/bn/asm/bn-win32.asm new file mode 100644 index 0000000000..017ea462b0 --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/asm/bn-win32.asm @@ -0,0 +1,689 @@ + ; Don't even think of reading this code + ; It was automatically generated by bn-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE bn-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _bn_mul_add_words + +_bn_mul_add_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + xor esi, esi + mov edi, DWORD PTR 20[esp] + mov ecx, DWORD PTR 28[esp] + mov ebx, DWORD PTR 24[esp] + and ecx, 4294967288 + mov ebp, DWORD PTR 32[esp] + push ecx + jz $L000maw_finish +L001maw_loop: + mov DWORD PTR [esp],ecx + ; Round 0 + mov eax, DWORD PTR [ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR [edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR [edi],eax + mov esi, edx + ; Round 4 + mov eax, DWORD PTR 4[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 4[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 4[edi],eax + mov esi, edx + ; Round 8 + mov eax, DWORD PTR 8[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 8[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 8[edi],eax + mov esi, edx + ; Round 12 + mov eax, DWORD PTR 12[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 12[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 12[edi],eax + mov esi, edx + ; Round 16 + mov eax, DWORD PTR 16[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 16[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 16[edi],eax + mov esi, edx + ; Round 20 + mov eax, DWORD PTR 20[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 20[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 20[edi],eax + mov esi, edx + ; Round 24 + mov eax, DWORD PTR 24[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 24[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx + ; Round 28 + mov eax, DWORD PTR 28[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 28[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 28[edi],eax + mov esi, edx + ; + mov ecx, DWORD PTR [esp] + add ebx, 32 + add edi, 32 + sub ecx, 8 + jnz L001maw_loop +$L000maw_finish: + mov ecx, DWORD PTR 32[esp] + and ecx, 7 + jnz $L002maw_finish2 + jmp $L003maw_end +$L002maw_finish2: + ; Tail Round 0 + mov eax, DWORD PTR [ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR [edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR [edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 1 + mov eax, DWORD PTR 4[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 4[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 4[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 2 + mov eax, DWORD PTR 8[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 8[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 8[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 3 + mov eax, DWORD PTR 12[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 12[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 12[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 4 + mov eax, DWORD PTR 16[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 16[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 16[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 5 + mov eax, DWORD PTR 20[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 20[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + dec ecx + mov DWORD PTR 20[edi],eax + mov esi, edx + jz $L003maw_end + ; Tail Round 6 + mov eax, DWORD PTR 24[ebx] + mul ebp + add eax, esi + mov esi, DWORD PTR 24[edi] + adc edx, 0 + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx +$L003maw_end: + mov eax, esi + pop ecx + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_mul_add_words ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_mul_words + +_bn_mul_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + xor esi, esi + mov edi, DWORD PTR 20[esp] + mov ebx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 28[esp] + mov ecx, DWORD PTR 32[esp] + and ebp, 4294967288 + jz $L004mw_finish +L005mw_loop: + ; Round 0 + mov eax, DWORD PTR [ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR [edi],eax + mov esi, edx + ; Round 4 + mov eax, DWORD PTR 4[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 4[edi],eax + mov esi, edx + ; Round 8 + mov eax, DWORD PTR 8[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 8[edi],eax + mov esi, edx + ; Round 12 + mov eax, DWORD PTR 12[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 12[edi],eax + mov esi, edx + ; Round 16 + mov eax, DWORD PTR 16[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 16[edi],eax + mov esi, edx + ; Round 20 + mov eax, DWORD PTR 20[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 20[edi],eax + mov esi, edx + ; Round 24 + mov eax, DWORD PTR 24[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx + ; Round 28 + mov eax, DWORD PTR 28[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 28[edi],eax + mov esi, edx + ; + add ebx, 32 + add edi, 32 + sub ebp, 8 + jz $L004mw_finish + jmp L005mw_loop +$L004mw_finish: + mov ebp, DWORD PTR 28[esp] + and ebp, 7 + jnz $L006mw_finish2 + jmp $L007mw_end +$L006mw_finish2: + ; Tail Round 0 + mov eax, DWORD PTR [ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR [edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 1 + mov eax, DWORD PTR 4[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 4[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 2 + mov eax, DWORD PTR 8[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 8[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 3 + mov eax, DWORD PTR 12[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 12[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 4 + mov eax, DWORD PTR 16[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 16[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 5 + mov eax, DWORD PTR 20[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 20[edi],eax + mov esi, edx + dec ebp + jz $L007mw_end + ; Tail Round 6 + mov eax, DWORD PTR 24[ebx] + mul ecx + add eax, esi + adc edx, 0 + mov DWORD PTR 24[edi],eax + mov esi, edx +$L007mw_end: + mov eax, esi + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_mul_words ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_sqr_words + +_bn_sqr_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + mov esi, DWORD PTR 20[esp] + mov edi, DWORD PTR 24[esp] + mov ebx, DWORD PTR 28[esp] + and ebx, 4294967288 + jz $L008sw_finish +L009sw_loop: + ; Round 0 + mov eax, DWORD PTR [edi] + mul eax + mov DWORD PTR [esi],eax + mov DWORD PTR 4[esi],edx + ; Round 4 + mov eax, DWORD PTR 4[edi] + mul eax + mov DWORD PTR 8[esi],eax + mov DWORD PTR 12[esi],edx + ; Round 8 + mov eax, DWORD PTR 8[edi] + mul eax + mov DWORD PTR 16[esi],eax + mov DWORD PTR 20[esi],edx + ; Round 12 + mov eax, DWORD PTR 12[edi] + mul eax + mov DWORD PTR 24[esi],eax + mov DWORD PTR 28[esi],edx + ; Round 16 + mov eax, DWORD PTR 16[edi] + mul eax + mov DWORD PTR 32[esi],eax + mov DWORD PTR 36[esi],edx + ; Round 20 + mov eax, DWORD PTR 20[edi] + mul eax + mov DWORD PTR 40[esi],eax + mov DWORD PTR 44[esi],edx + ; Round 24 + mov eax, DWORD PTR 24[edi] + mul eax + mov DWORD PTR 48[esi],eax + mov DWORD PTR 52[esi],edx + ; Round 28 + mov eax, DWORD PTR 28[edi] + mul eax + mov DWORD PTR 56[esi],eax + mov DWORD PTR 60[esi],edx + ; + add edi, 32 + add esi, 64 + sub ebx, 8 + jnz L009sw_loop +$L008sw_finish: + mov ebx, DWORD PTR 28[esp] + and ebx, 7 + jz $L010sw_end + ; Tail Round 0 + mov eax, DWORD PTR [edi] + mul eax + mov DWORD PTR [esi],eax + dec ebx + mov DWORD PTR 4[esi],edx + jz $L010sw_end + ; Tail Round 1 + mov eax, DWORD PTR 4[edi] + mul eax + mov DWORD PTR 8[esi],eax + dec ebx + mov DWORD PTR 12[esi],edx + jz $L010sw_end + ; Tail Round 2 + mov eax, DWORD PTR 8[edi] + mul eax + mov DWORD PTR 16[esi],eax + dec ebx + mov DWORD PTR 20[esi],edx + jz $L010sw_end + ; Tail Round 3 + mov eax, DWORD PTR 12[edi] + mul eax + mov DWORD PTR 24[esi],eax + dec ebx + mov DWORD PTR 28[esi],edx + jz $L010sw_end + ; Tail Round 4 + mov eax, DWORD PTR 16[edi] + mul eax + mov DWORD PTR 32[esi],eax + dec ebx + mov DWORD PTR 36[esi],edx + jz $L010sw_end + ; Tail Round 5 + mov eax, DWORD PTR 20[edi] + mul eax + mov DWORD PTR 40[esi],eax + dec ebx + mov DWORD PTR 44[esi],edx + jz $L010sw_end + ; Tail Round 6 + mov eax, DWORD PTR 24[edi] + mul eax + mov DWORD PTR 48[esi],eax + mov DWORD PTR 52[esi],edx +$L010sw_end: + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_sqr_words ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_div64 + +_bn_div64 PROC NEAR + push ebp + push ebx + push esi + push edi + mov edx, DWORD PTR 20[esp] + mov eax, DWORD PTR 24[esp] + mov ebx, DWORD PTR 28[esp] + div ebx + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_div64 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _bn_add_words + +_bn_add_words PROC NEAR + push ebp + push ebx + push esi + push edi + ; + mov ebx, DWORD PTR 20[esp] + mov esi, DWORD PTR 24[esp] + mov edi, DWORD PTR 28[esp] + mov ebp, DWORD PTR 32[esp] + xor eax, eax + and ebp, 4294967288 + jz $L011aw_finish +L012aw_loop: + ; Round 0 + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR [edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR [ebx],ecx + ; Round 1 + mov ecx, DWORD PTR 4[esi] + mov edx, DWORD PTR 4[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 4[ebx],ecx + ; Round 2 + mov ecx, DWORD PTR 8[esi] + mov edx, DWORD PTR 8[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 8[ebx],ecx + ; Round 3 + mov ecx, DWORD PTR 12[esi] + mov edx, DWORD PTR 12[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 12[ebx],ecx + ; Round 4 + mov ecx, DWORD PTR 16[esi] + mov edx, DWORD PTR 16[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 16[ebx],ecx + ; Round 5 + mov ecx, DWORD PTR 20[esi] + mov edx, DWORD PTR 20[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 20[ebx],ecx + ; Round 6 + mov ecx, DWORD PTR 24[esi] + mov edx, DWORD PTR 24[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 24[ebx],ecx + ; Round 7 + mov ecx, DWORD PTR 28[esi] + mov edx, DWORD PTR 28[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 28[ebx],ecx + ; + add esi, 32 + add edi, 32 + add ebx, 32 + sub ebp, 8 + jnz L012aw_loop +$L011aw_finish: + mov ebp, DWORD PTR 32[esp] + and ebp, 7 + jz $L013aw_end + ; Tail Round 0 + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR [edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR [ebx],ecx + jz $L013aw_end + ; Tail Round 1 + mov ecx, DWORD PTR 4[esi] + mov edx, DWORD PTR 4[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 4[ebx],ecx + jz $L013aw_end + ; Tail Round 2 + mov ecx, DWORD PTR 8[esi] + mov edx, DWORD PTR 8[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 8[ebx],ecx + jz $L013aw_end + ; Tail Round 3 + mov ecx, DWORD PTR 12[esi] + mov edx, DWORD PTR 12[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 12[ebx],ecx + jz $L013aw_end + ; Tail Round 4 + mov ecx, DWORD PTR 16[esi] + mov edx, DWORD PTR 16[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 16[ebx],ecx + jz $L013aw_end + ; Tail Round 5 + mov ecx, DWORD PTR 20[esi] + mov edx, DWORD PTR 20[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + dec ebp + mov DWORD PTR 20[ebx],ecx + jz $L013aw_end + ; Tail Round 6 + mov ecx, DWORD PTR 24[esi] + mov edx, DWORD PTR 24[edi] + add ecx, eax + mov eax, 0 + adc eax, eax + add ecx, edx + adc eax, 0 + mov DWORD PTR 24[ebx],ecx +$L013aw_end: + mov eax, eax + pop edi + pop esi + pop ebx + pop ebp + ret +_bn_add_words ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp b/src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp new file mode 100644 index 0000000000..64702201ea --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp @@ -0,0 +1,752 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define bn_mul_add_words _bn_mul_add_words +#define bn_mul_words _bn_mul_words +#define bn_sqr_words _bn_sqr_words +#define bn_div64 _bn_div64 +#define bn_add_words _bn_add_words + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by bn-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "bn-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl bn_mul_add_words + TYPE(bn_mul_add_words,@function) +bn_mul_add_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + xorl %esi, %esi + movl 20(%esp), %edi + movl 28(%esp), %ecx + movl 24(%esp), %ebx + andl $4294967288, %ecx + movl 32(%esp), %ebp + pushl %ecx + jz .L000maw_finish +.L001maw_loop: + movl %ecx, (%esp) + /* Round 0 */ + movl (%ebx), %eax + mull %ebp + addl %esi, %eax + movl (%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, (%edi) + movl %edx, %esi + /* Round 4 */ + movl 4(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 4(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 4(%edi) + movl %edx, %esi + /* Round 8 */ + movl 8(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 8(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 8(%edi) + movl %edx, %esi + /* Round 12 */ + movl 12(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 12(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 12(%edi) + movl %edx, %esi + /* Round 16 */ + movl 16(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 16(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 16(%edi) + movl %edx, %esi + /* Round 20 */ + movl 20(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 20(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 20(%edi) + movl %edx, %esi + /* Round 24 */ + movl 24(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 24(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi + /* Round 28 */ + movl 28(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 28(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 28(%edi) + movl %edx, %esi + + movl (%esp), %ecx + addl $32, %ebx + addl $32, %edi + subl $8, %ecx + jnz .L001maw_loop +.L000maw_finish: + movl 32(%esp), %ecx + andl $7, %ecx + jnz .L002maw_finish2 + jmp .L003maw_end +.align ALIGN +.L002maw_finish2: + /* Tail Round 0 */ + movl (%ebx), %eax + mull %ebp + addl %esi, %eax + movl (%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, (%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 1 */ + movl 4(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 4(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 4(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 2 */ + movl 8(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 8(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 8(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 3 */ + movl 12(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 12(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 12(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 4 */ + movl 16(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 16(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 16(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 5 */ + movl 20(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 20(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + decl %ecx + movl %eax, 20(%edi) + movl %edx, %esi + jz .L003maw_end + /* Tail Round 6 */ + movl 24(%ebx), %eax + mull %ebp + addl %esi, %eax + movl 24(%edi), %esi + adcl $0, %edx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi +.L003maw_end: + movl %esi, %eax + popl %ecx + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_mul_add_words_end: + SIZE(bn_mul_add_words,.bn_mul_add_words_end-bn_mul_add_words) +.ident "bn_mul_add_words" +.text + .align ALIGN +.globl bn_mul_words + TYPE(bn_mul_words,@function) +bn_mul_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + xorl %esi, %esi + movl 20(%esp), %edi + movl 24(%esp), %ebx + movl 28(%esp), %ebp + movl 32(%esp), %ecx + andl $4294967288, %ebp + jz .L004mw_finish +.L005mw_loop: + /* Round 0 */ + movl (%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, (%edi) + movl %edx, %esi + /* Round 4 */ + movl 4(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 4(%edi) + movl %edx, %esi + /* Round 8 */ + movl 8(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 8(%edi) + movl %edx, %esi + /* Round 12 */ + movl 12(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 12(%edi) + movl %edx, %esi + /* Round 16 */ + movl 16(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 16(%edi) + movl %edx, %esi + /* Round 20 */ + movl 20(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 20(%edi) + movl %edx, %esi + /* Round 24 */ + movl 24(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi + /* Round 28 */ + movl 28(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 28(%edi) + movl %edx, %esi + + addl $32, %ebx + addl $32, %edi + subl $8, %ebp + jz .L004mw_finish + jmp .L005mw_loop +.L004mw_finish: + movl 28(%esp), %ebp + andl $7, %ebp + jnz .L006mw_finish2 + jmp .L007mw_end +.align ALIGN +.L006mw_finish2: + /* Tail Round 0 */ + movl (%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, (%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 1 */ + movl 4(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 4(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 2 */ + movl 8(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 8(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 3 */ + movl 12(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 12(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 4 */ + movl 16(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 16(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 5 */ + movl 20(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 20(%edi) + movl %edx, %esi + decl %ebp + jz .L007mw_end + /* Tail Round 6 */ + movl 24(%ebx), %eax + mull %ecx + addl %esi, %eax + adcl $0, %edx + movl %eax, 24(%edi) + movl %edx, %esi +.L007mw_end: + movl %esi, %eax + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_mul_words_end: + SIZE(bn_mul_words,.bn_mul_words_end-bn_mul_words) +.ident "bn_mul_words" +.text + .align ALIGN +.globl bn_sqr_words + TYPE(bn_sqr_words,@function) +bn_sqr_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + movl 20(%esp), %esi + movl 24(%esp), %edi + movl 28(%esp), %ebx + andl $4294967288, %ebx + jz .L008sw_finish +.L009sw_loop: + /* Round 0 */ + movl (%edi), %eax + mull %eax + movl %eax, (%esi) + movl %edx, 4(%esi) + /* Round 4 */ + movl 4(%edi), %eax + mull %eax + movl %eax, 8(%esi) + movl %edx, 12(%esi) + /* Round 8 */ + movl 8(%edi), %eax + mull %eax + movl %eax, 16(%esi) + movl %edx, 20(%esi) + /* Round 12 */ + movl 12(%edi), %eax + mull %eax + movl %eax, 24(%esi) + movl %edx, 28(%esi) + /* Round 16 */ + movl 16(%edi), %eax + mull %eax + movl %eax, 32(%esi) + movl %edx, 36(%esi) + /* Round 20 */ + movl 20(%edi), %eax + mull %eax + movl %eax, 40(%esi) + movl %edx, 44(%esi) + /* Round 24 */ + movl 24(%edi), %eax + mull %eax + movl %eax, 48(%esi) + movl %edx, 52(%esi) + /* Round 28 */ + movl 28(%edi), %eax + mull %eax + movl %eax, 56(%esi) + movl %edx, 60(%esi) + + addl $32, %edi + addl $64, %esi + subl $8, %ebx + jnz .L009sw_loop +.L008sw_finish: + movl 28(%esp), %ebx + andl $7, %ebx + jz .L010sw_end + /* Tail Round 0 */ + movl (%edi), %eax + mull %eax + movl %eax, (%esi) + decl %ebx + movl %edx, 4(%esi) + jz .L010sw_end + /* Tail Round 1 */ + movl 4(%edi), %eax + mull %eax + movl %eax, 8(%esi) + decl %ebx + movl %edx, 12(%esi) + jz .L010sw_end + /* Tail Round 2 */ + movl 8(%edi), %eax + mull %eax + movl %eax, 16(%esi) + decl %ebx + movl %edx, 20(%esi) + jz .L010sw_end + /* Tail Round 3 */ + movl 12(%edi), %eax + mull %eax + movl %eax, 24(%esi) + decl %ebx + movl %edx, 28(%esi) + jz .L010sw_end + /* Tail Round 4 */ + movl 16(%edi), %eax + mull %eax + movl %eax, 32(%esi) + decl %ebx + movl %edx, 36(%esi) + jz .L010sw_end + /* Tail Round 5 */ + movl 20(%edi), %eax + mull %eax + movl %eax, 40(%esi) + decl %ebx + movl %edx, 44(%esi) + jz .L010sw_end + /* Tail Round 6 */ + movl 24(%edi), %eax + mull %eax + movl %eax, 48(%esi) + movl %edx, 52(%esi) +.L010sw_end: + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_sqr_words_end: + SIZE(bn_sqr_words,.bn_sqr_words_end-bn_sqr_words) +.ident "bn_sqr_words" +.text + .align ALIGN +.globl bn_div64 + TYPE(bn_div64,@function) +bn_div64: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + movl 20(%esp), %edx + movl 24(%esp), %eax + movl 28(%esp), %ebx + divl %ebx + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_div64_end: + SIZE(bn_div64,.bn_div64_end-bn_div64) +.ident "bn_div64" +.text + .align ALIGN +.globl bn_add_words + TYPE(bn_add_words,@function) +bn_add_words: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + movl 20(%esp), %ebx + movl 24(%esp), %esi + movl 28(%esp), %edi + movl 32(%esp), %ebp + xorl %eax, %eax + andl $4294967288, %ebp + jz .L011aw_finish +.L012aw_loop: + /* Round 0 */ + movl (%esi), %ecx + movl (%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, (%ebx) + /* Round 1 */ + movl 4(%esi), %ecx + movl 4(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 4(%ebx) + /* Round 2 */ + movl 8(%esi), %ecx + movl 8(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 8(%ebx) + /* Round 3 */ + movl 12(%esi), %ecx + movl 12(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 12(%ebx) + /* Round 4 */ + movl 16(%esi), %ecx + movl 16(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 16(%ebx) + /* Round 5 */ + movl 20(%esi), %ecx + movl 20(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 20(%ebx) + /* Round 6 */ + movl 24(%esi), %ecx + movl 24(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 24(%ebx) + /* Round 7 */ + movl 28(%esi), %ecx + movl 28(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 28(%ebx) + + addl $32, %esi + addl $32, %edi + addl $32, %ebx + subl $8, %ebp + jnz .L012aw_loop +.L011aw_finish: + movl 32(%esp), %ebp + andl $7, %ebp + jz .L013aw_end + /* Tail Round 0 */ + movl (%esi), %ecx + movl (%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, (%ebx) + jz .L013aw_end + /* Tail Round 1 */ + movl 4(%esi), %ecx + movl 4(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 4(%ebx) + jz .L013aw_end + /* Tail Round 2 */ + movl 8(%esi), %ecx + movl 8(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 8(%ebx) + jz .L013aw_end + /* Tail Round 3 */ + movl 12(%esi), %ecx + movl 12(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 12(%ebx) + jz .L013aw_end + /* Tail Round 4 */ + movl 16(%esi), %ecx + movl 16(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 16(%ebx) + jz .L013aw_end + /* Tail Round 5 */ + movl 20(%esi), %ecx + movl 20(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + decl %ebp + movl %ecx, 20(%ebx) + jz .L013aw_end + /* Tail Round 6 */ + movl 24(%esi), %ecx + movl 24(%edi), %edx + addl %eax, %ecx + movl $0, %eax + adcl %eax, %eax + addl %edx, %ecx + adcl $0, %eax + movl %ecx, 24(%ebx) +.L013aw_end: + movl %eax, %eax + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.bn_add_words_end: + SIZE(bn_add_words,.bn_add_words_end-bn_add_words) +.ident "bn_add_words" diff --git a/src/lib/libssl/src/crypto/bn/asm/sparc.s b/src/lib/libssl/src/crypto/bn/asm/sparc.s new file mode 100644 index 0000000000..f9e533caa8 --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/asm/sparc.s @@ -0,0 +1,462 @@ + .file "bn_mulw.c" +gcc2_compiled.: +.section ".text" + .align 4 + .global bn_mul_add_words + .type bn_mul_add_words,#function + .proc 016 +bn_mul_add_words: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov %i0,%o0 + mov %i1,%o2 + mov %i2,%g1 + mov %i3,%o1 + mov 0,%i4 + add %o0,12,%g4 + add %o2,12,%o7 +.LL2: + mov %i4,%i3 + mov 0,%i2 + ld [%o0],%g2 + mov %g2,%i1 + ld [%o2],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%o0] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + mov %i4,%i3 + mov 0,%i2 + ld [%g4-8],%g2 + mov %g2,%i1 + ld [%o7-8],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%g4-8] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + mov %i4,%i3 + mov 0,%i2 + ld [%g4-4],%g2 + mov %g2,%i1 + ld [%o7-4],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%g4-4] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + mov %i4,%i3 + mov 0,%i2 + ld [%g4],%g2 + mov %g2,%i1 + ld [%o7],%g2 + mov 0,%i0 + umul %o1,%g2,%g3 + rd %y,%g2 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %g3,%i3,%g3 + addx %g2,%i2,%g2 + st %g3,[%g4] + mov %g2,%i5 + mov 0,%i4 + addcc %g1,-1,%g1 + be .LL3 + mov %i5,%i4 + add %o7,16,%o7 + add %o2,16,%o2 + add %g4,16,%g4 + b .LL2 + add %o0,16,%o0 +.LL3: + ret + restore %g0,%i4,%o0 +.LLfe1: + .size bn_mul_add_words,.LLfe1-bn_mul_add_words + .align 4 + .global bn_mul_words + .type bn_mul_words,#function + .proc 016 +bn_mul_words: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov %i0,%o7 + mov %i1,%o0 + mov %i2,%i4 + mov %i3,%g4 + mov 0,%i0 + add %o7,12,%g1 + add %o0,12,%i5 +.LL18: + mov %i0,%g3 + mov 0,%g2 + ld [%o0],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%o7] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + mov %i0,%g3 + mov 0,%g2 + ld [%i5-8],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%g1-8] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + mov %i0,%g3 + mov 0,%g2 + ld [%i5-4],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%g1-4] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + mov %i0,%g3 + mov 0,%g2 + ld [%i5],%i2 + umul %g4,%i2,%i3 + rd %y,%i2 + addcc %i3,%g3,%i3 + addx %i2,%g2,%i2 + st %i3,[%g1] + mov %i2,%i1 + mov 0,%i0 + addcc %i4,-1,%i4 + be .LL19 + mov %i1,%i0 + add %i5,16,%i5 + add %o0,16,%o0 + add %g1,16,%g1 + b .LL18 + add %o7,16,%o7 +.LL19: + ret + restore +.LLfe2: + .size bn_mul_words,.LLfe2-bn_mul_words + .align 4 + .global bn_sqr_words + .type bn_sqr_words,#function + .proc 020 +bn_sqr_words: + !#PROLOGUE# 0 + !#PROLOGUE# 1 + mov %o0,%g4 + add %g4,28,%o3 + add %o1,12,%g1 +.LL34: + ld [%o1],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%g4] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3-24] + ld [%g1-8],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%o3-20] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3-16] + ld [%g1-4],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%o3-12] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3-8] + ld [%g1],%o0 + addcc %o2,-1,%o2 + umul %o0,%o0,%o5 + rd %y,%o4 + st %o5,[%o3-4] + mov %o4,%g3 + mov 0,%g2 + be .LL35 + st %g3,[%o3] + add %g1,16,%g1 + add %o1,16,%o1 + add %o3,32,%o3 + b .LL34 + add %g4,32,%g4 +.LL35: + retl + nop +.LLfe3: + .size bn_sqr_words,.LLfe3-bn_sqr_words + .align 4 + .global bn_add_words + .type bn_add_words,#function + .proc 016 +bn_add_words: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov %i0,%o2 + mov %i1,%o3 + mov %i2,%o4 + mov %i3,%i5 + mov 0,%o0 + mov 0,%o1 + add %o2,12,%o7 + add %o4,12,%g4 + b .LL42 + add %o3,12,%g1 +.LL45: + add %i5,-1,%i5 + mov %i4,%g3 + ld [%g4-8],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o7-8] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + ble .LL43 + add %i5,-1,%i5 + ld [%g1-4],%i4 + mov %i4,%g3 + ld [%g4-4],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o7-4] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + ble .LL43 + add %i5,-1,%i5 + ld [%g1],%i4 + mov %i4,%g3 + ld [%g4],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o7] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + ble .LL43 + add %g1,16,%g1 + add %o3,16,%o3 + add %g4,16,%g4 + add %o4,16,%o4 + add %o7,16,%o7 + add %o2,16,%o2 +.LL42: + ld [%o3],%i4 + add %i5,-1,%i5 + mov %i4,%g3 + ld [%o4],%i4 + mov 0,%g2 + mov %i4,%i1 + mov 0,%i0 + addcc %g3,%i1,%g3 + addx %g2,%i0,%g2 + addcc %o1,%g3,%o1 + addx %o0,%g2,%o0 + st %o1,[%o2] + mov %o0,%i3 + mov 0,%i2 + mov %i2,%o0 + mov %i3,%o1 + cmp %i5,0 + bg,a .LL45 + ld [%g1-8],%i4 +.LL43: + ret + restore %g0,%o1,%o0 +.LLfe4: + .size bn_add_words,.LLfe4-bn_add_words +.section ".rodata" + .align 8 +.LLC0: + .asciz "Division would overflow (%d)\n" +.section ".text" + .align 4 + .global bn_div64 + .type bn_div64,#function + .proc 016 +bn_div64: + !#PROLOGUE# 0 + save %sp,-112,%sp + !#PROLOGUE# 1 + mov 0,%l1 + cmp %i2,0 + bne .LL51 + mov 2,%l0 + b .LL68 + mov -1,%i0 +.LL51: + call BN_num_bits_word,0 + mov %i2,%o0 + mov %o0,%o2 + cmp %o2,32 + be .LL52 + mov 1,%o0 + sll %o0,%o2,%o0 + cmp %i0,%o0 + bleu .LL69 + mov 32,%o0 + sethi %hi(__iob+32),%o0 + or %o0,%lo(__iob+32),%o0 + sethi %hi(.LLC0),%o1 + call fprintf,0 + or %o1,%lo(.LLC0),%o1 + call abort,0 + nop +.LL52: + mov 32,%o0 +.LL69: + cmp %i0,%i2 + blu .LL53 + sub %o0,%o2,%o2 + sub %i0,%i2,%i0 +.LL53: + cmp %o2,0 + be .LL54 + sll %i0,%o2,%o1 + sll %i2,%o2,%i2 + sub %o0,%o2,%o0 + srl %i1,%o0,%o0 + or %o1,%o0,%i0 + sll %i1,%o2,%i1 +.LL54: + srl %i2,16,%g2 + sethi %hi(65535),%o0 + or %o0,%lo(65535),%o1 + and %i2,%o1,%g3 + mov %o0,%g4 + sethi %hi(-65536),%o7 + mov %o1,%g1 +.LL55: + srl %i0,16,%o0 + cmp %o0,%g2 + be .LL59 + or %g4,%lo(65535),%o3 + wr %g0,%g0,%y + nop + nop + nop + udiv %i0,%g2,%o3 +.LL59: + and %i1,%o7,%o0 + srl %o0,16,%o5 + smul %o3,%g3,%o4 + smul %o3,%g2,%o2 +.LL60: + sub %i0,%o2,%o1 + andcc %o1,%o7,%g0 + bne .LL61 + sll %o1,16,%o0 + add %o0,%o5,%o0 + cmp %o4,%o0 + bleu .LL61 + sub %o4,%g3,%o4 + sub %o2,%g2,%o2 + b .LL60 + add %o3,-1,%o3 +.LL61: + smul %o3,%g2,%o2 + smul %o3,%g3,%o0 + srl %o0,16,%o1 + sll %o0,16,%o0 + and %o0,%o7,%o0 + cmp %i1,%o0 + bgeu .LL65 + add %o2,%o1,%o2 + add %o2,1,%o2 +.LL65: + cmp %i0,%o2 + bgeu .LL66 + sub %i1,%o0,%i1 + add %i0,%i2,%i0 + add %o3,-1,%o3 +.LL66: + addcc %l0,-1,%l0 + be .LL56 + sub %i0,%o2,%i0 + sll %o3,16,%l1 + sll %i0,16,%o0 + srl %i1,16,%o1 + or %o0,%o1,%i0 + and %i1,%g1,%o0 + b .LL55 + sll %o0,16,%i1 +.LL56: + or %l1,%o3,%i0 +.LL68: + ret + restore +.LLfe5: + .size bn_div64,.LLfe5-bn_div64 + .ident "GCC: (GNU) 2.7.2.3" diff --git a/src/lib/libssl/src/crypto/bn/asm/x86w16.asm b/src/lib/libssl/src/crypto/bn/asm/x86w16.asm new file mode 100644 index 0000000000..74a933a8cd --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/asm/x86w16.asm @@ -0,0 +1,297 @@ +; Static Name Aliases +; + TITLE bn_mulw.c + .8087 +F_TEXT SEGMENT WORD PUBLIC 'CODE' +F_TEXT ENDS +_DATA SEGMENT WORD PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT WORD PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT WORD PUBLIC 'BSS' +_BSS ENDS +DGROUP GROUP CONST, _BSS, _DATA + ASSUME DS: DGROUP, SS: DGROUP +F_TEXT SEGMENT + ASSUME CS: F_TEXT + PUBLIC _bn_mul_add_words +_bn_mul_add_words PROC FAR +; Line 58 + push bp + push bx + push si + push di + push ds + push es + mov bp,sp +; w = 26 +; num = 24 +; ap = 20 +; rp = 16 + xor si,si ;c=0; + mov di,WORD PTR [bp+16] ; load r + mov ds,WORD PTR [bp+18] ; load r + mov bx,WORD PTR [bp+20] ; load a + mov es,WORD PTR [bp+22] ; load a + mov cx,WORD PTR [bp+26] ; load w + mov bp,WORD PTR [bp+24] ; load num + + shr bp,1 ; div count by 4 and do groups of 4 + shr bp,1 + je $L555 + +$L546: + mov ax,cx + mul WORD PTR es:[bx] ; w* *a + add ax,WORD PTR ds:[di] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di],ax + mov si,dx + ; + mov ax,cx + mul WORD PTR es:[bx+2] ; w* *a + add ax,WORD PTR ds:[di+2] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+2],ax + mov si,dx + ; + mov ax,cx + mul WORD PTR es:[bx+4] ; w* *a + add ax,WORD PTR ds:[di+4] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+4],ax + mov si,dx + ; + mov ax,cx + mul WORD PTR es:[bx+6] ; w* *a + add ax,WORD PTR ds:[di+6] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+6],ax + mov si,dx + ; + add bx,8 + add di,8 + ; + dec bp + je $L555 + jmp $L546 +; +; +$L555: + mov bp,sp + mov bp,WORD PTR [bp+24] ; load num + and bp,3 + dec bp + js $L547 + + mov ax,cx + mul WORD PTR es:[bx] ; w* *a + add ax,WORD PTR ds:[di] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di],ax + mov si,dx + dec bp + js $L547 ; Note that we are now testing for -1 + ; + mov ax,cx + mul WORD PTR es:[bx+2] ; w* *a + add ax,WORD PTR ds:[di+2] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+2],ax + mov si,dx + dec bp + js $L547 + ; + mov ax,cx + mul WORD PTR es:[bx+4] ; w* *a + add ax,WORD PTR ds:[di+4] ; + *r + adc dx,0 + adc ax,si + adc dx,0 + mov WORD PTR ds:[di+4],ax + mov si,dx +$L547: + mov ax,si + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret + nop + +_bn_mul_add_words ENDP + PUBLIC _bn_mul_words +_bn_mul_words PROC FAR +; Line 76 + push bp + push bx + push si + push di + push ds + push es + xor si,si + mov bp,sp + mov di,WORD PTR [bp+16] ; r + mov ds,WORD PTR [bp+18] + mov bx,WORD PTR [bp+20] ; a + mov es,WORD PTR [bp+22] + mov cx,WORD PTR [bp+26] ; w + mov bp,WORD PTR [bp+24] ; num +$FC743: + mov ax,cx + mul WORD PTR es:[bx] + add ax,si + adc dx,0 + mov WORD PTR ds:[di],ax + mov si,dx + dec bp + je $L764 + ; + mov ax,cx + mul WORD PTR es:[bx+2] + add ax,si + adc dx,0 + mov WORD PTR ds:[di+2],ax + mov si,dx + dec bp + je $L764 + ; + mov ax,cx + mul WORD PTR es:[bx+4] + add ax,si + adc dx,0 + mov WORD PTR ds:[di+4],ax + mov si,dx + dec bp + je $L764 + ; + mov ax,cx + mul WORD PTR es:[bx+6] + add ax,si + adc dx,0 + mov WORD PTR ds:[di+6],ax + mov si,dx + dec bp + je $L764 + ; + add bx,8 + add di,8 + jmp $FC743 + nop +$L764: + mov ax,si + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret + nop +_bn_mul_words ENDP + PUBLIC _bn_sqr_words +_bn_sqr_words PROC FAR +; Line 92 + push bp + push bx + push si + push di + push ds + push es + mov bp,sp + mov si,WORD PTR [bp+16] + mov ds,WORD PTR [bp+18] + mov di,WORD PTR [bp+20] + mov es,WORD PTR [bp+22] + mov bx,WORD PTR [bp+24] + + mov bp,bx ; save a memory lookup later + shr bx,1 ; div count by 4 and do groups of 4 + shr bx,1 + je $L666 + +$L765: + mov ax,WORD PTR es:[di] + mul ax + mov WORD PTR ds:[si],ax + mov WORD PTR ds:[si+2],dx + ; + mov ax,WORD PTR es:[di+2] + mul ax + mov WORD PTR ds:[si+4],ax + mov WORD PTR ds:[si+6],dx + ; + mov ax,WORD PTR es:[di+4] + mul ax + mov WORD PTR ds:[si+8],ax + mov WORD PTR ds:[si+10],dx + ; + mov ax,WORD PTR es:[di+6] + mul ax + mov WORD PTR ds:[si+12],ax + mov WORD PTR ds:[si+14],dx + ; + add di,8 + add si,16 + dec bx + je $L666 + jmp $L765 +$L666: + and bp,3 + dec bp ; The copied value of bx (num) + js $L645 + ; + mov ax,WORD PTR es:[di] + mul ax + mov WORD PTR ds:[si],ax + mov WORD PTR ds:[si+2],dx + dec bp + js $L645 + ; + mov ax,WORD PTR es:[di+2] + mul ax + mov WORD PTR ds:[si+4],ax + mov WORD PTR ds:[si+6],dx + dec bp + js $L645 + ; + mov ax,WORD PTR es:[di+4] + mul ax + mov WORD PTR ds:[si+8],ax + mov WORD PTR ds:[si+10],dx +$L645: + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret + +_bn_sqr_words ENDP + PUBLIC _bn_div64 +_bn_div64 PROC FAR + push bp + mov bp,sp + mov dx, WORD PTR [bp+6] + mov ax, WORD PTR [bp+8] + div WORD PTR [bp+10] + pop bp + ret +_bn_div64 ENDP +F_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/bn/asm/x86w32.asm b/src/lib/libssl/src/crypto/bn/asm/x86w32.asm new file mode 100644 index 0000000000..fc6f917714 --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/asm/x86w32.asm @@ -0,0 +1,362 @@ +; Static Name Aliases +; + TITLE bn_mulw.c + .386 +F_TEXT SEGMENT WORD USE16 PUBLIC 'CODE' +F_TEXT ENDS +_DATA SEGMENT WORD USE16 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT WORD USE16 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT WORD USE16 PUBLIC 'BSS' +_BSS ENDS +DGROUP GROUP CONST, _BSS, _DATA + ASSUME DS: DGROUP, SS: DGROUP +F_TEXT SEGMENT + ASSUME CS: F_TEXT + PUBLIC _bn_mul_add_words +_bn_mul_add_words PROC FAR +; Line 58 + push bp + push bx + push esi + push di + push ds + push es + mov bp,sp +; w = 28 +; num = 26 +; ap = 22 +; rp = 18 + xor esi,esi ;c=0; + mov di,WORD PTR [bp+18] ; load r + mov ds,WORD PTR [bp+20] ; load r + mov bx,WORD PTR [bp+22] ; load a + mov es,WORD PTR [bp+24] ; load a + mov ecx,DWORD PTR [bp+28] ; load w + mov bp,WORD PTR [bp+26] ; load num + shr bp,1 ; div count by 4 and do groups of 4 + shr bp,1 + je $L555 + +$L546: + mov eax,ecx + mul DWORD PTR es:[bx] ; w* *a + add eax,DWORD PTR ds:[di] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di],eax + mov esi,edx + ; + mov eax,ecx + mul DWORD PTR es:[bx+4] ; w* *a + add eax,DWORD PTR ds:[di+4] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+4],eax + mov esi,edx + ; + mov eax,ecx + mul DWORD PTR es:[bx+8] ; w* *a + add eax,DWORD PTR ds:[di+8] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+8],eax + mov esi,edx + ; + mov eax,ecx + mul DWORD PTR es:[bx+12] ; w* *a + add eax,DWORD PTR ds:[di+12] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+12],eax + mov esi,edx + ; + add bx,16 + add di,16 + ; + dec bp + je $L555 + jmp $L546 +; +; +$L555: + mov bp,sp + mov bp,WORD PTR [bp+26] ; load num + and bp,3 + dec bp + js $L547 + + mov eax,ecx + mul DWORD PTR es:[bx] ; w* *a + add eax,DWORD PTR ds:[di] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di],eax + mov esi,edx + dec bp + js $L547 ; Note that we are now testing for -1 + ; + mov eax,ecx + mul DWORD PTR es:[bx+4] ; w* *a + add eax,DWORD PTR ds:[di+4] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+4],eax + mov esi,edx + dec bp + js $L547 + ; + mov eax,ecx + mul DWORD PTR es:[bx+8] ; w* *a + add eax,DWORD PTR ds:[di+8] ; + *r + adc edx,0 + adc eax,esi + adc edx,0 + mov DWORD PTR ds:[di+8],eax + mov esi,edx +$L547: + mov eax,esi + mov edx,esi + shr edx,16 + pop es + pop ds + pop di + pop esi + pop bx + pop bp + ret + nop +_bn_mul_add_words ENDP + + PUBLIC _bn_mul_words +_bn_mul_words PROC FAR +; Line 76 + push bp + push bx + push esi + push di + push ds + push es + xor esi,esi + mov bp,sp + mov di,WORD PTR [bp+18] ; r + mov ds,WORD PTR [bp+20] + mov bx,WORD PTR [bp+22] ; a + mov es,WORD PTR [bp+24] + mov ecx,DWORD PTR [bp+28] ; w + mov bp,WORD PTR [bp+26] ; num + +$FC743: + mov eax,ecx + mul DWORD PTR es:[bx] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di],eax + mov esi,edx + dec bp + je $L764 + ; + mov eax,ecx + mul DWORD PTR es:[bx+4] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di+4],eax + mov esi,edx + dec bp + je $L764 + ; + mov eax,ecx + mul DWORD PTR es:[bx+8] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di+8],eax + mov esi,edx + dec bp + je $L764 + ; + mov eax,ecx + mul DWORD PTR es:[bx+12] + add eax,esi + adc edx,0 + mov DWORD PTR ds:[di+12],eax + mov esi,edx + dec bp + je $L764 + ; + add bx,16 + add di,16 + jmp $FC743 + nop +$L764: + mov eax,esi + mov edx,esi + shr edx,16 + pop es + pop ds + pop di + pop esi + pop bx + pop bp + ret + nop +_bn_mul_words ENDP + PUBLIC _bn_sqr_words +_bn_sqr_words PROC FAR +; Line 92 + push bp + push bx + push si + push di + push ds + push es + mov bp,sp + mov si,WORD PTR [bp+16] + mov ds,WORD PTR [bp+18] + mov di,WORD PTR [bp+20] + mov es,WORD PTR [bp+22] + mov bx,WORD PTR [bp+24] + + mov bp,bx ; save a memory lookup later + shr bx,1 ; div count by 4 and do groups of 4 + shr bx,1 + je $L666 + +$L765: + mov eax,DWORD PTR es:[di] + mul eax + mov DWORD PTR ds:[si],eax + mov DWORD PTR ds:[si+4],edx + ; + mov eax,DWORD PTR es:[di+4] + mul eax + mov DWORD PTR ds:[si+8],eax + mov DWORD PTR ds:[si+12],edx + ; + mov eax,DWORD PTR es:[di+8] + mul eax + mov DWORD PTR ds:[si+16],eax + mov DWORD PTR ds:[si+20],edx + ; + mov eax,DWORD PTR es:[di+12] + mul eax + mov DWORD PTR ds:[si+24],eax + mov DWORD PTR ds:[si+28],edx + ; + add di,16 + add si,32 + dec bx + je $L666 + jmp $L765 +$L666: + and bp,3 + dec bp ; The copied value of bx (num) + js $L645 + ; + mov eax,DWORD PTR es:[di] + mul eax + mov DWORD PTR ds:[si],eax + mov DWORD PTR ds:[si+4],edx + dec bp + js $L645 + ; + mov eax,DWORD PTR es:[di+4] + mul eax + mov DWORD PTR ds:[si+8],eax + mov DWORD PTR ds:[si+12],edx + dec bp + js $L645 + ; + mov eax,DWORD PTR es:[di+8] + mul eax + mov DWORD PTR ds:[si+16],eax + mov DWORD PTR ds:[si+20],edx +$L645: + pop es + pop ds + pop di + pop si + pop bx + pop bp + ret +_bn_sqr_words ENDP + + PUBLIC _bn_div64 +_bn_div64 PROC FAR + push bp + mov bp,sp + mov edx, DWORD PTR [bp+6] + mov eax, DWORD PTR [bp+10] + div DWORD PTR [bp+14] + mov edx,eax + shr edx,16 + pop bp + ret +_bn_div64 ENDP + + PUBLIC _bn_add_words +_bn_add_words PROC FAR +; Line 58 + push bp + push bx + push esi + push di + push ds + push es + mov bp,sp +; w = 28 +; num = 26 +; ap = 22 +; rp = 18 + xor esi,esi ;c=0; + mov si,WORD PTR [bp+22] ; load a + mov es,WORD PTR [bp+24] ; load a + mov di,WORD PTR [bp+26] ; load b + mov ds,WORD PTR [bp+28] ; load b + + mov dx,WORD PTR [bp+30] ; load num + dec dx + js $L547 + xor ecx,ecx + +$L5477: + xor ebx,ebx + mov eax,DWORD PTR es:[si] ; *a + add eax,ecx + adc ebx,0 + add si,4 ; a++ + add eax,DWORD PTR ds:[di] ; + *b + mov ecx,ebx + adc ecx,0 + add di,4 + mov bx,WORD PTR [bp+18] + mov ds,WORD PTR [bp+20] + mov DWORD PTR ds:[bx],eax + add bx,4 + mov ds,WORD PTR [bp+28] + mov WORD PTR [bp+18],bx + dec dx + js $L547 ; Note that we are now testing for -1 + jmp $L5477 + ; +$L547: + mov eax,ecx + mov edx,ecx + shr edx,16 + pop es + pop ds + pop di + pop esi + pop bx + pop bp + ret + nop +_bn_add_words ENDP +F_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/bn/bn.err b/src/lib/libssl/src/crypto/bn/bn.err new file mode 100644 index 0000000000..7ccc247c41 --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/bn.err @@ -0,0 +1,27 @@ +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BN_BLINDING_CONVERT 100 +#define BN_F_BN_BLINDING_INVERT 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_DIV 107 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 + +/* Reason codes. */ +#define BN_R_BAD_RECIPROCAL 100 +#define BN_R_CALLED_WITH_EVEN_MODULUS 101 +#define BN_R_DIV_BY_ZERO 102 +#define BN_R_ENCODING_ERROR 103 +#define BN_R_INVALID_LENGTH 104 +#define BN_R_NOT_INITALISED 105 +#define BN_R_NO_INVERSE 106 diff --git a/src/lib/libssl/src/crypto/bn/bn.org b/src/lib/libssl/src/crypto/bn/bn.org new file mode 100644 index 0000000000..66dde285d6 --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/bn.org @@ -0,0 +1,502 @@ +/* crypto/bn/bn.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify bn.org since bn.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_BN_H +#define HEADER_BN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#undef BN_LLONG + +#ifdef WIN32 +#define BN_LLONG /* This comment stops Configure mutilating things */ +#endif + +#define RECP_MUL_MOD +#define MONT_MUL_MOD + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using nornal cc. This would + * be a common occurance because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assember code. */ +#if defined(MSDOS) || defined(WINDOWS) || defined(linux) +#define BN_DIV2W +#endif + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits :-(, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG +/* #define BN_ULLONG unsigned long long */ +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef WIN32 +#define BN_ULLONG unsigned _int64 +#else +#define BN_ULLONG unsigned long long +#endif +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (100000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%05u" +#define BN_DEC_NUM 5 +#endif + +#ifdef EIGHT_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK2 (0xff) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#endif + +#define BN_DEFAULT_BITS 1280 + +#ifdef BIGNUM +#undef BIGNUM +#endif + +typedef struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int max; /* Size of the d array. */ + int neg; /* one if the number is negative */ + } BIGNUM; + +/* Used for temp variables */ +#define BN_CTX_NUM 12 +typedef struct bignum_ctx + { + int tos; + BIGNUM *bn[BN_CTX_NUM+1]; + } BN_CTX; + +typedef struct bn_blinding_st + { + int init; + BIGNUM *A; + BIGNUM *Ai; + BIGNUM *mod; /* just a reference */ + } BN_BLINDING; + +/* Used for montgomery multiplication */ +typedef struct bn_mont_ctx_st + { + int ri; /* number of bits in R */ + BIGNUM *RR; /* used to convert to montgomery form */ + BIGNUM *N; /* The modulus */ + BIGNUM *Ni; /* The inverse of N */ + BN_ULONG n0; /* word form of inverse, normally only one of + * Ni or n0 is defined */ + } BN_MONT_CTX; + +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + r,a,(mont)->RR,(mont),ctx) + +#define BN_prime_checks (5) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) +#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) +#define BN_is_zero(a) (((a)->top <= 1) && ((a)->d[0] == (BN_ULONG)0)) +#define BN_is_one(a) (BN_is_word((a),1)) +#define BN_is_odd(a) ((a)->d[0] & 1) +#define BN_one(a) (BN_set_word((a),1)) +#define BN_zero(a) (BN_set_word((a),0)) + +#define BN_ascii2bn(a) BN_hex2bn(a) +#define BN_bn2ascii(a) BN_bn2hex(a) + +#define bn_fix_top(a) \ + { \ + BN_ULONG *fix_top_l; \ + for (fix_top_l= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(fix_top_l--)) break; \ + } + +#define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?\ + (n):bn_expand2((n),(b)/BN_BITS2)) +#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b))) + + +#ifndef NOPROTO +BIGNUM *BN_value_one(void); +char * BN_options(void); +BN_CTX *BN_CTX_new(void); +void BN_CTX_free(BN_CTX *c); +int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_num_bits(BIGNUM *a); +int BN_num_bits_word(BN_ULONG); +BIGNUM *BN_new(void); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b); +void bn_qsub(BIGNUM *r, BIGNUM *a, BIGNUM *b); +void bn_qadd(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); +int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); +int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b); +int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); +BN_ULONG BN_mod_word(BIGNUM *a, unsigned long w); +BN_ULONG BN_div_word(BIGNUM *a, unsigned long w); +int BN_mul_word(BIGNUM *a, unsigned long w); +int BN_add_word(BIGNUM *a, unsigned long w); +int BN_sub_word(BIGNUM *a, unsigned long w); +int BN_set_word(BIGNUM *a, unsigned long w); +unsigned long BN_get_word(BIGNUM *a); +int BN_cmp(BIGNUM *a, BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, BIGNUM *a); +int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx); +int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx, + BN_MONT_CTX *m_ctx); +int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, + BIGNUM *m,BN_CTX *ctx); +int BN_mask_bits(BIGNUM *a,int n); +int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BIGNUM *m, + BIGNUM *i, int nb, BN_CTX *ctx); +int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m, + BN_CTX *ctx); +#ifndef WIN16 +int BN_print_fp(FILE *fp, BIGNUM *a); +#endif +#ifdef HEADER_BIO_H +int BN_print(BIO *fp, BIGNUM *a); +#else +int BN_print(char *fp, BIGNUM *a); +#endif +int BN_reciprocal(BIGNUM *r, BIGNUM *m, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *bn_expand2(BIGNUM *b, int bits); +BIGNUM *BN_dup(BIGNUM *a); +int BN_ucmp(BIGNUM *a, BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(BIGNUM *a); +char * BN_bn2dec(BIGNUM *a); +int BN_hex2bn(BIGNUM **a,char *str); +int BN_dec2bn(BIGNUM **a,char *str); +int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); +BIGNUM *BN_mod_inverse(BIGNUM *a, BIGNUM *n,BN_CTX *ctx); +BIGNUM *BN_generate_prime(int bits,int strong,BIGNUM *add, + BIGNUM *rem,void (*callback)(int,int,char *),char *cb_arg); +int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,char *), + BN_CTX *ctx,char *cb_arg); +void ERR_load_BN_strings(void ); + +BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); +BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); +void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num); +BN_ULONG bn_div64(BN_ULONG h, BN_ULONG l, BN_ULONG d); +BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num); + +BN_MONT_CTX *BN_MONT_CTX_new(void ); +int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont, + BN_CTX *ctx); +int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont,BIGNUM *modulus,BN_CTX *ctx); + +BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *r, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); + +#else + +BIGNUM *BN_value_one(); +char * BN_options(); +BN_CTX *BN_CTX_new(); +void BN_CTX_free(); +int BN_rand(); +int BN_num_bits(); +int BN_num_bits_word(); +BIGNUM *BN_new(); +void BN_clear_free(); +BIGNUM *BN_copy(); +BIGNUM *BN_bin2bn(); +int BN_bn2bin(); +BIGNUM *BN_mpi2bn(); +int BN_bn2mpi(); +int BN_sub(); +void bn_qsub(); +void bn_qadd(); +int BN_add(); +int BN_mod(); +int BN_div(); +int BN_mul(); +int BN_sqr(); +BN_ULONG BN_mod_word(); +BN_ULONG BN_div_word(); +int BN_add_word(); +int BN_sub_word(); +int BN_mul_word(); +int BN_set_word(); +unsigned long BN_get_word(); +int BN_cmp(); +void BN_free(); +int BN_is_bit_set(); +int BN_lshift(); +int BN_lshift1(); +int BN_exp(); +int BN_mod_exp(); +int BN_mod_exp_mont(); +int BN_mod_exp_recp(); +int BN_mod_exp_simple(); +int BN_mask_bits(); +int BN_mod_mul_reciprocal(); +int BN_mod_mul(); +#ifndef WIN16 +int BN_print_fp(); +#endif +int BN_print(); +int BN_reciprocal(); +int BN_rshift(); +int BN_rshift1(); +void BN_clear(); +BIGNUM *bn_expand2(); +BIGNUM *BN_dup(); +int BN_ucmp(); +int BN_set_bit(); +int BN_clear_bit(); +char * BN_bn2hex(); +char * BN_bn2dec(); +int BN_hex2bn(); +int BN_dec2bn(); +int BN_gcd(); +BIGNUM *BN_mod_inverse(); +BIGNUM *BN_generate_prime(); +int BN_is_prime(); +void ERR_load_BN_strings(); + +BN_ULONG bn_mul_add_words(); +BN_ULONG bn_mul_words(); +void bn_sqr_words(); +BN_ULONG bn_div64(); +BN_ULONG bn_add_words(); + +int BN_mod_mul_montgomery(); +int BN_from_montgomery(); +BN_MONT_CTX *BN_MONT_CTX_new(); +void BN_MONT_CTX_free(); +int BN_MONT_CTX_set(); + +BN_BLINDING *BN_BLINDING_new(); +void BN_BLINDING_free(); +int BN_BLINDING_update(); +int BN_BLINDING_convert(); +int BN_BLINDING_invert(); + +#endif + +/* BEGIN ERROR CODES */ +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BN_BLINDING_CONVERT 100 +#define BN_F_BN_BLINDING_INVERT 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_DIV 107 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 + +/* Reason codes. */ +#define BN_R_BAD_RECIPROCAL 100 +#define BN_R_CALLED_WITH_EVEN_MODULUS 101 +#define BN_R_DIV_BY_ZERO 102 +#define BN_R_ENCODING_ERROR 103 +#define BN_R_INVALID_LENGTH 104 +#define BN_R_NOT_INITALISED 105 +#define BN_R_NO_INVERSE 106 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/lib/libssl/src/crypto/bn/bn_m.c b/src/lib/libssl/src/crypto/bn/bn_m.c new file mode 100644 index 0000000000..5166daaeec --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/bn_m.c @@ -0,0 +1,169 @@ +/* crypto/bn/bn_m.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn_lcl.h" +#include "stack.h" + +int limit=16; + +typedef struct bn_pool_st + { + int used; + int tos; + STACK *sk; + } BN_POOL; + +BIGNUM *BN_POOL_push(bp) +BN_POOL *bp; + { + BIGNUM *ret; + + if (bp->used >= bp->tos) + { + ret=BN_new(); + sk_push(bp->sk,(char *)ret); + bp->tos++; + bp->used++; + } + else + { + ret=(BIGNUM *)sk_value(bp->sk,bp->used); + bp->used++; + } + return(ret); + } + +void BN_POOL_pop(bp,num) +BN_POOL *bp; +int num; + { + bp->used-=num; + } + +int BN_m(r,a,b) +BIGNUM *r,*a,*b; + { + static BN_POOL bp; + static init=1; + + if (init) + { + bp.used=0; + bp.tos=0; + bp.sk=sk_new_null(); + init=0; + } + return(BN_mm(r,a,b,&bp)); + } + +/* r must be different to a and b */ +int BN_mm(m, A, B, bp) +BIGNUM *m,*A,*B; +BN_POOL *bp; + { + int i,num; + int an,bn; + BIGNUM *a,*b,*c,*d,*ac,*bd; + + an=A->top; + bn=B->top; + if ((an <= limit) || (bn <= limit)) + { + return(BN_mul(m,A,B)); + } + + a=BN_POOL_push(bp); + b=BN_POOL_push(bp); + c=BN_POOL_push(bp); + d=BN_POOL_push(bp); + ac=BN_POOL_push(bp); + bd=BN_POOL_push(bp); + + num=(an <= bn)?an:bn; + num=1<<(BN_num_bits_word(num-1)-1); + + /* Are going to now chop things into 'num' word chunks. */ + num*=BN_BITS2; + + BN_copy(a,A); + BN_mask_bits(a,num); + BN_rshift(b,A,num); + + BN_copy(c,B); + BN_mask_bits(c,num); + BN_rshift(d,B,num); + + BN_sub(ac ,b,a); + BN_sub(bd,c,d); + BN_mm(m,ac,bd,bp); + BN_mm(ac,a,c,bp); + BN_mm(bd,b,d,bp); + + BN_add(m,m,ac); + BN_add(m,m,bd); + BN_lshift(m,m,num); + BN_lshift(bd,bd,num*2); + + BN_add(m,m,ac); + BN_add(m,m,bd); + BN_POOL_pop(bp,6); + return(1); + } + diff --git a/src/lib/libssl/src/crypto/bn/bn_mulw.c b/src/lib/libssl/src/crypto/bn/bn_mulw.c new file mode 100644 index 0000000000..abfc7e4d6c --- /dev/null +++ b/src/lib/libssl/src/crypto/bn/bn_mulw.c @@ -0,0 +1,366 @@ +/* crypto/bn/bn_mulw.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "bn_lcl.h" + +#ifdef BN_LLONG + +BN_ULONG bn_mul_add_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c1=0; + + for (;;) + { + mul_add(rp[0],ap[0],w,c1); + if (--num == 0) break; + mul_add(rp[1],ap[1],w,c1); + if (--num == 0) break; + mul_add(rp[2],ap[2],w,c1); + if (--num == 0) break; + mul_add(rp[3],ap[3],w,c1); + if (--num == 0) break; + ap+=4; + rp+=4; + } + + return(c1); + } + +BN_ULONG bn_mul_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c1=0; + + for (;;) + { + mul(rp[0],ap[0],w,c1); + if (--num == 0) break; + mul(rp[1],ap[1],w,c1); + if (--num == 0) break; + mul(rp[2],ap[2],w,c1); + if (--num == 0) break; + mul(rp[3],ap[3],w,c1); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(c1); + } + +void bn_sqr_words(r,a,n) +BN_ULONG *r,*a; +int n; + { + for (;;) + { + BN_ULLONG t; + + t=(BN_ULLONG)(a[0])*(a[0]); + r[0]=Lw(t); r[1]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[1])*(a[1]); + r[2]=Lw(t); r[3]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[2])*(a[2]); + r[4]=Lw(t); r[5]=Hw(t); + if (--n == 0) break; + + t=(BN_ULLONG)(a[3])*(a[3]); + r[6]=Lw(t); r[7]=Hw(t); + if (--n == 0) break; + + a+=4; + r+=8; + } + } + +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULLONG ll; + + ll=0; + for (;;) + { + ll+= (BN_ULLONG)a[0]+b[0]; + r[0]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[1]+b[1]; + r[1]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[2]+b[2]; + r[2]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[3]+b[3]; + r[3]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + a+=4; + b+=4; + r+=4; + } + return(ll&BN_MASK2); + } + +#else + +BN_ULONG bn_mul_add_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG c=0; + BN_ULONG bl,bh; + + bl=LBITS(w); + bh=HBITS(w); + + for (;;) + { + mul_add(rp[0],ap[0],bl,bh,c); + if (--num == 0) break; + mul_add(rp[1],ap[1],bl,bh,c); + if (--num == 0) break; + mul_add(rp[2],ap[2],bl,bh,c); + if (--num == 0) break; + mul_add(rp[3],ap[3],bl,bh,c); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(c); + } + +BN_ULONG bn_mul_words(rp,ap,num,w) +BN_ULONG *rp,*ap; +int num; +BN_ULONG w; + { + BN_ULONG carry=0; + BN_ULONG bl,bh; + + bl=LBITS(w); + bh=HBITS(w); + + for (;;) + { + mul(rp[0],ap[0],bl,bh,carry); + if (--num == 0) break; + mul(rp[1],ap[1],bl,bh,carry); + if (--num == 0) break; + mul(rp[2],ap[2],bl,bh,carry); + if (--num == 0) break; + mul(rp[3],ap[3],bl,bh,carry); + if (--num == 0) break; + ap+=4; + rp+=4; + } + return(carry); + } + +void bn_sqr_words(r,a,n) +BN_ULONG *r,*a; +int n; + { + for (;;) + { + sqr64(r[0],r[1],a[0]); + if (--n == 0) break; + + sqr64(r[2],r[3],a[1]); + if (--n == 0) break; + + sqr64(r[4],r[5],a[2]); + if (--n == 0) break; + + sqr64(r[6],r[7],a[3]); + if (--n == 0) break; + + a+=4; + r+=8; + } + } + +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULONG t1,t2; + int carry,i; + + carry=0; + for (i=0; i= ((~t1)&BN_MASK2)); + t2=(t1+t2+1)&BN_MASK2; + } + else + { + t2=(t1+t2)&BN_MASK2; + carry=(t2 (BN_ULONG)1<= d) h-=d; + + if (i) + { + d<<=i; + h=(h<>(BN_BITS2-i)); + l<<=i; + } + dh=(d&BN_MASK2h)>>BN_BITS4; + dl=(d&BN_MASK2l); + for (;;) + { + if ((h>>BN_BITS4) == dh) + q=BN_MASK2l; + else + q=h/dh; + + for (;;) + { + t=(h-q*dh); + if ((t&BN_MASK2h) || + ((dl*q) <= ( + (t<>BN_BITS4)))) + break; + q--; + } + th=q*dh; + tl=q*dl; + t=(tl>>BN_BITS4); + tl=(tl<>BN_BITS4))&BN_MASK2; + l=(l&BN_MASK2l)< +#include "cryptlib.h" +#include "bn_lcl.h" + +/* unsigned subtraction of b from a, a must be larger than b. */ +void bn_qsub(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + int max,min; + register BN_ULONG t1,t2,*ap,*bp,*rp; + int i,carry; +#if defined(IRIX_CC_BUG) && !defined(LINT) + int dummy; +#endif + + max=a->top; + min=b->top; + ap=a->d; + bp=b->d; + rp=r->d; + + carry=0; + for (i=0; i t2) break; + } + } +#if 0 + memcpy(rp,ap,sizeof(*rp)*(max-i)); +#else + for (; itop=max; + bn_fix_top(r); + } + +int BN_sub(r, a, b) +BIGNUM *r; +BIGNUM *a; +BIGNUM *b; + { + int max,i; + int add=0,neg=0; + BIGNUM *tmp; + + /* a - b a-b + * a - -b a+b + * -a - b -(a+b) + * -a - -b b-a + */ + if (a->neg) + { + if (b->neg) + { tmp=a; a=b; b=tmp; } + else + { add=1; neg=1; } + } + else + { + if (b->neg) { add=1; neg=0; } + } + + if (add) + { + /* As a fast max size, do a a->top | b->top */ + i=(a->top | b->top)+1; + if (bn_wexpand(r,i) == NULL) + return(0); + if (i) + bn_qadd(r,a,b); + else + bn_qadd(r,b,a); + r->neg=neg; + return(1); + } + + /* We are actually doing a - b :-) */ + + max=(a->top > b->top)?a->top:b->top; + if (bn_wexpand(r,max) == NULL) return(0); + if (BN_ucmp(a,b) < 0) + { + bn_qsub(r,b,a); + r->neg=1; + } + else + { + bn_qsub(r,a,b); + r->neg=0; + } + return(1); + } + diff --git a/src/lib/libssl/src/crypto/buffer/Makefile.ssl b/src/lib/libssl/src/crypto/buffer/Makefile.ssl new file mode 100644 index 0000000000..a5f150e523 --- /dev/null +++ b/src/lib/libssl/src/crypto/buffer/Makefile.ssl @@ -0,0 +1,84 @@ +# +# SSLeay/crypto/buffer/Makefile +# + +DIR= buffer +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=buffer +ERRC=buf_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= buffer.c $(ERRC).c +LIBOBJ= buffer.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= buffer.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/buffer/buffer.err b/src/lib/libssl/src/crypto/buffer/buffer.err new file mode 100644 index 0000000000..62b775e637 --- /dev/null +++ b/src/lib/libssl/src/crypto/buffer/buffer.err @@ -0,0 +1,9 @@ +/* Error codes for the BUF functions. */ + +/* Function codes. */ +#define BUF_F_BUF_MEM_GROW 100 +#define BUF_F_BUF_MEM_NEW 101 +#define BUF_F_BUF_STRDUP 102 +#define BUF_F_PXYCLNT_READ 103 + +/* Reason codes. */ diff --git a/src/lib/libssl/src/crypto/cast/Makefile.ssl b/src/lib/libssl/src/crypto/cast/Makefile.ssl new file mode 100644 index 0000000000..0143827ae5 --- /dev/null +++ b/src/lib/libssl/src/crypto/cast/Makefile.ssl @@ -0,0 +1,109 @@ +# +# SSLeay/crypto/cast/Makefile +# + +DIR= cast +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CAST_ENC=c_enc.o +# or use +#CAST_ENC=asm/cx86-elf.o +#CAST_ENC=asm/cx86-out.o +#CAST_ENC=asm/cx86-sol.o +#CAST_ENC=asm/cx86bdsi.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=casttest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= cast.h +HEADER= cast_s.h cast_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/cx86-elf.o: asm/cx86unix.cpp + $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o + +# solaris +asm/cx86-sol.o: asm/cx86unix.cpp + $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s + as -o asm/cx86-sol.o asm/cx86-sol.s + rm -f asm/cx86-sol.s + +# a.out +asm/cx86-out.o: asm/cx86unix.cpp + $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o + +# bsdi +asm/cx86bsdi.o: asm/cx86unix.cpp + $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o + +asm/cx86unix.cpp: + (cd asm; perl cast-586.pl cpp >cx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/cast/Makefile.uni b/src/lib/libssl/src/crypto/cast/Makefile.uni new file mode 100644 index 0000000000..780073e75b --- /dev/null +++ b/src/lib/libssl/src/crypto/cast/Makefile.uni @@ -0,0 +1,123 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +# There are 3 possible performance options, experiment :-) +#OPTS= -DBF_PTR +#OPTS= -DBF_PTR2 +OPTS= + +DIR= cast +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +CAST_ENC=c_enc.o +# or use +#CAST_ENC=asm/cx86-elf.o +#CAST_ENC=asm/cx86-out.o +#CAST_ENC=asm/cx86-sol.o +#CAST_ENC=asm/cx86bdsi.o + +CFLAGS= $(OPTS) $(INCLUDES) $(CFLAG) -DFULL_TEST + +GENERAL=Makefile +TEST=casttest +APP1=cast_spd +APP2=castopts +APPS=$(APP1) $(APP2) + +LIB=libcast.a +LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c +LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= cast.h +HEADER= cast_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) +# elf +asm/cx86-elf.o: asm/cx86unix.cpp + $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o + +# solaris +asm/cx86-sol.o: asm/cx86unix.cpp + $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s + as -o asm/cx86-sol.o asm/cx86-sol.s + rm -f asm/cx86-sol.s + +# a.out +asm/cx86-out.o: asm/cx86unix.cpp + $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o + +# bsdi +asm/cx86bsdi.o: asm/cx86unix.cpp + $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o + +asm/cx86unix.cpp: + (cd asm; perl cast-586.pl cpp >cx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APP1): $(APP1).c $(LIB) + $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB) + +$(APP2): $(APP2).c $(LIB) + $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) CAST_ENC="asm/cx86-elf.o" CFLAG="-DELF $(CFLAGS)" all + +x86-out: + $(MAKE) CAST_ENC="asm/cx86-out.o" CFLAG="-DOUT $(CFLAGS)" all + +x86-solaris: + $(MAKE) CAST_ENC="asm/cx86-sol.o" CFLAG="-DSOL $(CFLAGS)" all + +x86-bdsi: + $(MAKE) CAST_ENC="asm/cx86-bdsi.o" CFLAG="-DBDSI $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/cast/asm/c-win32.asm b/src/lib/libssl/src/crypto/cast/asm/c-win32.asm new file mode 100644 index 0000000000..a1d8a2671a --- /dev/null +++ b/src/lib/libssl/src/crypto/cast/asm/c-win32.asm @@ -0,0 +1,940 @@ + ; Don't even think of reading this code + ; It was automatically generated by cast-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE cast-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _CAST_encrypt +EXTERN _CAST_S_table0:DWORD +EXTERN _CAST_S_table1:DWORD +EXTERN _CAST_S_table2:DWORD +EXTERN _CAST_S_table3:DWORD + +_CAST_encrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + ; round 0 + mov edx, DWORD PTR [ebp] + mov ecx, DWORD PTR 4[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 1 + mov edx, DWORD PTR 8[ebp] + mov ecx, DWORD PTR 12[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 2 + mov edx, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 20[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 3 + mov edx, DWORD PTR 24[ebp] + mov ecx, DWORD PTR 28[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 4 + mov edx, DWORD PTR 32[ebp] + mov ecx, DWORD PTR 36[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 5 + mov edx, DWORD PTR 40[ebp] + mov ecx, DWORD PTR 44[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 6 + mov edx, DWORD PTR 48[ebp] + mov ecx, DWORD PTR 52[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 7 + mov edx, DWORD PTR 56[ebp] + mov ecx, DWORD PTR 60[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 8 + mov edx, DWORD PTR 64[ebp] + mov ecx, DWORD PTR 68[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 9 + mov edx, DWORD PTR 72[ebp] + mov ecx, DWORD PTR 76[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 10 + mov edx, DWORD PTR 80[ebp] + mov ecx, DWORD PTR 84[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 11 + mov edx, DWORD PTR 88[ebp] + mov ecx, DWORD PTR 92[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 12 + mov edx, DWORD PTR 96[ebp] + mov ecx, DWORD PTR 100[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 13 + mov edx, DWORD PTR 104[ebp] + mov ecx, DWORD PTR 108[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 14 + mov edx, DWORD PTR 112[ebp] + mov ecx, DWORD PTR 116[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 15 + mov edx, DWORD PTR 120[ebp] + mov ecx, DWORD PTR 124[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + mov eax, DWORD PTR 20[esp] + xor esi, ecx + nop + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_CAST_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _CAST_decrypt +EXTERN _CAST_S_table0:DWORD +EXTERN _CAST_S_table1:DWORD +EXTERN _CAST_S_table2:DWORD +EXTERN _CAST_S_table3:DWORD + +_CAST_decrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + xor eax, eax + ; round 15 + mov edx, DWORD PTR 120[ebp] + mov ecx, DWORD PTR 124[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 14 + mov edx, DWORD PTR 112[ebp] + mov ecx, DWORD PTR 116[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 13 + mov edx, DWORD PTR 104[ebp] + mov ecx, DWORD PTR 108[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 12 + mov edx, DWORD PTR 96[ebp] + mov ecx, DWORD PTR 100[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 11 + mov edx, DWORD PTR 88[ebp] + mov ecx, DWORD PTR 92[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 10 + mov edx, DWORD PTR 80[ebp] + mov ecx, DWORD PTR 84[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 9 + mov edx, DWORD PTR 72[ebp] + mov ecx, DWORD PTR 76[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 8 + mov edx, DWORD PTR 64[ebp] + mov ecx, DWORD PTR 68[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 7 + mov edx, DWORD PTR 56[ebp] + mov ecx, DWORD PTR 60[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 6 + mov edx, DWORD PTR 48[ebp] + mov ecx, DWORD PTR 52[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 5 + mov edx, DWORD PTR 40[ebp] + mov ecx, DWORD PTR 44[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 4 + mov edx, DWORD PTR 32[ebp] + mov ecx, DWORD PTR 36[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 3 + mov edx, DWORD PTR 24[ebp] + mov ecx, DWORD PTR 28[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 2 + mov edx, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 20[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 1 + mov edx, DWORD PTR 8[ebp] + mov ecx, DWORD PTR 12[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 0 + mov edx, DWORD PTR [ebp] + mov ecx, DWORD PTR 4[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + mov eax, DWORD PTR 20[esp] + xor esi, ecx + nop + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_CAST_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _CAST_cbc_encrypt + +_CAST_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L000decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L001encrypt_finish +L002encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L002encrypt_loop +$L001encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4] + jmp ebp +L005ej7: + xor edx, edx + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L006ej6: + mov dh, BYTE PTR 5[esi] +L007ej5: + mov dl, BYTE PTR 4[esi] +L008ej4: + mov ecx, DWORD PTR [esi] + jmp $L009ejend +L010ej3: + mov ch, BYTE PTR 2[esi] + xor ecx, ecx + shl ecx, 8 +L011ej2: + mov ch, BYTE PTR 1[esi] +L012ej1: + mov cl, BYTE PTR [esi] +$L009ejend: + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L003finish +$L000decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L013decrypt_finish +L014decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L014decrypt_loop +$L013decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L003finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L015dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L016dj6: + mov BYTE PTR 5[edi],dh +L017dj5: + mov BYTE PTR 4[edi],dl +L018dj4: + mov DWORD PTR [edi],ecx + jmp $L019djend +L020dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L021dj2: + mov BYTE PTR 1[esi],ch +L022dj1: + mov BYTE PTR [esi], cl +$L019djend: + jmp $L003finish +$L003finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L004cbc_enc_jmp_table: + DD 0 + DD L012ej1 + DD L011ej2 + DD L010ej3 + DD L008ej4 + DD L007ej5 + DD L006ej6 + DD L005ej7 +L023cbc_dec_jmp_table: + DD 0 + DD L022dj1 + DD L021dj2 + DD L020dj3 + DD L018dj4 + DD L017dj5 + DD L016dj6 + DD L015dj7 +_CAST_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp b/src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp new file mode 100644 index 0000000000..035692a5af --- /dev/null +++ b/src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp @@ -0,0 +1,1010 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define CAST_S_table0 _CAST_S_table0 +#define CAST_S_table1 _CAST_S_table1 +#define CAST_S_table2 _CAST_S_table2 +#define CAST_S_table3 _CAST_S_table3 +#define CAST_encrypt _CAST_encrypt +#define CAST_S_table0 _CAST_S_table0 +#define CAST_S_table1 _CAST_S_table1 +#define CAST_S_table2 _CAST_S_table2 +#define CAST_S_table3 _CAST_S_table3 +#define CAST_decrypt _CAST_decrypt +#define CAST_cbc_encrypt _CAST_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by cast-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "cast-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl CAST_encrypt + TYPE(CAST_encrypt,@function) +CAST_encrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + /* round 0 */ + movl (%ebp), %edx + movl 4(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 1 */ + movl 8(%ebp), %edx + movl 12(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 2 */ + movl 16(%ebp), %edx + movl 20(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 3 */ + movl 24(%ebp), %edx + movl 28(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 4 */ + movl 32(%ebp), %edx + movl 36(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 5 */ + movl 40(%ebp), %edx + movl 44(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 6 */ + movl 48(%ebp), %edx + movl 52(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 7 */ + movl 56(%ebp), %edx + movl 60(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 8 */ + movl 64(%ebp), %edx + movl 68(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 9 */ + movl 72(%ebp), %edx + movl 76(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 10 */ + movl 80(%ebp), %edx + movl 84(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 11 */ + movl 88(%ebp), %edx + movl 92(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 12 */ + movl 96(%ebp), %edx + movl 100(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 13 */ + movl 104(%ebp), %edx + movl 108(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 14 */ + movl 112(%ebp), %edx + movl 116(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 15 */ + movl 120(%ebp), %edx + movl 124(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + movl 20(%esp), %eax + xorl %ecx, %esi + nop + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.CAST_encrypt_end: + SIZE(CAST_encrypt,.CAST_encrypt_end-CAST_encrypt) +.ident "CAST_encrypt" +.text + .align ALIGN +.globl CAST_decrypt + TYPE(CAST_decrypt,@function) +CAST_decrypt: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebx + movl 16(%esp), %ebp + pushl %esi + pushl %edi + /* Load the 2 words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + xorl %eax, %eax + /* round 15 */ + movl 120(%ebp), %edx + movl 124(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 14 */ + movl 112(%ebp), %edx + movl 116(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 13 */ + movl 104(%ebp), %edx + movl 108(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 12 */ + movl 96(%ebp), %edx + movl 100(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 11 */ + movl 88(%ebp), %edx + movl 92(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 10 */ + movl 80(%ebp), %edx + movl 84(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 9 */ + movl 72(%ebp), %edx + movl 76(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 8 */ + movl 64(%ebp), %edx + movl 68(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 7 */ + movl 56(%ebp), %edx + movl 60(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 6 */ + movl 48(%ebp), %edx + movl 52(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %esi + /* round 5 */ + movl 40(%ebp), %edx + movl 44(%ebp), %ecx + subl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %edi + /* round 4 */ + movl 32(%ebp), %edx + movl 36(%ebp), %ecx + xorl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %esi + /* round 3 */ + movl 24(%ebp), %edx + movl 28(%ebp), %ecx + addl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + xorl %ecx, %edi + /* round 2 */ + movl 16(%ebp), %edx + movl 20(%ebp), %ecx + subl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + addl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + subl %ebx, %ecx + xorl %ecx, %esi + /* round 1 */ + movl 8(%ebp), %edx + movl 12(%ebp), %ecx + xorl %esi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + subl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + addl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + xorl %ebx, %ecx + xorl %ecx, %edi + /* round 0 */ + movl (%ebp), %edx + movl 4(%ebp), %ecx + addl %edi, %edx + roll %cl, %edx + movl %edx, %ebx + xorl %ecx, %ecx + movb %dh, %cl + andl $255, %ebx + shrl $16, %edx + xorl %eax, %eax + movb %dh, %al + andl $255, %edx + movl CAST_S_table0(,%ecx,4),%ecx + movl CAST_S_table1(,%ebx,4),%ebx + xorl %ebx, %ecx + movl CAST_S_table2(,%eax,4),%ebx + subl %ebx, %ecx + movl CAST_S_table3(,%edx,4),%ebx + addl %ebx, %ecx + movl 20(%esp), %eax + xorl %ecx, %esi + nop + movl %edi, 4(%eax) + movl %esi, (%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.CAST_decrypt_end: + SIZE(CAST_decrypt,.CAST_decrypt_end-CAST_decrypt) +.ident "CAST_decrypt" +.text + .align ALIGN +.globl CAST_cbc_encrypt + TYPE(CAST_cbc_encrypt,@function) +CAST_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L000decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L001encrypt_finish +.L002encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L002encrypt_loop +.L001encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L005ej7: + xorl %edx, %edx + movb 6(%esi), %dh + sall $8, %edx +.L006ej6: + movb 5(%esi), %dh +.L007ej5: + movb 4(%esi), %dl +.L008ej4: + movl (%esi), %ecx + jmp .L009ejend +.L010ej3: + movb 2(%esi), %ch + xorl %ecx, %ecx + sall $8, %ecx +.L011ej2: + movb 1(%esi), %ch +.L012ej1: + movb (%esi), %cl +.L009ejend: + xorl %ecx, %eax + xorl %edx, %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L003finish +.align ALIGN +.L000decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L013decrypt_finish +.L014decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L014decrypt_loop +.L013decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L003finish + movl (%esi), %eax + movl 4(%esi), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call CAST_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx +.byte 15 +.byte 200 /* bswapl %eax */ +.byte 15 +.byte 203 /* bswapl %ebx */ + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L015dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L016dj6: + movb %dh, 5(%edi) +.L017dj5: + movb %dl, 4(%edi) +.L018dj4: + movl %ecx, (%edi) + jmp .L019djend +.L020dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L021dj2: + movb %ch, 1(%esi) +.L022dj1: + movb %cl, (%esi) +.L019djend: + jmp .L003finish +.align ALIGN +.L003finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L004cbc_enc_jmp_table: + .long 0 + .long .L012ej1 + .long .L011ej2 + .long .L010ej3 + .long .L008ej4 + .long .L007ej5 + .long .L006ej6 + .long .L005ej7 +.align ALIGN +.L023cbc_dec_jmp_table: + .long 0 + .long .L022dj1 + .long .L021dj2 + .long .L020dj3 + .long .L018dj4 + .long .L017dj5 + .long .L016dj6 + .long .L015dj7 +.CAST_cbc_encrypt_end: + SIZE(CAST_cbc_encrypt,.CAST_cbc_encrypt_end-CAST_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/conf/Makefile.ssl b/src/lib/libssl/src/crypto/conf/Makefile.ssl new file mode 100644 index 0000000000..00e917aa44 --- /dev/null +++ b/src/lib/libssl/src/crypto/conf/Makefile.ssl @@ -0,0 +1,85 @@ +# +# SSLeay/crypto/conf/Makefile +# + +DIR= conf +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=conf +ERRC=conf_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= conf.c $(ERRC).c + +LIBOBJ= conf.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= conf.h +HEADER= conf_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/conf/conf.c b/src/lib/libssl/src/crypto/conf/conf.c new file mode 100644 index 0000000000..9e84300c5e --- /dev/null +++ b/src/lib/libssl/src/crypto/conf/conf.c @@ -0,0 +1,727 @@ +/* crypto/conf/conf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include "cryptlib.h" +#include "stack.h" +#include "lhash.h" +#include "conf.h" +#include "buffer.h" +#include "err.h" + +#include "conf_lcl.h" + +#ifndef NOPROTO +static void value_free_hash(CONF_VALUE *a, LHASH *conf); +static void value_free_stack(CONF_VALUE *a,LHASH *conf); +static unsigned long hash(CONF_VALUE *v); +static int cmp(CONF_VALUE *a,CONF_VALUE *b); +static char *eat_ws(char *p); +static char *eat_alpha_numeric(char *p); +static void clear_comments(char *p); +static int str_copy(LHASH *conf,char *section,char **to, char *from); +static char *scan_quote(char *p); +static CONF_VALUE *new_section(LHASH *conf,char *section); +static CONF_VALUE *get_section(LHASH *conf,char *section); +#else +static void value_free_hash(); +static void value_free_stack(); +static unsigned long hash(); +static int cmp(); +static char *eat_ws(); +static char *eat_alpha_numeric(); +static void clear_comments(); +static int str_copy(); +static char *scan_quote(); +static CONF_VALUE *new_section(); +static CONF_VALUE *get_section(); +#endif + +#define scan_esc(p) ((*(++p) == '\0')?(p):(++p)) + +char *CONF_version="CONF part of SSLeay 0.9.0b 29-Jun-1998"; + +LHASH *CONF_load(h,file,line) +LHASH *h; +char *file; +long *line; + { + LHASH *ret=NULL; + FILE *in=NULL; +#define BUFSIZE 512 + int bufnum=0,i,ii; + BUF_MEM *buff=NULL; + char *s,*p,*end; + int again,n,eline=0; + CONF_VALUE *v=NULL,*vv,*tv; + CONF_VALUE *sv=NULL; + char *section=NULL,*buf; + STACK *section_sk=NULL,*ts; + char *start,*psection,*pname; + + if ((buff=BUF_MEM_new()) == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB); + goto err; + } + + in=fopen(file,"rb"); + if (in == NULL) + { + SYSerr(SYS_F_FOPEN,get_last_sys_error()); + ERR_set_error_data(BUF_strdup(file), + ERR_TXT_MALLOCED|ERR_TXT_STRING); + CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); + goto err; + } + + section=(char *)Malloc(10); + if (section == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + strcpy(section,"default"); + + if (h == NULL) + { + if ((ret=lh_new(hash,cmp)) == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + } + else + ret=h; + + sv=new_section(ret,section); + if (sv == NULL) + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + goto err; + } + section_sk=(STACK *)sv->value; + + bufnum=0; + for (;;) + { + again=0; + if (!BUF_MEM_grow(buff,bufnum+BUFSIZE)) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB); + goto err; + } + p= &(buff->data[bufnum]); + *p='\0'; + fgets(p,BUFSIZE-1,in); + p[BUFSIZE-1]='\0'; + ii=i=strlen(p); + if (i == 0) break; + while (i > 0) + { + if ((p[i-1] != '\r') && (p[i-1] != '\n')) + break; + else + i--; + } + /* we removed some trailing stuff so there is a new + * line on the end. */ + if (i == ii) + again=1; /* long line */ + else + { + p[i]='\0'; + eline++; /* another input line */ + } + + /* we now have a line with trailing \r\n removed */ + + /* i is the number of bytes */ + bufnum+=i; + + v=NULL; + /* check for line continuation */ + if (bufnum >= 1) + { + /* If we have bytes and the last char '\\' and + * second last char is not '\\' */ + p= &(buff->data[bufnum-1]); + if ( IS_ESC(p[0]) && + ((bufnum <= 1) || !IS_ESC(p[-1]))) + { + bufnum--; + again=1; + } + } + if (again) continue; + bufnum=0; + buf=buff->data; + + clear_comments(buf); + n=strlen(buf); + s=eat_ws(buf); + if (IS_EOF(*s)) continue; /* blank line */ + if (*s == '[') + { + s++; + start=eat_ws(s); + end=eat_alpha_numeric(start); + p=eat_ws(end); + if (*p != ']') + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_CLOSE_SQUARE_BRACKET); + goto err; + } + *end='\0'; + if (!str_copy(ret,NULL,§ion,start)) goto err; + if ((sv=get_section(ret,section)) == NULL) + sv=new_section(ret,section); + if (sv == NULL) + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + goto err; + } + section_sk=(STACK *)sv->value; + continue; + } + else + { + pname=s; + psection=NULL; + end=eat_alpha_numeric(s); + if ((end[0] == ':') && (end[1] == ':')) + { + *end='\0'; + end+=2; + psection=pname; + pname=end; + end=eat_alpha_numeric(end); + } + p=eat_ws(end); + if (*p != '=') + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_EQUAL_SIGN); + goto err; + } + *end='\0'; + p++; + start=eat_ws(p); + while (!IS_EOF(*p)) + p++; + p--; + while ((p != start) && (IS_WS(*p))) + p--; + p++; + *p='\0'; + + if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + if (psection == NULL) psection=section; + v->name=(char *)Malloc(strlen(pname)+1); + v->value=NULL; + if (v->name == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + strcpy(v->name,pname); + if (!str_copy(ret,psection,&(v->value),start)) goto err; + + if (strcmp(psection,section) != 0) + { + if ((tv=get_section(ret,psection)) + == NULL) + tv=new_section(ret,psection); + if (tv == NULL) + { + CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION); + goto err; + } + ts=(STACK *)tv->value; + } + else + { + tv=sv; + ts=section_sk; + } + v->section=tv->section; + if (!sk_push(ts,(char *)v)) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE); + goto err; + } + vv=(CONF_VALUE *)lh_insert(ret,(char *)v); + if (vv != NULL) + { + sk_delete_ptr(ts,(char *)vv); + Free(vv->name); + Free(vv->value); + Free(vv); + } + v=NULL; + } + } + if (buff != NULL) BUF_MEM_free(buff); + if (section != NULL) Free(section); + if (in != NULL) fclose(in); + return(ret); +err: + if (buff != NULL) BUF_MEM_free(buff); + if (section != NULL) Free(section); + if (line != NULL) *line=eline; + if (in != NULL) fclose(in); + if ((h != ret) && (ret != NULL)) CONF_free(ret); + if (v != NULL) + { + if (v->name != NULL) Free(v->name); + if (v->value != NULL) Free(v->value); + if (v != NULL) Free(v); + } + return(NULL); + } + +char *CONF_get_string(conf,section,name) +LHASH *conf; +char *section; +char *name; + { + CONF_VALUE *v,vv; + char *p; + + if (name == NULL) return(NULL); + if (conf != NULL) + { + if (section != NULL) + { + vv.name=name; + vv.section=section; + v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + if (v != NULL) return(v->value); + if (strcmp(section,"ENV") == 0) + { + p=Getenv(name); + if (p != NULL) return(p); + } + } + vv.section="default"; + vv.name=name; + v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + if (v != NULL) + return(v->value); + else + return(NULL); + } + else + return(Getenv(name)); + } + +static CONF_VALUE *get_section(conf,section) +LHASH *conf; +char *section; + { + CONF_VALUE *v,vv; + + if ((conf == NULL) || (section == NULL)) return(NULL); + vv.name=NULL; + vv.section=section; + v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv); + return(v); + } + +STACK *CONF_get_section(conf,section) +LHASH *conf; +char *section; + { + CONF_VALUE *v; + + v=get_section(conf,section); + if (v != NULL) + return((STACK *)v->value); + else + return(NULL); + } + +long CONF_get_number(conf,section,name) +LHASH *conf; +char *section; +char *name; + { + char *str; + long ret=0; + + str=CONF_get_string(conf,section,name); + if (str == NULL) return(0); + for (;;) + { + if (IS_NUMER(*str)) + ret=ret*10+(*str -'0'); + else + return(ret); + str++; + } + } + +void CONF_free(conf) +LHASH *conf; + { + if (conf == NULL) return; + + conf->down_load=0; /* evil thing to make sure the 'Free()' + * works as expected */ + lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf); + + /* We now have only 'section' entries in the hash table. + * Due to problems with */ + + lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf); + lh_free(conf); + } + +static void value_free_hash(a,conf) +CONF_VALUE *a; +LHASH *conf; + { + if (a->name != NULL) + { + a=(CONF_VALUE *)lh_delete(conf,(char *)a); + } + } + +static void value_free_stack(a,conf) +CONF_VALUE *a; +LHASH *conf; + { + CONF_VALUE *vv; + STACK *sk; + int i; + + if (a->name != NULL) return; + + sk=(STACK *)a->value; + for (i=sk_num(sk)-1; i>=0; i--) + { + vv=(CONF_VALUE *)sk_value(sk,i); + Free(vv->value); + Free(vv->name); + Free(vv); + } + if (sk != NULL) sk_free(sk); + Free(a->section); + Free(a); + } + +static void clear_comments(p) +char *p; + { + char *to; + + to=p; + for (;;) + { + if (IS_COMMENT(*p)) + { + *p='\0'; + return; + } + if (IS_QUOTE(*p)) + { + p=scan_quote(p); + continue; + } + if (IS_ESC(*p)) + { + p=scan_esc(p); + continue; + } + if (IS_EOF(*p)) + return; + else + p++; + } + } + +static int str_copy(conf,section,pto,from) +LHASH *conf; +char *section; +char **pto,*from; + { + int q,r,rr=0,to=0,len=0; + char *s,*e,*rp,*p,*rrp,*np,*cp,v; + BUF_MEM *buf; + + if ((buf=BUF_MEM_new()) == NULL) return(0); + + len=strlen(from)+1; + if (!BUF_MEM_grow(buf,len)) goto err; + + for (;;) + { + if (IS_QUOTE(*from)) + { + q= *from; + from++; + while ((*from != '\0') && (*from != q)) + { + if (*from == '\\') + { + from++; + if (*from == '\0') break; + } + buf->data[to++]= *(from++); + } + } + else if (*from == '\\') + { + from++; + v= *(from++); + if (v == '\0') break; + else if (v == 'r') v='\r'; + else if (v == 'n') v='\n'; + else if (v == 'b') v='\b'; + else if (v == 't') v='\t'; + buf->data[to++]= v; + } + else if (*from == '\0') + break; + else if (*from == '$') + { + /* try to expand it */ + rrp=NULL; + s= &(from[1]); + if (*s == '{') + q='}'; + else if (*s == '(') + q=')'; + else q=0; + + if (q) s++; + cp=section; + e=np=s; + while (IS_ALPHA_NUMERIC(*e)) + e++; + if ((e[0] == ':') && (e[1] == ':')) + { + cp=np; + rrp=e; + rr= *e; + *rrp='\0'; + e+=2; + np=e; + while (IS_ALPHA_NUMERIC(*e)) + e++; + } + r= *e; + *e='\0'; + rp=e; + if (q) + { + if (r != q) + { + CONFerr(CONF_F_STR_COPY,CONF_R_NO_CLOSE_BRACE); + goto err; + } + e++; + } + /* So at this point we have + * ns which is the start of the name string which is + * '\0' terminated. + * cs which is the start of the section string which is + * '\0' terminated. + * e is the 'next point after'. + * r and s are the chars replaced by the '\0' + * rp and sp is where 'r' and 's' came from. + */ + p=CONF_get_string(conf,cp,np); + if (rrp != NULL) *rrp=rr; + *rp=r; + if (p == NULL) + { + CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE); + goto err; + } + BUF_MEM_grow(buf,(strlen(p)+len-(e-from))); + while (*p) + buf->data[to++]= *(p++); + from=e; + } + else + buf->data[to++]= *(from++); + } + buf->data[to]='\0'; + if (*pto != NULL) Free(*pto); + *pto=buf->data; + Free(buf); + return(1); +err: + if (buf != NULL) BUF_MEM_free(buf); + return(0); + } + +static char *eat_ws(p) +char *p; + { + while (IS_WS(*p) && (!IS_EOF(*p))) + p++; + return(p); + } + +static char *eat_alpha_numeric(p) +char *p; + { + for (;;) + { + if (IS_ESC(*p)) + { + p=scan_esc(p); + continue; + } + if (!IS_ALPHA_NUMERIC_PUNCT(*p)) + return(p); + p++; + } + } + +static unsigned long hash(v) +CONF_VALUE *v; + { + return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); + } + +static int cmp(a,b) +CONF_VALUE *a,*b; + { + int i; + + if (a->section != b->section) + { + i=strcmp(a->section,b->section); + if (i) return(i); + } + + if ((a->name != NULL) && (b->name != NULL)) + { + i=strcmp(a->name,b->name); + return(i); + } + else if (a->name == b->name) + return(0); + else + return((a->name == NULL)?-1:1); + } + +static char *scan_quote(p) +char *p; + { + int q= *p; + + p++; + while (!(IS_EOF(*p)) && (*p != q)) + { + if (IS_ESC(*p)) + { + p++; + if (IS_EOF(*p)) return(p); + } + p++; + } + if (*p == q) p++; + return(p); + } + +static CONF_VALUE *new_section(conf,section) +LHASH *conf; +char *section; + { + STACK *sk=NULL; + int ok=0,i; + CONF_VALUE *v=NULL,*vv; + + if ((sk=sk_new_null()) == NULL) + goto err; + if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL) + goto err; + i=strlen(section)+1; + if ((v->section=(char *)Malloc(i)) == NULL) + goto err; + + memcpy(v->section,section,i); + v->name=NULL; + v->value=(char *)sk; + + vv=(CONF_VALUE *)lh_insert(conf,(char *)v); + if (vv != NULL) + { +#if !defined(NO_STDIO) && !defined(WIN16) + fprintf(stderr,"internal fault\n"); +#endif + abort(); + } + ok=1; +err: + if (!ok) + { + if (sk != NULL) sk_free(sk); + if (v != NULL) Free(v); + v=NULL; + } + return(v); + } diff --git a/src/lib/libssl/src/crypto/conf/conf.err b/src/lib/libssl/src/crypto/conf/conf.err new file mode 100644 index 0000000000..933d3d692a --- /dev/null +++ b/src/lib/libssl/src/crypto/conf/conf.err @@ -0,0 +1,12 @@ +/* Error codes for the CONF functions. */ + +/* Function codes. */ +#define CONF_F_CONF_LOAD 100 +#define CONF_F_STR_COPY 101 + +/* Reason codes. */ +#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +#define CONF_R_MISSING_EQUAL_SIGN 101 +#define CONF_R_NO_CLOSE_BRACE 102 +#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +#define CONF_R_VARIABLE_HAS_NO_VALUE 104 diff --git a/src/lib/libssl/src/crypto/conf/conf_lcl.h b/src/lib/libssl/src/crypto/conf/conf_lcl.h new file mode 100644 index 0000000000..4e5644ed79 --- /dev/null +++ b/src/lib/libssl/src/crypto/conf/conf_lcl.h @@ -0,0 +1,102 @@ +/* crypto/conf/conf_lcl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#define CONF_NUMBER 1 +#define CONF_UPPER 2 +#define CONF_LOWER 4 +#define CONF_UNDER 256 +#define CONF_PUNCTUATION 512 +#define CONF_WS 16 +#define CONF_ESC 32 +#define CONF_QUOTE 64 +#define CONF_COMMENT 128 +#define CONF_EOF 8 +#define CONF_ALPHA (CONF_UPPER|CONF_LOWER) +#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) +#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \ + CONF_PUNCTUATION) + +#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f])) +#define IS_EOF(a) ((a) == '\0') +#define IS_ESC(a) ((a) == '\\') +#define IS_NUMER(a) (CONF_type[(a)&0x7f]&CONF_NUMBER) +#define IS_WS(a) (CONF_type[(a)&0x7f]&CONF_WS) +#define IS_ALPHA_NUMERIC(a) (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC) +#define IS_ALPHA_NUMERIC_PUNCT(a) \ + (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) +#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE) + +static unsigned short CONF_type[128]={ + 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000, + 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000, + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, + 0x010,0x200,0x040,0x080,0x000,0x200,0x200,0x040, + 0x000,0x000,0x200,0x200,0x200,0x200,0x200,0x200, + 0x001,0x001,0x001,0x001,0x001,0x001,0x001,0x001, + 0x001,0x001,0x000,0x200,0x000,0x000,0x000,0x200, + 0x200,0x002,0x002,0x002,0x002,0x002,0x002,0x002, + 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, + 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, + 0x002,0x002,0x002,0x000,0x020,0x000,0x200,0x100, + 0x040,0x004,0x004,0x004,0x004,0x004,0x004,0x004, + 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, + 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, + 0x004,0x004,0x004,0x000,0x200,0x000,0x200,0x000, + }; + diff --git a/src/lib/libssl/src/crypto/cryptall.h b/src/lib/libssl/src/crypto/cryptall.h new file mode 100644 index 0000000000..65a46452a8 --- /dev/null +++ b/src/lib/libssl/src/crypto/cryptall.h @@ -0,0 +1,110 @@ +/* crypto/cryptall.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CRYPTOALL_H +#define HEADER_CRYPTOALL_H + +#include "buffer.h" +#include "stack.h" +#include "lhash.h" + +#include "err.h" + +#ifdef NO_MD2 +#include +#else +#include "md2.h" +#endif +#ifdef NO_MD5 +#include +#else +#include "md5.h" +#endif +#include "sha.h" + +#ifdef NO_DES +#include +#else +#include "des.h" +#endif +#include "rc2.h" +#include "rc4.h" +#include "idea.h" + +#include "bn.h" +#include "dh.h" +#include "rsa.h" +#include "dsa.h" + +#include "rand.h" +#include "conf.h" +#include "txt_db.h" + +#include "err.h" +#include "evp.h" + +#include "meth.h" +#include "x509.h" +#include "pkcs7.h" +#include "pem.h" +#include "asn1.h" +#include "objects.h" + +#include "crypto.h" + +#endif diff --git a/src/lib/libssl/src/crypto/crypto.c b/src/lib/libssl/src/crypto/crypto.c new file mode 100644 index 0000000000..366e25c939 --- /dev/null +++ b/src/lib/libssl/src/crypto/crypto.c @@ -0,0 +1,575 @@ +/* crypto/crypto.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* If you are happy to use the assmbler version of bn/bn_mulw.c, define + * BN_ASM */ +#ifndef BN_ASM +#undef BN_ASM +#define X86_ASM +#endif + +#ifndef DES_ASM +#undef DES_ASM +#endif + +#ifndef BF_ASM +#undef BF_ASM +#endif + +/* The following defines are only to break the compiles into chunks. + * If you wish to not compile some sections, use the 'NO_XXX' macros + */ +#ifndef CRYPTO_SUBSET +/* Define all subset symbols. */ +#define CRYPTO_LIB_SUBSET +#define CRYPTO_ASN1_SUBSET +#define CRYPTO_BN_SUBSET +#define CRYPTO_BUFFER_SUBSET +#define CRYPTO_BIO_SUBSET +#define CRYPTO_CONF_SUBSET +#define CRYPTO_DES_SUBSET +#define CRYPTO_DH_SUBSET +#define CRYPTO_DSA_SUBSET +#define CRYPTO_ERROR_SUBSET +#define CRYPTO_EVP_SUBSET +#define CRYPTO_IDEA_SUBSET +#define CRYPTO_LHASH_SUBSET +#define CRYPTO_MD_SUBSET +#define CRYPTO_MDC2_SUBSET +#define CRYPTO_METH_SUBSET +#define CRYPTO_OBJECTS_SUBSET +#define CRYPTO_PEM_SUBSET +#define CRYPTO_RAND_SUBSET +#define CRYPTO_RC_SUBSET +#define CRYPTO_BLOWFISH_SUBSET +#define CRYPTO_CAST_SUBSET +#define CRYPTO_RSA_SUBSET +#define CRYPTO_SHA_SUBSET +#define CRYPTO_HMAC_SUBSET +#define CRYPTO_SHA1_SUBSET +#define CRYPTO_STACK_SUBSET +#define CRYPTO_TXT_DB_SUBSET +#define CRYPTO_X509_SUBSET +#define CRYPTO_PKCS7_SUBSET +#endif + +#include +#include +#include + +#define USE_SOCKETS +#include "../e_os.h" + +#include "buffer.h" +#include "bio.h" +#include "stack.h" +#include "lhash.h" + +#include "err.h" + +#include "bn.h" +#include "evp.h" + +#include "rand.h" +#include "conf.h" +#include "txt_db.h" + +#include "x509.h" +#include "pkcs7.h" +#include "pem.h" +#include "asn1.h" +#include "objects.h" + +#ifdef CRYPTO_LIB_SUBSET +#include "cryptlib.c" +#include "mem.c" +#include "cversion.c" +#endif + +#ifdef CRYPTO_ASN1_SUBSET +#include "asn1/a_meth.c" +#include "asn1/a_bitstr.c" +#include "asn1/a_d2i_fp.c" +#include "asn1/a_dup.c" +#include "asn1/a_hdr.c" +#include "asn1/a_i2d_fp.c" +#include "asn1/a_int.c" +#include "asn1/a_bool.c" +#include "asn1/a_bytes.c" +#include "asn1/a_object.c" +#include "asn1/a_octet.c" +#include "asn1/a_print.c" +#include "asn1/a_set.c" +#include "asn1/a_sign.c" +#include "asn1/a_type.c" +#include "asn1/a_utctm.c" +#include "asn1/a_verify.c" +#include "asn1/a_digest.c" +#include "asn1/asn1_err.c" +#include "asn1/asn1_lib.c" +#include "asn1/asn1_par.c" +#ifndef NO_DH +#include "asn1/d2i_dhp.c" +#include "asn1/i2d_dhp.c" +#endif +#ifndef NO_DSA +#include "asn1/d2i_dsap.c" +#include "asn1/i2d_dsap.c" +#include "asn1/d2i_s_pr.c" +#include "asn1/i2d_s_pr.c" +#include "asn1/d2i_s_pu.c" +#include "asn1/i2d_s_pu.c" +#endif +#ifndef NO_RSA +#include "asn1/d2i_r_pr.c" +#include "asn1/i2d_r_pr.c" +#include "asn1/d2i_r_pu.c" +#include "asn1/i2d_r_pu.c" +#include "asn1/n_pkey.c" +#endif +#include "asn1/d2i_pr.c" +#include "asn1/d2i_pu.c" +#include "asn1/i2d_pr.c" +#include "asn1/i2d_pu.c" +#include "asn1/f_int.c" +#include "asn1/f_string.c" +#include "asn1/p7_dgst.c" +#include "asn1/p7_enc.c" +#include "asn1/p7_enc_c.c" +#include "asn1/p7_evp.c" +#include "asn1/p7_i_s.c" +#include "asn1/p7_lib.c" +#include "asn1/p7_recip.c" +#include "asn1/p7_s_e.c" +#include "asn1/p7_signd.c" +#include "asn1/p7_signi.c" +#include "asn1/t_pkey.c" +#include "asn1/t_req.c" +#include "asn1/t_x509.c" +#include "asn1/x_algor.c" +#include "asn1/x_attrib.c" +#include "asn1/x_exten.c" +#include "asn1/x_cinf.c" +#include "asn1/x_crl.c" +#include "asn1/x_info.c" +#include "asn1/x_name.c" +#include "asn1/x_pkey.c" +#include "asn1/x_pubkey.c" +#include "asn1/x_req.c" +#include "asn1/x_sig.c" +#include "asn1/x_spki.c" +#include "asn1/x_val.c" +#include "asn1/x_x509.c" +#endif + +#ifdef CRYPTO_BN_SUBSET +#include "bn/bn_add.c" +#include "bn/bn_div.c" +#include "bn/bn_exp.c" +#include "bn/bn_mont.c" +#include "bn/bn_recp.c" +#include "bn/bn_gcd.c" +#include "bn/bn_lib.c" +#include "bn/bn_mod.c" +#include "bn/bn_mul.c" +#ifndef BN_ASM +#include "bn/bn_mulw.c" +#endif +#include "bn/bn_prime.c" +#include "bn/bn_rand.c" +#include "bn/bn_shift.c" +#include "bn/bn_sqr.c" +#include "bn/bn_sub.c" +#include "bn/bn_word.c" +#include "bn/bn_print.c" +#include "bn/bn_err.c" +#include "bn/bn_blind.c" +#endif + +#ifdef CRYPTO_BIO_SUBSET +#include "bio/bf_buff.c" +#include "bio/bf_null.c" +#include "bio/bf_nbio.c" +#include "bio/bio_cb.c" +#include "bio/bio_lib.c" +#include "bio/bss_fd.c" +#include "bio/bss_file.c" +#include "bio/bss_mem.c" +#include "bio/bss_null.c" +#ifdef VMS +#include "bio/bss_rtcp.c" +#endif +#include "bio/bss_sock.c" +#include "bio/bss_conn.c" +#include "bio/bss_acpt.c" +#include "bio/b_sock.c" +#include "bio/b_print.c" +#include "bio/b_dump.c" +#include "bio/bio_err.c" +#endif + +#ifdef CRYPTO_BUFFER_SUBSET +#include "buffer/buf_err.c" +#include "buffer/buffer.c" +#endif + +#ifdef CRYPTO_CONF_SUBSET +#include "conf/conf.c" +#include "conf/conf_err.c" +#endif + +#ifdef CRYPTO_DES_SUBSET +#include "des/read_pwd.c" +#ifndef NO_DES +#ifndef DES_ASM +#include "des/fcrypt_b.c" +#include "des/des_enc.c" +#endif +#include "des/cbc_cksm.c" +#include "des/xcbc_enc.c" +#include "des/cbc_enc.c" +#include "des/cfb64ede.c" +#include "des/cfb64enc.c" +#include "des/cfb_enc.c" +#include "des/ecb3_enc.c" +#include "des/ecb_enc.c" +#include "des/enc_read.c" +#include "des/enc_writ.c" +#include "des/fcrypt.c" +#include "des/ofb64ede.c" +#include "des/ofb64enc.c" +#include "des/ofb_enc.c" +#include "des/pcbc_enc.c" +#include "des/qud_cksm.c" +#include "des/rand_key.c" +#include "des/read2pwd.c" +#include "des/rpc_enc.c" +#include "des/set_key.c" +#include "des/str2key.c" +#include "des/supp.c" +#endif +#endif + +#ifdef CRYPTO_DH_SUBSET +#ifndef NO_DH +#include "dh/dh_check.c" +#include "dh/dh_err.c" +#include "dh/dh_gen.c" +#include "dh/dh_key.c" +#include "dh/dh_lib.c" +#endif +#endif + +#ifdef CRYPTO_DSA_SUBSET +#ifndef NO_DSA +#include "dsa/dsa_gen.c" +#include "dsa/dsa_key.c" +#include "dsa/dsa_lib.c" +#include "dsa/dsa_sign.c" +#include "dsa/dsa_vrf.c" +#include "dsa/dsa_err.c" +#endif +#endif + +#ifdef CRYPTO_ERROR_SUBSET +#include "err/err.c" +#include "err/err_all.c" +#include "err/err_prn.c" +#endif + +#ifdef CRYPTO_EVP_SUBSET +#include "evp/bio_md.c" +#include "evp/bio_b64.c" +#include "evp/bio_enc.c" +#include "evp/c_all.c" +#include "evp/digest.c" +#ifndef NO_DES +#include "evp/e_cbc_3d.c" +#include "evp/e_cfb_3d.c" +#include "evp/e_ecb_3d.c" +#include "evp/e_ofb_3d.c" +#include "evp/e_cbc_d.c" +#include "evp/e_cfb_d.c" +#include "evp/e_xcbc_d.c" +#include "evp/e_ecb_d.c" +#include "evp/e_ofb_d.c" +#endif +#ifndef NO_IDEA +#include "evp/e_cbc_i.c" +#include "evp/e_cfb_i.c" +#include "evp/e_ecb_i.c" +#include "evp/e_ofb_i.c" +#endif +#ifndef NO_RC2 +#include "evp/e_cbc_r2.c" +#include "evp/e_cfb_r2.c" +#include "evp/e_ecb_r2.c" +#include "evp/e_ofb_r2.c" +#endif +#ifndef NO_BLOWFISH +#include "evp/e_cbc_bf.c" +#include "evp/e_cfb_bf.c" +#include "evp/e_ecb_bf.c" +#include "evp/e_ofb_bf.c" +#endif +#ifndef NO_CAST +#include "evp/e_cbc_c.c" +#include "evp/e_cfb_c.c" +#include "evp/e_ecb_c.c" +#include "evp/e_ofb_c.c" +#endif +#ifndef NO_RC4 +#include "evp/e_rc4.c" +#endif +#include "rc5/rc5_enc.c" +#include "rc5/rc5cfb64.c" +#include "rc5/rc5_ecb.c" +#include "rc5/rc5_skey.c" +#include "rc5/rc5ofb64.c" +#include "ripemd/rmd160.c" +#include "ripemd/rmd_dgst.c" +#include "ripemd/rmd_one.c" +#include "evp/evp_lib.c" + +#include "evp/names.c" +#include "evp/e_null.c" +#include "evp/encode.c" +#include "evp/evp_enc.c" +#include "evp/evp_err.c" +#include "evp/evp_key.c" +#include "evp/m_null.c" +#include "evp/p_lib.c" +#ifndef NO_RSA +#include "evp/p_open.c" +#include "evp/p_seal.c" +#endif +#include "evp/p_sign.c" +#include "evp/p_verify.c" +#endif + +#ifdef CRYPTO_IDEA_SUBSET +#ifndef NO_IDEA +#include "idea/i_cbc.c" +#include "idea/i_cfb64.c" +#include "idea/i_ecb.c" +#include "idea/i_ofb64.c" +#include "idea/i_skey.c" +#endif +#endif + +#ifdef CRYPTO_BLOWFISH_SUBSET +#ifndef NO_BLOWFISH +#include "bf/bf_cfb64.c" +#include "bf/bf_ecb.c" +#ifndef BF_ASM +#include "bf/bf_enc.c" +#endif +#include "bf/bf_ofb64.c" +#include "bf/bf_skey.c" +#endif +#endif + +#ifdef CRYPTO_CAST_SUBSET +#ifndef NO_CAST +#include "cast/c_cfb64.c" +#include "cast/c_ecb.c" +#ifndef CAST_ASM +#include "cast/c_enc.c" +#endif +#include "cast/c_ofb64.c" +#include "cast/c_skey.c" +#endif +#endif + +#ifdef CRYPTO_LHASH_SUBSET +#include "lhash/lh_stats.c" +#include "lhash/lhash.c" +#endif + +#ifdef CRYPTO_MD_SUBSET +#ifndef NO_MD2 +#include "md2/md2_dgst.c" +#include "md2/md2_one.c" +#include "evp/m_md2.c" +#endif +#ifndef NO_MD5 +#include "md5/md5_dgst.c" +#include "md5/md5_one.c" +#include "evp/m_md5.c" +#endif +#endif + +#ifdef CRYPTO_MDC2_SUBSET +#ifndef NO_MDC2 +#include "mdc2/mdc2dgst.c" +#include "mdc2/mdc2_one.c" +#include "evp/m_mdc2.c" +#endif +#endif + +#ifdef CRYPTO_OBJECTS_SUBSET +#include "objects/obj_dat.c" +#include "objects/obj_err.c" +#include "objects/obj_lib.c" +#endif + +#ifdef CRYPTO_PEM_SUBSET +#include "pem/pem_err.c" +#include "pem/pem_info.c" +#include "pem/pem_lib.c" +#include "pem/pem_all.c" +#ifndef NO_RSA +#include "pem/pem_seal.c" +#include "pem/pem_sign.c" +#endif +#endif + +#ifdef CRYPTO_RAND_SUBSET +#include "rand/md_rand.c" +#include "rand/randfile.c" +#endif + +#ifdef CRYPTO_RC_SUBSET +#ifndef NO_RC2 +#include "rc2/rc2_cbc.c" +#include "rc2/rc2_ecb.c" +#include "rc2/rc2_skey.c" +#include "rc2/rc2cfb64.c" +#include "rc2/rc2ofb64.c" +#endif +#ifndef NO_RC4 +#include "rc4/rc4_skey.c" +#ifndef RC4_ASM +#include "rc4/rc4_enc.c" +#endif +#endif +#endif + +#ifdef CRYPTO_HMAC_SUBSET +#include "hmac/hmac.c" +#endif + +#ifdef CRYPTO_RSA_SUBSET +#ifndef NO_RSA +#include "rsa/rsa_eay.c" +#include "rsa/rsa_err.c" +#include "rsa/rsa_gen.c" +#include "rsa/rsa_lib.c" +#include "rsa/rsa_sign.c" +#include "rsa/rsa_saos.c" +#endif +#endif + +#ifdef CRYPTO_SHA1_SUBSET +#ifndef NO_SHA1 +#include "sha/sha1_one.c" +#include "sha/sha1dgst.c" +#include "evp/m_dss1.c" +#include "evp/m_sha1.c" +#endif +#endif + +#ifdef CRYPTO_SHA_SUBSET +#ifndef NO_SHA +#include "evp/m_dss.c" +#include "sha/sha_dgst.c" +#include "sha/sha_one.c" +#include "evp/m_sha.c" +#endif +#endif + +#ifdef CRYPTO_STACK_SUBSET +#include "stack/stack.c" +#endif + +#ifdef CRYPTO_TXT_DB_SUBSET +#include "txt_db/txt_db.c" +#endif + +#ifdef CRYPTO_X509_SUBSET +#include "x509/x509_cmp.c" +#include "x509/x509_d2.c" +#include "x509/x509_def.c" +#include "x509/x509_err.c" +#include "x509/x509_ext.c" +#include "x509/x509_lu.c" +#include "x509/x509_obj.c" +#include "x509/x509_r2x.c" +#include "x509/x509_req.c" +#include "x509/x509_set.c" +#include "x509/x509_v3.c" +#include "x509/x509_vfy.c" +#include "x509/x509name.c" +#include "x509/x509pack.c" +#include "x509/x509rset.c" +#include "x509/x509type.c" +#include "x509/x_all.c" +#include "x509/x509_txt.c" +#include "x509/by_dir.c" +#include "x509/by_file.c" +#include "x509/v3_net.c" +#include "x509/v3_x509.c" +#endif + + +#ifdef CRYPTO_PKCS7_SUBSET /* I have an explicit removal of 7 lines */ +#include "pkcs7/pk7_lib.c" +#include "pkcs7/pkcs7err.c" +#include "pkcs7/pk7_doit.c" +#endif /* CRYPTO_PKCS7_SUBSET */ + diff --git a/src/lib/libssl/src/crypto/crypto.err b/src/lib/libssl/src/crypto/crypto.err new file mode 100644 index 0000000000..4ea3385e73 --- /dev/null +++ b/src/lib/libssl/src/crypto/crypto.err @@ -0,0 +1,8 @@ +/* Error codes for the CRYPTO functions. */ + +/* Function codes. */ +#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 +#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 + +/* Reason codes. */ diff --git a/src/lib/libssl/src/crypto/date.h b/src/lib/libssl/src/crypto/date.h new file mode 100644 index 0000000000..dbb71bd1b7 --- /dev/null +++ b/src/lib/libssl/src/crypto/date.h @@ -0,0 +1 @@ +#define DATE "Sun Jul 12 21:04:32 MDT 1998" diff --git a/src/lib/libssl/src/crypto/des/DES.pod b/src/lib/libssl/src/crypto/des/DES.pod new file mode 100644 index 0000000000..8a739e7ca0 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/DES.pod @@ -0,0 +1,16 @@ +crypt <= crypt(buf,salt) +key <= set_odd_parity(key) +int <= is_weak_key(key) +keysched<= set_key(key) +key <= ecb_encrypt(string8,ks,enc) +key <= ecb3_encrypt(input,ks1,ks2,enc) +string <= cbc_encrypt(input,ks,ivec,enc) => ivec +string <= cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,enc) => ivec1&ivec2 +ck1,ck2 <= cbc_cksum(input,ks,ivec) => ivec +string <= pcbc_encrypt(input,ks,ivec,enc) => ivec +string <= ofb_encrypt(input,numbits,ks,ivec) => ivec +string <= cfb_encrypt(input,numbits,ks,ivec,enc) => ivec +key <= random_key() +key <= string_to_key(string) +key1,key2<= string_to_2keys(string) + diff --git a/src/lib/libssl/src/crypto/des/FILES b/src/lib/libssl/src/crypto/des/FILES new file mode 100644 index 0000000000..4c7ea2de7a --- /dev/null +++ b/src/lib/libssl/src/crypto/des/FILES @@ -0,0 +1,96 @@ +/* General stuff */ +COPYRIGHT - Copyright info. +MODES.DES - A description of the features of the different modes of DES. +FILES - This file. +INSTALL - How to make things compile. +Imakefile - For use with kerberos. +README - What this package is. +VERSION - Which version this is and what was changed. +KERBEROS - Kerberos version 4 notes. +Makefile.PL - An old makefile to build with perl5, not current. +Makefile.ssl - The SSLeay makefile +Makefile.uni - The normal unix makefile. +GNUmakefile - The makefile for use with glibc. +makefile.bc - A Borland C makefile +times - Some outputs from 'speed' on some machines. +vms.com - For use when compiling under VMS + +/* My SunOS des(1) replacement */ +des.c - des(1) source code. +des.man - des(1) manual. + +/* Testing and timing programs. */ +destest.c - Source for libdes.a test program. +speed.c - Source for libdes.a timing program. +rpw.c - Source for libdes.a testing password reading routines. + +/* libdes.a source code */ +des_crypt.man - libdes.a manual page. +des.h - Public libdes.a header file. +ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code. +ecb3_enc.c - des_ecb3_encrypt() source. +cbc_ckm.c - des_cbc_cksum() source. +cbc_enc.c - des_cbc_encrypt() source. +ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies + the new iv values back in the passed iv vector. +ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES. +cbc3_enc.c - des_3cbc_encrypt() source, don't use this function. +cfb_enc.c - des_cfb_encrypt() source. +cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be + used as a stream cipher. +cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be + used as a stream cipher and using triple DES. +ofb_enc.c - des_cfb_encrypt() source. +ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be + used as a stream cipher. +ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be + used as a stream cipher and using triple DES. +enc_read.c - des_enc_read() source. +enc_writ.c - des_enc_write() source. +pcbc_enc.c - des_pcbc_encrypt() source. +qud_cksm.c - quad_cksum() source. +rand_key.c - des_random_key() source. +read_pwd.c - Source for des_read_password() plus related functions. +set_key.c - Source for des_set_key(). +str2key.c - Covert a string of any length into a key. +fcrypt.c - A small, fast version of crypt(3). +des_locl.h - Internal libdes.a header file. +podd.h - Odd parity tables - used in des_set_key(). +sk.h - Lookup tables used in des_set_key(). +spr.h - What is left of the S tables - used in ecb_encrypt(). +des_ver.h - header file for the external definition of the + version string. +des.doc - SSLeay documentation for the library. + +/* The perl scripts - you can ignore these files they are only + * included for the curious */ +des.pl - des in perl anyone? des_set_key and des_ecb_encrypt + both done in a perl library. +testdes.pl - Testing program for des.pl +doIP - Perl script used to develop IP xor/shift code. +doPC1 - Perl script used to develop PC1 xor/shift code. +doPC2 - Generates sk.h. +PC1 - Output of doPC1 should be the same as output from PC1. +PC2 - used in development of doPC2. +shifts.pl - Perl library used by my perl scripts. + +/* I started making a perl5 dynamic library for libdes + * but did not fully finish, these files are part of that effort. */ +DES.pm +DES.pod +DES.xs +t +typemap + +/* The following are for use with sun RPC implementaions. */ +rpc_des.h +rpc_enc.c + +/* The following are contibuted by Mark Murray . They + * are not normally built into libdes due to machine specific routines + * contained in them. They are for use in the most recent incarnation of + * export kerberos v 4 (eBones). */ +supp.c +new_rkey.c + + diff --git a/src/lib/libssl/src/crypto/des/MODES.DES b/src/lib/libssl/src/crypto/des/MODES.DES new file mode 100644 index 0000000000..0cbc44f51d --- /dev/null +++ b/src/lib/libssl/src/crypto/des/MODES.DES @@ -0,0 +1,84 @@ +Modes of DES +Quite a bit of the following information has been taken from + AS 2805.5.2 + Australian Standard + Electronic funds transfer - Requirements for interfaces, + Part 5.2: Modes of operation for an n-bit block cipher algorithm + Appendix A + +There are several different modes in which DES can be used, they are +as follows. + +Electronic Codebook Mode (ECB) (des_ecb_encrypt()) +- 64 bits are enciphered at a time. +- The order of the blocks can be rearranged without detection. +- The same plaintext block always produces the same ciphertext block + (for the same key) making it vulnerable to a 'dictionary attack'. +- An error will only affect one ciphertext block. + +Cipher Block Chaining Mode (CBC) (des_cbc_encrypt()) +- a multiple of 64 bits are enciphered at a time. +- The CBC mode produces the same ciphertext whenever the same + plaintext is encrypted using the same key and starting variable. +- The chaining operation makes the ciphertext blocks dependent on the + current and all preceding plaintext blocks and therefore blocks can not + be rearranged. +- The use of different starting variables prevents the same plaintext + enciphering to the same ciphertext. +- An error will affect the current and the following ciphertext blocks. + +Cipher Feedback Mode (CFB) (des_cfb_encrypt()) +- a number of bits (j) <= 64 are enciphered at a time. +- The CFB mode produces the same ciphertext whenever the same + plaintext is encrypted using the same key and starting variable. +- The chaining operation makes the ciphertext variables dependent on the + current and all preceding variables and therefore j-bit variables are + chained together and con not be rearranged. +- The use of different starting variables prevents the same plaintext + enciphering to the same ciphertext. +- The strength of the CFB mode depends on the size of k (maximal if + j == k). In my implementation this is always the case. +- Selection of a small value for j will require more cycles through + the encipherment algorithm per unit of plaintext and thus cause + greater processing overheads. +- Only multiples of j bits can be enciphered. +- An error will affect the current and the following ciphertext variables. + +Output Feedback Mode (OFB) (des_ofb_encrypt()) +- a number of bits (j) <= 64 are enciphered at a time. +- The OFB mode produces the same ciphertext whenever the same + plaintext enciphered using the same key and starting variable. More + over, in the OFB mode the same key stream is produced when the same + key and start variable are used. Consequently, for security reasons + a specific start variable should be used only once for a given key. +- The absence of chaining makes the OFB more vulnerable to specific attacks. +- The use of different start variables values prevents the same + plaintext enciphering to the same ciphertext, by producing different + key streams. +- Selection of a small value for j will require more cycles through + the encipherment algorithm per unit of plaintext and thus cause + greater processing overheads. +- Only multiples of j bits can be enciphered. +- OFB mode of operation does not extend ciphertext errors in the + resultant plaintext output. Every bit error in the ciphertext causes + only one bit to be in error in the deciphered plaintext. +- OFB mode is not self-synchronising. If the two operation of + encipherment and decipherment get out of synchronism, the system needs + to be re-initialised. +- Each re-initialisation should use a value of the start variable +different from the start variable values used before with the same +key. The reason for this is that an identical bit stream would be +produced each time from the same parameters. This would be +susceptible to a 'known plaintext' attack. + +Triple ECB Mode (des_ecb3_encrypt()) +- Encrypt with key1, decrypt with key2 and encrypt with key1 again. +- As for ECB encryption but increases the effective key length to 112 bits. +- If both keys are the same it is equivalent to encrypting once with + just one key. + +Triple CBC Mode (des_3cbc_encrypt()) +- Encrypt with key1, decrypt with key2 and encrypt with key1 again. +- As for CBC encryption but increases the effective key length to 112 bits. +- If both keys are the same it is equivalent to encrypting once with + just one key. diff --git a/src/lib/libssl/src/crypto/des/Makefile.PL b/src/lib/libssl/src/crypto/des/Makefile.PL new file mode 100644 index 0000000000..b54a24387c --- /dev/null +++ b/src/lib/libssl/src/crypto/des/Makefile.PL @@ -0,0 +1,14 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile being created. +&writeMakefile( + 'potential_libs' => '', # e.g., '-lm' + 'INC' => '', # e.g., '-I/usr/include/other' + 'DISTNAME' => 'DES', + 'VERSION' => '0.1', + 'DEFINE' => '-DPERL5', + 'OBJECT' => 'DES.o cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \ + rand_key.o set_key.o str2key.o \ + enc_read.o enc_writ.o fcrypt.o cfb_enc.o \ + ecb3_enc.o ofb_enc.o cbc3_enc.o des_enc.o', + ); diff --git a/src/lib/libssl/src/crypto/des/Makefile.lit b/src/lib/libssl/src/crypto/des/Makefile.lit new file mode 100644 index 0000000000..c09f6969da --- /dev/null +++ b/src/lib/libssl/src/crypto/des/Makefile.lit @@ -0,0 +1,250 @@ +# You must select the correct terminal control system to be used to +# turn character echo off when reading passwords. There a 5 systems +# SGTTY - the old BSD system +# TERMIO - most system V boxes +# TERMIOS - SGI (ala IRIX). +# VMS - the DEC operating system +# MSDOS - we all know what it is :-) +# read_pwd.c makes a reasonable guess at what is correct. + +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +# If you are on a DEC Alpha, edit des.h and change the DES_LONG +# define to 'unsigned int'. I have seen this give a %20 speedup. + +OPTS0= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST + +# Version 1.94 has changed the strings_to_key function so that it is +# now compatible with MITs when the string is longer than 8 characters. +# If you wish to keep the old version, uncomment the following line. +# This will affect the -E/-D options on des(1). +#OPTS1= -DOLD_STR_TO_KEY + +# There are 4 possible performance options +# -DDES_PTR +# -DDES_RISC1 +# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2) +# -DDES_UNROLL +# after the initial build, run 'des_opts' to see which options are best +# for your platform. There are some listed in options.txt +#OPTS2= -DDES_PTR +#OPTS3= -DDES_RISC1 # or DES_RISC2 +#OPTS4= -DDES_UNROLL + +OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4) + +MAKE=make -f Makefile +#CC=cc +#CFLAG= -O + +CC=gcc +#CFLAG= -O4 -funroll-loops -fomit-frame-pointer +CFLAG= -O3 -fomit-frame-pointer + +CFLAGS=$(OPTS) $(CFLAG) +CPP=$(CC) -E +AS=as + +# Assember version of des_encrypt*(). +DES_ENC=des_enc.o fcrypt_b.o # normal C version +#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86 +#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86 +#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86 +#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86 + +LIBDIR=/usr/local/lib +BINDIR=/usr/local/bin +INCDIR=/usr/local/include +MANDIR=/usr/local/man +MAN1=1 +MAN3=3 +SHELL=/bin/sh +OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o +OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \ + xcbc_enc.o qud_cksm.o \ + cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \ + enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \ + rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o + +GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \ + des.doc options.txt asm +GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \ + des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \ + Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \ + des.org des_locl.org +TESTING_LIT= destest speed des_opts +TESTING_FULL= rpw $(TESTING_LIT) +TESTING_SRC_LIT=destest.c speed.c des_opts.c +TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT) +HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h +HEADERS_FULL= $(HEADERS_LIT) rpc_des.h +LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c +LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \ + cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \ + enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \ + rand_key.c rpc_enc.c str2key.c supp.c \ + xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c + +PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl + +OBJ= $(OBJ_LIT) +GENERAL=$(GENERAL_LIT) +TESTING=$(TESTING_LIT) +TESTING_SRC=$(TESTING_SRC_LIT) +HEADERS=$(HEADERS_LIT) +LIBDES= $(LIBDES_LIT) + +ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS) + +DLIB= libdes.a + +all: $(DLIB) $(TESTING) + +cc: + $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all + +gcc: + $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all + +x86-elf: + $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all + +x86-out: + $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all + +x86-solaris: + $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all + +x86-bsdi: + $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all + +# elf +asm/dx86-elf.o: asm/dx86unix.cpp + $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o + +asm/yx86-elf.o: asm/yx86unix.cpp + $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o + +# solaris +asm/dx86-sol.o: asm/dx86unix.cpp + $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s + as -o asm/dx86-sol.o asm/dx86-sol.s + rm -f asm/dx86-sol.s + +asm/yx86-sol.o: asm/yx86unix.cpp + $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s + as -o asm/yx86-sol.o asm/yx86-sol.s + rm -f asm/yx86-sol.s + +# a.out +asm/dx86-out.o: asm/dx86unix.cpp + $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o + +asm/yx86-out.o: asm/yx86unix.cpp + $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o + +# bsdi +asm/dx86bsdi.o: asm/dx86unix.cpp + $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o + +asm/yx86bsdi.o: asm/yx86unix.cpp + $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o + +asm/dx86unix.cpp: + (cd asm; perl des-586.pl cpp >dx86unix.cpp) + +asm/yx86unix.cpp: + (cd asm; perl crypt586.pl cpp >yx86unix.cpp) + +test: all + ./destest + +$(DLIB): $(OBJ) + /bin/rm -f $(DLIB) + ar cr $(DLIB) $(OBJ) + -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \ + else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \ + else exit 0; fi; fi + +des_opts: des_opts.o $(DLIB) + $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB) + +destest: destest.o $(DLIB) + $(CC) $(CFLAGS) -o destest destest.o $(DLIB) + +rpw: rpw.o $(DLIB) + $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB) + +speed: speed.o $(DLIB) + $(CC) $(CFLAGS) -o speed speed.o $(DLIB) + +des: des.o $(DLIB) + $(CC) $(CFLAGS) -o des des.o $(DLIB) + +tags: + ctags $(TESTING_SRC) $(LIBDES) + +tar_lit: + /bin/mv Makefile Makefile.tmp + /bin/cp Makefile.lit Makefile + tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \ + $(GENERAL_LIT) $(TESTING_SRC_LIT) + /bin/rm -f Makefile + /bin/mv Makefile.tmp Makefile + +tar: + tar chf libdes.tar $(ALL) + +shar: + shar $(ALL) >libdes.shar + +depend: + makedepend $(LIBDES) $(TESTING_SRC) + +clean: + /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o + +dclean: + sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new + mv -f Makefile.new Makefile + +# Eric is probably going to choke when he next looks at this --tjh +install: + if test $(INSTALLTOP); then \ + echo SSL style install; \ + cp $(DLIB) $(INSTALLTOP)/lib; \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + fi; fi; \ + chmod 644 $(INSTALLTOP)/lib/$(DLIB); \ + cp des.h $(INSTALLTOP)/include; \ + chmod 644 $(INSTALLTOP)/include/des.h; \ + else \ + echo Standalone install; \ + cp $(DLIB) $(LIBDIR)/$(DLIB); \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(LIBDIR)/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(LIBDIR)/$(DLIB); \ + fi; \ + fi; \ + chmod 644 $(LIBDIR)/$(DLIB); \ + cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + cp des.h $(INCDIR)/des.h; \ + chmod 644 $(INCDIR)/des.h; \ + fi +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/des/Makefile.ssl b/src/lib/libssl/src/crypto/des/Makefile.ssl new file mode 100644 index 0000000000..78b5189ee3 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/Makefile.ssl @@ -0,0 +1,140 @@ +# +# SSLeay/crypto/des/Makefile +# + +DIR= des +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r +DES_ENC= des_enc.o fcrypt_b.o +# or use +#DES_ENC= dx86-elf.o yx86-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile des.org des_locl.org +TEST=destest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ + ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \ + fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ + qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ + des_enc.c fcrypt_b.c read2pwd.c \ + fcrypt.c xcbc_enc.c \ + str2key.c cfb64ede.c ofb64ede.c supp.c + +LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ + ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ + enc_read.o enc_writ.o ofb64enc.o \ + ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ + ${DES_ENC} read2pwd.o \ + fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o + +SRC= $(LIBSRC) + +EXHEADER= des.h +HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/dx86-elf.o: asm/dx86unix.cpp + $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o + +asm/yx86-elf.o: asm/yx86unix.cpp + $(CPP) -DELF asm/yx86unix.cpp | as -o asm/yx86-elf.o + +# solaris +asm/dx86-sol.o: asm/dx86unix.cpp + $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s + as -o asm/dx86-sol.o asm/dx86-sol.s + rm -f asm/dx86-sol.s + +asm/yx86-sol.o: asm/yx86unix.cpp + $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s + as -o asm/yx86-sol.o asm/yx86-sol.s + rm -f asm/yx86-sol.s + +# a.out +asm/dx86-out.o: asm/dx86unix.cpp + $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o + +asm/yx86-out.o: asm/yx86unix.cpp + $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o + +# bsdi +asm/dx86bsdi.o: asm/dx86unix.cpp + $(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o + +asm/yx86bsdi.o: asm/yx86unix.cpp + $(CPP) -DBSDI asm/yx86unix.cpp | as -o asm/yx86bsdi.o + +asm/dx86unix.cpp: + (cd asm; perl des-586.pl cpp >dx86unix.cpp) + +asm/yx86unix.cpp: + (cd asm; perl crypt586.pl cpp >yx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile + /bin/rm -f des.doc + /bin/rm -fr asm/perlasm + $(TOP)/util/point.sh ../../perlasm asm/perlasm + $(TOP)/util/point.sh ../../doc/des.doc des.doc + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: installs + +installs: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/des/Makefile.uni b/src/lib/libssl/src/crypto/des/Makefile.uni new file mode 100644 index 0000000000..8f1759748a --- /dev/null +++ b/src/lib/libssl/src/crypto/des/Makefile.uni @@ -0,0 +1,263 @@ +# You must select the correct terminal control system to be used to +# turn character echo off when reading passwords. There a 5 systems +# SGTTY - the old BSD system +# TERMIO - most system V boxes +# TERMIOS - SGI (ala IRIX). +# VMS - the DEC operating system +# MSDOS - we all know what it is :-) +# read_pwd.c makes a reasonable guess at what is correct. + +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +# If you are on a DEC Alpha, edit des.h and change the DES_LONG +# define to 'unsigned int'. I have seen this give a %20 speedup. + +OPTS0= -DRAND -DTERMIO #-DNOCONST + +# Version 1.94 has changed the strings_to_key function so that it is +# now compatible with MITs when the string is longer than 8 characters. +# If you wish to keep the old version, uncomment the following line. +# This will affect the -E/-D options on des(1). +#OPTS1= -DOLD_STR_TO_KEY + +# There are 4 possible performance options +# -DDES_PTR +# -DDES_RISC1 +# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2) +# -DDES_UNROLL +# after the initial build, run 'des_opts' to see which options are best +# for your platform. There are some listed in options.txt +#OPTS2= -DDES_PTR +#OPTS3= -DDES_RISC1 # or DES_RISC2 +#OPTS4= -DDES_UNROLL + +OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4) + +MAKE=make -f Makefile +#CC=cc +#CFLAG= -O + +CC=gcc +#CFLAG= -O4 -funroll-loops -fomit-frame-pointer +CFLAG= -O3 -fomit-frame-pointer + +CFLAGS=$(OPTS) $(CFLAG) +CPP=$(CC) -E +AS=as + +# Assember version of des_encrypt*(). +DES_ENC=des_enc.o fcrypt_b.o # normal C version +#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86 +#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86 +#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86 +#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86 + +LIBDIR=/usr/local/lib +BINDIR=/usr/local/bin +INCDIR=/usr/local/include +MANDIR=/usr/local/man +MAN1=1 +MAN3=3 +SHELL=/bin/sh +OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o +OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \ + xcbc_enc.o qud_cksm.o cbc3_enc.o \ + cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \ + enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \ + rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o + +GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \ + des.doc options.txt asm +GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \ + des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \ + Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \ + des.org des_locl.org +TESTING_LIT= destest speed des_opts +TESTING_FULL= rpw des $(TESTING_LIT) +TESTING_SRC_LIT=destest.c speed.c des_opts.c +TESTING_SRC_FULL=rpw.c des.c $(TESTING_SRC_LIT) +HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h +HEADERS_FULL= $(HEADERS_LIT) rpc_des.h +LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c +LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c cbc3_enc.c \ + cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \ + enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \ + rand_key.c rpc_enc.c str2key.c supp.c \ + xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c + +PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl + +OBJ= $(OBJ_FULL) +GENERAL=$(GENERAL_FULL) +TESTING=$(TESTING_FULL) +TESTING_SRC=$(TESTING_SRC_FULL) +HEADERS=$(HEADERS_FULL) +LIBDES= $(LIBDES_FULL) + +ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS) + +DLIB= libdes.a + +all: $(DLIB) $(TESTING) + +cc: + $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all + +gcc: + $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all + +x86-elf: + $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all + +x86-out: + $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all + +x86-solaris: + $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all + +x86-bsdi: + $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all + +# elf +asm/dx86-elf.o: asm/dx86unix.cpp + $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o + +asm/yx86-elf.o: asm/yx86unix.cpp + $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o + +# solaris +asm/dx86-sol.o: asm/dx86unix.cpp + $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s + as -o asm/dx86-sol.o asm/dx86-sol.s + rm -f asm/dx86-sol.s + +asm/yx86-sol.o: asm/yx86unix.cpp + $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s + as -o asm/yx86-sol.o asm/yx86-sol.s + rm -f asm/yx86-sol.s + +# a.out +asm/dx86-out.o: asm/dx86unix.cpp + $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o + +asm/yx86-out.o: asm/yx86unix.cpp + $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o + +# bsdi +asm/dx86bsdi.o: asm/dx86unix.cpp + $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o + +asm/yx86bsdi.o: asm/yx86unix.cpp + $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o + +asm/dx86unix.cpp: + (cd asm; perl des-586.pl cpp >dx86unix.cpp) + +asm/yx86unix.cpp: + (cd asm; perl crypt586.pl cpp >yx86unix.cpp) + +test: all + ./destest + +$(DLIB): $(OBJ) + /bin/rm -f $(DLIB) + ar cr $(DLIB) $(OBJ) + -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \ + else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \ + else exit 0; fi; fi + +des_opts: des_opts.o $(DLIB) + $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB) + +destest: destest.o $(DLIB) + $(CC) $(CFLAGS) -o destest destest.o $(DLIB) + +rpw: rpw.o $(DLIB) + $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB) + +speed: speed.o $(DLIB) + $(CC) $(CFLAGS) -o speed speed.o $(DLIB) + +des: des.o $(DLIB) + $(CC) $(CFLAGS) -o des des.o $(DLIB) + +tags: + ctags $(TESTING_SRC) $(LIBDES) + +tar_lit: + /bin/mv Makefile Makefile.tmp + /bin/cp Makefile.lit Makefile + for i in $(HEADERS_LIT) $(LIBDES_LIT) $(GENERAL_LIT) $(TESTING_SRC_LIT) ;\ + do \ + n="$$n des/$$i"; \ + done; \ + ( cd .. ; tar chf - $$n )| gzip > libdes-l.tgz + /bin/rm -f Makefile + /bin/mv Makefile.tmp Makefile + +tar: + mv Makefile Makefile.tmp + /bin/cp Makefile.uni Makefile + for i in $(ALL) ;\ + do \ + n="$$n des/$$i"; \ + done; \ + ( cd .. ; tar chf - $$n )| gzip > libdes.tgz + /bin/rm -f Makefile + /bin/mv Makefile.tmp Makefile + +shar: + shar $(ALL) >libdes.shar + +depend: + makedepend $(LIBDES) $(TESTING_SRC) + +clean: + /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o + +dclean: + sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new + mv -f Makefile.new Makefile + +# Eric is probably going to choke when he next looks at this --tjh +install: des + if test $(INSTALLTOP); then \ + echo SSL style install; \ + cp $(DLIB) $(INSTALLTOP)/lib; \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \ + fi; fi; \ + chmod 644 $(INSTALLTOP)/lib/$(DLIB); \ + cp des.h $(INSTALLTOP)/include; \ + chmod 644 $(INSTALLTOP)/include/des.h; \ + else \ + echo Standalone install; \ + cp $(DLIB) $(LIBDIR)/$(DLIB); \ + if test -s /bin/ranlib; then \ + /bin/ranlib $(LIBDIR)/$(DLIB); \ + else \ + if test -s /usr/bin/ranlib; then \ + /usr/bin/ranlib $(LIBDIR)/$(DLIB); \ + fi; \ + fi; \ + chmod 644 $(LIBDIR)/$(DLIB); \ + cp des $(BINDIR)/des; \ + chmod 711 $(BINDIR)/des; \ + cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \ + cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \ + cp des.h $(INCDIR)/des.h; \ + chmod 644 $(INCDIR)/des.h; \ + fi +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/des/PC1 b/src/lib/libssl/src/crypto/des/PC1 new file mode 100644 index 0000000000..efb8348b72 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/PC1 @@ -0,0 +1,28 @@ +#!/usr/local/bin/perl + +@PC1=( 57,49,41,33,25,17, 9, + 1,58,50,42,34,26,18, + 10, 2,59,51,43,35,27, + 19,11, 3,60,52,44,36, + "-","-","-","-", + 63,55,47,39,31,23,15, + 7,62,54,46,38,30,22, + 14, 6,61,53,45,37,29, + 21,13, 5,28,20,12, 4, + "-","-","-","-", + ); + +foreach (@PC1) + { + if ($_ ne "-") + { + $_--; + $_=int($_/8)*8+7-($_%8); + printf "%2d ",$_; + } + else + { print "-- "; } + print "\n" if (((++$i) % 8) == 0); + print "\n" if ((($i) % 32) == 0); + } + diff --git a/src/lib/libssl/src/crypto/des/PC2 b/src/lib/libssl/src/crypto/des/PC2 new file mode 100644 index 0000000000..2d560270ec --- /dev/null +++ b/src/lib/libssl/src/crypto/des/PC2 @@ -0,0 +1,57 @@ +#!/usr/local/bin/perl + +@PC2_C=(14,17,11,24, 1, 5, + 3,28,15, 6,21,10, + 23,19,12, 4,26, 8, + 16, 7,27,20,13, 2, + ); + +@PC2_D=(41,52,31,37,47,55, + 30,40,51,45,33,48, + 44,49,39,56,34,53, + 46,42,50,36,29,32, + ); + +foreach (@PC2_C) { + if ($_ ne "-") + { + $_--; + printf "%2d ",$_; } + else { print "-- "; } + $C{$_}=1; + print "\n" if (((++$i) % 8) == 0); + } +$i=0; +print "\n"; +foreach (@PC2_D) { + if ($_ ne "-") + { + $_-=29; + printf "%2d ",$_; } + else { print "-- "; } + $D{$_}=1; + print "\n" if (((++$i) % 8) == 0); } + +print "\n"; +foreach $i (0 .. 27) + { + $_=$C{$i}; + if ($_ ne "-") {printf "%2d ",$_;} + else { print "-- "; } + print "\n" if (((++$i) % 8) == 0); + } +print "\n"; + +print "\n"; +foreach $i (0 .. 27) + { + $_=$D{$i}; + if ($_ ne "-") {printf "%2d ",$_;} + else { print "-- "; } + print "\n" if (((++$i) % 8) == 0); + } +print "\n"; +sub numsort + { + $a-$b; + } diff --git a/src/lib/libssl/src/crypto/des/asm/d-win32.asm b/src/lib/libssl/src/crypto/des/asm/d-win32.asm new file mode 100644 index 0000000000..9e3dc9cd87 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/asm/d-win32.asm @@ -0,0 +1,3132 @@ + ; Don't even think of reading this code + ; It was automatically generated by des-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE des-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _des_encrypt +EXTRN _des_SPtrans:DWORD +_des_encrypt PROC NEAR + push esi + push edi + ; + ; Load the 2 words + mov esi, DWORD PTR 12[esp] + xor ecx, ecx + push ebx + push ebp + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 28[esp] + mov edi, DWORD PTR 4[esi] + ; + ; IP + rol eax, 4 + mov esi, eax + xor eax, edi + and eax, 0f0f0f0f0h + xor esi, eax + xor edi, eax + ; + rol edi, 20 + mov eax, edi + xor edi, esi + and edi, 0fff0000fh + xor eax, edi + xor esi, edi + ; + rol eax, 14 + mov edi, eax + xor eax, esi + and eax, 033333333h + xor edi, eax + xor esi, eax + ; + rol esi, 22 + mov eax, esi + xor esi, edi + and esi, 003fc03fch + xor eax, esi + xor edi, esi + ; + rol eax, 9 + mov esi, eax + xor eax, edi + and eax, 0aaaaaaaah + xor esi, eax + xor edi, eax + ; + rol edi, 1 + mov ebp, DWORD PTR 24[esp] + cmp ebx, 0 + je $L000start_decrypt + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + jmp $L001end +$L000start_decrypt: + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx +$L001end: + ; + ; FP + mov edx, DWORD PTR 20[esp] + ror esi, 1 + mov eax, edi + xor edi, esi + and edi, 0aaaaaaaah + xor eax, edi + xor esi, edi + ; + rol eax, 23 + mov edi, eax + xor eax, esi + and eax, 003fc03fch + xor edi, eax + xor esi, eax + ; + rol edi, 10 + mov eax, edi + xor edi, esi + and edi, 033333333h + xor eax, edi + xor esi, edi + ; + rol esi, 18 + mov edi, esi + xor esi, eax + and esi, 0fff0000fh + xor edi, esi + xor eax, esi + ; + rol edi, 12 + mov esi, edi + xor edi, eax + and edi, 0f0f0f0f0h + xor esi, edi + xor eax, edi + ; + ror eax, 4 + mov DWORD PTR [edx],eax + mov DWORD PTR 4[edx],esi + pop ebp + pop ebx + pop edi + pop esi + ret +_des_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_encrypt2 +EXTRN _des_SPtrans:DWORD +_des_encrypt2 PROC NEAR + push esi + push edi + ; + ; Load the 2 words + mov eax, DWORD PTR 12[esp] + xor ecx, ecx + push ebx + push ebp + mov esi, DWORD PTR [eax] + mov ebx, DWORD PTR 28[esp] + rol esi, 3 + mov edi, DWORD PTR 4[eax] + rol edi, 3 + mov ebp, DWORD PTR 24[esp] + cmp ebx, 0 + je $L002start_decrypt + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + jmp $L003end +$L002start_decrypt: + ; + ; Round 15 + mov eax, DWORD PTR 120[ebp] + xor ebx, ebx + mov edx, DWORD PTR 124[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 112[ebp] + xor ebx, ebx + mov edx, DWORD PTR 116[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 104[ebp] + xor ebx, ebx + mov edx, DWORD PTR 108[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 96[ebp] + xor ebx, ebx + mov edx, DWORD PTR 100[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 88[ebp] + xor ebx, ebx + mov edx, DWORD PTR 92[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 80[ebp] + xor ebx, ebx + mov edx, DWORD PTR 84[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 72[ebp] + xor ebx, ebx + mov edx, DWORD PTR 76[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 64[ebp] + xor ebx, ebx + mov edx, DWORD PTR 68[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 56[ebp] + xor ebx, ebx + mov edx, DWORD PTR 60[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 48[ebp] + xor ebx, ebx + mov edx, DWORD PTR 52[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 40[ebp] + xor ebx, ebx + mov edx, DWORD PTR 44[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[ebp] + xor ebx, ebx + mov edx, DWORD PTR 36[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 24[ebp] + xor ebx, ebx + mov edx, DWORD PTR 28[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 16[ebp] + xor ebx, ebx + mov edx, DWORD PTR 20[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 8[ebp] + xor ebx, ebx + mov edx, DWORD PTR 12[ebp] + xor eax, esi + xor edx, esi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 0 + mov eax, DWORD PTR [ebp] + xor ebx, ebx + mov edx, DWORD PTR 4[ebp] + xor eax, edi + xor edx, edi + and eax, 0fcfcfcfch + and edx, 0cfcfcfcfh + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx +$L003end: + ; + ; Fixup + ror edi, 3 + mov eax, DWORD PTR 20[esp] + ror esi, 3 + mov DWORD PTR [eax],edi + mov DWORD PTR 4[eax],esi + pop ebp + pop ebx + pop edi + pop esi + ret +_des_encrypt2 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_encrypt3 + +_des_encrypt3 PROC NEAR + push ebx + mov ebx, DWORD PTR 8[esp] + push ebp + push esi + push edi + ; + ; Load the data words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + sub esp, 12 + ; + ; IP + rol edi, 4 + mov edx, edi + xor edi, esi + and edi, 0f0f0f0f0h + xor edx, edi + xor esi, edi + ; + rol esi, 20 + mov edi, esi + xor esi, edx + and esi, 0fff0000fh + xor edi, esi + xor edx, esi + ; + rol edi, 14 + mov esi, edi + xor edi, edx + and edi, 033333333h + xor esi, edi + xor edx, edi + ; + rol edx, 22 + mov edi, edx + xor edx, esi + and edx, 003fc03fch + xor edi, edx + xor esi, edx + ; + rol edi, 9 + mov edx, edi + xor edi, esi + and edi, 0aaaaaaaah + xor edx, edi + xor esi, edi + ; + ror edx, 3 + ror esi, 2 + mov DWORD PTR 4[ebx],esi + mov eax, DWORD PTR 36[esp] + mov DWORD PTR [ebx],edx + mov edi, DWORD PTR 40[esp] + mov esi, DWORD PTR 44[esp] + mov DWORD PTR 8[esp],1 + mov DWORD PTR 4[esp],eax + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],0 + mov DWORD PTR 4[esp],edi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],1 + mov DWORD PTR 4[esp],esi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + add esp, 12 + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + ; + ; FP + rol esi, 2 + rol edi, 3 + mov eax, edi + xor edi, esi + and edi, 0aaaaaaaah + xor eax, edi + xor esi, edi + ; + rol eax, 23 + mov edi, eax + xor eax, esi + and eax, 003fc03fch + xor edi, eax + xor esi, eax + ; + rol edi, 10 + mov eax, edi + xor edi, esi + and edi, 033333333h + xor eax, edi + xor esi, edi + ; + rol esi, 18 + mov edi, esi + xor esi, eax + and esi, 0fff0000fh + xor edi, esi + xor eax, esi + ; + rol edi, 12 + mov esi, edi + xor edi, eax + and edi, 0f0f0f0f0h + xor esi, edi + xor eax, edi + ; + ror eax, 4 + mov DWORD PTR [ebx],eax + mov DWORD PTR 4[ebx],esi + pop edi + pop esi + pop ebp + pop ebx + ret +_des_encrypt3 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_decrypt3 + +_des_decrypt3 PROC NEAR + push ebx + mov ebx, DWORD PTR 8[esp] + push ebp + push esi + push edi + ; + ; Load the data words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + sub esp, 12 + ; + ; IP + rol edi, 4 + mov edx, edi + xor edi, esi + and edi, 0f0f0f0f0h + xor edx, edi + xor esi, edi + ; + rol esi, 20 + mov edi, esi + xor esi, edx + and esi, 0fff0000fh + xor edi, esi + xor edx, esi + ; + rol edi, 14 + mov esi, edi + xor edi, edx + and edi, 033333333h + xor esi, edi + xor edx, edi + ; + rol edx, 22 + mov edi, edx + xor edx, esi + and edx, 003fc03fch + xor edi, edx + xor esi, edx + ; + rol edi, 9 + mov edx, edi + xor edi, esi + and edi, 0aaaaaaaah + xor edx, edi + xor esi, edi + ; + ror edx, 3 + ror esi, 2 + mov DWORD PTR 4[ebx],esi + mov esi, DWORD PTR 36[esp] + mov DWORD PTR [ebx],edx + mov edi, DWORD PTR 40[esp] + mov eax, DWORD PTR 44[esp] + mov DWORD PTR 8[esp],0 + mov DWORD PTR 4[esp],eax + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],1 + mov DWORD PTR 4[esp],edi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + mov DWORD PTR 8[esp],0 + mov DWORD PTR 4[esp],esi + mov DWORD PTR [esp],ebx + call _des_encrypt2 + add esp, 12 + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + ; + ; FP + rol esi, 2 + rol edi, 3 + mov eax, edi + xor edi, esi + and edi, 0aaaaaaaah + xor eax, edi + xor esi, edi + ; + rol eax, 23 + mov edi, eax + xor eax, esi + and eax, 003fc03fch + xor edi, eax + xor esi, eax + ; + rol edi, 10 + mov eax, edi + xor edi, esi + and edi, 033333333h + xor eax, edi + xor esi, edi + ; + rol esi, 18 + mov edi, esi + xor esi, eax + and esi, 0fff0000fh + xor edi, esi + xor eax, esi + ; + rol edi, 12 + mov esi, edi + xor edi, eax + and edi, 0f0f0f0f0h + xor esi, edi + xor eax, edi + ; + ror eax, 4 + mov DWORD PTR [ebx],eax + mov DWORD PTR 4[ebx],esi + pop edi + pop esi + pop ebp + pop ebx + ret +_des_decrypt3 ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_ncbc_encrypt + +_des_ncbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 5 + push ecx + ; get and push parameter 3 + mov eax, DWORD PTR 52[esp] + push eax + push ebx + cmp ecx, 0 + jz $L004decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + jz $L005encrypt_finish +L006encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L006encrypt_loop +$L005encrypt_finish: + mov ebp, DWORD PTR 56[esp] + and ebp, 7 + jz $L007finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4] + jmp ebp +L009ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L010ej6: + mov dh, BYTE PTR 5[esi] +L011ej5: + mov dl, BYTE PTR 4[esi] +L012ej4: + mov ecx, DWORD PTR [esi] + jmp $L013ejend +L014ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L015ej2: + mov ch, BYTE PTR 1[esi] +L016ej1: + mov cl, BYTE PTR [esi] +$L013ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L007finish +$L004decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 20[esp] + mov ebx, DWORD PTR 24[esp] + jz $L017decrypt_finish +L018decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov ecx, DWORD PTR 20[esp] + mov edx, DWORD PTR 24[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 20[esp],eax + mov DWORD PTR 24[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L018decrypt_loop +$L017decrypt_finish: + mov ebp, DWORD PTR 56[esp] + and ebp, 7 + jz $L007finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + call _des_encrypt + mov eax, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + mov ecx, DWORD PTR 20[esp] + mov edx, DWORD PTR 24[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L019dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L020dj6: + mov BYTE PTR 5[edi],dh +L021dj5: + mov BYTE PTR 4[edi],dl +L022dj4: + mov DWORD PTR [edi],ecx + jmp $L023djend +L024dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L025dj2: + mov BYTE PTR 1[esi],ch +L026dj1: + mov BYTE PTR [esi], cl +$L023djend: + jmp $L007finish +$L007finish: + mov ecx, DWORD PTR 64[esp] + add esp, 28 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L008cbc_enc_jmp_table: + DD 0 + DD L016ej1 + DD L015ej2 + DD L014ej3 + DD L012ej4 + DD L011ej5 + DD L010ej6 + DD L009ej7 +L027cbc_dec_jmp_table: + DD 0 + DD L026dj1 + DD L025dj2 + DD L024dj3 + DD L022dj4 + DD L021dj5 + DD L020dj6 + DD L019dj7 +_des_ncbc_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _des_ede3_cbc_encrypt + +_des_ede3_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 6 + mov ebx, DWORD PTR 44[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 7 + mov ecx, DWORD PTR 64[esp] + ; get and push parameter 5 + mov eax, DWORD PTR 56[esp] + push eax + ; get and push parameter 4 + mov eax, DWORD PTR 56[esp] + push eax + ; get and push parameter 3 + mov eax, DWORD PTR 56[esp] + push eax + push ebx + cmp ecx, 0 + jz $L028decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L029encrypt_finish +L030encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_encrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L030encrypt_loop +$L029encrypt_finish: + mov ebp, DWORD PTR 60[esp] + and ebp, 7 + jz $L031finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L032cbc_enc_jmp_table[ebp*4] + jmp ebp +L033ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L034ej6: + mov dh, BYTE PTR 5[esi] +L035ej5: + mov dl, BYTE PTR 4[esi] +L036ej4: + mov ecx, DWORD PTR [esi] + jmp $L037ejend +L038ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L039ej2: + mov ch, BYTE PTR 1[esi] +L040ej1: + mov cl, BYTE PTR [esi] +$L037ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_encrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L031finish +$L028decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 24[esp] + mov ebx, DWORD PTR 28[esp] + jz $L041decrypt_finish +L042decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_decrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov ecx, DWORD PTR 24[esp] + mov edx, DWORD PTR 28[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 24[esp],eax + mov DWORD PTR 28[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L042decrypt_loop +$L041decrypt_finish: + mov ebp, DWORD PTR 60[esp] + and ebp, 7 + jz $L031finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + call _des_decrypt3 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + mov ecx, DWORD PTR 24[esp] + mov edx, DWORD PTR 28[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L043dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L044dj6: + mov BYTE PTR 5[edi],dh +L045dj5: + mov BYTE PTR 4[edi],dl +L046dj4: + mov DWORD PTR [edi],ecx + jmp $L047djend +L048dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L049dj2: + mov BYTE PTR 1[esi],ch +L050dj1: + mov BYTE PTR [esi], cl +$L047djend: + jmp $L031finish +$L031finish: + mov ecx, DWORD PTR 76[esp] + add esp, 32 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L032cbc_enc_jmp_table: + DD 0 + DD L040ej1 + DD L039ej2 + DD L038ej3 + DD L036ej4 + DD L035ej5 + DD L034ej6 + DD L033ej7 +L051cbc_dec_jmp_table: + DD 0 + DD L050dj1 + DD L049dj2 + DD L048dj3 + DD L046dj4 + DD L045dj5 + DD L044dj6 + DD L043dj7 +_des_ede3_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/des/asm/dx86unix.cpp b/src/lib/libssl/src/crypto/des/asm/dx86unix.cpp new file mode 100644 index 0000000000..6fca9afa16 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/asm/dx86unix.cpp @@ -0,0 +1,3202 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define des_SPtrans _des_SPtrans +#define des_encrypt _des_encrypt +#define des_encrypt2 _des_encrypt2 +#define des_encrypt3 _des_encrypt3 +#define des_decrypt3 _des_decrypt3 +#define des_ncbc_encrypt _des_ncbc_encrypt +#define des_ede3_cbc_encrypt _des_ede3_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by des-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "des-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl des_encrypt + TYPE(des_encrypt,@function) +des_encrypt: + pushl %esi + pushl %edi + + /* Load the 2 words */ + movl 12(%esp), %esi + xorl %ecx, %ecx + pushl %ebx + pushl %ebp + movl (%esi), %eax + movl 28(%esp), %ebx + movl 4(%esi), %edi + + /* IP */ + roll $4, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0xf0f0f0f0, %eax + xorl %eax, %esi + xorl %eax, %edi + + roll $20, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xfff0000f, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $14, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x33333333, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $22, %esi + movl %esi, %eax + xorl %edi, %esi + andl $0x03fc03fc, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $9, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0xaaaaaaaa, %eax + xorl %eax, %esi + xorl %eax, %edi + +.byte 209 +.byte 199 /* roll $1 %edi */ + movl 24(%esp), %ebp + cmpl $0, %ebx + je .L000start_decrypt + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + jmp .L001end +.L000start_decrypt: + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi +.L001end: + + /* FP */ + movl 20(%esp), %edx +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%edx) + movl %esi, 4(%edx) + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +.des_encrypt_end: + SIZE(des_encrypt,.des_encrypt_end-des_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_encrypt2 + TYPE(des_encrypt2,@function) +des_encrypt2: + pushl %esi + pushl %edi + + /* Load the 2 words */ + movl 12(%esp), %eax + xorl %ecx, %ecx + pushl %ebx + pushl %ebp + movl (%eax), %esi + movl 28(%esp), %ebx + roll $3, %esi + movl 4(%eax), %edi + roll $3, %edi + movl 24(%esp), %ebp + cmpl $0, %ebx + je .L002start_decrypt + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + jmp .L003end +.L002start_decrypt: + + /* Round 15 */ + movl 120(%ebp), %eax + xorl %ebx, %ebx + movl 124(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 14 */ + movl 112(%ebp), %eax + xorl %ebx, %ebx + movl 116(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 13 */ + movl 104(%ebp), %eax + xorl %ebx, %ebx + movl 108(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 12 */ + movl 96(%ebp), %eax + xorl %ebx, %ebx + movl 100(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 11 */ + movl 88(%ebp), %eax + xorl %ebx, %ebx + movl 92(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 10 */ + movl 80(%ebp), %eax + xorl %ebx, %ebx + movl 84(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 9 */ + movl 72(%ebp), %eax + xorl %ebx, %ebx + movl 76(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 8 */ + movl 64(%ebp), %eax + xorl %ebx, %ebx + movl 68(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 7 */ + movl 56(%ebp), %eax + xorl %ebx, %ebx + movl 60(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 6 */ + movl 48(%ebp), %eax + xorl %ebx, %ebx + movl 52(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 5 */ + movl 40(%ebp), %eax + xorl %ebx, %ebx + movl 44(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 4 */ + movl 32(%ebp), %eax + xorl %ebx, %ebx + movl 36(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 3 */ + movl 24(%ebp), %eax + xorl %ebx, %ebx + movl 28(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 2 */ + movl 16(%ebp), %eax + xorl %ebx, %ebx + movl 20(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 1 */ + movl 8(%ebp), %eax + xorl %ebx, %ebx + movl 12(%ebp), %edx + xorl %esi, %eax + xorl %esi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 0 */ + movl (%ebp), %eax + xorl %ebx, %ebx + movl 4(%ebp), %edx + xorl %edi, %eax + xorl %edi, %edx + andl $0xfcfcfcfc, %eax + andl $0xcfcfcfcf, %edx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi +.L003end: + + /* Fixup */ + rorl $3, %edi + movl 20(%esp), %eax + rorl $3, %esi + movl %edi, (%eax) + movl %esi, 4(%eax) + popl %ebp + popl %ebx + popl %edi + popl %esi + ret +.des_encrypt2_end: + SIZE(des_encrypt2,.des_encrypt2_end-des_encrypt2) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_encrypt3 + TYPE(des_encrypt3,@function) +des_encrypt3: + pushl %ebx + movl 8(%esp), %ebx + pushl %ebp + pushl %esi + pushl %edi + + /* Load the data words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + subl $12, %esp + + /* IP */ + roll $4, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %edx + xorl %edi, %esi + + roll $20, %esi + movl %esi, %edi + xorl %edx, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %edx + + roll $14, %edi + movl %edi, %esi + xorl %edx, %edi + andl $0x33333333, %edi + xorl %edi, %esi + xorl %edi, %edx + + roll $22, %edx + movl %edx, %edi + xorl %esi, %edx + andl $0x03fc03fc, %edx + xorl %edx, %edi + xorl %edx, %esi + + roll $9, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %edx + xorl %edi, %esi + + rorl $3, %edx + rorl $2, %esi + movl %esi, 4(%ebx) + movl 36(%esp), %eax + movl %edx, (%ebx) + movl 40(%esp), %edi + movl 44(%esp), %esi + movl $1, 8(%esp) + movl %eax, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $0, 8(%esp) + movl %edi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $1, 8(%esp) + movl %esi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + addl $12, %esp + movl (%ebx), %edi + movl 4(%ebx), %esi + + /* FP */ + roll $2, %esi + roll $3, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%ebx) + movl %esi, 4(%ebx) + popl %edi + popl %esi + popl %ebp + popl %ebx + ret +.des_encrypt3_end: + SIZE(des_encrypt3,.des_encrypt3_end-des_encrypt3) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_decrypt3 + TYPE(des_decrypt3,@function) +des_decrypt3: + pushl %ebx + movl 8(%esp), %ebx + pushl %ebp + pushl %esi + pushl %edi + + /* Load the data words */ + movl (%ebx), %edi + movl 4(%ebx), %esi + subl $12, %esp + + /* IP */ + roll $4, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %edx + xorl %edi, %esi + + roll $20, %esi + movl %esi, %edi + xorl %edx, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %edx + + roll $14, %edi + movl %edi, %esi + xorl %edx, %edi + andl $0x33333333, %edi + xorl %edi, %esi + xorl %edi, %edx + + roll $22, %edx + movl %edx, %edi + xorl %esi, %edx + andl $0x03fc03fc, %edx + xorl %edx, %edi + xorl %edx, %esi + + roll $9, %edi + movl %edi, %edx + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %edx + xorl %edi, %esi + + rorl $3, %edx + rorl $2, %esi + movl %esi, 4(%ebx) + movl 36(%esp), %esi + movl %edx, (%ebx) + movl 40(%esp), %edi + movl 44(%esp), %eax + movl $0, 8(%esp) + movl %eax, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $1, 8(%esp) + movl %edi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + movl $0, 8(%esp) + movl %esi, 4(%esp) + movl %ebx, (%esp) + call des_encrypt2 + addl $12, %esp + movl (%ebx), %edi + movl 4(%ebx), %esi + + /* FP */ + roll $2, %esi + roll $3, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0xaaaaaaaa, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $23, %eax + movl %eax, %edi + xorl %esi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %edi + xorl %eax, %esi + + roll $10, %edi + movl %edi, %eax + xorl %esi, %edi + andl $0x33333333, %edi + xorl %edi, %eax + xorl %edi, %esi + + roll $18, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xfff0000f, %esi + xorl %esi, %edi + xorl %esi, %eax + + roll $12, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xf0f0f0f0, %edi + xorl %edi, %esi + xorl %edi, %eax + + rorl $4, %eax + movl %eax, (%ebx) + movl %esi, 4(%ebx) + popl %edi + popl %esi + popl %ebp + popl %ebx + ret +.des_decrypt3_end: + SIZE(des_decrypt3,.des_decrypt3_end-des_decrypt3) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_ncbc_encrypt + TYPE(des_ncbc_encrypt,@function) +des_ncbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 5 */ + pushl %ecx + /* get and push parameter 3 */ + movl 52(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L004decrypt + andl $4294967288, %ebp + movl 12(%esp), %eax + movl 16(%esp), %ebx + jz .L005encrypt_finish +.L006encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L006encrypt_loop +.L005encrypt_finish: + movl 56(%esp), %ebp + andl $7, %ebp + jz .L007finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L009ej7: + movb 6(%esi), %dh + sall $8, %edx +.L010ej6: + movb 5(%esi), %dh +.L011ej5: + movb 4(%esi), %dl +.L012ej4: + movl (%esi), %ecx + jmp .L013ejend +.L014ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L015ej2: + movb 1(%esi), %ch +.L016ej1: + movb (%esi), %cl +.L013ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L007finish +.align ALIGN +.L004decrypt: + andl $4294967288, %ebp + movl 20(%esp), %eax + movl 24(%esp), %ebx + jz .L017decrypt_finish +.L018decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl 24(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 20(%esp) + movl %ebx, 24(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L018decrypt_loop +.L017decrypt_finish: + movl 56(%esp), %ebp + andl $7, %ebp + jz .L007finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + call des_encrypt + movl 12(%esp), %eax + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl 24(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L019dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L020dj6: + movb %dh, 5(%edi) +.L021dj5: + movb %dl, 4(%edi) +.L022dj4: + movl %ecx, (%edi) + jmp .L023djend +.L024dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L025dj2: + movb %ch, 1(%esi) +.L026dj1: + movb %cl, (%esi) +.L023djend: + jmp .L007finish +.align ALIGN +.L007finish: + movl 64(%esp), %ecx + addl $28, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L008cbc_enc_jmp_table: + .long 0 + .long .L016ej1 + .long .L015ej2 + .long .L014ej3 + .long .L012ej4 + .long .L011ej5 + .long .L010ej6 + .long .L009ej7 +.align ALIGN +.L027cbc_dec_jmp_table: + .long 0 + .long .L026dj1 + .long .L025dj2 + .long .L024dj3 + .long .L022dj4 + .long .L021dj5 + .long .L020dj6 + .long .L019dj7 +.des_ncbc_encrypt_end: + SIZE(des_ncbc_encrypt,.des_ncbc_encrypt_end-des_ncbc_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl des_ede3_cbc_encrypt + TYPE(des_ede3_cbc_encrypt,@function) +des_ede3_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 6 */ + movl 44(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 7 */ + movl 64(%esp), %ecx + /* get and push parameter 5 */ + movl 56(%esp), %eax + pushl %eax + /* get and push parameter 4 */ + movl 56(%esp), %eax + pushl %eax + /* get and push parameter 3 */ + movl 56(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L028decrypt + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L029encrypt_finish +.L030encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_encrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L030encrypt_loop +.L029encrypt_finish: + movl 60(%esp), %ebp + andl $7, %ebp + jz .L031finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L032cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L033ej7: + movb 6(%esi), %dh + sall $8, %edx +.L034ej6: + movb 5(%esi), %dh +.L035ej5: + movb 4(%esi), %dl +.L036ej4: + movl (%esi), %ecx + jmp .L037ejend +.L038ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L039ej2: + movb 1(%esi), %ch +.L040ej1: + movb (%esi), %cl +.L037ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_encrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L031finish +.align ALIGN +.L028decrypt: + andl $4294967288, %ebp + movl 24(%esp), %eax + movl 28(%esp), %ebx + jz .L041decrypt_finish +.L042decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_decrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl 24(%esp), %ecx + movl 28(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 24(%esp) + movl %ebx, 28(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L042decrypt_loop +.L041decrypt_finish: + movl 60(%esp), %ebp + andl $7, %ebp + jz .L031finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + call des_decrypt3 + movl 16(%esp), %eax + movl 20(%esp), %ebx + movl 24(%esp), %ecx + movl 28(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L043dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L044dj6: + movb %dh, 5(%edi) +.L045dj5: + movb %dl, 4(%edi) +.L046dj4: + movl %ecx, (%edi) + jmp .L047djend +.L048dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L049dj2: + movb %ch, 1(%esi) +.L050dj1: + movb %cl, (%esi) +.L047djend: + jmp .L031finish +.align ALIGN +.L031finish: + movl 76(%esp), %ecx + addl $32, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L032cbc_enc_jmp_table: + .long 0 + .long .L040ej1 + .long .L039ej2 + .long .L038ej3 + .long .L036ej4 + .long .L035ej5 + .long .L034ej6 + .long .L033ej7 +.align ALIGN +.L051cbc_dec_jmp_table: + .long 0 + .long .L050dj1 + .long .L049dj2 + .long .L048dj3 + .long .L046dj4 + .long .L045dj5 + .long .L044dj6 + .long .L043dj7 +.des_ede3_cbc_encrypt_end: + SIZE(des_ede3_cbc_encrypt,.des_ede3_cbc_encrypt_end-des_ede3_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/des/asm/y-win32.asm b/src/lib/libssl/src/crypto/des/asm/y-win32.asm new file mode 100644 index 0000000000..af5c102422 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/asm/y-win32.asm @@ -0,0 +1,929 @@ + ; Don't even think of reading this code + ; It was automatically generated by crypt586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE crypt586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _fcrypt_body +EXTRN _des_SPtrans:DWORD +_fcrypt_body PROC NEAR + push ebp + push ebx + push esi + push edi + ; + ; Load the 2 words + xor edi, edi + xor esi, esi + mov ebp, DWORD PTR 24[esp] + push 25 +L000start: + ; + ; Round 0 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR [ebp] + xor eax, ebx + mov ecx, DWORD PTR 4[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 1 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 8[ebp] + xor eax, ebx + mov ecx, DWORD PTR 12[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 2 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 16[ebp] + xor eax, ebx + mov ecx, DWORD PTR 20[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 3 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 24[ebp] + xor eax, ebx + mov ecx, DWORD PTR 28[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 4 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 32[ebp] + xor eax, ebx + mov ecx, DWORD PTR 36[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 5 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 40[ebp] + xor eax, ebx + mov ecx, DWORD PTR 44[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 6 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 48[ebp] + xor eax, ebx + mov ecx, DWORD PTR 52[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 7 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 56[ebp] + xor eax, ebx + mov ecx, DWORD PTR 60[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 8 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 64[ebp] + xor eax, ebx + mov ecx, DWORD PTR 68[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 9 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 72[ebp] + xor eax, ebx + mov ecx, DWORD PTR 76[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 10 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 80[ebp] + xor eax, ebx + mov ecx, DWORD PTR 84[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 11 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 88[ebp] + xor eax, ebx + mov ecx, DWORD PTR 92[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 12 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 96[ebp] + xor eax, ebx + mov ecx, DWORD PTR 100[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 13 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 104[ebp] + xor eax, ebx + mov ecx, DWORD PTR 108[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + ; + ; Round 14 + mov eax, DWORD PTR 32[esp] + mov edx, esi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, esi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 112[ebp] + xor eax, ebx + mov ecx, DWORD PTR 116[ebp] + xor eax, esi + xor edx, esi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor edi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor edi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor edi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor edi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor edi, ebx + ; + ; Round 15 + mov eax, DWORD PTR 32[esp] + mov edx, edi + shr edx, 16 + mov ecx, DWORD PTR 36[esp] + xor edx, edi + and eax, edx + and edx, ecx + mov ebx, eax + shl ebx, 16 + mov ecx, edx + shl ecx, 16 + xor eax, ebx + xor edx, ecx + mov ebx, DWORD PTR 120[ebp] + xor eax, ebx + mov ecx, DWORD PTR 124[ebp] + xor eax, edi + xor edx, edi + xor edx, ecx + and eax, 0fcfcfcfch + xor ebx, ebx + and edx, 0cfcfcfcfh + xor ecx, ecx + mov bl, al + mov cl, ah + ror edx, 4 + mov ebp, DWORD PTR _des_SPtrans[ebx] + mov bl, dl + xor esi, ebp + mov ebp, DWORD PTR _des_SPtrans[0200h+ecx] + xor esi, ebp + mov cl, dh + shr eax, 16 + mov ebp, DWORD PTR _des_SPtrans[0100h+ebx] + xor esi, ebp + mov bl, ah + shr edx, 16 + mov ebp, DWORD PTR _des_SPtrans[0300h+ecx] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + mov cl, dh + and eax, 0ffh + and edx, 0ffh + mov ebx, DWORD PTR _des_SPtrans[0600h+ebx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0700h+ecx] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0400h+eax] + xor esi, ebx + mov ebx, DWORD PTR _des_SPtrans[0500h+edx] + xor esi, ebx + mov ebx, DWORD PTR [esp] + mov eax, edi + dec ebx + mov edi, esi + mov esi, eax + mov DWORD PTR [esp],ebx + jnz L000start + ; + ; FP + mov edx, DWORD PTR 24[esp] + ror edi, 1 + mov eax, esi + xor esi, edi + and esi, 0aaaaaaaah + xor eax, esi + xor edi, esi + ; + rol eax, 23 + mov esi, eax + xor eax, edi + and eax, 003fc03fch + xor esi, eax + xor edi, eax + ; + rol esi, 10 + mov eax, esi + xor esi, edi + and esi, 033333333h + xor eax, esi + xor edi, esi + ; + rol edi, 18 + mov esi, edi + xor edi, eax + and edi, 0fff0000fh + xor esi, edi + xor eax, edi + ; + rol esi, 12 + mov edi, esi + xor esi, eax + and esi, 0f0f0f0f0h + xor edi, esi + xor eax, esi + ; + ror eax, 4 + mov DWORD PTR [edx],eax + mov DWORD PTR 4[edx],edi + pop ecx + pop edi + pop esi + pop ebx + pop ebp + ret +_fcrypt_body ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/des/asm/yx86unix.cpp b/src/lib/libssl/src/crypto/des/asm/yx86unix.cpp new file mode 100644 index 0000000000..8719e38607 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/asm/yx86unix.cpp @@ -0,0 +1,976 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define des_SPtrans _des_SPtrans +#define fcrypt_body _fcrypt_body + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by crypt586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "crypt586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl fcrypt_body + TYPE(fcrypt_body,@function) +fcrypt_body: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + + /* Load the 2 words */ + xorl %edi, %edi + xorl %esi, %esi + movl 24(%esp), %ebp + pushl $25 +.L000start: + + /* Round 0 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl (%ebp), %ebx + xorl %ebx, %eax + movl 4(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 1 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 8(%ebp), %ebx + xorl %ebx, %eax + movl 12(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 2 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 16(%ebp), %ebx + xorl %ebx, %eax + movl 20(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 3 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 24(%ebp), %ebx + xorl %ebx, %eax + movl 28(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 4 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 32(%ebp), %ebx + xorl %ebx, %eax + movl 36(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 5 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 40(%ebp), %ebx + xorl %ebx, %eax + movl 44(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 6 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 48(%ebp), %ebx + xorl %ebx, %eax + movl 52(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 7 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 56(%ebp), %ebx + xorl %ebx, %eax + movl 60(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 8 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 64(%ebp), %ebx + xorl %ebx, %eax + movl 68(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 9 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 72(%ebp), %ebx + xorl %ebx, %eax + movl 76(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 10 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 80(%ebp), %ebx + xorl %ebx, %eax + movl 84(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 11 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 88(%ebp), %ebx + xorl %ebx, %eax + movl 92(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 12 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 96(%ebp), %ebx + xorl %ebx, %eax + movl 100(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 13 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 104(%ebp), %ebx + xorl %ebx, %eax + movl 108(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + + /* Round 14 */ + movl 32(%esp), %eax + movl %esi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %esi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 112(%ebp), %ebx + xorl %ebx, %eax + movl 116(%ebp), %ecx + xorl %esi, %eax + xorl %esi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %edi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %edi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %edi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %edi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %edi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %edi + + /* Round 15 */ + movl 32(%esp), %eax + movl %edi, %edx + shrl $16, %edx + movl 36(%esp), %ecx + xorl %edi, %edx + andl %edx, %eax + andl %ecx, %edx + movl %eax, %ebx + sall $16, %ebx + movl %edx, %ecx + sall $16, %ecx + xorl %ebx, %eax + xorl %ecx, %edx + movl 120(%ebp), %ebx + xorl %ebx, %eax + movl 124(%ebp), %ecx + xorl %edi, %eax + xorl %edi, %edx + xorl %ecx, %edx + andl $0xfcfcfcfc, %eax + xorl %ebx, %ebx + andl $0xcfcfcfcf, %edx + xorl %ecx, %ecx + movb %al, %bl + movb %ah, %cl + rorl $4, %edx + movl des_SPtrans(%ebx),%ebp + movb %dl, %bl + xorl %ebp, %esi + movl 0x200+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movb %dh, %cl + shrl $16, %eax + movl 0x100+des_SPtrans(%ebx),%ebp + xorl %ebp, %esi + movb %ah, %bl + shrl $16, %edx + movl 0x300+des_SPtrans(%ecx),%ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + movb %dh, %cl + andl $0xff, %eax + andl $0xff, %edx + movl 0x600+des_SPtrans(%ebx),%ebx + xorl %ebx, %esi + movl 0x700+des_SPtrans(%ecx),%ebx + xorl %ebx, %esi + movl 0x400+des_SPtrans(%eax),%ebx + xorl %ebx, %esi + movl 0x500+des_SPtrans(%edx),%ebx + xorl %ebx, %esi + movl (%esp), %ebx + movl %edi, %eax + decl %ebx + movl %esi, %edi + movl %eax, %esi + movl %ebx, (%esp) + jnz .L000start + + /* FP */ + movl 24(%esp), %edx +.byte 209 +.byte 207 /* rorl $1 %edi */ + movl %esi, %eax + xorl %edi, %esi + andl $0xaaaaaaaa, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $23, %eax + movl %eax, %esi + xorl %edi, %eax + andl $0x03fc03fc, %eax + xorl %eax, %esi + xorl %eax, %edi + + roll $10, %esi + movl %esi, %eax + xorl %edi, %esi + andl $0x33333333, %esi + xorl %esi, %eax + xorl %esi, %edi + + roll $18, %edi + movl %edi, %esi + xorl %eax, %edi + andl $0xfff0000f, %edi + xorl %edi, %esi + xorl %edi, %eax + + roll $12, %esi + movl %esi, %edi + xorl %eax, %esi + andl $0xf0f0f0f0, %esi + xorl %esi, %edi + xorl %esi, %eax + + rorl $4, %eax + movl %eax, (%edx) + movl %edi, 4(%edx) + popl %ecx + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.fcrypt_body_end: + SIZE(fcrypt_body,.fcrypt_body_end-fcrypt_body) +.ident "fcrypt_body" diff --git a/src/lib/libssl/src/crypto/des/des.man b/src/lib/libssl/src/crypto/des/des.man new file mode 100644 index 0000000000..7e06a1851a --- /dev/null +++ b/src/lib/libssl/src/crypto/des/des.man @@ -0,0 +1,186 @@ +.TH DES 1 +.SH NAME +des - encrypt or decrypt data using Data Encryption Standard +.SH SYNOPSIS +.B des +( +.B \-e +| +.B \-E +) | ( +.B \-d +| +.B \-D +) | ( +.B \-\fR[\fPcC\fR][\fPckname\fR]\fP +) | +[ +.B \-b3hfs +] [ +.B \-k +.I key +] +] [ +.B \-u\fR[\fIuuname\fR] +[ +.I input-file +[ +.I output-file +] ] +.SH DESCRIPTION +.B des +encrypts and decrypts data using the +Data Encryption Standard algorithm. +One of +.B \-e, \-E +(for encrypt) or +.B \-d, \-D +(for decrypt) must be specified. +It is also possible to use +.B \-c +or +.B \-C +in conjunction or instead of the a encrypt/decrypt option to generate +a 16 character hexadecimal checksum, generated via the +.I des_cbc_cksum. +.LP +Two standard encryption modes are supported by the +.B des +program, Cipher Block Chaining (the default) and Electronic Code Book +(specified with +.B \-b +). +.LP +The key used for the DES +algorithm is obtained by prompting the user unless the +.B `\-k +.I key' +option is given. +If the key is an argument to the +.B des +command, it is potentially visible to users executing +.BR ps (1) +or a derivative. To minimise this possibility, +.B des +takes care to destroy the key argument immediately upon entry. +If your shell keeps a history file be careful to make sure it is not +world readable. +.LP +Since this program attempts to maintain compatability with sunOS's +des(1) command, there are 2 different methods used to convert the user +supplied key to a des key. +Whenever and one or more of +.B \-E, \-D, \-C +or +.B \-3 +options are used, the key conversion procedure will not be compatible +with the sunOS des(1) version but will use all the user supplied +character to generate the des key. +.B des +command reads from standard input unless +.I input-file +is specified and writes to standard output unless +.I output-file +is given. +.SH OPTIONS +.TP +.B \-b +Select ECB +(eight bytes at a time) encryption mode. +.TP +.B \-3 +Encrypt using triple encryption. +By default triple cbc encryption is used but if the +.B \-b +option is used then triple ecb encryption is performed. +If the key is less than 8 characters long, the flag has no effect. +.TP +.B \-e +Encrypt data using an 8 byte key in a manner compatible with sunOS +des(1). +.TP +.B \-E +Encrypt data using a key of nearly unlimited length (1024 bytes). +This will product a more secure encryption. +.TP +.B \-d +Decrypt data that was encrypted with the \-e option. +.TP +.B \-D +Decrypt data that was encrypted with the \-E option. +.TP +.B \-c +Generate a 16 character hexadecimal cbc checksum and output this to +stderr. +If a filename was specified after the +.B \-c +option, the checksum is output to that file. +The checksum is generated using a key generated in a sunOS compatible +manner. +.TP +.B \-C +A cbc checksum is generated in the same manner as described for the +.B \-c +option but the DES key is generated in the same manner as used for the +.B \-E +and +.B \-D +options +.TP +.B \-f +Does nothing - allowed for compatibility with sunOS des(1) command. +.TP +.B \-s +Does nothing - allowed for compatibility with sunOS des(1) command. +.TP +.B "\-k \fIkey\fP" +Use the encryption +.I key +specified. +.TP +.B "\-h" +The +.I key +is assumed to be a 16 character hexadecimal number. +If the +.B "\-3" +option is used the key is assumed to be a 32 character hexadecimal +number. +.TP +.B \-u +This flag is used to read and write uuencoded files. If decrypting, +the input file is assumed to contain uuencoded, DES encrypted data. +If encrypting, the characters following the -u are used as the name of +the uuencoded file to embed in the begin line of the uuencoded +output. If there is no name specified after the -u, the name text.des +will be embedded in the header. +.SH SEE ALSO +.B ps (1) +.B des_crypt(3) +.SH BUGS +.LP +The problem with using the +.B -e +option is the short key length. +It would be better to use a real 56-bit key rather than an +ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII +radically reduces the time necessary for a brute-force cryptographic attack. +My attempt to remove this problem is to add an alternative text-key to +DES-key function. This alternative function (accessed via +.B -E, -D, -S +and +.B -3 +) +uses DES to help generate the key. +.LP +Be carefully when using the -u option. Doing des -ud will +not decrypt filename (the -u option will gobble the d option). +.LP +The VMS operating system operates in a world where files are always a +multiple of 512 bytes. This causes problems when encrypted data is +send from unix to VMS since a 88 byte file will suddenly be padded +with 424 null bytes. To get around this problem, use the -u option +to uuencode the data before it is send to the VMS system. +.SH AUTHOR +.LP +Eric Young (eay@cryptsoft.com) diff --git a/src/lib/libssl/src/crypto/des/des.org b/src/lib/libssl/src/crypto/des/des.org new file mode 100644 index 0000000000..a4cf5c8770 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/des.org @@ -0,0 +1,301 @@ +/* crypto/des/des.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify des.org since des.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_DES_H +#define HEADER_DES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif + +typedef unsigned char des_cblock[8]; +typedef struct des_ks_struct + { + union { + des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; +#undef _ +#define _ ks._ + } des_key_schedule[16]; + +#define DES_KEY_SZ (sizeof(des_cblock)) +#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define C_Block des_cblock +#define Key_schedule des_key_schedule +#ifdef KERBEROS +#define ENCRYPT DES_ENCRYPT +#define DECRYPT DES_DECRYPT +#endif +#define KEY_SZ DES_KEY_SZ +#define string_to_key des_string_to_key +#define read_pw_string des_read_pw_string +#define random_key des_random_key +#define pcbc_encrypt des_pcbc_encrypt +#define set_key des_set_key +#define key_sched des_key_sched +#define ecb_encrypt des_ecb_encrypt +#define cbc_encrypt des_cbc_encrypt +#define ncbc_encrypt des_ncbc_encrypt +#define xcbc_encrypt des_xcbc_encrypt +#define cbc_cksum des_cbc_cksum +#define quad_cksum des_quad_cksum + +/* For compatibility with the MIT lib - eay 20/05/92 */ +typedef des_key_schedule bit_64; +#define des_fixup_key_parity des_set_odd_parity +#define des_check_key_parity check_parity + +extern int des_check_key; /* defaults to false */ +extern int des_rw_mode; /* defaults to DES_PCBC_MODE */ + +/* The next line is used to disable full ANSI prototypes, if your + * compiler has problems with the prototypes, make sure this line always + * evaluates to true :-) */ +#if defined(MSDOS) || defined(__STDC__) +#undef NOPROTO +#endif +#ifndef NOPROTO +char *des_options(void); +void des_ecb3_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks1,des_key_schedule ks2, + des_key_schedule ks3, int enc); +DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output, + long length,des_key_schedule schedule,des_cblock *ivec); +void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec, + des_cblock *inw,des_cblock *outw,int enc); +void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,des_key_schedule schedule,des_cblock *ivec,int enc); +void des_ecb_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks,int enc); +void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc); +void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc); +void des_encrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3); +void des_decrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3); +void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int enc); +void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num, int enc); +void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num); + +void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white), + des_cblock (*out_white)); + +int des_enc_read(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv); +int des_enc_write(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv); +char *des_fcrypt(const char *buf,const char *salt, char *ret); +#ifdef PERL5 +char *des_crypt(const char *buf,const char *salt); +#else +/* some stupid compilers complain because I have declared char instead + * of const char */ +#ifdef HEADER_DES_LOCL_H +char *crypt(const char *buf,const char *salt); +#else +char *crypt(); +#endif +#endif +void des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,des_key_schedule schedule,des_cblock *ivec); +void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output, + long length,int out_count,des_cblock *seed); +void des_random_seed(des_cblock key); +void des_random_key(des_cblock ret); +int des_read_password(des_cblock *key,char *prompt,int verify); +int des_read_2passwords(des_cblock *key1,des_cblock *key2, + char *prompt,int verify); +int des_read_pw_string(char *buf,int length,char *prompt,int verify); +void des_set_odd_parity(des_cblock *key); +int des_is_weak_key(des_cblock *key); +int des_set_key(des_cblock *key,des_key_schedule schedule); +int des_key_sched(des_cblock *key,des_key_schedule schedule); +void des_string_to_key(char *str,des_cblock *key); +void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2); +void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num, int enc); +void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num); +int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify); + +/* Extra functions from Mark Murray */ +void des_cblock_print_file(des_cblock *cb, FILE *fp); +/* The following functions are not in the normal unix build or the + * SSLeay build. When using the SSLeay build, use RAND_seed() + * and RAND_bytes() instead. */ +int des_new_random_key(des_cblock *key); +void des_init_random_number_generator(des_cblock *key); +void des_set_random_generator_seed(des_cblock *key); +void des_set_sequence_number(des_cblock new_sequence_number); +void des_generate_random_block(des_cblock *block); + +#else + +char *des_options(); +void des_ecb3_encrypt(); +DES_LONG des_cbc_cksum(); +void des_cbc_encrypt(); +void des_ncbc_encrypt(); +void des_xcbc_encrypt(); +void des_cfb_encrypt(); +void des_ede3_cfb64_encrypt(); +void des_ede3_ofb64_encrypt(); +void des_ecb_encrypt(); +void des_encrypt(); +void des_encrypt2(); +void des_encrypt3(); +void des_decrypt3(); +void des_ede3_cbc_encrypt(); +int des_enc_read(); +int des_enc_write(); +char *des_fcrypt(); +#ifdef PERL5 +char *des_crypt(); +#else +char *crypt(); +#endif +void des_ofb_encrypt(); +void des_pcbc_encrypt(); +DES_LONG des_quad_cksum(); +void des_random_seed(); +void des_random_key(); +int des_read_password(); +int des_read_2passwords(); +int des_read_pw_string(); +void des_set_odd_parity(); +int des_is_weak_key(); +int des_set_key(); +int des_key_sched(); +void des_string_to_key(); +void des_string_to_2keys(); +void des_cfb64_encrypt(); +void des_ofb64_encrypt(); +int des_read_pw(); +void des_xwhite_in2out(); + +/* Extra functions from Mark Murray */ +void des_cblock_print_file(); +/* The following functions are not in the normal unix build or the + * SSLeay build. When using the SSLeay build, use RAND_seed() + * and RAND_bytes() instead. */ +#ifdef FreeBSD +int des_new_random_key(); +void des_init_random_number_generator(); +void des_set_random_generator_seed(); +void des_set_sequence_number(); +void des_generate_random_block(); +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libssl/src/crypto/des/des.pl b/src/lib/libssl/src/crypto/des/des.pl new file mode 100644 index 0000000000..935eacb504 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/des.pl @@ -0,0 +1,552 @@ +#!/usr/bin/perl +# des.pl - eric young 22/11/1991 eay@cryptsoft.com +# +# Copyright (C) 1993 Eric Young +# +# 11 April 1996 - patched to circumvent Perl 5 (through 5.002) problem +# with sign-extension on right shift operations. +# Ed Kubaitis - ejk@uiuc.edu +# +# eay - 92/08/31 - I think I have fixed all problems for 64bit +# versions of perl but I could be wrong since I have not tested it yet :-). +# +# This is an implementation of DES in perl. +# The two routines (des_set_key and des_ecb_encrypt) +# take 8 byte objects as arguments. +# +# des_set_key takes an 8 byte string as a key and returns a key schedule +# for use in calls to des_ecb_encrypt. +# des_ecb_encrypt takes three arguments, the first is a key schedule +# (make sure to pass it by reference with the *), the second is 1 +# to encrypt, 0 to decrypt. The third argument is an 8 byte object +# to encrypt. The function returns an 8 byte object that has been +# DES encrypted. +# +# example: +# require 'des.pl' +# +# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef); +# @ks= &des_set_key($key); +# +# $outbytes= &des_ecb_encrypt(*ks,1,$data); +# @enc =unpack("C8",$outbytes); +# + +package des; + +eval("use integer;") if (int($]) > 4); + +# The following 8 arrays are used in des_set_key +@skb0=( +# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 +0x00000000,0x00000010,0x20000000,0x20000010, +0x00010000,0x00010010,0x20010000,0x20010010, +0x00000800,0x00000810,0x20000800,0x20000810, +0x00010800,0x00010810,0x20010800,0x20010810, +0x00000020,0x00000030,0x20000020,0x20000030, +0x00010020,0x00010030,0x20010020,0x20010030, +0x00000820,0x00000830,0x20000820,0x20000830, +0x00010820,0x00010830,0x20010820,0x20010830, +0x00080000,0x00080010,0x20080000,0x20080010, +0x00090000,0x00090010,0x20090000,0x20090010, +0x00080800,0x00080810,0x20080800,0x20080810, +0x00090800,0x00090810,0x20090800,0x20090810, +0x00080020,0x00080030,0x20080020,0x20080030, +0x00090020,0x00090030,0x20090020,0x20090030, +0x00080820,0x00080830,0x20080820,0x20080830, +0x00090820,0x00090830,0x20090820,0x20090830, +); +@skb1=( +# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 +0x00000000,0x02000000,0x00002000,0x02002000, +0x00200000,0x02200000,0x00202000,0x02202000, +0x00000004,0x02000004,0x00002004,0x02002004, +0x00200004,0x02200004,0x00202004,0x02202004, +0x00000400,0x02000400,0x00002400,0x02002400, +0x00200400,0x02200400,0x00202400,0x02202400, +0x00000404,0x02000404,0x00002404,0x02002404, +0x00200404,0x02200404,0x00202404,0x02202404, +0x10000000,0x12000000,0x10002000,0x12002000, +0x10200000,0x12200000,0x10202000,0x12202000, +0x10000004,0x12000004,0x10002004,0x12002004, +0x10200004,0x12200004,0x10202004,0x12202004, +0x10000400,0x12000400,0x10002400,0x12002400, +0x10200400,0x12200400,0x10202400,0x12202400, +0x10000404,0x12000404,0x10002404,0x12002404, +0x10200404,0x12200404,0x10202404,0x12202404, +); +@skb2=( +# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 +0x00000000,0x00000001,0x00040000,0x00040001, +0x01000000,0x01000001,0x01040000,0x01040001, +0x00000002,0x00000003,0x00040002,0x00040003, +0x01000002,0x01000003,0x01040002,0x01040003, +0x00000200,0x00000201,0x00040200,0x00040201, +0x01000200,0x01000201,0x01040200,0x01040201, +0x00000202,0x00000203,0x00040202,0x00040203, +0x01000202,0x01000203,0x01040202,0x01040203, +0x08000000,0x08000001,0x08040000,0x08040001, +0x09000000,0x09000001,0x09040000,0x09040001, +0x08000002,0x08000003,0x08040002,0x08040003, +0x09000002,0x09000003,0x09040002,0x09040003, +0x08000200,0x08000201,0x08040200,0x08040201, +0x09000200,0x09000201,0x09040200,0x09040201, +0x08000202,0x08000203,0x08040202,0x08040203, +0x09000202,0x09000203,0x09040202,0x09040203, +); +@skb3=( +# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 +0x00000000,0x00100000,0x00000100,0x00100100, +0x00000008,0x00100008,0x00000108,0x00100108, +0x00001000,0x00101000,0x00001100,0x00101100, +0x00001008,0x00101008,0x00001108,0x00101108, +0x04000000,0x04100000,0x04000100,0x04100100, +0x04000008,0x04100008,0x04000108,0x04100108, +0x04001000,0x04101000,0x04001100,0x04101100, +0x04001008,0x04101008,0x04001108,0x04101108, +0x00020000,0x00120000,0x00020100,0x00120100, +0x00020008,0x00120008,0x00020108,0x00120108, +0x00021000,0x00121000,0x00021100,0x00121100, +0x00021008,0x00121008,0x00021108,0x00121108, +0x04020000,0x04120000,0x04020100,0x04120100, +0x04020008,0x04120008,0x04020108,0x04120108, +0x04021000,0x04121000,0x04021100,0x04121100, +0x04021008,0x04121008,0x04021108,0x04121108, +); +@skb4=( +# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 +0x00000000,0x10000000,0x00010000,0x10010000, +0x00000004,0x10000004,0x00010004,0x10010004, +0x20000000,0x30000000,0x20010000,0x30010000, +0x20000004,0x30000004,0x20010004,0x30010004, +0x00100000,0x10100000,0x00110000,0x10110000, +0x00100004,0x10100004,0x00110004,0x10110004, +0x20100000,0x30100000,0x20110000,0x30110000, +0x20100004,0x30100004,0x20110004,0x30110004, +0x00001000,0x10001000,0x00011000,0x10011000, +0x00001004,0x10001004,0x00011004,0x10011004, +0x20001000,0x30001000,0x20011000,0x30011000, +0x20001004,0x30001004,0x20011004,0x30011004, +0x00101000,0x10101000,0x00111000,0x10111000, +0x00101004,0x10101004,0x00111004,0x10111004, +0x20101000,0x30101000,0x20111000,0x30111000, +0x20101004,0x30101004,0x20111004,0x30111004, +); +@skb5=( +# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 +0x00000000,0x08000000,0x00000008,0x08000008, +0x00000400,0x08000400,0x00000408,0x08000408, +0x00020000,0x08020000,0x00020008,0x08020008, +0x00020400,0x08020400,0x00020408,0x08020408, +0x00000001,0x08000001,0x00000009,0x08000009, +0x00000401,0x08000401,0x00000409,0x08000409, +0x00020001,0x08020001,0x00020009,0x08020009, +0x00020401,0x08020401,0x00020409,0x08020409, +0x02000000,0x0A000000,0x02000008,0x0A000008, +0x02000400,0x0A000400,0x02000408,0x0A000408, +0x02020000,0x0A020000,0x02020008,0x0A020008, +0x02020400,0x0A020400,0x02020408,0x0A020408, +0x02000001,0x0A000001,0x02000009,0x0A000009, +0x02000401,0x0A000401,0x02000409,0x0A000409, +0x02020001,0x0A020001,0x02020009,0x0A020009, +0x02020401,0x0A020401,0x02020409,0x0A020409, +); +@skb6=( +# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 +0x00000000,0x00000100,0x00080000,0x00080100, +0x01000000,0x01000100,0x01080000,0x01080100, +0x00000010,0x00000110,0x00080010,0x00080110, +0x01000010,0x01000110,0x01080010,0x01080110, +0x00200000,0x00200100,0x00280000,0x00280100, +0x01200000,0x01200100,0x01280000,0x01280100, +0x00200010,0x00200110,0x00280010,0x00280110, +0x01200010,0x01200110,0x01280010,0x01280110, +0x00000200,0x00000300,0x00080200,0x00080300, +0x01000200,0x01000300,0x01080200,0x01080300, +0x00000210,0x00000310,0x00080210,0x00080310, +0x01000210,0x01000310,0x01080210,0x01080310, +0x00200200,0x00200300,0x00280200,0x00280300, +0x01200200,0x01200300,0x01280200,0x01280300, +0x00200210,0x00200310,0x00280210,0x00280310, +0x01200210,0x01200310,0x01280210,0x01280310, +); +@skb7=( +# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 +0x00000000,0x04000000,0x00040000,0x04040000, +0x00000002,0x04000002,0x00040002,0x04040002, +0x00002000,0x04002000,0x00042000,0x04042000, +0x00002002,0x04002002,0x00042002,0x04042002, +0x00000020,0x04000020,0x00040020,0x04040020, +0x00000022,0x04000022,0x00040022,0x04040022, +0x00002020,0x04002020,0x00042020,0x04042020, +0x00002022,0x04002022,0x00042022,0x04042022, +0x00000800,0x04000800,0x00040800,0x04040800, +0x00000802,0x04000802,0x00040802,0x04040802, +0x00002800,0x04002800,0x00042800,0x04042800, +0x00002802,0x04002802,0x00042802,0x04042802, +0x00000820,0x04000820,0x00040820,0x04040820, +0x00000822,0x04000822,0x00040822,0x04040822, +0x00002820,0x04002820,0x00042820,0x04042820, +0x00002822,0x04002822,0x00042822,0x04042822, +); + +@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0); + +# used in ecb_encrypt +@SP0=( +0x00410100, 0x00010000, 0x40400000, 0x40410100, +0x00400000, 0x40010100, 0x40010000, 0x40400000, +0x40010100, 0x00410100, 0x00410000, 0x40000100, +0x40400100, 0x00400000, 0x00000000, 0x40010000, +0x00010000, 0x40000000, 0x00400100, 0x00010100, +0x40410100, 0x00410000, 0x40000100, 0x00400100, +0x40000000, 0x00000100, 0x00010100, 0x40410000, +0x00000100, 0x40400100, 0x40410000, 0x00000000, +0x00000000, 0x40410100, 0x00400100, 0x40010000, +0x00410100, 0x00010000, 0x40000100, 0x00400100, +0x40410000, 0x00000100, 0x00010100, 0x40400000, +0x40010100, 0x40000000, 0x40400000, 0x00410000, +0x40410100, 0x00010100, 0x00410000, 0x40400100, +0x00400000, 0x40000100, 0x40010000, 0x00000000, +0x00010000, 0x00400000, 0x40400100, 0x00410100, +0x40000000, 0x40410000, 0x00000100, 0x40010100, +); +@SP1=( +0x08021002, 0x00000000, 0x00021000, 0x08020000, +0x08000002, 0x00001002, 0x08001000, 0x00021000, +0x00001000, 0x08020002, 0x00000002, 0x08001000, +0x00020002, 0x08021000, 0x08020000, 0x00000002, +0x00020000, 0x08001002, 0x08020002, 0x00001000, +0x00021002, 0x08000000, 0x00000000, 0x00020002, +0x08001002, 0x00021002, 0x08021000, 0x08000002, +0x08000000, 0x00020000, 0x00001002, 0x08021002, +0x00020002, 0x08021000, 0x08001000, 0x00021002, +0x08021002, 0x00020002, 0x08000002, 0x00000000, +0x08000000, 0x00001002, 0x00020000, 0x08020002, +0x00001000, 0x08000000, 0x00021002, 0x08001002, +0x08021000, 0x00001000, 0x00000000, 0x08000002, +0x00000002, 0x08021002, 0x00021000, 0x08020000, +0x08020002, 0x00020000, 0x00001002, 0x08001000, +0x08001002, 0x00000002, 0x08020000, 0x00021000, +); +@SP2=( +0x20800000, 0x00808020, 0x00000020, 0x20800020, +0x20008000, 0x00800000, 0x20800020, 0x00008020, +0x00800020, 0x00008000, 0x00808000, 0x20000000, +0x20808020, 0x20000020, 0x20000000, 0x20808000, +0x00000000, 0x20008000, 0x00808020, 0x00000020, +0x20000020, 0x20808020, 0x00008000, 0x20800000, +0x20808000, 0x00800020, 0x20008020, 0x00808000, +0x00008020, 0x00000000, 0x00800000, 0x20008020, +0x00808020, 0x00000020, 0x20000000, 0x00008000, +0x20000020, 0x20008000, 0x00808000, 0x20800020, +0x00000000, 0x00808020, 0x00008020, 0x20808000, +0x20008000, 0x00800000, 0x20808020, 0x20000000, +0x20008020, 0x20800000, 0x00800000, 0x20808020, +0x00008000, 0x00800020, 0x20800020, 0x00008020, +0x00800020, 0x00000000, 0x20808000, 0x20000020, +0x20800000, 0x20008020, 0x00000020, 0x00808000, +); +@SP3=( +0x00080201, 0x02000200, 0x00000001, 0x02080201, +0x00000000, 0x02080000, 0x02000201, 0x00080001, +0x02080200, 0x02000001, 0x02000000, 0x00000201, +0x02000001, 0x00080201, 0x00080000, 0x02000000, +0x02080001, 0x00080200, 0x00000200, 0x00000001, +0x00080200, 0x02000201, 0x02080000, 0x00000200, +0x00000201, 0x00000000, 0x00080001, 0x02080200, +0x02000200, 0x02080001, 0x02080201, 0x00080000, +0x02080001, 0x00000201, 0x00080000, 0x02000001, +0x00080200, 0x02000200, 0x00000001, 0x02080000, +0x02000201, 0x00000000, 0x00000200, 0x00080001, +0x00000000, 0x02080001, 0x02080200, 0x00000200, +0x02000000, 0x02080201, 0x00080201, 0x00080000, +0x02080201, 0x00000001, 0x02000200, 0x00080201, +0x00080001, 0x00080200, 0x02080000, 0x02000201, +0x00000201, 0x02000000, 0x02000001, 0x02080200, +); +@SP4=( +0x01000000, 0x00002000, 0x00000080, 0x01002084, +0x01002004, 0x01000080, 0x00002084, 0x01002000, +0x00002000, 0x00000004, 0x01000004, 0x00002080, +0x01000084, 0x01002004, 0x01002080, 0x00000000, +0x00002080, 0x01000000, 0x00002004, 0x00000084, +0x01000080, 0x00002084, 0x00000000, 0x01000004, +0x00000004, 0x01000084, 0x01002084, 0x00002004, +0x01002000, 0x00000080, 0x00000084, 0x01002080, +0x01002080, 0x01000084, 0x00002004, 0x01002000, +0x00002000, 0x00000004, 0x01000004, 0x01000080, +0x01000000, 0x00002080, 0x01002084, 0x00000000, +0x00002084, 0x01000000, 0x00000080, 0x00002004, +0x01000084, 0x00000080, 0x00000000, 0x01002084, +0x01002004, 0x01002080, 0x00000084, 0x00002000, +0x00002080, 0x01002004, 0x01000080, 0x00000084, +0x00000004, 0x00002084, 0x01002000, 0x01000004, +); +@SP5=( +0x10000008, 0x00040008, 0x00000000, 0x10040400, +0x00040008, 0x00000400, 0x10000408, 0x00040000, +0x00000408, 0x10040408, 0x00040400, 0x10000000, +0x10000400, 0x10000008, 0x10040000, 0x00040408, +0x00040000, 0x10000408, 0x10040008, 0x00000000, +0x00000400, 0x00000008, 0x10040400, 0x10040008, +0x10040408, 0x10040000, 0x10000000, 0x00000408, +0x00000008, 0x00040400, 0x00040408, 0x10000400, +0x00000408, 0x10000000, 0x10000400, 0x00040408, +0x10040400, 0x00040008, 0x00000000, 0x10000400, +0x10000000, 0x00000400, 0x10040008, 0x00040000, +0x00040008, 0x10040408, 0x00040400, 0x00000008, +0x10040408, 0x00040400, 0x00040000, 0x10000408, +0x10000008, 0x10040000, 0x00040408, 0x00000000, +0x00000400, 0x10000008, 0x10000408, 0x10040400, +0x10040000, 0x00000408, 0x00000008, 0x10040008, +); +@SP6=( +0x00000800, 0x00000040, 0x00200040, 0x80200000, +0x80200840, 0x80000800, 0x00000840, 0x00000000, +0x00200000, 0x80200040, 0x80000040, 0x00200800, +0x80000000, 0x00200840, 0x00200800, 0x80000040, +0x80200040, 0x00000800, 0x80000800, 0x80200840, +0x00000000, 0x00200040, 0x80200000, 0x00000840, +0x80200800, 0x80000840, 0x00200840, 0x80000000, +0x80000840, 0x80200800, 0x00000040, 0x00200000, +0x80000840, 0x00200800, 0x80200800, 0x80000040, +0x00000800, 0x00000040, 0x00200000, 0x80200800, +0x80200040, 0x80000840, 0x00000840, 0x00000000, +0x00000040, 0x80200000, 0x80000000, 0x00200040, +0x00000000, 0x80200040, 0x00200040, 0x00000840, +0x80000040, 0x00000800, 0x80200840, 0x00200000, +0x00200840, 0x80000000, 0x80000800, 0x80200840, +0x80200000, 0x00200840, 0x00200800, 0x80000800, +); +@SP7=( +0x04100010, 0x04104000, 0x00004010, 0x00000000, +0x04004000, 0x00100010, 0x04100000, 0x04104010, +0x00000010, 0x04000000, 0x00104000, 0x00004010, +0x00104010, 0x04004010, 0x04000010, 0x04100000, +0x00004000, 0x00104010, 0x00100010, 0x04004000, +0x04104010, 0x04000010, 0x00000000, 0x00104000, +0x04000000, 0x00100000, 0x04004010, 0x04100010, +0x00100000, 0x00004000, 0x04104000, 0x00000010, +0x00100000, 0x00004000, 0x04000010, 0x04104010, +0x00004010, 0x04000000, 0x00000000, 0x00104000, +0x04100010, 0x04004010, 0x04004000, 0x00100010, +0x04104000, 0x00000010, 0x00100010, 0x04004000, +0x04104010, 0x00100000, 0x04100000, 0x04000010, +0x00104000, 0x00004010, 0x04004010, 0x04100000, +0x00000010, 0x04104000, 0x00104010, 0x00000000, +0x04000000, 0x04100010, 0x00004000, 0x00104010, +); + +sub main'des_set_key + { + local($param)=@_; + local(@key); + local($c,$d,$i,$s,$t); + local(@ks)=(); + + # Get the bytes in the order we want. + @key=unpack("C8",$param); + + $c= ($key[0] )| + ($key[1]<< 8)| + ($key[2]<<16)| + ($key[3]<<24); + $d= ($key[4] )| + ($key[5]<< 8)| + ($key[6]<<16)| + ($key[7]<<24); + + &doPC1(*c,*d); + + for $i (@shifts2) + { + if ($i) + { + $c=($c>>2)|($c<<26); + $d=($d>>2)|($d<<26); + } + else + { + $c=($c>>1)|($c<<27); + $d=($d>>1)|($d<<27); + } + $c&=0x0fffffff; + $d&=0x0fffffff; + $s= $skb0[ ($c )&0x3f ]| + $skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]| + $skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]| + $skb3[(($c>>20)&0x01)|(($c>>21)&0x06) | + (($c>>22)&0x38)]; + $t= $skb4[ ($d )&0x3f ]| + $skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]| + $skb6[ ($d>>15)&0x3f ]| + $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)]; + push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff); + $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ; + push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff); + } + @ks; + } + +sub doPC1 + { + local(*a,*b)=@_; + local($t); + + $t=(($b>>4)^$a)&0x0f0f0f0f; + $b^=($t<<4); $a^=$t; + # do $a first + $t=(($a<<18)^$a)&0xcccc0000; + $a=$a^$t^(($t>>18)&0x00003fff); + $t=(($a<<17)^$a)&0xaaaa0000; + $a=$a^$t^(($t>>17)&0x00007fff); + $t=(($a<< 8)^$a)&0x00ff0000; + $a=$a^$t^(($t>> 8)&0x00ffffff); + $t=(($a<<17)^$a)&0xaaaa0000; + $a=$a^$t^(($t>>17)&0x00007fff); + + # now do $b + $t=(($b<<24)^$b)&0xff000000; + $b=$b^$t^(($t>>24)&0x000000ff); + $t=(($b<< 8)^$b)&0x00ff0000; + $b=$b^$t^(($t>> 8)&0x00ffffff); + $t=(($b<<14)^$b)&0x33330000; + $b=$b^$t^(($t>>14)&0x0003ffff); + $b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55); + $b=(($b>>8)&0x00ffffff)|((($a&0xf0000000)>>4)&0x0fffffff); + $a&=0x0fffffff; + } + +sub doIP + { + local(*a,*b)=@_; + local($t); + + $t=(($b>> 4)^$a)&0x0f0f0f0f; + $b^=($t<< 4); $a^=$t; + $t=(($a>>16)^$b)&0x0000ffff; + $a^=($t<<16); $b^=$t; + $t=(($b>> 2)^$a)&0x33333333; + $b^=($t<< 2); $a^=$t; + $t=(($a>> 8)^$b)&0x00ff00ff; + $a^=($t<< 8); $b^=$t; + $t=(($b>> 1)^$a)&0x55555555; + $b^=($t<< 1); $a^=$t; + $t=$a; + $a=$b&0xffffffff; + $b=$t&0xffffffff; + } + +sub doFP + { + local(*a,*b)=@_; + local($t); + + $t=(($b>> 1)^$a)&0x55555555; + $b^=($t<< 1); $a^=$t; + $t=(($a>> 8)^$b)&0x00ff00ff; + $a^=($t<< 8); $b^=$t; + $t=(($b>> 2)^$a)&0x33333333; + $b^=($t<< 2); $a^=$t; + $t=(($a>>16)^$b)&0x0000ffff; + $a^=($t<<16); $b^=$t; + $t=(($b>> 4)^$a)&0x0f0f0f0f; + $b^=($t<< 4); $a^=$t; + $a&=0xffffffff; + $b&=0xffffffff; + } + +sub main'des_ecb_encrypt + { + local(*ks,$encrypt,$in)=@_; + local($l,$r,$i,$t,$u,@input); + + @input=unpack("C8",$in); + # Get the bytes in the order we want. + $l= ($input[0] )| + ($input[1]<< 8)| + ($input[2]<<16)| + ($input[3]<<24); + $r= ($input[4] )| + ($input[5]<< 8)| + ($input[6]<<16)| + ($input[7]<<24); + + $l&=0xffffffff; + $r&=0xffffffff; + &doIP(*l,*r); + if ($encrypt) + { + for ($i=0; $i<32; $i+=4) + { + $t=((($r&0x7fffffff)<<1)|(($r>>31)&0x00000001)); + $u=$t^$ks[$i ]; + $t=$t^$ks[$i+1]; + $t2=(($t&0x0000000f)<<28); + + $t=((($t>>4)&0x0fffffff)|(($t&0x0000000f)<<28)); + $l^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + + $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff; + $u=$t^$ks[$i+2]; + $t=$t^$ks[$i+3]; + $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff; + $r^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + } + } + else + { + for ($i=30; $i>0; $i-=4) + { + $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff; + $u=$t^$ks[$i ]; + $t=$t^$ks[$i+1]; + $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff; + $l^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + + $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff; + $u=$t^$ks[$i-2]; + $t=$t^$ks[$i-1]; + $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff; + $r^= $SP1[ $t &0x3f]| + $SP3[($t>> 8)&0x3f]| + $SP5[($t>>16)&0x3f]| + $SP7[($t>>24)&0x3f]| + $SP0[ $u &0x3f]| + $SP2[($u>> 8)&0x3f]| + $SP4[($u>>16)&0x3f]| + $SP6[($u>>24)&0x3f]; + } + } + &doFP(*l,*r); + pack("C8",$l&0xff, + ($l>> 8)&0x00ffffff, + ($l>>16)&0x0000ffff, + ($l>>24)&0x000000ff, + $r&0xff, + ($r>> 8)&0x00ffffff, + ($r>>16)&0x0000ffff, + ($r>>24)&0x000000ff); + } diff --git a/src/lib/libssl/src/crypto/des/des_crypt.man b/src/lib/libssl/src/crypto/des/des_crypt.man new file mode 100644 index 0000000000..0ecc416877 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/des_crypt.man @@ -0,0 +1,508 @@ +.TH DES_CRYPT 3 +.SH NAME +des_read_password, des_read_2password, +des_string_to_key, des_string_to_2key, des_read_pw_string, +des_random_key, des_set_key, +des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt, +des_3cbc_encrypt, +des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt, +des_cbc_cksum, des_quad_cksum, +des_enc_read, des_enc_write, des_set_odd_parity, +des_is_weak_key, crypt \- (non USA) DES encryption +.SH SYNOPSIS +.nf +.nj +.ft B +#include +.PP +.B int des_read_password(key,prompt,verify) +des_cblock *key; +char *prompt; +int verify; +.PP +.B int des_read_2password(key1,key2,prompt,verify) +des_cblock *key1,*key2; +char *prompt; +int verify; +.PP +.B int des_string_to_key(str,key) +char *str; +des_cblock *key; +.PP +.B int des_string_to_2keys(str,key1,key2) +char *str; +des_cblock *key1,*key2; +.PP +.B int des_read_pw_string(buf,length,prompt,verify) +char *buf; +int length; +char *prompt; +int verify; +.PP +.B int des_random_key(key) +des_cblock *key; +.PP +.B int des_set_key(key,schedule) +des_cblock *key; +des_key_schedule schedule; +.PP +.B int des_key_sched(key,schedule) +des_cblock *key; +des_key_schedule schedule; +.PP +.B int des_ecb_encrypt(input,output,schedule,encrypt) +des_cblock *input; +des_cblock *output; +des_key_schedule schedule; +int encrypt; +.PP +.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt) +des_cblock *input; +des_cblock *output; +des_key_schedule ks1,ks2; +int encrypt; +.PP +.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule schedule; +des_cblock *ivec; +int encrypt; +.PP +.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule sk1; +des_key_schedule sk2; +des_cblock *ivec1; +des_cblock *ivec2; +int encrypt; +.PP +.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule schedule; +des_cblock *ivec; +int encrypt; +.PP +.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt) +unsigned char *input; +unsigned char *output; +int numbits; +long length; +des_key_schedule schedule; +des_cblock *ivec; +int encrypt; +.PP +.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec) +unsigned char *input,*output; +int numbits; +long length; +des_key_schedule schedule; +des_cblock *ivec; +.PP +.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec) +des_cblock *input; +des_cblock *output; +long length; +des_key_schedule schedule; +des_cblock *ivec; +.PP +.B unsigned long des_quad_cksum(input,output,length,out_count,seed) +des_cblock *input; +des_cblock *output; +long length; +int out_count; +des_cblock *seed; +.PP +.B int des_check_key; +.PP +.B int des_enc_read(fd,buf,len,sched,iv) +int fd; +char *buf; +int len; +des_key_schedule sched; +des_cblock *iv; +.PP +.B int des_enc_write(fd,buf,len,sched,iv) +int fd; +char *buf; +int len; +des_key_schedule sched; +des_cblock *iv; +.PP +.B extern int des_rw_mode; +.PP +.B void des_set_odd_parity(key) +des_cblock *key; +.PP +.B int des_is_weak_key(key) +des_cblock *key; +.PP +.B char *crypt(passwd,salt) +char *passwd; +char *salt; +.PP +.fi +.SH DESCRIPTION +This library contains a fast implementation of the DES encryption +algorithm. +.PP +There are two phases to the use of DES encryption. +The first is the generation of a +.I des_key_schedule +from a key, +the second is the actual encryption. +A des key is of type +.I des_cblock. +This type is made from 8 characters with odd parity. +The least significant bit in the character is the parity bit. +The key schedule is an expanded form of the key; it is used to speed the +encryption process. +.PP +.I des_read_password +writes the string specified by prompt to the standard output, +turns off echo and reads an input string from standard input +until terminated with a newline. +If verify is non-zero, it prompts and reads the input again and verifies +that both entered passwords are the same. +The entered string is converted into a des key by using the +.I des_string_to_key +routine. +The new key is placed in the +.I des_cblock +that was passed (by reference) to the routine. +If there were no errors, +.I des_read_password +returns 0, +-1 is returned if there was a terminal error and 1 is returned for +any other error. +.PP +.I des_read_2password +operates in the same way as +.I des_read_password +except that it generates 2 keys by using the +.I des_string_to_2key +function. +.PP +.I des_read_pw_string +is called by +.I des_read_password +to read and verify a string from a terminal device. +The string is returned in +.I buf. +The size of +.I buf +is passed to the routine via the +.I length +parameter. +.PP +.I des_string_to_key +converts a string into a valid des key. +.PP +.I des_string_to_2key +converts a string into 2 valid des keys. +This routine is best suited for used to generate keys for use with +.I des_ecb3_encrypt. +.PP +.I des_random_key +returns a random key that is made of a combination of process id, +time and an increasing counter. +.PP +Before a des key can be used it is converted into a +.I des_key_schedule +via the +.I des_set_key +routine. +If the +.I des_check_key +flag is non-zero, +.I des_set_key +will check that the key passed is of odd parity and is not a week or +semi-weak key. +If the parity is wrong, +then -1 is returned. +If the key is a weak key, +then -2 is returned. +If an error is returned, +the key schedule is not generated. +.PP +.I des_key_sched +is another name for the +.I des_set_key +function. +.PP +The following routines mostly operate on an input and output stream of +.I des_cblock's. +.PP +.I des_ecb_encrypt +is the basic DES encryption routine that encrypts or decrypts a single 8-byte +.I des_cblock +in +.I electronic code book +mode. +It always transforms the input data, pointed to by +.I input, +into the output data, +pointed to by the +.I output +argument. +If the +.I encrypt +argument is non-zero (DES_ENCRYPT), +the +.I input +(cleartext) is encrypted in to the +.I output +(ciphertext) using the key_schedule specified by the +.I schedule +argument, +previously set via +.I des_set_key. +If +.I encrypt +is zero (DES_DECRYPT), +the +.I input +(now ciphertext) +is decrypted into the +.I output +(now cleartext). +Input and output may overlap. +No meaningful value is returned. +.PP +.I des_ecb3_encrypt +encrypts/decrypts the +.I input +block by using triple ecb DES encryption. +This involves encrypting the input with +.I ks1, +decryption with the key schedule +.I ks2, +and then encryption with the first again. +This routine greatly reduces the chances of brute force breaking of +DES and has the advantage of if +.I ks1 +and +.I ks2 +are the same, it is equivalent to just encryption using ecb mode and +.I ks1 +as the key. +.PP +.I des_cbc_encrypt +encrypts/decrypts using the +.I cipher-block-chaining +mode of DES. +If the +.I encrypt +argument is non-zero, +the routine cipher-block-chain encrypts the cleartext data pointed to by the +.I input +argument into the ciphertext pointed to by the +.I output +argument, +using the key schedule provided by the +.I schedule +argument, +and initialisation vector provided by the +.I ivec +argument. +If the +.I length +argument is not an integral multiple of eight bytes, +the last block is copied to a temporary area and zero filled. +The output is always +an integral multiple of eight bytes. +To make multiple cbc encrypt calls on a large amount of data appear to +be one +.I des_cbc_encrypt +call, the +.I ivec +of subsequent calls should be the last 8 bytes of the output. +.PP +.I des_3cbc_encrypt +encrypts/decrypts the +.I input +block by using triple cbc DES encryption. +This involves encrypting the input with key schedule +.I ks1, +decryption with the key schedule +.I ks2, +and then encryption with the first again. +2 initialisation vectors are required, +.I ivec1 +and +.I ivec2. +Unlike +.I des_cbc_encrypt, +these initialisation vectors are modified by the subroutine. +This routine greatly reduces the chances of brute force breaking of +DES and has the advantage of if +.I ks1 +and +.I ks2 +are the same, it is equivalent to just encryption using cbc mode and +.I ks1 +as the key. +.PP +.I des_pcbc_encrypt +encrypt/decrypts using a modified block chaining mode. +It provides better error propagation characteristics than cbc +encryption. +.PP +.I des_cfb_encrypt +encrypt/decrypts using cipher feedback mode. This method takes an +array of characters as input and outputs and array of characters. It +does not require any padding to 8 character groups. Note: the ivec +variable is changed and the new changed value needs to be passed to +the next call to this function. Since this function runs a complete +DES ecb encryption per numbits, this function is only suggested for +use when sending small numbers of characters. +.PP +.I des_ofb_encrypt +encrypt using output feedback mode. This method takes an +array of characters as input and outputs and array of characters. It +does not require any padding to 8 character groups. Note: the ivec +variable is changed and the new changed value needs to be passed to +the next call to this function. Since this function runs a complete +DES ecb encryption per numbits, this function is only suggested for +use when sending small numbers of characters. +.PP +.I des_cbc_cksum +produces an 8 byte checksum based on the input stream (via cbc encryption). +The last 4 bytes of the checksum is returned and the complete 8 bytes is +placed in +.I output. +.PP +.I des_quad_cksum +returns a 4 byte checksum from the input bytes. +The algorithm can be iterated over the input, +depending on +.I out_count, +1, 2, 3 or 4 times. +If +.I output +is non-NULL, +the 8 bytes generated by each pass are written into +.I output. +.PP +.I des_enc_write +is used to write +.I len +bytes +to file descriptor +.I fd +from buffer +.I buf. +The data is encrypted via +.I pcbc_encrypt +(default) using +.I sched +for the key and +.I iv +as a starting vector. +The actual data send down +.I fd +consists of 4 bytes (in network byte order) containing the length of the +following encrypted data. The encrypted data then follows, padded with random +data out to a multiple of 8 bytes. +.PP +.I des_enc_read +is used to read +.I len +bytes +from file descriptor +.I fd +into buffer +.I buf. +The data being read from +.I fd +is assumed to have come from +.I des_enc_write +and is decrypted using +.I sched +for the key schedule and +.I iv +for the initial vector. +The +.I des_enc_read/des_enc_write +pair can be used to read/write to files, pipes and sockets. +I have used them in implementing a version of rlogin in which all +data is encrypted. +.PP +.I des_rw_mode +is used to specify the encryption mode to use with +.I des_enc_read +and +.I des_end_write. +If set to +.I DES_PCBC_MODE +(the default), des_pcbc_encrypt is used. +If set to +.I DES_CBC_MODE +des_cbc_encrypt is used. +These two routines and the variable are not part of the normal MIT library. +.PP +.I des_set_odd_parity +sets the parity of the passed +.I key +to odd. This routine is not part of the standard MIT library. +.PP +.I des_is_weak_key +returns 1 is the passed key is a weak key (pick again :-), +0 if it is ok. +This routine is not part of the standard MIT library. +.PP +.I crypt +is a replacement for the normal system crypt. +It is much faster than the system crypt. +.PP +.SH FILES +/usr/include/des.h +.br +/usr/lib/libdes.a +.PP +The encryption routines have been tested on 16bit, 32bit and 64bit +machines of various endian and even works under VMS. +.PP +.SH BUGS +.PP +If you think this manual is sparse, +read the des_crypt(3) manual from the MIT kerberos (or bones outside +of the USA) distribution. +.PP +.I des_cfb_encrypt +and +.I des_ofb_encrypt +operates on input of 8 bits. What this means is that if you set +numbits to 12, and length to 2, the first 12 bits will come from the 1st +input byte and the low half of the second input byte. The second 12 +bits will have the low 8 bits taken from the 3rd input byte and the +top 4 bits taken from the 4th input byte. The same holds for output. +This function has been implemented this way because most people will +be using a multiple of 8 and because once you get into pulling bytes input +bytes apart things get ugly! +.PP +.I des_read_pw_string +is the most machine/OS dependent function and normally generates the +most problems when porting this code. +.PP +.I des_string_to_key +is probably different from the MIT version since there are lots +of fun ways to implement one-way encryption of a text string. +.PP +The routines are optimised for 32 bit machines and so are not efficient +on IBM PCs. +.PP +NOTE: extensive work has been done on this library since this document +was origionally written. Please try to read des.doc from the libdes +distribution since it is far more upto date and documents more of the +functions. Libdes is now also being shipped as part of SSLeay, a +general cryptographic library that amonst other things implements +netscapes SSL protocoll. The most recent version can be found in +SSLeay distributions. +.SH AUTHOR +Eric Young (eay@cryptsoft.com) diff --git a/src/lib/libssl/src/crypto/des/des_locl.org b/src/lib/libssl/src/crypto/des/des_locl.org new file mode 100644 index 0000000000..e2e503cbed --- /dev/null +++ b/src/lib/libssl/src/crypto/des/des_locl.org @@ -0,0 +1,516 @@ +/* crypto/des/des_locl.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify des_locl.org since des_locl.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_DES_LOCL_H +#define HEADER_DES_LOCL_H + +#if defined(WIN32) || defined(WIN16) +#ifndef MSDOS +#define MSDOS +#endif +#endif + +#include +#include +#ifndef MSDOS +#include +#endif +#include "des.h" + +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ + #define DES_PTR + #define DES_RISC1 + #define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ + #define DES_PTR + #define DES_RISC2 + #define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ + #define DES_PTR + #define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ + #define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ + #define DES_PTR + #define DES_RISC2 + #define DES_UNROLL +#elif defined( i386 ) /* x86 boxes, should be gcc */ + #define DES_PTR + #define DES_RISC1 + #define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ + +#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ +#include +#include +#include +#include +#ifndef RAND +#define RAND +#endif +#undef NOPROTO +#endif + +#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) +#include +#endif + +#ifndef RAND +#define RAND +#endif + +#ifdef linux +#undef RAND +#endif + +#ifdef MSDOS +#define getpid() 2 +#define RAND +#undef NOPROTO +#endif + +#if defined(NOCONST) +#define const +#endif + +#ifdef __STDC__ +#undef NOPROTO +#endif + +#ifdef RAND +#define srandom(s) srand(s) +#define random rand +#endif + +#define ITERATIONS 16 +#define HALF_ITERATIONS 8 + +/* used in des_read and des_write */ +#define MAXWRITE (1024*16) +#define BSIZE (MAXWRITE+4) + +#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ + case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ + case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ + case 5: l2|=((DES_LONG)(*(--(c)))); \ + case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ + case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ + case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ + case 1: l1|=((DES_LONG)(*(--(c)))); \ + } \ + } + +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* replacements for htonl and ntohl since I have no idea what to do + * when faced with machines with 8 byte longs. */ +#define HDRSIZE 4 + +#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))) + +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +#if defined(WIN32) +#define ROTATE(a,n) (_lrotr(a,n)) +#else +#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) +#endif + +/* Don't worry about the LOAD_DATA() stuff, that is used by + * fcrypt() to add it's little bit to the front */ + +#ifdef DES_FCRYPT + +#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ + { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } + +#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + t=R^(R>>16L); \ + u=t&E0; t&=E1; \ + tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ + tmp=(t<<16); t^=R^s[S+1]; t^=tmp +#else +#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) +#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + u=R^s[S ]; \ + t=R^s[S+1] +#endif + +/* The changes to this macro may help or hinder, depending on the + * compiler and the achitecture. gcc2 always seems to do well :-). + * Inspired by Dana How + * DO NOT use the alternative version on machines with 8 byte longs. + * It does not seem to work on the Alpha, even when DES_LONG is 4 + * bytes, probably an issue of accessing non-word aligned objects :-( */ +#ifdef DES_PTR + +/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there + * is no reason to not xor all the sub items together. This potentially + * saves a register since things can be xored directly into L */ + +#if defined(DES_RISC1) || defined(DES_RISC2) +#ifdef DES_RISC1 +#define D_ENCRYPT(LL,R,S) { \ + unsigned int u1,u2,u3; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u2=(int)u>>8L; \ + u1=(int)u&0xfc; \ + u2&=0xfc; \ + t=ROTATE(t,4); \ + u>>=16L; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \ + u3=(int)(u>>8L); \ + u1=(int)u&0xfc; \ + u3&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \ + u2=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u2&=0xfc; \ + t>>=16L; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \ + u3=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u3&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); } +#endif +#ifdef DES_RISC2 +#define D_ENCRYPT(LL,R,S) { \ + unsigned int u1,u2,s1,s2; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u2=(int)u>>8L; \ + u1=(int)u&0xfc; \ + u2&=0xfc; \ + t=ROTATE(t,4); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \ + s1=(int)(u>>16L); \ + s2=(int)(u>>24L); \ + s1&=0xfc; \ + s2&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \ + u2=(int)t>>8L; \ + u1=(int)t&0xfc; \ + u2&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \ + s1=(int)(t>>16L); \ + s2=(int)(t>>24L); \ + s1&=0xfc; \ + s2&=0xfc; \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \ + LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); } +#endif +#else +#define D_ENCRYPT(LL,R,S) { \ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^= \ + *(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \ + *(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); } +#endif + +#else /* original version */ + +#if defined(DES_RISC1) || defined(DES_RISC2) +#ifdef DES_RISC1 +#define D_ENCRYPT(LL,R,S) {\ + unsigned int u1,u2,u3; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u>>=2L; \ + t=ROTATE(t,6); \ + u2=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u2&=0x3f; \ + u>>=16L; \ + LL^=des_SPtrans[0][u1]; \ + LL^=des_SPtrans[2][u2]; \ + u3=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u3&=0x3f; \ + LL^=des_SPtrans[4][u1]; \ + LL^=des_SPtrans[6][u3]; \ + u2=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u2&=0x3f; \ + t>>=16L; \ + LL^=des_SPtrans[1][u1]; \ + LL^=des_SPtrans[3][u2]; \ + u3=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u3&=0x3f; \ + LL^=des_SPtrans[5][u1]; \ + LL^=des_SPtrans[7][u3]; } +#endif +#ifdef DES_RISC2 +#define D_ENCRYPT(LL,R,S) {\ + unsigned int u1,u2,s1,s2; \ + LOAD_DATA(R,S,u,t,E0,E1,u1); \ + u>>=2L; \ + t=ROTATE(t,6); \ + u2=(int)u>>8L; \ + u1=(int)u&0x3f; \ + u2&=0x3f; \ + LL^=des_SPtrans[0][u1]; \ + LL^=des_SPtrans[2][u2]; \ + s1=(int)u>>16L; \ + s2=(int)u>>24L; \ + s1&=0x3f; \ + s2&=0x3f; \ + LL^=des_SPtrans[4][s1]; \ + LL^=des_SPtrans[6][s2]; \ + u2=(int)t>>8L; \ + u1=(int)t&0x3f; \ + u2&=0x3f; \ + LL^=des_SPtrans[1][u1]; \ + LL^=des_SPtrans[3][u2]; \ + s1=(int)t>>16; \ + s2=(int)t>>24L; \ + s1&=0x3f; \ + s2&=0x3f; \ + LL^=des_SPtrans[5][s1]; \ + LL^=des_SPtrans[7][s2]; } +#endif + +#else + +#define D_ENCRYPT(LL,R,S) {\ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^=\ + des_SPtrans[0][(u>> 2L)&0x3f]^ \ + des_SPtrans[2][(u>>10L)&0x3f]^ \ + des_SPtrans[4][(u>>18L)&0x3f]^ \ + des_SPtrans[6][(u>>26L)&0x3f]^ \ + des_SPtrans[1][(t>> 2L)&0x3f]^ \ + des_SPtrans[3][(t>>10L)&0x3f]^ \ + des_SPtrans[5][(t>>18L)&0x3f]^ \ + des_SPtrans[7][(t>>26L)&0x3f]; } +#endif +#endif + + /* IP and FP + * The problem is more of a geometric problem that random bit fiddling. + 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 + 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 + 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 + 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 + + 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 + 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 + 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 + 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 + + The output has been subject to swaps of the form + 0 1 -> 3 1 but the odd and even bits have been put into + 2 3 2 0 + different words. The main trick is to remember that + t=((l>>size)^r)&(mask); + r^=t; + l^=(t<>(n))^(b))&(m)),\ + (b)^=(t),\ + (a)^=((t)<<(n))) + +#define IP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ + PERM_OP(l,r,tt,16,0x0000ffffL); \ + PERM_OP(r,l,tt, 2,0x33333333L); \ + PERM_OP(l,r,tt, 8,0x00ff00ffL); \ + PERM_OP(r,l,tt, 1,0x55555555L); \ + } + +#define FP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(l,r,tt, 1,0x55555555L); \ + PERM_OP(r,l,tt, 8,0x00ff00ffL); \ + PERM_OP(l,r,tt, 2,0x33333333L); \ + PERM_OP(r,l,tt,16,0x0000ffffL); \ + PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ + } + +extern const DES_LONG des_SPtrans[8][64]; + +#ifndef NOPROTO +void fcrypt_body(DES_LONG *out,des_key_schedule ks, + DES_LONG Eswap0, DES_LONG Eswap1); +#else +void fcrypt_body(); +#endif + +#endif diff --git a/src/lib/libssl/src/crypto/des/doIP b/src/lib/libssl/src/crypto/des/doIP new file mode 100644 index 0000000000..18cf231303 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/doIP @@ -0,0 +1,46 @@ +#!/usr/local/bin/perl + +@l=( + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23, + 24,25,26,27,28,29,30,31 + ); +@r=( + 32,33,34,35,36,37,38,39, + 40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55, + 56,57,58,59,60,61,62,63 + ); + +require 'shifts.pl'; + +sub PERM_OP + { + local(*a,*b,*t,$n,$m)=@_; + + @z=&shift(*a,-$n); + @z=&xor(*b,*z); + @z=&and(*z,$m); + @b=&xor(*b,*z); + @z=&shift(*z,$n); + @a=&xor(*a,*z); + } + + +@L=@l; +@R=@r; +&PERM_OP(*R,*L,*T,4,0x0f0f0f0f); +&PERM_OP(*L,*R,*T,16,0x0000ffff); +&PERM_OP(*R,*L,*T,2,0x33333333); +&PERM_OP(*L,*R,*T,8,0x00ff00ff); +&PERM_OP(*R,*L,*T,1,0x55555555); + &printit(@L); + &printit(@R); +&PERM_OP(*R,*L,*T,1,0x55555555); +&PERM_OP(*L,*R,*T,8,0x00ff00ff); +&PERM_OP(*R,*L,*T,2,0x33333333); +&PERM_OP(*L,*R,*T,16,0x0000ffff); +&PERM_OP(*R,*L,*T,4,0x0f0f0f0f); + &printit(@L); + &printit(@R); diff --git a/src/lib/libssl/src/crypto/des/doPC1 b/src/lib/libssl/src/crypto/des/doPC1 new file mode 100644 index 0000000000..096afd8c46 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/doPC1 @@ -0,0 +1,110 @@ +#!/usr/local/bin/perl + +@l=( + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23, + 24,25,26,27,28,29,30,31 + ); +@r=( + 32,33,34,35,36,37,38,39, + 40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55, + 56,57,58,59,60,61,62,63 + ); + +require 'shifts.pl'; + +sub PERM_OP + { + local(*a,*b,*t,$n,$m)=@_; + + @z=&shift(*a,-$n); + @z=&xor(*b,*z); + @z=&and(*z,$m); + @b=&xor(*b,*z); + @z=&shift(*z,$n); + @a=&xor(*a,*z); + } + +sub HPERM_OP2 + { + local(*a,*t,$n,$m)=@_; + local(@x,@y,$i); + + @z=&shift(*a,16-$n); + @z=&xor(*a,*z); + @z=&and(*z,$m); + @a=&xor(*a,*z); + @z=&shift(*z,$n-16); + @a=&xor(*a,*z); + } + +sub HPERM_OP + { + local(*a,*t,$n,$m)=@_; + local(@x,@y,$i); + + for ($i=0; $i<16; $i++) + { + $x[$i]=$a[$i]; + $y[$i]=$a[16+$i]; + } + @z=&shift(*x,-$n); + @z=&xor(*y,*z); + @z=&and(*z,$m); + @y=&xor(*y,*z); + @z=&shift(*z,$n); + @x=&xor(*x,*z); + for ($i=0; $i<16; $i++) + { + $a[$i]=$x[$i]; + $a[16+$i]=$y[$i]; + } + } + +@L=@l; +@R=@r; + + print "---\n"; &printit(@R); +&PERM_OP(*R,*L,*T,4,0x0f0f0f0f); + print "---\n"; &printit(@R); +&HPERM_OP2(*L,*T,-2,0xcccc0000); +&HPERM_OP2(*R,*T,-2,0xcccc0000); + print "---\n"; &printit(@R); +&PERM_OP(*R,*L,*T,1,0x55555555); + print "---\n"; &printit(@R); +&PERM_OP(*L,*R,*T,8,0x00ff00ff); + print "---\n"; &printit(@R); +&PERM_OP(*R,*L,*T,1,0x55555555); + print "---\n"; &printit(@R); +# &printit(@L); + &printit(@R); +print <<"EOF"; +============================== +63 55 47 39 31 23 15 7 +62 54 46 38 30 22 14 6 +61 53 45 37 29 21 13 5 +60 52 44 36 -- -- -- -- + +57 49 41 33 25 17 9 1 +58 50 42 34 26 18 10 2 +59 51 43 35 27 19 11 3 +28 20 12 4 -- -- -- -- +EOF +exit(1); +@A=&and(*R,0x000000ff); +@A=&shift(*A,16); +@B=&and(*R,0x0000ff00); +@C=&and(*R,0x00ff0000); +@C=&shift(*C,-16); +@D=&and(*L,0xf0000000); +@D=&shift(*D,-4); +@A=&or(*A,*B); +@B=&or(*D,*C); +@R=&or(*A,*B); +@L=&and(*L,0x0fffffff); + + &printit(@L); + &printit(@R); + diff --git a/src/lib/libssl/src/crypto/des/doPC2 b/src/lib/libssl/src/crypto/des/doPC2 new file mode 100644 index 0000000000..fa5cf74cf7 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/doPC2 @@ -0,0 +1,94 @@ +#!/usr/local/bin/perl + +@PC2_C=(14,17,11,24, 1, 5, + 3,28,15, 6,21,10, + 23,19,12, 4,26, 8, + 16, 7,27,20,13, 2, + ); + +@PC2_D=(41,52,31,37,47,55, + 30,40,51,45,33,48, + 44,49,39,56,34,53, + 46,42,50,36,29,32, + ); + +$i=0; +foreach (@PC2_C) { + $_--; +# printf "%2d,",$_; + $C{$_}=$i; + ++$i; +# print "\n" if ((($i) % 8) == 0); + } +$i=0; +#print "\n"; +foreach (@PC2_D) { + $_-=28; + $_--; +# printf "%2d,",$_; + $D{$_}=$i; + $i++; +# print "\n" if ((($i) % 8) == 0); + } + +#print "\n"; +foreach $i (0 .. 27) + { + $_=$C{$i}; +# printf "%2d,",$_; + $i++; +# print "\n" if ((($i) % 8) == 0); + } +#print "\n"; + +#print "\n"; +foreach $i (0 .. 27) + { + $_=$D{$i}; +# printf "%2d,",$_; + $i++; +# print "\n" if ((($i) % 8) == 0); + } +#print "\n"; + +print "static ulong skb[8][64]={\n"; +&doit("C",*C, 0, 1, 2, 3, 4, 5); +&doit("C",*C, 6, 7, 9,10,11,12); +&doit("C",*C,13,14,15,16,18,19); +&doit("C",*C,20,22,23,25,26,27); + +&doit("D",*D, 0, 1, 2, 3, 4, 5); +&doit("D",*D, 7, 8,10,11,12,13); +&doit("D",*D,15,16,17,18,19,20); +&doit("D",*D,21,22,23,24,26,27); +print "};\n"; + +sub doit + { + local($l,*A,@b)=@_; + local(@out); + + printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n", + $b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1); + for ($i=0; $i<64; $i++) + { + $out[$i]=0; + $j=1; +#print "\n"; + for ($k=0; $k<6; $k++) + { + $l=$A{$b[$k]}; +#print"$l - "; + if ((1<<$k) & $i) + { + $ll=int($l/6)*8+($l%6); + $out[$i]|=1<<($ll); + } + } + $pp=$out[$i]; + $pp=($pp&0xff0000ff)| (($pp&0x00ff0000)>>8)| + (($pp&0x0000ff00)<<8); + printf("0x%08X,",$pp); + print "\n" if (($i+1) % 4 == 0); + } + } diff --git a/src/lib/libssl/src/crypto/des/ede_enc.c b/src/lib/libssl/src/crypto/des/ede_enc.c new file mode 100644 index 0000000000..9f75dd1037 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/ede_enc.c @@ -0,0 +1,190 @@ +/* crypto/des/ede_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "des_locl.h" + +void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc) +des_cblock (*input); +des_cblock (*output); +long length; +des_key_schedule ks1; +des_key_schedule ks2; +des_key_schedule ks3; +des_cblock (*ivec); +int enc; + { + register DES_LONG tin0,tin1; + register DES_LONG tout0,tout1,xor0,xor1; + register unsigned char *in,*out; + register long l=length; + DES_LONG tin[2]; + unsigned char *iv; + + in=(unsigned char *)input; + out=(unsigned char *)output; + iv=(unsigned char *)ivec; + + if (enc) + { + c2l(iv,tout0); + c2l(iv,tout1); + for (l-=8; l>=0; l-=8) + { + c2l(in,tin0); + c2l(in,tin1); + tin0^=tout0; + tin1^=tout1; + + tin[0]=tin0; + tin[1]=tin1; + des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + l2c(tout0,out); + l2c(tout1,out); + } + if (l != -8) + { + c2ln(in,tin0,tin1,l+8); + tin0^=tout0; + tin1^=tout1; + + tin[0]=tin0; + tin[1]=tin1; + des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + l2c(tout0,out); + l2c(tout1,out); + } + iv=(unsigned char *)ivec; + l2c(tout0,iv); + l2c(tout1,iv); + } + else + { + register DES_LONG t0,t1; + + c2l(iv,xor0); + c2l(iv,xor1); + for (l-=8; l>=0; l-=8) + { + c2l(in,tin0); + c2l(in,tin1); + + t0=tin0; + t1=tin1; + + tin[0]=tin0; + tin[1]=tin1; + des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + tout0^=xor0; + tout1^=xor1; + l2c(tout0,out); + l2c(tout1,out); + xor0=t0; + xor1=t1; + } + if (l != -8) + { + c2l(in,tin0); + c2l(in,tin1); + + t0=tin0; + t1=tin1; + + tin[0]=tin0; + tin[1]=tin1; + des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + tout0=tin[0]; + tout1=tin[1]; + + tout0^=xor0; + tout1^=xor1; + l2cn(tout0,tout1,out,l+8); + xor0=t0; + xor1=t1; + } + + iv=(unsigned char *)ivec; + l2c(xor0,iv); + l2c(xor1,iv); + } + tin0=tin1=tout0=tout1=xor0=xor1=0; + tin[0]=tin[1]=0; + } + +#ifdef undef /* MACRO */ +void des_ede2_cbc_encrypt(input, output, length, ks1, ks2, ivec, enc) +des_cblock (*input); +des_cblock (*output); +long length; +des_key_schedule ks1; +des_key_schedule ks2; +des_cblock (*ivec); +int enc; + { + des_ede3_cbc_encrypt(input,output,length,ks1,ks2,ks1,ivec,enc); + } +#endif + diff --git a/src/lib/libssl/src/crypto/des/podd.h b/src/lib/libssl/src/crypto/des/podd.h new file mode 100644 index 0000000000..1b2bfe0843 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/podd.h @@ -0,0 +1,75 @@ +/* crypto/des/podd.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +static const unsigned char odd_parity[256]={ + 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, + 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, + 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, + 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, + 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, + 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, + 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, +112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, +128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, +145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, +161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, +176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, +193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, +208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, +224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, +241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; diff --git a/src/lib/libssl/src/crypto/des/ranlib.sh b/src/lib/libssl/src/crypto/des/ranlib.sh new file mode 100644 index 0000000000..543f712c6b --- /dev/null +++ b/src/lib/libssl/src/crypto/des/ranlib.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cwd=`pwd` +cd /tmp + +if [ -s /bin/ranlib ] ; then + RL=/bin/ranlib +else if [ -s /usr/bin/ranlib ] ; then + RL=/usr/bin/ranlib +fi +fi + +if [ "x$RL" != "x" ] +then + case "$1" in + /*) + $RL "$1" + ;; + *) + $RL "$cwd/$1" + ;; + esac +fi diff --git a/src/lib/libssl/src/crypto/des/shifts.pl b/src/lib/libssl/src/crypto/des/shifts.pl new file mode 100644 index 0000000000..d8a240c1ba --- /dev/null +++ b/src/lib/libssl/src/crypto/des/shifts.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl + +sub lab_shift + { + local(*a,$n)=@_; + local(@r,$i,$j,$k,$d,@z); + + @r=&shift(*a,$n); + foreach $i (0 .. 31) + { + @z=split(/\^/,$r[$i]); + for ($j=0; $j <= $#z; $j++) + { + ($d)=($z[$j] =~ /^(..)/); + ($k)=($z[$j] =~ /\[(.*)\]$/); + $k.=",$n" if ($k ne ""); + $k="$n" if ($k eq ""); + $d="$d[$k]"; + $z[$j]=$d; + } + $r[$i]=join('^',@z); + } + return(@r); + } + +sub shift + { + local(*a,$n)=@_; + local(@f); + + if ($n > 0) + { + @f=&shiftl(*a,$n); + } + else + { + @f=&shiftr(*a,-$n); + } + return(@f); + } + +sub rotate + { + local(*a,$n)=@_; + local(@f); + + if ($n > 0) + { @f=&rotatel(*a,$n); } + else + { @f=&rotater(*a,-$n); } + return(@f); + } + +sub rotater + { + local(*a,$n)=@_; + local(@f,@g); + + @f=&shiftr(*a,$n); + @g=&shiftl(*a,32-$n); + $#f=31; + $#g=31; + return(&or(*f,*g)); + } + +sub rotatel + { + local(*a,$n)=@_; + local(@f,@g); + + @f=&shiftl(*a,$n); + @g=&shiftr(*a,32-$n); + $#f=31; + $#g=31; + return(&or(*f,*g)); + } + +sub shiftr + { + local(*a,$n)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + if (($i+$n) > 31) + { + $r[$i]="--"; + } + else + { + $r[$i]=$a[$i+$n]; + } + } + return(@r); + } + +sub shiftl + { + local(*a,$n)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + if ($i < $n) + { + $r[$i]="--"; + } + else + { + $r[$i]=$a[$i-$n]; + } + } + return(@r); + } + +sub printit + { + local(@a)=@_; + local($i); + + foreach $i (0 .. 31) + { + printf "%2s ",$a[$i]; + print "\n" if (($i%8) == 7); + } + print "\n"; + } + +sub xor + { + local(*a,*b)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + $r[$i]=&compress($a[$i].'^'.$b[$i]); +# $r[$i]=$a[$i]."^".$b[$i]; + } + return(@r); + } + +sub and + { + local(*a,$m)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + $r[$i]=(($m & (1<<$i))?($a[$i]):('--')); + } + return(@r); + } + +sub or + { + local(*a,*b)=@_; + local(@r,$i); + + $#r=31; + foreach $i (0 .. 31) + { + $r[$i]='--' if (($a[$i] eq '--') && ($b[$i] eq '--')); + $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--')); + $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--')); + $r[$i]='++' if (($a[$i] ne '--') && ($b[$i] ne '--')); + } + return(@r); + } + +sub compress + { + local($s)=@_; + local($_,$i,@a,%a,$r); + + $s =~ s/\^\^/\^/g; + $s =~ s/^\^//; + $s =~ s/\^$//; + @a=split(/\^/,$s); + + while ($#a >= 0) + { + $_=shift(@a); + next unless /\d/; + $a{$_}++; + } + foreach $i (sort keys %a) + { + next if ($a{$i}%2 == 0); + $r.="$i^"; + } + chop($r); + return($r); + } +1; diff --git a/src/lib/libssl/src/crypto/des/sk.h b/src/lib/libssl/src/crypto/des/sk.h new file mode 100644 index 0000000000..f2ade88c7c --- /dev/null +++ b/src/lib/libssl/src/crypto/des/sk.h @@ -0,0 +1,204 @@ +/* crypto/des/sk.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +static const DES_LONG des_skb[8][64]={ +{ +/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ +0x00000000L,0x00000010L,0x20000000L,0x20000010L, +0x00010000L,0x00010010L,0x20010000L,0x20010010L, +0x00000800L,0x00000810L,0x20000800L,0x20000810L, +0x00010800L,0x00010810L,0x20010800L,0x20010810L, +0x00000020L,0x00000030L,0x20000020L,0x20000030L, +0x00010020L,0x00010030L,0x20010020L,0x20010030L, +0x00000820L,0x00000830L,0x20000820L,0x20000830L, +0x00010820L,0x00010830L,0x20010820L,0x20010830L, +0x00080000L,0x00080010L,0x20080000L,0x20080010L, +0x00090000L,0x00090010L,0x20090000L,0x20090010L, +0x00080800L,0x00080810L,0x20080800L,0x20080810L, +0x00090800L,0x00090810L,0x20090800L,0x20090810L, +0x00080020L,0x00080030L,0x20080020L,0x20080030L, +0x00090020L,0x00090030L,0x20090020L,0x20090030L, +0x00080820L,0x00080830L,0x20080820L,0x20080830L, +0x00090820L,0x00090830L,0x20090820L,0x20090830L, +},{ +/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ +0x00000000L,0x02000000L,0x00002000L,0x02002000L, +0x00200000L,0x02200000L,0x00202000L,0x02202000L, +0x00000004L,0x02000004L,0x00002004L,0x02002004L, +0x00200004L,0x02200004L,0x00202004L,0x02202004L, +0x00000400L,0x02000400L,0x00002400L,0x02002400L, +0x00200400L,0x02200400L,0x00202400L,0x02202400L, +0x00000404L,0x02000404L,0x00002404L,0x02002404L, +0x00200404L,0x02200404L,0x00202404L,0x02202404L, +0x10000000L,0x12000000L,0x10002000L,0x12002000L, +0x10200000L,0x12200000L,0x10202000L,0x12202000L, +0x10000004L,0x12000004L,0x10002004L,0x12002004L, +0x10200004L,0x12200004L,0x10202004L,0x12202004L, +0x10000400L,0x12000400L,0x10002400L,0x12002400L, +0x10200400L,0x12200400L,0x10202400L,0x12202400L, +0x10000404L,0x12000404L,0x10002404L,0x12002404L, +0x10200404L,0x12200404L,0x10202404L,0x12202404L, +},{ +/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ +0x00000000L,0x00000001L,0x00040000L,0x00040001L, +0x01000000L,0x01000001L,0x01040000L,0x01040001L, +0x00000002L,0x00000003L,0x00040002L,0x00040003L, +0x01000002L,0x01000003L,0x01040002L,0x01040003L, +0x00000200L,0x00000201L,0x00040200L,0x00040201L, +0x01000200L,0x01000201L,0x01040200L,0x01040201L, +0x00000202L,0x00000203L,0x00040202L,0x00040203L, +0x01000202L,0x01000203L,0x01040202L,0x01040203L, +0x08000000L,0x08000001L,0x08040000L,0x08040001L, +0x09000000L,0x09000001L,0x09040000L,0x09040001L, +0x08000002L,0x08000003L,0x08040002L,0x08040003L, +0x09000002L,0x09000003L,0x09040002L,0x09040003L, +0x08000200L,0x08000201L,0x08040200L,0x08040201L, +0x09000200L,0x09000201L,0x09040200L,0x09040201L, +0x08000202L,0x08000203L,0x08040202L,0x08040203L, +0x09000202L,0x09000203L,0x09040202L,0x09040203L, +},{ +/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ +0x00000000L,0x00100000L,0x00000100L,0x00100100L, +0x00000008L,0x00100008L,0x00000108L,0x00100108L, +0x00001000L,0x00101000L,0x00001100L,0x00101100L, +0x00001008L,0x00101008L,0x00001108L,0x00101108L, +0x04000000L,0x04100000L,0x04000100L,0x04100100L, +0x04000008L,0x04100008L,0x04000108L,0x04100108L, +0x04001000L,0x04101000L,0x04001100L,0x04101100L, +0x04001008L,0x04101008L,0x04001108L,0x04101108L, +0x00020000L,0x00120000L,0x00020100L,0x00120100L, +0x00020008L,0x00120008L,0x00020108L,0x00120108L, +0x00021000L,0x00121000L,0x00021100L,0x00121100L, +0x00021008L,0x00121008L,0x00021108L,0x00121108L, +0x04020000L,0x04120000L,0x04020100L,0x04120100L, +0x04020008L,0x04120008L,0x04020108L,0x04120108L, +0x04021000L,0x04121000L,0x04021100L,0x04121100L, +0x04021008L,0x04121008L,0x04021108L,0x04121108L, +},{ +/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ +0x00000000L,0x10000000L,0x00010000L,0x10010000L, +0x00000004L,0x10000004L,0x00010004L,0x10010004L, +0x20000000L,0x30000000L,0x20010000L,0x30010000L, +0x20000004L,0x30000004L,0x20010004L,0x30010004L, +0x00100000L,0x10100000L,0x00110000L,0x10110000L, +0x00100004L,0x10100004L,0x00110004L,0x10110004L, +0x20100000L,0x30100000L,0x20110000L,0x30110000L, +0x20100004L,0x30100004L,0x20110004L,0x30110004L, +0x00001000L,0x10001000L,0x00011000L,0x10011000L, +0x00001004L,0x10001004L,0x00011004L,0x10011004L, +0x20001000L,0x30001000L,0x20011000L,0x30011000L, +0x20001004L,0x30001004L,0x20011004L,0x30011004L, +0x00101000L,0x10101000L,0x00111000L,0x10111000L, +0x00101004L,0x10101004L,0x00111004L,0x10111004L, +0x20101000L,0x30101000L,0x20111000L,0x30111000L, +0x20101004L,0x30101004L,0x20111004L,0x30111004L, +},{ +/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ +0x00000000L,0x08000000L,0x00000008L,0x08000008L, +0x00000400L,0x08000400L,0x00000408L,0x08000408L, +0x00020000L,0x08020000L,0x00020008L,0x08020008L, +0x00020400L,0x08020400L,0x00020408L,0x08020408L, +0x00000001L,0x08000001L,0x00000009L,0x08000009L, +0x00000401L,0x08000401L,0x00000409L,0x08000409L, +0x00020001L,0x08020001L,0x00020009L,0x08020009L, +0x00020401L,0x08020401L,0x00020409L,0x08020409L, +0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, +0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, +0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, +0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, +0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, +0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, +0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, +0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, +},{ +/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ +0x00000000L,0x00000100L,0x00080000L,0x00080100L, +0x01000000L,0x01000100L,0x01080000L,0x01080100L, +0x00000010L,0x00000110L,0x00080010L,0x00080110L, +0x01000010L,0x01000110L,0x01080010L,0x01080110L, +0x00200000L,0x00200100L,0x00280000L,0x00280100L, +0x01200000L,0x01200100L,0x01280000L,0x01280100L, +0x00200010L,0x00200110L,0x00280010L,0x00280110L, +0x01200010L,0x01200110L,0x01280010L,0x01280110L, +0x00000200L,0x00000300L,0x00080200L,0x00080300L, +0x01000200L,0x01000300L,0x01080200L,0x01080300L, +0x00000210L,0x00000310L,0x00080210L,0x00080310L, +0x01000210L,0x01000310L,0x01080210L,0x01080310L, +0x00200200L,0x00200300L,0x00280200L,0x00280300L, +0x01200200L,0x01200300L,0x01280200L,0x01280300L, +0x00200210L,0x00200310L,0x00280210L,0x00280310L, +0x01200210L,0x01200310L,0x01280210L,0x01280310L, +},{ +/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ +0x00000000L,0x04000000L,0x00040000L,0x04040000L, +0x00000002L,0x04000002L,0x00040002L,0x04040002L, +0x00002000L,0x04002000L,0x00042000L,0x04042000L, +0x00002002L,0x04002002L,0x00042002L,0x04042002L, +0x00000020L,0x04000020L,0x00040020L,0x04040020L, +0x00000022L,0x04000022L,0x00040022L,0x04040022L, +0x00002020L,0x04002020L,0x00042020L,0x04042020L, +0x00002022L,0x04002022L,0x00042022L,0x04042022L, +0x00000800L,0x04000800L,0x00040800L,0x04040800L, +0x00000802L,0x04000802L,0x00040802L,0x04040802L, +0x00002800L,0x04002800L,0x00042800L,0x04042800L, +0x00002802L,0x04002802L,0x00042802L,0x04042802L, +0x00000820L,0x04000820L,0x00040820L,0x04040820L, +0x00000822L,0x04000822L,0x00040822L,0x04040822L, +0x00002820L,0x04002820L,0x00042820L,0x04042820L, +0x00002822L,0x04002822L,0x00042822L,0x04042822L, +}}; diff --git a/src/lib/libssl/src/crypto/des/supp.c b/src/lib/libssl/src/crypto/des/supp.c new file mode 100644 index 0000000000..f8e5833f69 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/supp.c @@ -0,0 +1,109 @@ +/* crypto/des/supp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* + * Copyright (c) 1995 + * Mark Murray. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Mark Murray + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: supp.c,v 1.1.1.1 1998/10/05 20:12:45 ryker Exp $ + */ + +#include +#include "des_locl.h" + +void des_cblock_print_file(cb, fp) + des_cblock *cb; + FILE *fp; +{ + int i; + unsigned int *p = (unsigned int *)cb; + + fprintf(fp, " 0x { "); + for (i = 0; i < 8; i++) { + fprintf(fp, "%x", p[i]); + if (i != 7) fprintf(fp, ", "); + } + fprintf(fp, " }"); +} diff --git a/src/lib/libssl/src/crypto/des/testdes.pl b/src/lib/libssl/src/crypto/des/testdes.pl new file mode 100644 index 0000000000..67fbd47f36 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/testdes.pl @@ -0,0 +1,167 @@ +#!/usr/bin/perl + +# des.pl tesing code + +require 'des.pl'; + +$num_tests=34; +@key_data=( + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10, + 0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57, + 0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E, + 0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86, + 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E, + 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6, + 0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE, + 0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6, + 0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE, + 0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16, + 0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F, + 0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46, + 0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E, + 0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76, + 0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07, + 0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F, + 0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7, + 0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF, + 0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6, + 0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E, + 0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10, + ); + +@plain_data=( + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42, + 0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA, + 0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72, + 0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A, + 0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2, + 0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A, + 0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2, + 0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A, + 0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02, + 0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A, + 0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32, + 0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA, + 0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62, + 0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2, + 0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA, + 0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92, + 0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A, + 0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2, + 0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF); + +@cipher_data=( + 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7, + 0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58, + 0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B, + 0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33, + 0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D, + 0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD, + 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7, + 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4, + 0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B, + 0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71, + 0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A, + 0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A, + 0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95, + 0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B, + 0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09, + 0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A, + 0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F, + 0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88, + 0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77, + 0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A, + 0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56, + 0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56, + 0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56, + 0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC, + 0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A, + 0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41, + 0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93, + 0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00, + 0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06, + 0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7, + 0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51, + 0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE, + 0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D, + 0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2); + +print "Doing ecb tests\n"; +for ($i=0; $i<$num_tests; $i++) + { + printf "Doing test $i\n"; + $key =pack("C8",splice(@key_data ,0,8)); + $data=pack("C8",splice(@plain_data ,0,8)); + $res =pack("C8",splice(@cipher_data,0,8)); + + @ks= &des_set_key($key); + $out1= &des_ecb_encrypt(*ks,1,$data); + $out2= &des_ecb_encrypt(*ks,0,$out1); + $out3= &des_ecb_encrypt(*ks,0,$res); + &eprint("encryption failure",$res,$out1) + if ($out1 ne $res); + &eprint("encryption/decryption failure",$data,$out2) + if ($out2 ne $data); + &eprint("decryption failure",$data,$out3) + if ($data ne $out3); + } +print "Done\n"; + +print "doing speed test over 30 seconds\n"; +$SIG{'ALRM'}='done'; +sub done {$done=1;} +$done=0; + +$count=0; +$d=pack("C8",0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef); +@ks= &des_set_key($d); +alarm(30); +$start=(times)[0]; +while (!$done) + { + $count++; + $d=&des_ecb_encrypt(*ks,1,$d); + } +$end=(times)[0]; +$t=$end-$start; +printf "$count DESs in %.2f seconds is %.2f DESs/sec or %.2f bytes/sec\n", + 1.0*$t,1.0*$count/$t,$count*8.0/$t; + +sub eprint + { + local($s,$c,$e)=@_; + local(@k); + + @k=unpack("C8",$c); + printf "%02x%02x%02x%02x %02x%02x%02x%02x - ",unpack("C8",$c); + printf "%02x%02x%02x%02x %02x%02x%02x%02x :",unpack("C8",$e); + print " $s\n"; + } diff --git a/src/lib/libssl/src/crypto/des/vms.com b/src/lib/libssl/src/crypto/des/vms.com new file mode 100644 index 0000000000..62ca1fbda4 --- /dev/null +++ b/src/lib/libssl/src/crypto/des/vms.com @@ -0,0 +1,90 @@ +$! --- VMS.com --- +$! +$ GoSub defines +$ GoSub linker_options +$ If (P1 .nes. "") +$ Then +$ GoSub 'P1' +$ Else +$ GoSub lib +$ GoSub destest +$ GoSub rpw +$ GoSub speed +$ GoSub des +$ EndIF +$! +$ Exit +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$DEFINES: +$ OPT_FILE := "VAX_LINKER_OPTIONS.OPT" +$! +$ CC_OPTS := "/NODebug/OPTimize/NOWarn" +$! +$ LINK_OPTS := "/NODebug/NOTraceback/Contiguous" +$! +$ OBJS = "cbc_cksm.obj,cbc_enc.obj,ecb_enc.obj,pcbc_enc.obj," + - + "qud_cksm.obj,rand_key.obj,read_pwd.obj,set_key.obj," + - + "str2key.obj,enc_read.obj,enc_writ.obj,fcrypt.obj," + - + "cfb_enc.obj,ecb3_enc.obj,ofb_enc.obj" + + +$! +$ LIBDES = "cbc_cksm.c,cbc_enc.c,ecb_enc.c,enc_read.c," + - + "enc_writ.c,pcbc_enc.c,qud_cksm.c,rand_key.c," + - + "read_pwd.c,set_key.c,str2key.c,fcrypt.c," + - + "cfb_enc.c,ecb3_enc.c,ofb_enc.c" +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$LINKER_OPTIONS: +$ If (f$search(OPT_FILE) .eqs. "") +$ Then +$ Create 'OPT_FILE' +$DECK +! Default system options file to link against the sharable C runtime library +! +Sys$Share:VAXcRTL.exe/Share +$EOD +$ EndIF +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$LIB: +$ CC 'CC_OPTS' 'LIBDES' +$ If (f$search("LIBDES.OLB") .nes. "") +$ Then Library /Object /Replace libdes 'OBJS' +$ Else Library /Create /Object libdes 'OBJS' +$ EndIF +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$DESTEST: +$ CC 'CC_OPTS' destest +$ Link 'link_opts' /Exec=destest destest.obj,libdes/LIBRARY,'opt_file'/Option +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$RPW: +$ CC 'CC_OPTS' rpw +$ Link 'link_opts' /Exec=rpw rpw.obj,libdes/LIBRARY,'opt_file'/Option +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$SPEED: +$ CC 'CC_OPTS' speed +$ Link 'link_opts' /Exec=speed speed.obj,libdes/LIBRARY,'opt_file'/Option +$ Return +$! +$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +$! +$DES: +$ CC 'CC_OPTS' des +$ Link 'link_opts' /Exec=des des.obj,libdes/LIBRARY,'opt_file'/Option +$ Return diff --git a/src/lib/libssl/src/crypto/dh/Makefile.ssl b/src/lib/libssl/src/crypto/dh/Makefile.ssl new file mode 100644 index 0000000000..dfa7e4525d --- /dev/null +++ b/src/lib/libssl/src/crypto/dh/Makefile.ssl @@ -0,0 +1,84 @@ +# +# SSLeay/crypto/dh/Makefile +# + +DIR= dh +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=dh +ERRC=dh_err +GENERAL=Makefile +TEST= dhtest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= dh_gen.c dh_key.c dh_lib.c dh_check.c $(ERRC).c +LIBOBJ= dh_gen.o dh_key.o dh_lib.o dh_check.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= dh.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/dh/dh.err b/src/lib/libssl/src/crypto/dh/dh.err new file mode 100644 index 0000000000..a4fe746985 --- /dev/null +++ b/src/lib/libssl/src/crypto/dh/dh.err @@ -0,0 +1,12 @@ +/* Error codes for the DH functions. */ + +/* Function codes. */ +#define DH_F_DHPARAMS_PRINT 100 +#define DH_F_DHPARAMS_PRINT_FP 101 +#define DH_F_DH_COMPUTE_KEY 102 +#define DH_F_DH_GENERATE_KEY 103 +#define DH_F_DH_GENERATE_PARAMETERS 104 +#define DH_F_DH_NEW 105 + +/* Reason codes. */ +#define DH_R_NO_PRIVATE_VALUE 100 diff --git a/src/lib/libssl/src/crypto/dsa/Makefile.ssl b/src/lib/libssl/src/crypto/dsa/Makefile.ssl new file mode 100644 index 0000000000..2cc4ddb39e --- /dev/null +++ b/src/lib/libssl/src/crypto/dsa/Makefile.ssl @@ -0,0 +1,84 @@ +# +# SSLeay/crypto/dsa/Makefile +# + +DIR= dsa +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=dsa +ERRC=dsa_err +GENERAL=Makefile +TEST=dsatest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c $(ERRC).c +LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= dsa.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/dsa/dsa.err b/src/lib/libssl/src/crypto/dsa/dsa.err new file mode 100644 index 0000000000..1131e9fa74 --- /dev/null +++ b/src/lib/libssl/src/crypto/dsa/dsa.err @@ -0,0 +1,15 @@ +/* Error codes for the DSA functions. */ + +/* Function codes. */ +#define DSA_F_DSAPARAMS_PRINT 100 +#define DSA_F_DSAPARAMS_PRINT_FP 101 +#define DSA_F_DSA_IS_PRIME 102 +#define DSA_F_DSA_NEW 103 +#define DSA_F_DSA_PRINT 104 +#define DSA_F_DSA_PRINT_FP 105 +#define DSA_F_DSA_SIGN 106 +#define DSA_F_DSA_SIGN_SETUP 107 +#define DSA_F_DSA_VERIFY 108 + +/* Reason codes. */ +#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 diff --git a/src/lib/libssl/src/crypto/err/Makefile.ssl b/src/lib/libssl/src/crypto/err/Makefile.ssl new file mode 100644 index 0000000000..57c87eb041 --- /dev/null +++ b/src/lib/libssl/src/crypto/err/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/err/Makefile +# + +DIR= err +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=err.c err_all.c err_prn.c +LIBOBJ=err.o err_all.o err_prn.o + +SRC= $(LIBSRC) + +EXHEADER= err.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/err/err_code.pl b/src/lib/libssl/src/crypto/err/err_code.pl new file mode 100644 index 0000000000..ebc8eef913 --- /dev/null +++ b/src/lib/libssl/src/crypto/err/err_code.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl + +while (@ARGV) + { + $in=shift(@ARGV); + if ($in =~ /^-conf$/) + { + $in=shift(@ARGV); + open(IN,"<$in") || die "unable to open '$in'\n"; + while () + { + s/#.*$//; + s/\s+$//; + next if (/^$/); + if (/^L\s+(\S+)\s+(\S+)$/) + { $errfile{$1}=$2; } + elsif (/^F\s+(\S+)$/) + { $function{$1}=1; } + elsif (/^R\s+(\S+)\s+(\S+)$/) + { $r_value{$1}=$2; } + else { die "bad input line: $in:$.\n"; } + } + close(IN); + next; + } + + open(IN,"<$in") || die "unable to open '$in'\n"; + $last=""; + while () + { + if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/) + { + if ($1 != $last) + { + if ($function{$1} == 0) + { + printf STDERR "$. $1 is bad\n"; + } + } + $function{$1}++; + $last=$1; + $reason{$2}++; + } + } + close(IN); + } + +foreach (keys %function,keys %reason) + { + /^([A-Z0-9]+)_/; + $prefix{$1}++; + } + +@F=sort keys %function; +@R=sort keys %reason; +foreach $j (sort keys %prefix) + { + next if $errfile{$j} eq "NONE"; + printf STDERR "doing %-6s - ",$j; + if (defined($errfile{$j})) + { + open(OUT,">$errfile{$j}") || + die "unable to open '$errfile{$j}':$!\n"; + $close_file=1; + } + else + { + *OUT=*STDOUT; + $close=0; + } + @f=grep(/^${j}_/,@F); + @r=grep(/^${j}_/,@R); + $num=100; + print OUT "/* Error codes for the $j functions. */\n\n"; + print OUT "/* Function codes. */\n"; + $f_count=0; + foreach $i (@f) + { + $z=6-int(length($i)/8); + printf OUT "#define $i%s $num\n","\t" x $z; + $num++; + $f_count++; + } + $num=100; + print OUT "\n/* Reason codes. */\n"; + $r_count=0; + foreach $i (@r) + { + $z=6-int(length($i)/8); + if (defined($r_value{$i})) + { + printf OUT "#define $i%s $r_value{$i}\n","\t" x $z; + } + else + { + printf OUT "#define $i%s $num\n","\t" x $z; + $num++; + } + $r_count++; + } + close(OUT) if $close_file; + + printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count; + } + diff --git a/src/lib/libssl/src/crypto/err/err_genc.pl b/src/lib/libssl/src/crypto/err/err_genc.pl new file mode 100644 index 0000000000..a8e36c2f0c --- /dev/null +++ b/src/lib/libssl/src/crypto/err/err_genc.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl + +if ($ARGV[0] eq "-s") { $static=1; shift @ARGV; } + +($#ARGV == 1) || die "usage: $0 [-s]
\n"; +open(IN,"<$ARGV[0]") || die "unable to open $ARGV[0]:$!\n"; +open(STDOUT,">$ARGV[1]") || die "unable to open $ARGV[1]:$!\n"; + +$Func=0; +$Reas=0; +$fuction{'FOPEN'}='fopen'; +while () + { + if (/(\S+)\s*\(\);/) + { + $t=$1; + $t =~ s/\*//; + ($upper=$t) =~ tr/a-z/A-Z/; + $fuction{$upper}=$t; + } + next unless (/^#define\s+(\S+)\s/); + + $o=$1; + if ($o =~ /^([^_]+)_F_(.*)/) + { + $type=$1; + $Func++; + $n=$2; + $n=$fuction{$n} if (defined($fuction{$n})); + $out{$1."_str_functs"}.= + sprintf("{ERR_PACK(0,%s,0),\t\"$n\"},\n",$o); + } + elsif ($o =~ /^([^_]+)_R_(.*)/) + { + $type=$1; + $Reas++; + $r=$2; + $r =~ tr/A-Z_/a-z /; + $pkg{$type."_str_reasons"}=$type; + $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o); + } + elsif ($ARGV[0] =~ /rsaref/ && $o =~ /^RE_(.*)/) + { + $type="RSAREF"; + $Reas++; + $r=$1; + $r =~ tr/A-Z_/a-z /; + $pkg{$type."_str_reasons"}=$type; + $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o); + } + } +close(IN); + +&header($type,$ARGV[0]); + +foreach (sort keys %out) + { + print "static ERR_STRING_DATA ${_}[]=\n\t{\n"; + print $out{$_}; + print "{0,NULL},\n"; + print "\t};\n\n"; + } +print "#endif\n"; + +if ($static) + { $lib="ERR_LIB_$type"; } +else + { $lib="${type}_lib_error_code"; } + +$str=""; +$str.="#ifndef NO_ERR\n"; +$str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func; +$str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas; +$str.="#endif\n"; + +if (!$static) + { +print <<"EOF"; + +static int ${type}_lib_error_code=0; + +void ERR_load_${type}_strings() + { + static int init=1; + + if (${type}_lib_error_code == 0) + ${type}_lib_error_code=ERR_get_next_error_library(); + + if (init); + {; + init=0; +$str + } + } + +void ERR_${type}_error(function,reason,file,line) +int function; +int reason; +char *file; +int line; + { + if (${type}_lib_error_code == 0) + ${type}_lib_error_code=ERR_get_next_error_library(); + ERR_PUT_error(${type}_lib_error_code,function,reason,file,line); + } +EOF + } +else # $static + { + print <<"EOF"; + +void ERR_load_${type}_strings() + { + static int init=1; + + if (init); + {; + init=0; +$str + } + } +EOF + } + +sub header + { + ($type,$header)=@_; + + ($lc=$type) =~ tr/A-Z/a-z/; + $header =~ s/^.*\///; + + print "/* lib/$lc/${lc}\_err.c */\n"; + print <<'EOF'; +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +EOF + + print "#include \n"; + print "#include \"err.h\"\n"; + print "#include \"$header\"\n"; + print "\n/* BEGIN ERROR CODES */\n"; + print "#ifndef NO_ERR\n"; + } + diff --git a/src/lib/libssl/src/crypto/err/error.err b/src/lib/libssl/src/crypto/err/error.err new file mode 100644 index 0000000000..f09557d8d9 --- /dev/null +++ b/src/lib/libssl/src/crypto/err/error.err @@ -0,0 +1,13 @@ +/* Error codes for the ERR functions. */ + +/* Function codes. */ + +/* Reason codes. */ +#define ERR_R_BN_LIB 100 +#define ERR_R_DER_LIB 101 +#define ERR_R_MALLOC_FAILURE 102 +#define ERR_R_PEM_LIB 103 +#define ERR_R_RSA_LIB 104 +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED 105 +#define ERR_R_SYS_LIB 106 +#define ERR_R_X509_LIB 107 diff --git a/src/lib/libssl/src/crypto/err/ssleay.ec b/src/lib/libssl/src/crypto/err/ssleay.ec new file mode 100644 index 0000000000..10b5dbb59d --- /dev/null +++ b/src/lib/libssl/src/crypto/err/ssleay.ec @@ -0,0 +1,57 @@ +L ERR NONE +L CRYPTO crypto.err +L BN bn/bn.err +L RSA rsa/rsa.err +L DSA dsa/dsa.err +L DH dh/dh.err +L EVP evp/evp.err +L BUF buffer/buffer.err +L BIO bio/bio.err +L OBJ objects/objects.err +L PEM pem/pem.err +L X509 x509/x509.err +L METH meth/meth.err +L ASN1 asn1/asn1.err +L CONF conf/conf.err +L PROXY proxy/proxy.err +L PKCS7 pkcs7/pkcs7.err +L RSAREF ../rsaref/rsaref.err +L SSL ../ssl/ssl.err +L SSL2 ../ssl/ssl2.err +L SSL3 ../ssl/ssl3.err +L SSL23 ../ssl/ssl23.err + +F RSAREF_F_RSA_BN2BIN +F RSAREF_F_RSA_PRIVATE_DECRYPT +F RSAREF_F_RSA_PRIVATE_ENCRYPT +F RSAREF_F_RSA_PUBLIC_DECRYPT +F RSAREF_F_RSA_PUBLIC_ENCRYPT +#F SSL_F_CLIENT_CERTIFICATE + +R SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +R SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +R SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +R SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +R SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +R SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +R SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +R SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +R SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +R SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +R SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 + +R RSAREF_R_CONTENT_ENCODING 0x0400 +R RSAREF_R_DATA 0x0401 +R RSAREF_R_DIGEST_ALGORITHM 0x0402 +R RSAREF_R_ENCODING 0x0403 +R RSAREF_R_KEY 0x0404 +R RSAREF_R_KEY_ENCODING 0x0405 +R RSAREF_R_LEN 0x0406 +R RSAREF_R_MODULUS_LEN 0x0407 +R RSAREF_R_NEED_RANDOM 0x0408 +R RSAREF_R_PRIVATE_KEY 0x0409 +R RSAREF_R_PUBLIC_KEY 0x040a +R RSAREF_R_SIGNATURE 0x040b +R RSAREF_R_SIGNATURE_ENCODING 0x040c +R RSAREF_R_ENCRYPTION_ALGORITHM 0x040d + diff --git a/src/lib/libssl/src/crypto/evp/Makefile.ssl b/src/lib/libssl/src/crypto/evp/Makefile.ssl new file mode 100644 index 0000000000..8bf2516458 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/Makefile.ssl @@ -0,0 +1,111 @@ +# +# SSLeay/crypto/evp/Makefile +# + +DIR= evp +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=evp +ERRC=evp_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= encode.c digest.c evp_enc.c evp_key.c \ + e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c \ + e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c \ + e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c \ + e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c \ + e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c \ + e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c \ + e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c \ + e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c \ + m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c \ + m_ripemd.c \ + p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ + bio_md.c bio_b64.c bio_enc.c $(ERRC).c e_null.c \ + c_all.c evp_lib.c + +LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \ + e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \ + e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o \ + e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o \ + e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o \ + e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o \ + e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o \ + e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o \ + e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o \ + m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o \ + m_ripemd.o \ + p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ + bio_md.o bio_b64.o bio_enc.o $(ERRC).o e_null.o \ + c_all.o evp_lib.o + +SRC= $(LIBSRC) + +EXHEADER= evp.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_3d.c b/src/lib/libssl/src/crypto/evp/e_cbc_3d.c new file mode 100644 index 0000000000..5761bf186a --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_3d.c @@ -0,0 +1,163 @@ +/* crypto/evp/e_cbc_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_cbc_ede_init_key(); +static void des_cbc_ede3_init_key(); +static void des_cbc_ede_cipher(); +#endif + +static EVP_CIPHER d_cbc_ede_cipher2= + { + NID_des_ede_cbc, + 8,16,8, + des_cbc_ede_init_key, + des_cbc_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +static EVP_CIPHER d_cbc_ede_cipher3= + { + NID_des_ede3_cbc, + 8,24,8, + des_cbc_ede3_init_key, + des_cbc_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ede_cbc() + { + return(&d_cbc_ede_cipher2); + } + +EVP_CIPHER *EVP_des_ede3_cbc() + { + return(&d_cbc_ede_cipher3); + } + +static void des_cbc_ede_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_cbc_ede3_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_cbc_ede_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ede3_cbc_encrypt( + (des_cblock *)in,(des_cblock *)out, + (long)inl, ctx->c.des_ede.ks1, + ctx->c.des_ede.ks2,ctx->c.des_ede.ks3, + (des_cblock *)&(ctx->iv[0]), + ctx->encrypt); + } diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_bf.c b/src/lib/libssl/src/crypto/evp/e_cbc_bf.c new file mode 100644 index 0000000000..be605f4a13 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_bf.c @@ -0,0 +1,119 @@ +/* crypto/evp/e_cbc_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_cbc_init_key(); +static void bf_cbc_cipher(); +#endif + +static EVP_CIPHER bfish_cbc_cipher= + { + NID_bf_cbc, + 8,EVP_BLOWFISH_KEY_SIZE,8, + bf_cbc_init_key, + bf_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_bf_cbc() + { + return(&bfish_cbc_cipher); + } + +static void bf_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + BF_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.bf_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_c.c b/src/lib/libssl/src/crypto/evp/e_cbc_c.c new file mode 100644 index 0000000000..b50c7874b3 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_c.c @@ -0,0 +1,119 @@ +/* crypto/evp/e_cbc_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_cbc_init_key(); +static void cast_cbc_cipher(); +#endif + +static EVP_CIPHER cast5_cbc_cipher= + { + NID_cast5_cbc, + 8,EVP_CAST5_KEY_SIZE,8, + cast_cbc_init_key, + cast_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_cast5_cbc() + { + return(&cast5_cbc_cipher); + } + +static void cast_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + CAST_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.cast_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_d.c b/src/lib/libssl/src/crypto/evp/e_cbc_d.c new file mode 100644 index 0000000000..c67706e3a0 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_d.c @@ -0,0 +1,116 @@ +/* crypto/evp/e_cbc_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_cbc_init_key(); +static void des_cbc_cipher(); +#endif + +static EVP_CIPHER d_cbc_cipher= + { + NID_des_cbc, + 8,8,8, + des_cbc_init_key, + des_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_des_cbc() + { + return(&d_cbc_cipher); + } + +static void des_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ncbc_encrypt( + (des_cblock *)in,(des_cblock *)out, + (long)inl, ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + ctx->encrypt); + } diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_i.c b/src/lib/libssl/src/crypto/evp/e_cbc_i.c new file mode 100644 index 0000000000..312ffcb721 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_i.c @@ -0,0 +1,131 @@ +/* crypto/evp/e_cbc_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_cbc_init_key(); +static void idea_cbc_cipher(); +#endif + +static EVP_CIPHER i_cbc_cipher= + { + NID_idea_cbc, + 8,16,8, + idea_cbc_init_key, + idea_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +EVP_CIPHER *EVP_idea_cbc() + { + return(&i_cbc_cipher); + } + +static void idea_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + if (enc) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + else + { + IDEA_KEY_SCHEDULE tmp; + + idea_set_encrypt_key(key,&tmp); + idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks)); + memset((unsigned char *)&tmp,0, + sizeof(IDEA_KEY_SCHEDULE)); + } + } + } + +static void idea_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + idea_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.idea_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_r2.c b/src/lib/libssl/src/crypto/evp/e_cbc_r2.c new file mode 100644 index 0000000000..4f8002f16d --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_r2.c @@ -0,0 +1,136 @@ +/* crypto/evp/e_cbc_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_cbc_init_key(); +static void rc2_cbc_cipher(); +#endif + +static EVP_CIPHER r2_cbc_cipher= + { + NID_rc2_cbc, + 8,EVP_RC2_KEY_SIZE,8, + rc2_cbc_init_key, + rc2_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + EVP_CIPHER_get_asn1_iv, + EVP_CIPHER_set_asn1_iv, + }; + +static EVP_CIPHER r2_40_cbc_cipher= + { + NID_rc2_40_cbc, + 8,5 /* 40 bit */,8, + rc2_cbc_init_key, + rc2_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + }; + +EVP_CIPHER *EVP_rc2_cbc() + { + return(&r2_cbc_cipher); + } + +EVP_CIPHER *EVP_rc2_40_cbc() + { + return(&r2_40_cbc_cipher); + } + +static void rc2_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx), + key,EVP_CIPHER_CTX_key_length(ctx)*8); + } + +static void rc2_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC2_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.rc2_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_r5.c b/src/lib/libssl/src/crypto/evp/e_cbc_r5.c new file mode 100644 index 0000000000..f7d46ca91f --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cbc_r5.c @@ -0,0 +1,120 @@ +/* crypto/evp/e_cbc_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void r_32_12_16_cbc_init_key(); +static void r_32_12_16_cbc_cipher(); +#endif + +static EVP_CIPHER rc5_32_12_16_cbc_cipher= + { + NID_rc5_cbc, + 8,EVP_RC5_32_12_16_KEY_SIZE,8, + r_32_12_16_cbc_init_key, + r_32_12_16_cbc_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_cbc() + { + return(&rc5_32_12_16_cbc_cipher); + } + +static void r_32_12_16_cbc_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE, + key,RC5_12_ROUNDS); + } + +static void r_32_12_16_cbc_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC5_32_cbc_encrypt( + in,out,(long)inl, + &(ctx->c.rc5_ks),&(ctx->iv[0]), + ctx->encrypt); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_3d.c b/src/lib/libssl/src/crypto/evp/e_cfb_3d.c new file mode 100644 index 0000000000..e7e3419411 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_3d.c @@ -0,0 +1,166 @@ +/* crypto/evp/e_cfb_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ede_cfb_init_key(); +static void des_ede3_cfb_init_key(); +static void des_ede_cfb_cipher(); +#endif + +static EVP_CIPHER d_ede_cfb_cipher2= + { + NID_des_ede_cfb64, + 1,16,8, + des_ede_cfb_init_key, + des_ede_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +static EVP_CIPHER d_ede3_cfb_cipher3= + { + NID_des_ede3_cfb64, + 1,24,8, + des_ede3_cfb_init_key, + des_ede_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ede_cfb() + { + return(&d_ede_cfb_cipher2); + } + +EVP_CIPHER *EVP_des_ede3_cfb() + { + return(&d_ede3_cfb_cipher3); + } + +static void des_ede_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_ede3_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_ede_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ede3_cfb64_encrypt( + in,out,(long)inl, + ctx->c.des_ede.ks1, + ctx->c.des_ede.ks2, + ctx->c.des_ede.ks3, + (des_cblock *)&(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_bf.c b/src/lib/libssl/src/crypto/evp/e_cfb_bf.c new file mode 100644 index 0000000000..8aba2564b8 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_bf.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_cfb_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_cfb_init_key(); +static void bf_cfb_cipher(); +#endif + +static EVP_CIPHER bfish_cfb_cipher= + { + NID_bf_cfb64, + 1,EVP_BLOWFISH_KEY_SIZE,8, + bf_cfb_init_key, + bf_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_bf_cfb() + { + return(&bfish_cfb_cipher); + } + +static void bf_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + BF_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.bf_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_c.c b/src/lib/libssl/src/crypto/evp/e_cfb_c.c new file mode 100644 index 0000000000..936df55fd8 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_c.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_cfb_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_cfb_init_key(); +static void cast_cfb_cipher(); +#endif + +static EVP_CIPHER cast5_cfb_cipher= + { + NID_cast5_cfb64, + 1,EVP_CAST5_KEY_SIZE,8, + cast_cfb_init_key, + cast_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_cast5_cfb() + { + return(&cast5_cfb_cipher); + } + +static void cast_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + CAST_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.cast_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_d.c b/src/lib/libssl/src/crypto/evp/e_cfb_d.c new file mode 100644 index 0000000000..9ae4558f51 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_d.c @@ -0,0 +1,118 @@ +/* crypto/evp/e_cfb_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_cfb_init_key(); +static void des_cfb_cipher(); +#endif + +static EVP_CIPHER d_cfb_cipher= + { + NID_des_cfb64, + 1,8,8, + des_cfb_init_key, + des_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_cfb() + { + return(&d_cfb_cipher); + } + +static void des_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_cfb64_encrypt( + in,out, + (long)inl, ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_i.c b/src/lib/libssl/src/crypto/evp/e_cfb_i.c new file mode 100644 index 0000000000..9225efaa86 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_i.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_cfb_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_cfb_init_key(); +static void idea_cfb_cipher(); +#endif + +static EVP_CIPHER i_cfb_cipher= + { + NID_idea_cfb64, + 1,IDEA_KEY_LENGTH,IDEA_BLOCK, + idea_cfb_init_key, + idea_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_idea_cfb() + { + return(&i_cfb_cipher); + } + +static void idea_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + } + +static void idea_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + idea_cfb64_encrypt( + in,out,(long)inl, + &(ctx->c.idea_ks),&(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_r2.c b/src/lib/libssl/src/crypto/evp/e_cfb_r2.c new file mode 100644 index 0000000000..af5a39d1f4 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_r2.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_cfb_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_cfb_init_key(); +static void rc2_cfb_cipher(); +#endif + +static EVP_CIPHER r2_cfb_cipher= + { + NID_rc2_cfb64, + 1,EVP_RC2_KEY_SIZE,8, + rc2_cfb_init_key, + rc2_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc2_cfb() + { + return(&r2_cfb_cipher); + } + +static void rc2_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, + EVP_RC2_KEY_SIZE*8); + } + +static void rc2_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC2_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc2_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_r5.c b/src/lib/libssl/src/crypto/evp/e_cfb_r5.c new file mode 100644 index 0000000000..a2fddaedc0 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_cfb_r5.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_cfb_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc5_32_12_16_cfb_init_key(); +static void rc5_32_12_16_cfb_cipher(); +#endif + +static EVP_CIPHER rc5_cfb_cipher= + { + NID_rc5_cfb64, + 1,EVP_RC5_32_12_16_KEY_SIZE,8, + rc5_32_12_16_cfb_init_key, + rc5_32_12_16_cfb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_cfb() + { + return(&rc5_cfb_cipher); + } + +static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, + RC5_12_ROUNDS); + } + +static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC5_32_cfb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc5_ks), + &(ctx->iv[0]), + &ctx->num,ctx->encrypt); + } +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_3d.c b/src/lib/libssl/src/crypto/evp/e_ecb_3d.c new file mode 100644 index 0000000000..908fc0760a --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_3d.c @@ -0,0 +1,161 @@ +/* crypto/evp/e_ecb_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ede_init_key(); +static void des_ede3_init_key(); +static void des_ede_cipher(); +#endif + +static EVP_CIPHER d_ede_cipher2= + { + NID_des_ede, + 8,16,0, + des_ede_init_key, + des_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + NULL, + NULL, + }; + +static EVP_CIPHER d_ede3_cipher3= + { + NID_des_ede3, + 8,24,0, + des_ede3_init_key, + des_ede_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + NULL, + }; + +EVP_CIPHER *EVP_des_ede() + { + return(&d_ede_cipher2); + } + +EVP_CIPHER *EVP_des_ede3() + { + return(&d_ede3_cipher3); + } + +static void des_ede_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_ede3_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_ede_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + des_ecb3_encrypt( + (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), + ctx->c.des_ede.ks1, + ctx->c.des_ede.ks2, + ctx->c.des_ede.ks3, + ctx->encrypt); + } + } diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_bf.c b/src/lib/libssl/src/crypto/evp/e_ecb_bf.c new file mode 100644 index 0000000000..142a9d3123 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_bf.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ecb_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_ecb_init_key(); +static void bf_ecb_cipher(); +#endif + +static EVP_CIPHER bfish_ecb_cipher= + { + NID_bf_ecb, + 8,EVP_BLOWFISH_KEY_SIZE,0, + bf_ecb_init_key, + bf_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_bf_ecb() + { + return(&bfish_ecb_cipher); + } + +static void bf_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + BF_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.bf_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_c.c b/src/lib/libssl/src/crypto/evp/e_ecb_c.c new file mode 100644 index 0000000000..34e0c18296 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_c.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ecb_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_ecb_init_key(); +static void cast_ecb_cipher(); +#endif + +static EVP_CIPHER cast5_ecb_cipher= + { + NID_cast5_ecb, + 8,EVP_CAST5_KEY_SIZE,0, + cast_ecb_init_key, + cast_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_cast5_ecb() + { + return(&cast5_ecb_cipher); + } + +static void cast_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + CAST_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.cast_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_d.c b/src/lib/libssl/src/crypto/evp/e_ecb_d.c new file mode 100644 index 0000000000..7a409d6459 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_d.c @@ -0,0 +1,118 @@ +/* crypto/evp/e_ecb_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ecb_init_key(); +static void des_ecb_cipher(); +#endif + +static EVP_CIPHER d_ecb_cipher= + { + NID_des_ecb, + 8,8,0, + des_ecb_init_key, + des_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_des_ecb() + { + return(&d_ecb_cipher); + } + +static void des_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + des_ecb_encrypt( + (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), + ctx->c.des_ks,ctx->encrypt); + } + } diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_i.c b/src/lib/libssl/src/crypto/evp/e_ecb_i.c new file mode 100644 index 0000000000..e24022a12c --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_i.c @@ -0,0 +1,133 @@ +/* crypto/evp/e_ecb_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_ecb_init_key(); +static void idea_ecb_cipher(); +#endif + +static EVP_CIPHER i_ecb_cipher= + { + NID_idea_ecb, + 8,16,0, + idea_ecb_init_key, + idea_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_idea_ecb() + { + return(&i_ecb_cipher); + } + +static void idea_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + { + if (enc) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + else + { + IDEA_KEY_SCHEDULE tmp; + + idea_set_encrypt_key(key,&tmp); + idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks)); + memset((unsigned char *)&tmp,0, + sizeof(IDEA_KEY_SCHEDULE)); + } + } + } + +static void idea_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + idea_ecb_encrypt( + &(in[i]),&(out[i]),&(ctx->c.idea_ks)); + } + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_r2.c b/src/lib/libssl/src/crypto/evp/e_ecb_r2.c new file mode 100644 index 0000000000..e35b06dc6d --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_r2.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ecb_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_ecb_init_key(); +static void rc2_ecb_cipher(); +#endif + +static EVP_CIPHER r2_ecb_cipher= + { + NID_rc2_ecb, + 8,EVP_RC2_KEY_SIZE,0, + rc2_ecb_init_key, + rc2_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_rc2_ecb() + { + return(&r2_ecb_cipher); + } + +static void rc2_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, + EVP_RC2_KEY_SIZE*8); + } + +static void rc2_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + RC2_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.rc2_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_r5.c b/src/lib/libssl/src/crypto/evp/e_ecb_r5.c new file mode 100644 index 0000000000..08f4a82651 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ecb_r5.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ecb_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc5_32_12_16_ecb_init_key(); +static void rc5_32_12_16_ecb_cipher(); +#endif + +static EVP_CIPHER rc5_ecb_cipher= + { + NID_rc5_ecb, + 8,EVP_RC5_32_12_16_KEY_SIZE,0, + rc5_32_12_16_ecb_init_key, + rc5_32_12_16_ecb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + NULL, + NULL, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_ecb() + { + return(&rc5_ecb_cipher); + } + +static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, + RC5_12_ROUNDS); + } + +static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + unsigned int i; + + if (inl < 8) return; + inl-=8; + for (i=0; i<=inl; i+=8) + { + RC5_32_ecb_encrypt( + &(in[i]),&(out[i]), + &(ctx->c.rc5_ks),ctx->encrypt); + } + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_3d.c b/src/lib/libssl/src/crypto/evp/e_ofb_3d.c new file mode 100644 index 0000000000..c3add18e93 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_3d.c @@ -0,0 +1,165 @@ +/* crypto/evp/e_ofb_3d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ede_ofb_init_key(); +static void des_ede3_ofb_init_key(); +static void des_ede_ofb_cipher(); +#endif + +static EVP_CIPHER d_ede_ofb_cipher2= + { + NID_des_ede_ofb64, + 1,16,8, + des_ede_ofb_init_key, + des_ede_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +static EVP_CIPHER d_ede3_ofb_cipher3= + { + NID_des_ede3_ofb64, + 1,24,8, + des_ede3_ofb_init_key, + des_ede_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ede_ofb() + { + return(&d_ede_ofb_cipher2); + } + +EVP_CIPHER *EVP_des_ede3_ofb() + { + return(&d_ede3_ofb_cipher3); + } + +static void des_ede_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + memcpy( (char *)ctx->c.des_ede.ks3, + (char *)ctx->c.des_ede.ks1, + sizeof(ctx->c.des_ede.ks1)); + } + } + +static void des_ede3_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + { + des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); + des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); + des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); + } + } + +static void des_ede_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ede3_ofb64_encrypt( + in,out, + (long)inl, + ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, + (des_cblock *)&(ctx->iv[0]), + &ctx->num); + } diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_bf.c b/src/lib/libssl/src/crypto/evp/e_ofb_bf.c new file mode 100644 index 0000000000..492f9b9082 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_bf.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ofb_bf.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_BLOWFISH + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void bf_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void bf_ofb_init_key(); +static void bf_ofb_cipher(); +#endif + +static EVP_CIPHER bfish_ofb_cipher= + { + NID_bf_ofb64, + 1,EVP_BLOWFISH_KEY_SIZE,8, + bf_ofb_init_key, + bf_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_bf_ofb() + { + return(&bfish_ofb_cipher); + } + +static void bf_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); + } + +static void bf_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + BF_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.bf_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_c.c b/src/lib/libssl/src/crypto/evp/e_ofb_c.c new file mode 100644 index 0000000000..f1eef4469c --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_c.c @@ -0,0 +1,122 @@ +/* crypto/evp/e_ofb_c.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_CAST + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void cast_ofb_init_key(); +static void cast_ofb_cipher(); +#endif + +static EVP_CIPHER cast5_ofb_cipher= + { + NID_cast5_ofb64, + 1,EVP_CAST5_KEY_SIZE,8, + cast_ofb_init_key, + cast_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_cast5_ofb() + { + return(&cast5_ofb_cipher); + } + +static void cast_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); + } + +static void cast_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + CAST_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.cast_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_d.c b/src/lib/libssl/src/crypto/evp/e_ofb_d.c new file mode 100644 index 0000000000..09d4b4139d --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_d.c @@ -0,0 +1,118 @@ +/* crypto/evp/e_ofb_d.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void des_ofb_init_key(); +static void des_ofb_cipher(); +#endif + +static EVP_CIPHER d_ofb_cipher= + { + NID_des_ofb64, + 1,8,8, + des_ofb_init_key, + des_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_des_ofb() + { + return(&d_ofb_cipher); + } + +static void des_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + des_set_key((des_cblock *)key,ctx->c.des_ks); + } + +static void des_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + des_ofb64_encrypt( + in,out, + (long)inl, ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + &ctx->num); + } diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_i.c b/src/lib/libssl/src/crypto/evp/e_ofb_i.c new file mode 100644 index 0000000000..96c8afd9c8 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_i.c @@ -0,0 +1,121 @@ +/* crypto/evp/e_ofb_i.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_IDEA + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void idea_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void idea_ofb_init_key(); +static void idea_ofb_cipher(); +#endif + +static EVP_CIPHER i_ofb_cipher= + { + NID_idea_ofb64, + 1,IDEA_KEY_LENGTH,IDEA_BLOCK, + idea_ofb_init_key, + idea_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_idea_ofb() + { + return(&i_ofb_cipher); + } + +static void idea_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + } + +static void idea_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + idea_ofb64_encrypt( + in,out,(long)inl, + &(ctx->c.idea_ks),&(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_r2.c b/src/lib/libssl/src/crypto/evp/e_ofb_r2.c new file mode 100644 index 0000000000..0f6d729988 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_r2.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ofb_r2.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC2 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc2_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc2_ofb_init_key(); +static void rc2_ofb_cipher(); +#endif + +static EVP_CIPHER r2_ofb_cipher= + { + NID_rc2_ofb64, + 1,EVP_RC2_KEY_SIZE,8, + rc2_ofb_init_key, + rc2_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc2_ofb() + { + return(&r2_ofb_cipher); + } + +static void rc2_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, + EVP_RC2_KEY_SIZE*8); + } + +static void rc2_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC2_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc2_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_r5.c b/src/lib/libssl/src/crypto/evp/e_ofb_r5.c new file mode 100644 index 0000000000..db28d6c317 --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/e_ofb_r5.c @@ -0,0 +1,123 @@ +/* crypto/evp/e_ofb_r5.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef NO_RC5 + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +#ifndef NOPROTO +static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, + unsigned char *iv,int enc); +static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, + unsigned char *in, unsigned int inl); +#else +static void rc5_32_12_16_ofb_init_key(); +static void rc5_32_12_16_ofb_cipher(); +#endif + +static EVP_CIPHER rc5_ofb_cipher= + { + NID_rc5_ofb64, + 1,EVP_RC5_32_12_16_KEY_SIZE,8, + rc5_32_12_16_ofb_init_key, + rc5_32_12_16_ofb_cipher, + NULL, + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), + EVP_CIPHER_set_asn1_iv, + EVP_CIPHER_get_asn1_iv, + }; + +EVP_CIPHER *EVP_rc5_32_12_16_ofb() + { + return(&rc5_ofb_cipher); + } + +static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc) +EVP_CIPHER_CTX *ctx; +unsigned char *key; +unsigned char *iv; +int enc; + { + ctx->num=0; + + if (iv != NULL) + memcpy(&(ctx->oiv[0]),iv,8); + memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); + if (key != NULL) + RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, + RC5_12_ROUNDS); + } + +static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl) +EVP_CIPHER_CTX *ctx; +unsigned char *out; +unsigned char *in; +unsigned int inl; + { + RC5_32_ofb64_encrypt( + in,out, + (long)inl, &(ctx->c.rc5_ks), + &(ctx->iv[0]), + &ctx->num); + } + +#endif diff --git a/src/lib/libssl/src/crypto/evp/evp.err b/src/lib/libssl/src/crypto/evp/evp.err new file mode 100644 index 0000000000..cfc17437bc --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/evp.err @@ -0,0 +1,24 @@ +/* Error codes for the EVP functions. */ + +/* Function codes. */ +#define EVP_F_D2I_PKEY 100 +#define EVP_F_EVP_DECRYPTFINAL 101 +#define EVP_F_EVP_OPENINIT 102 +#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 +#define EVP_F_EVP_PKEY_DECRYPT 104 +#define EVP_F_EVP_PKEY_ENCRYPT 105 +#define EVP_F_EVP_PKEY_NEW 106 +#define EVP_F_EVP_SIGNFINAL 107 +#define EVP_F_EVP_VERIFYFINAL 108 + +/* Reason codes. */ +#define EVP_R_BAD_DECRYPT 100 +#define EVP_R_DIFFERENT_KEY_TYPES 101 +#define EVP_R_IV_TOO_LARGE 102 +#define EVP_R_MISSING_PARMATERS 103 +#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 +#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_R_UNSUPPORTED_CIPHER 107 +#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108 +#define EVP_R_WRONG_PUBLIC_KEY_TYPE 109 diff --git a/src/lib/libssl/src/crypto/evp/pk_lib.c b/src/lib/libssl/src/crypto/evp/pk_lib.c new file mode 100644 index 0000000000..08f9fabbae --- /dev/null +++ b/src/lib/libssl/src/crypto/evp/pk_lib.c @@ -0,0 +1,82 @@ +/* crypto/evp/pk_lib.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" +#include "objects.h" + +static LHASH *pk_md=NULL; + +static LHASH *pk_md=NULL; + +int EVP_add_pkey_md(oid,pkm,md) +int oid; +EVP_PKEY_METHOD *pkm; +EVP_MD *md; + { + } + +EVP_add_pkey(pkm) +EVP_PKEY_METHOD *pkm; + { + } + +EVP_PKEY_METHOD:q + + diff --git a/src/lib/libssl/src/crypto/hmac/Makefile.ssl b/src/lib/libssl/src/crypto/hmac/Makefile.ssl new file mode 100644 index 0000000000..7a042b7261 --- /dev/null +++ b/src/lib/libssl/src/crypto/hmac/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/md/Makefile +# + +DIR= hmac +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=hmactest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=hmac.c +LIBOBJ=hmac.o + +SRC= $(LIBSRC) + +EXHEADER= hmac.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/idea/Makefile.ssl b/src/lib/libssl/src/crypto/idea/Makefile.ssl new file mode 100644 index 0000000000..41b42ce03b --- /dev/null +++ b/src/lib/libssl/src/crypto/idea/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/idea/Makefile +# + +DIR= idea +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=ideatest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c +LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o + +SRC= $(LIBSRC) + +EXHEADER= idea.h +HEADER= idea_lcl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/lhash/Makefile.ssl b/src/lib/libssl/src/crypto/lhash/Makefile.ssl new file mode 100644 index 0000000000..cb08547b4f --- /dev/null +++ b/src/lib/libssl/src/crypto/lhash/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/lhash/Makefile +# + +DIR= lhash +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=lhash.c lh_stats.c +LIBOBJ=lhash.o lh_stats.o + +SRC= $(LIBSRC) + +EXHEADER= lhash.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/libvms.com b/src/lib/libssl/src/crypto/libvms.com new file mode 100644 index 0000000000..44f90c65b0 --- /dev/null +++ b/src/lib/libssl/src/crypto/libvms.com @@ -0,0 +1,31 @@ +$! +$! Compile crypto.c as several subset modules and insert in crypto-xxx.olb. +$! If P1 is specifed, it specifies alternate list of subsets to compile. +$! +$ libname = "CRYPTO-AXP.OLB" +$ subset_list = "LIB,ASN1,BN,BUFFER,CONF,DES,DH,DSA,ERROR,EVP,IDEA,LHASH,MD," + - + "METH,OBJECTS,PEM,RAND,RC,RSA,SHA,STACK,TXT_DB,X509" +$ if p1 .nes. "" then subset_list = p1 +$! +$ if f$getsyi("CPU") .lt. 128 then libname = "CRYPTO-VAX.OLB" +$ if f$search(libname) .eqs. "" then library/create/object/log 'libname' +$! +$ cc = "cc/include=[-.include]/prefix=all" + P2 +$! +$ i = 0 +$ next_subset: +$ subset = f$element(i,",",subset_list) +$ if subset .eqs. "," then goto done +$ i = i + 1 +$ create crypto_'subset'.subset +#include "crypto.c" +$ ofile = "sys$disk:[]crypto_" + subset + ".obj" +$ on warning then goto next_subset +$ write sys$output "Compiling ", ofile +$ cc /object='ofile' crypto_'subset'.subset - + /define=(CRYPTO_SUBSET,CRYPTO_'subset'_SUBSET) +$ library/replace/log 'libname'/module=CRYPTO_'subset' 'ofile' +$ goto next_subset +$! +$ done: +$ exit diff --git a/src/lib/libssl/src/crypto/md2/Makefile.ssl b/src/lib/libssl/src/crypto/md2/Makefile.ssl new file mode 100644 index 0000000000..d8e7200c83 --- /dev/null +++ b/src/lib/libssl/src/crypto/md2/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/md/Makefile +# + +DIR= md +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=md2_dgst.c md5_one.c +LIBOBJ=md2_dgst.o md2_one.o + +SRC= $(LIBSRC) + +EXHEADER= md2.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/md2/md2.org b/src/lib/libssl/src/crypto/md2/md2.org new file mode 100644 index 0000000000..9f39933790 --- /dev/null +++ b/src/lib/libssl/src/crypto/md2/md2.org @@ -0,0 +1,106 @@ +/* crypto/md/md2.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify md2.org since md2.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + + +#ifndef HEADER_MD2_H +#define HEADER_MD2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MD2_DIGEST_LENGTH 16 +#define MD2_BLOCK 16 + +#define MD2_INT unsigned int + +typedef struct MD2state_st + { + int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; + } MD2_CTX; + +#ifndef NOPROTO +char *MD2_options(void); +void MD2_Init(MD2_CTX *c); +void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len); +void MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md); +#else +char *MD2_options(); +void MD2_Init(); +void MD2_Update(); +void MD2_Final(); +unsigned char *MD2(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libssl/src/crypto/md5/Makefile.ssl b/src/lib/libssl/src/crypto/md5/Makefile.ssl new file mode 100644 index 0000000000..47e1ce05ca --- /dev/null +++ b/src/lib/libssl/src/crypto/md5/Makefile.ssl @@ -0,0 +1,104 @@ +# +# SSLeay/crypto/md5/Makefile +# + +DIR= md5 +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +MD5_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md5test.c +APPS=md5.c + +LIB=$(TOP)/libcrypto.a +LIBSRC=md5_dgst.c md5_one.c +LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= md5.h +HEADER= md5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/mx86-elf.o: asm/mx86unix.cpp + $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o + +# solaris +asm/mx86-sol.o: asm/mx86unix.cpp + $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s + as -o asm/mx86-sol.o asm/mx86-sol.s + rm -f asm/mx86-sol.s + +# a.out +asm/mx86-out.o: asm/mx86unix.cpp + $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o + +# bsdi +asm/mx86bsdi.o: asm/mx86unix.cpp + $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o + +asm/mx86unix.cpp: + (cd asm; perl md5-586.pl cpp >mx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/md5/Makefile.uni b/src/lib/libssl/src/crypto/md5/Makefile.uni new file mode 100644 index 0000000000..54685712db --- /dev/null +++ b/src/lib/libssl/src/crypto/md5/Makefile.uni @@ -0,0 +1,109 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= md5 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +MD5_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md5test +APPS=md5 + +LIB=libmd5.a +LIBSRC=md5_dgst.c md5_one.c +LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= md5.h +HEADER= md5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/mx86-elf.o: asm/mx86unix.cpp + $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o + +# solaris +asm/mx86-sol.o: asm/mx86unix.cpp + $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s + as -o asm/mx86-sol.o asm/mx86-sol.s + rm -f asm/mx86-sol.s + +# a.out +asm/mx86-out.o: asm/mx86unix.cpp + $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o + +# bsdi +asm/mx86bsdi.o: asm/mx86unix.cpp + $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o + +asm/mx86unix.cpp: + (cd asm; perl md5-586.pl cpp >mx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-out: + $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-solaris: + $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-bdsi: + $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/md5/asm/m5-win32.asm b/src/lib/libssl/src/crypto/md5/asm/m5-win32.asm new file mode 100644 index 0000000000..c2081da746 --- /dev/null +++ b/src/lib/libssl/src/crypto/md5/asm/m5-win32.asm @@ -0,0 +1,686 @@ + ; Don't even think of reading this code + ; It was automatically generated by md5-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE md5-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _md5_block_x86 + +_md5_block_x86 PROC NEAR + push esi + push edi + mov edi, DWORD PTR 12[esp] + mov esi, DWORD PTR 16[esp] + mov ecx, DWORD PTR 20[esp] + push ebp + push ebx + add ecx, esi + sub ecx, 64 + mov eax, DWORD PTR [edi] + push ecx + mov ebx, DWORD PTR 4[edi] + mov ecx, DWORD PTR 8[edi] + mov edx, DWORD PTR 12[edi] +L000start: + ; + ; R0 section + mov edi, ecx + mov ebp, DWORD PTR [esi] + ; R0 0 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 3614090360[ebp*1+eax] + mov ebp, DWORD PTR 4[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 1 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 3905402710[ebp*1+edx] + mov ebp, DWORD PTR 8[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 2 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 606105819[ebp*1+ecx] + mov ebp, DWORD PTR 12[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 3 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 3250441966[ebp*1+ebx] + mov ebp, DWORD PTR 16[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; R0 4 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 4118548399[ebp*1+eax] + mov ebp, DWORD PTR 20[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 5 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 1200080426[ebp*1+edx] + mov ebp, DWORD PTR 24[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 6 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 2821735955[ebp*1+ecx] + mov ebp, DWORD PTR 28[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 7 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 4249261313[ebp*1+ebx] + mov ebp, DWORD PTR 32[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; R0 8 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 1770035416[ebp*1+eax] + mov ebp, DWORD PTR 36[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 9 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 2336552879[ebp*1+edx] + mov ebp, DWORD PTR 40[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 10 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 4294925233[ebp*1+ecx] + mov ebp, DWORD PTR 44[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 11 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 2304563134[ebp*1+ebx] + mov ebp, DWORD PTR 48[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; R0 12 + xor edi, edx + and edi, ebx + lea eax, DWORD PTR 1804603682[ebp*1+eax] + mov ebp, DWORD PTR 52[esi] + xor edi, edx + add eax, edi + mov edi, ebx + rol eax, 7 + add eax, ebx + ; R0 13 + xor edi, ecx + and edi, eax + lea edx, DWORD PTR 4254626195[ebp*1+edx] + mov ebp, DWORD PTR 56[esi] + xor edi, ecx + add edx, edi + mov edi, eax + rol edx, 12 + add edx, eax + ; R0 14 + xor edi, ebx + and edi, edx + lea ecx, DWORD PTR 2792965006[ebp*1+ecx] + mov ebp, DWORD PTR 60[esi] + xor edi, ebx + add ecx, edi + mov edi, edx + rol ecx, 17 + add ecx, edx + ; R0 15 + xor edi, eax + and edi, ecx + lea ebx, DWORD PTR 1236535329[ebp*1+ebx] + mov ebp, DWORD PTR 4[esi] + xor edi, eax + add ebx, edi + mov edi, ecx + rol ebx, 22 + add ebx, ecx + ; + ; R1 section + ; R1 16 + lea eax, DWORD PTR 4129170786[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 24[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 17 + lea edx, DWORD PTR 3225465664[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 44[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 18 + lea ecx, DWORD PTR 643717713[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR [esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 19 + lea ebx, DWORD PTR 3921069994[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 20[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; R1 20 + lea eax, DWORD PTR 3593408605[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 40[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 21 + lea edx, DWORD PTR 38016083[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 60[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 22 + lea ecx, DWORD PTR 3634488961[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR 16[esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 23 + lea ebx, DWORD PTR 3889429448[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 36[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; R1 24 + lea eax, DWORD PTR 568446438[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 56[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 25 + lea edx, DWORD PTR 3275163606[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 12[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 26 + lea ecx, DWORD PTR 4107603335[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR 32[esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 27 + lea ebx, DWORD PTR 1163531501[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 52[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; R1 28 + lea eax, DWORD PTR 2850285829[ebp*1+eax] + xor edi, ebx + and edi, edx + mov ebp, DWORD PTR 8[esi] + xor edi, ecx + add eax, edi + mov edi, ebx + rol eax, 5 + add eax, ebx + ; R1 29 + lea edx, DWORD PTR 4243563512[ebp*1+edx] + xor edi, eax + and edi, ecx + mov ebp, DWORD PTR 28[esi] + xor edi, ebx + add edx, edi + mov edi, eax + rol edx, 9 + add edx, eax + ; R1 30 + lea ecx, DWORD PTR 1735328473[ebp*1+ecx] + xor edi, edx + and edi, ebx + mov ebp, DWORD PTR 48[esi] + xor edi, eax + add ecx, edi + mov edi, edx + rol ecx, 14 + add ecx, edx + ; R1 31 + lea ebx, DWORD PTR 2368359562[ebp*1+ebx] + xor edi, ecx + and edi, eax + mov ebp, DWORD PTR 20[esi] + xor edi, edx + add ebx, edi + mov edi, ecx + rol ebx, 20 + add ebx, ecx + ; + ; R2 section + ; R2 32 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 4294588738[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR 32[esi] + rol eax, 4 + mov edi, ebx + ; R2 33 + lea edx, DWORD PTR 2272392833[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 44[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 34 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 1839030562[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 56[esi] + rol ecx, 16 + mov edi, edx + ; R2 35 + lea ebx, DWORD PTR 4259657740[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR 4[esi] + add ebx, edi + mov edi, ecx + rol ebx, 23 + add ebx, ecx + ; R2 36 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 2763975236[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR 16[esi] + rol eax, 4 + mov edi, ebx + ; R2 37 + lea edx, DWORD PTR 1272893353[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 28[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 38 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 4139469664[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 40[esi] + rol ecx, 16 + mov edi, edx + ; R2 39 + lea ebx, DWORD PTR 3200236656[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR 52[esi] + add ebx, edi + mov edi, ecx + rol ebx, 23 + add ebx, ecx + ; R2 40 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 681279174[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR [esi] + rol eax, 4 + mov edi, ebx + ; R2 41 + lea edx, DWORD PTR 3936430074[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 12[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 42 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 3572445317[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 24[esi] + rol ecx, 16 + mov edi, edx + ; R2 43 + lea ebx, DWORD PTR 76029189[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR 36[esi] + add ebx, edi + mov edi, ecx + rol ebx, 23 + add ebx, ecx + ; R2 44 + xor edi, edx + xor edi, ebx + lea eax, DWORD PTR 3654602809[ebp*1+eax] + add eax, edi + mov ebp, DWORD PTR 48[esi] + rol eax, 4 + mov edi, ebx + ; R2 45 + lea edx, DWORD PTR 3873151461[ebp*1+edx] + add eax, ebx + xor edi, ecx + xor edi, eax + mov ebp, DWORD PTR 60[esi] + add edx, edi + mov edi, eax + rol edx, 11 + add edx, eax + ; R2 46 + xor edi, ebx + xor edi, edx + lea ecx, DWORD PTR 530742520[ebp*1+ecx] + add ecx, edi + mov ebp, DWORD PTR 8[esi] + rol ecx, 16 + mov edi, edx + ; R2 47 + lea ebx, DWORD PTR 3299628645[ebp*1+ebx] + add ecx, edx + xor edi, eax + xor edi, ecx + mov ebp, DWORD PTR [esi] + add ebx, edi + mov edi, -1 + rol ebx, 23 + add ebx, ecx + ; + ; R3 section + ; R3 48 + xor edi, edx + or edi, ebx + lea eax, DWORD PTR 4096336452[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 28[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 49 + or edi, eax + lea edx, DWORD PTR 1126891415[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 56[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 50 + or edi, edx + lea ecx, DWORD PTR 2878612391[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 20[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 51 + or edi, ecx + lea ebx, DWORD PTR 4237533241[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 48[esi] + add ebx, edi + mov edi, -1 + rol ebx, 21 + xor edi, edx + add ebx, ecx + ; R3 52 + or edi, ebx + lea eax, DWORD PTR 1700485571[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 12[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 53 + or edi, eax + lea edx, DWORD PTR 2399980690[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 40[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 54 + or edi, edx + lea ecx, DWORD PTR 4293915773[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 4[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 55 + or edi, ecx + lea ebx, DWORD PTR 2240044497[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 32[esi] + add ebx, edi + mov edi, -1 + rol ebx, 21 + xor edi, edx + add ebx, ecx + ; R3 56 + or edi, ebx + lea eax, DWORD PTR 1873313359[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 60[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 57 + or edi, eax + lea edx, DWORD PTR 4264355552[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 24[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 58 + or edi, edx + lea ecx, DWORD PTR 2734768916[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 52[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 59 + or edi, ecx + lea ebx, DWORD PTR 1309151649[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 16[esi] + add ebx, edi + mov edi, -1 + rol ebx, 21 + xor edi, edx + add ebx, ecx + ; R3 60 + or edi, ebx + lea eax, DWORD PTR 4149444226[ebp*1+eax] + xor edi, ecx + mov ebp, DWORD PTR 44[esi] + add eax, edi + mov edi, -1 + rol eax, 6 + xor edi, ecx + add eax, ebx + ; R3 61 + or edi, eax + lea edx, DWORD PTR 3174756917[ebp*1+edx] + xor edi, ebx + mov ebp, DWORD PTR 8[esi] + add edx, edi + mov edi, -1 + rol edx, 10 + xor edi, ebx + add edx, eax + ; R3 62 + or edi, edx + lea ecx, DWORD PTR 718787259[ebp*1+ecx] + xor edi, eax + mov ebp, DWORD PTR 36[esi] + add ecx, edi + mov edi, -1 + rol ecx, 15 + xor edi, eax + add ecx, edx + ; R3 63 + or edi, ecx + lea ebx, DWORD PTR 3951481745[ebp*1+ebx] + xor edi, edx + mov ebp, DWORD PTR 24[esp] + add ebx, edi + add esi, 64 + rol ebx, 21 + mov edi, DWORD PTR [ebp] + add ebx, ecx + add eax, edi + mov edi, DWORD PTR 4[ebp] + add ebx, edi + mov edi, DWORD PTR 8[ebp] + add ecx, edi + mov edi, DWORD PTR 12[ebp] + add edx, edi + mov DWORD PTR [ebp],eax + mov DWORD PTR 4[ebp],ebx + mov edi, DWORD PTR [esp] + mov DWORD PTR 8[ebp],ecx + mov DWORD PTR 12[ebp],edx + cmp edi, esi + jge L000start + pop eax + pop ebx + pop ebp + pop edi + pop esi + ret +_md5_block_x86 ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp b/src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp new file mode 100644 index 0000000000..5d399122b6 --- /dev/null +++ b/src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp @@ -0,0 +1,730 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define md5_block_x86 _md5_block_x86 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by md5-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "md5-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl md5_block_x86 + TYPE(md5_block_x86,@function) +md5_block_x86: + pushl %esi + pushl %edi + movl 12(%esp), %edi + movl 16(%esp), %esi + movl 20(%esp), %ecx + pushl %ebp + pushl %ebx + addl %esi, %ecx + subl $64, %ecx + movl (%edi), %eax + pushl %ecx + movl 4(%edi), %ebx + movl 8(%edi), %ecx + movl 12(%edi), %edx +.L000start: + + /* R0 section */ + movl %ecx, %edi + movl (%esi), %ebp + /* R0 0 */ + xorl %edx, %edi + andl %ebx, %edi + leal 3614090360(%eax,%ebp,1),%eax + movl 4(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 1 */ + xorl %ecx, %edi + andl %eax, %edi + leal 3905402710(%edx,%ebp,1),%edx + movl 8(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 2 */ + xorl %ebx, %edi + andl %edx, %edi + leal 606105819(%ecx,%ebp,1),%ecx + movl 12(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 3 */ + xorl %eax, %edi + andl %ecx, %edi + leal 3250441966(%ebx,%ebp,1),%ebx + movl 16(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + /* R0 4 */ + xorl %edx, %edi + andl %ebx, %edi + leal 4118548399(%eax,%ebp,1),%eax + movl 20(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 5 */ + xorl %ecx, %edi + andl %eax, %edi + leal 1200080426(%edx,%ebp,1),%edx + movl 24(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 6 */ + xorl %ebx, %edi + andl %edx, %edi + leal 2821735955(%ecx,%ebp,1),%ecx + movl 28(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 7 */ + xorl %eax, %edi + andl %ecx, %edi + leal 4249261313(%ebx,%ebp,1),%ebx + movl 32(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + /* R0 8 */ + xorl %edx, %edi + andl %ebx, %edi + leal 1770035416(%eax,%ebp,1),%eax + movl 36(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 9 */ + xorl %ecx, %edi + andl %eax, %edi + leal 2336552879(%edx,%ebp,1),%edx + movl 40(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 10 */ + xorl %ebx, %edi + andl %edx, %edi + leal 4294925233(%ecx,%ebp,1),%ecx + movl 44(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 11 */ + xorl %eax, %edi + andl %ecx, %edi + leal 2304563134(%ebx,%ebp,1),%ebx + movl 48(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + /* R0 12 */ + xorl %edx, %edi + andl %ebx, %edi + leal 1804603682(%eax,%ebp,1),%eax + movl 52(%esi), %ebp + xorl %edx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $7, %eax + addl %ebx, %eax + /* R0 13 */ + xorl %ecx, %edi + andl %eax, %edi + leal 4254626195(%edx,%ebp,1),%edx + movl 56(%esi), %ebp + xorl %ecx, %edi + addl %edi, %edx + movl %eax, %edi + roll $12, %edx + addl %eax, %edx + /* R0 14 */ + xorl %ebx, %edi + andl %edx, %edi + leal 2792965006(%ecx,%ebp,1),%ecx + movl 60(%esi), %ebp + xorl %ebx, %edi + addl %edi, %ecx + movl %edx, %edi + roll $17, %ecx + addl %edx, %ecx + /* R0 15 */ + xorl %eax, %edi + andl %ecx, %edi + leal 1236535329(%ebx,%ebp,1),%ebx + movl 4(%esi), %ebp + xorl %eax, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $22, %ebx + addl %ecx, %ebx + + /* R1 section */ + /* R1 16 */ + leal 4129170786(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 24(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 17 */ + leal 3225465664(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 44(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 18 */ + leal 643717713(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl (%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 19 */ + leal 3921069994(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 20(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + /* R1 20 */ + leal 3593408605(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 40(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 21 */ + leal 38016083(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 60(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 22 */ + leal 3634488961(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl 16(%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 23 */ + leal 3889429448(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 36(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + /* R1 24 */ + leal 568446438(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 56(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 25 */ + leal 3275163606(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 12(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 26 */ + leal 4107603335(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl 32(%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 27 */ + leal 1163531501(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 52(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + /* R1 28 */ + leal 2850285829(%eax,%ebp,1),%eax + xorl %ebx, %edi + andl %edx, %edi + movl 8(%esi), %ebp + xorl %ecx, %edi + addl %edi, %eax + movl %ebx, %edi + roll $5, %eax + addl %ebx, %eax + /* R1 29 */ + leal 4243563512(%edx,%ebp,1),%edx + xorl %eax, %edi + andl %ecx, %edi + movl 28(%esi), %ebp + xorl %ebx, %edi + addl %edi, %edx + movl %eax, %edi + roll $9, %edx + addl %eax, %edx + /* R1 30 */ + leal 1735328473(%ecx,%ebp,1),%ecx + xorl %edx, %edi + andl %ebx, %edi + movl 48(%esi), %ebp + xorl %eax, %edi + addl %edi, %ecx + movl %edx, %edi + roll $14, %ecx + addl %edx, %ecx + /* R1 31 */ + leal 2368359562(%ebx,%ebp,1),%ebx + xorl %ecx, %edi + andl %eax, %edi + movl 20(%esi), %ebp + xorl %edx, %edi + addl %edi, %ebx + movl %ecx, %edi + roll $20, %ebx + addl %ecx, %ebx + + /* R2 section */ + /* R2 32 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 4294588738(%eax,%ebp,1),%eax + addl %edi, %eax + movl 32(%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 33 */ + leal 2272392833(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 44(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 34 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 1839030562(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 56(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 35 */ + leal 4259657740(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl 4(%esi), %ebp + addl %edi, %ebx + movl %ecx, %edi + roll $23, %ebx + addl %ecx, %ebx + /* R2 36 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 2763975236(%eax,%ebp,1),%eax + addl %edi, %eax + movl 16(%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 37 */ + leal 1272893353(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 28(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 38 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 4139469664(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 40(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 39 */ + leal 3200236656(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl 52(%esi), %ebp + addl %edi, %ebx + movl %ecx, %edi + roll $23, %ebx + addl %ecx, %ebx + /* R2 40 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 681279174(%eax,%ebp,1),%eax + addl %edi, %eax + movl (%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 41 */ + leal 3936430074(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 12(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 42 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 3572445317(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 24(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 43 */ + leal 76029189(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl 36(%esi), %ebp + addl %edi, %ebx + movl %ecx, %edi + roll $23, %ebx + addl %ecx, %ebx + /* R2 44 */ + xorl %edx, %edi + xorl %ebx, %edi + leal 3654602809(%eax,%ebp,1),%eax + addl %edi, %eax + movl 48(%esi), %ebp + roll $4, %eax + movl %ebx, %edi + /* R2 45 */ + leal 3873151461(%edx,%ebp,1),%edx + addl %ebx, %eax + xorl %ecx, %edi + xorl %eax, %edi + movl 60(%esi), %ebp + addl %edi, %edx + movl %eax, %edi + roll $11, %edx + addl %eax, %edx + /* R2 46 */ + xorl %ebx, %edi + xorl %edx, %edi + leal 530742520(%ecx,%ebp,1),%ecx + addl %edi, %ecx + movl 8(%esi), %ebp + roll $16, %ecx + movl %edx, %edi + /* R2 47 */ + leal 3299628645(%ebx,%ebp,1),%ebx + addl %edx, %ecx + xorl %eax, %edi + xorl %ecx, %edi + movl (%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $23, %ebx + addl %ecx, %ebx + + /* R3 section */ + /* R3 48 */ + xorl %edx, %edi + orl %ebx, %edi + leal 4096336452(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 28(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 49 */ + orl %eax, %edi + leal 1126891415(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 56(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 50 */ + orl %edx, %edi + leal 2878612391(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 20(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 51 */ + orl %ecx, %edi + leal 4237533241(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 48(%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $21, %ebx + xorl %edx, %edi + addl %ecx, %ebx + /* R3 52 */ + orl %ebx, %edi + leal 1700485571(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 12(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 53 */ + orl %eax, %edi + leal 2399980690(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 40(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 54 */ + orl %edx, %edi + leal 4293915773(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 4(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 55 */ + orl %ecx, %edi + leal 2240044497(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 32(%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $21, %ebx + xorl %edx, %edi + addl %ecx, %ebx + /* R3 56 */ + orl %ebx, %edi + leal 1873313359(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 60(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 57 */ + orl %eax, %edi + leal 4264355552(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 24(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 58 */ + orl %edx, %edi + leal 2734768916(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 52(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 59 */ + orl %ecx, %edi + leal 1309151649(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 16(%esi), %ebp + addl %edi, %ebx + movl $-1, %edi + roll $21, %ebx + xorl %edx, %edi + addl %ecx, %ebx + /* R3 60 */ + orl %ebx, %edi + leal 4149444226(%eax,%ebp,1),%eax + xorl %ecx, %edi + movl 44(%esi), %ebp + addl %edi, %eax + movl $-1, %edi + roll $6, %eax + xorl %ecx, %edi + addl %ebx, %eax + /* R3 61 */ + orl %eax, %edi + leal 3174756917(%edx,%ebp,1),%edx + xorl %ebx, %edi + movl 8(%esi), %ebp + addl %edi, %edx + movl $-1, %edi + roll $10, %edx + xorl %ebx, %edi + addl %eax, %edx + /* R3 62 */ + orl %edx, %edi + leal 718787259(%ecx,%ebp,1),%ecx + xorl %eax, %edi + movl 36(%esi), %ebp + addl %edi, %ecx + movl $-1, %edi + roll $15, %ecx + xorl %eax, %edi + addl %edx, %ecx + /* R3 63 */ + orl %ecx, %edi + leal 3951481745(%ebx,%ebp,1),%ebx + xorl %edx, %edi + movl 24(%esp), %ebp + addl %edi, %ebx + addl $64, %esi + roll $21, %ebx + movl (%ebp), %edi + addl %ecx, %ebx + addl %edi, %eax + movl 4(%ebp), %edi + addl %edi, %ebx + movl 8(%ebp), %edi + addl %edi, %ecx + movl 12(%ebp), %edi + addl %edi, %edx + movl %eax, (%ebp) + movl %ebx, 4(%ebp) + movl (%esp), %edi + movl %ecx, 8(%ebp) + movl %edx, 12(%ebp) + cmpl %esi, %edi + jge .L000start + popl %eax + popl %ebx + popl %ebp + popl %edi + popl %esi + ret +.md5_block_x86_end: + SIZE(md5_block_x86,.md5_block_x86_end-md5_block_x86) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/mdc2/Makefile.ssl b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl new file mode 100644 index 0000000000..495a2789a0 --- /dev/null +++ b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/mdc2/Makefile +# + +DIR= mdc2 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= mdc2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=mdc2dgst.c mdc2_one.c +LIBOBJ=mdc2dgst.o mdc2_one.o + +SRC= $(LIBSRC) + +EXHEADER= mdc2.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/objects/Makefile.ssl b/src/lib/libssl/src/crypto/objects/Makefile.ssl new file mode 100644 index 0000000000..320523cea1 --- /dev/null +++ b/src/lib/libssl/src/crypto/objects/Makefile.ssl @@ -0,0 +1,87 @@ +# +# SSLeay/crypto/objects/Makefile +# + +DIR= objects +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=objects +ERRC=obj_err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= obj_dat.c obj_lib.c $(ERRC).c +LIBOBJ= obj_dat.o obj_lib.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= objects.h +HEADER= $(EXHEADER) obj_dat.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: obj_dat.h lib + +obj_dat.h: objects.h obj_dat.pl + perl ./obj_dat.pl < objects.h > obj_dat.h + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/objects/objects.err b/src/lib/libssl/src/crypto/objects/objects.err new file mode 100644 index 0000000000..8bec3eaea2 --- /dev/null +++ b/src/lib/libssl/src/crypto/objects/objects.err @@ -0,0 +1,12 @@ +/* Error codes for the OBJ functions. */ + +/* Function codes. */ +#define OBJ_F_OBJ_CREATE 100 +#define OBJ_F_OBJ_DUP 101 +#define OBJ_F_OBJ_NID2LN 102 +#define OBJ_F_OBJ_NID2OBJ 103 +#define OBJ_F_OBJ_NID2SN 104 + +/* Reason codes. */ +#define OBJ_R_MALLOC_FAILURE 100 +#define OBJ_R_UNKNOWN_NID 101 diff --git a/src/lib/libssl/src/crypto/pem/Makefile.ssl b/src/lib/libssl/src/crypto/pem/Makefile.ssl new file mode 100644 index 0000000000..fc04a88fd9 --- /dev/null +++ b/src/lib/libssl/src/crypto/pem/Makefile.ssl @@ -0,0 +1,96 @@ +# +# SSLeay/crypto/pem/Makefile +# + +DIR= pem +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=pem +ERRC=pem_err +GENERAL=Makefile +TEST= +APPS= + +CTX_SIZE= ctx_size + +LIB=$(TOP)/libcrypto.a +LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c $(ERRC).c + +LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= pem.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: pem.h lib + +pem.h: $(CTX_SIZE) + ./$(CTX_SIZE) pem.new + if [ -f pem.h ]; then mv -f pem.h pem.old; fi + mv -f pem.new pem.h + +$(CTX_SIZE): $(CTX_SIZE).o + $(CC) $(CFLAGS) -o $(CTX_SIZE) $(CTX_SIZE).o + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(CTX_SIZE).c $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(CTX_SIZE) *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # SPECIAL CASE .org + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/pem/ctx_size.c b/src/lib/libssl/src/crypto/pem/ctx_size.c new file mode 100644 index 0000000000..87469bc4af --- /dev/null +++ b/src/lib/libssl/src/crypto/pem/ctx_size.c @@ -0,0 +1,122 @@ +/* crypto/pem/ctx_size.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "cryptlib.h" +#include "evp.h" + +int main(argc,argv) +int argc; +char *argv[]; + { + int i,j; + char buf[256]; + + for (;;) + { + char *str; + buf[0]='\0'; + fgets(buf,256,stdin); + if (buf[0] == '\0') break; + + str="#define EVP_ENCODE_CTX_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_ENCODE_CTX)); + continue; + } + str="#define EVP_MD_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_MD)); + continue; + } + str="#define EVP_MD_CTX_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_MD_CTX)); + continue; + } + str="#define EVP_CIPHER_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_CIPHER)); + continue; + } + str="#define EVP_CIPHER_CTX_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + printf("%s %d\n",str,(int)sizeof(EVP_CIPHER_CTX)); + continue; + } + + str="#define EVP_MAX_MD_SIZE "; + if (strncmp(buf,str,strlen(str)) == 0) + { + i=MD2_DIGEST_LENGTH; + j=MD5_DIGEST_LENGTH; + if (j > i) i=j; + j=SHA_DIGEST_LENGTH; + if (j > i) i=j; + printf("%s %d\n",str,i); + continue; + } + fputs(buf,stdout); + } + exit(0); + } diff --git a/src/lib/libssl/src/crypto/pem/pem.err b/src/lib/libssl/src/crypto/pem/pem.err new file mode 100644 index 0000000000..0e523abf82 --- /dev/null +++ b/src/lib/libssl/src/crypto/pem/pem.err @@ -0,0 +1,38 @@ +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_DEF_CALLBACK 100 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 diff --git a/src/lib/libssl/src/crypto/pem/pem.org b/src/lib/libssl/src/crypto/pem/pem.org new file mode 100644 index 0000000000..38952509dd --- /dev/null +++ b/src/lib/libssl/src/crypto/pem/pem.org @@ -0,0 +1,562 @@ +/* crypto/pem/pem.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify pem.org since pem.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_PEM_H +#define HEADER_PEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "evp.h" +#include "x509.h" + +#define PEM_OBJ_UNDEF 0 +#define PEM_OBJ_X509 1 +#define PEM_OBJ_X509_REQ 2 +#define PEM_OBJ_CRL 3 +#define PEM_OBJ_SSL_SESSION 4 +#define PEM_OBJ_PRIV_KEY 10 +#define PEM_OBJ_PRIV_RSA 11 +#define PEM_OBJ_PRIV_DSA 12 +#define PEM_OBJ_PRIV_DH 13 +#define PEM_OBJ_PUB_RSA 14 +#define PEM_OBJ_PUB_DSA 15 +#define PEM_OBJ_PUB_DH 16 +#define PEM_OBJ_DHPARAMS 17 +#define PEM_OBJ_DSAPARAMS 18 +#define PEM_OBJ_PRIV_RSA_PUBLIC 19 + +#define PEM_ERROR 30 +#define PEM_DEK_DES_CBC 40 +#define PEM_DEK_IDEA_CBC 45 +#define PEM_DEK_DES_EDE 50 +#define PEM_DEK_DES_ECB 60 +#define PEM_DEK_RSA 70 +#define PEM_DEK_RSA_MD2 80 +#define PEM_DEK_RSA_MD5 90 + +#define PEM_MD_MD2 NID_md2 +#define PEM_MD_MD5 NID_md5 +#define PEM_MD_SHA NID_sha +#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption +#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption +#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption + +#define PEM_STRING_X509_OLD "X509 CERTIFICATE" +#define PEM_STRING_X509 "CERTIFICATE" +#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +#define PEM_STRING_X509_CRL "X509 CRL" +#define PEM_STRING_EVP_PKEY "PRIVATE KEY" +#define PEM_STRING_RSA "RSA PRIVATE KEY" +#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +#define PEM_STRING_DSA "DSA PRIVATE KEY" +#define PEM_STRING_PKCS7 "PKCS7" +#define PEM_STRING_DHPARAMS "DH PARAMETERS" +#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" + +#ifndef HEADER_ENVELOPE_H + +#define EVP_ENCODE_CTX_SIZE 92 +#define EVP_MD_SIZE 48 +#define EVP_MD_CTX_SIZE 152 +#define EVP_CIPHER_SIZE 28 +#define EVP_CIPHER_CTX_SIZE 4212 +#define EVP_MAX_MD_SIZE 20 + +typedef struct evp_encode_ctx_st + { + char data[EVP_ENCODE_CTX_SIZE]; + } EVP_ENCODE_CTX; + +typedef struct env_md_ctx_st + { + char data[EVP_MD_CTX_SIZE]; + } EVP_MD_CTX; + +typedef struct evp_cipher_st + { + char data[EVP_CIPHER_SIZE]; + } EVP_CIPHER; + +typedef struct evp_cipher_ctx_st + { + char data[EVP_CIPHER_CTX_SIZE]; + } EVP_CIPHER_CTX; +#endif + + +typedef struct PEM_Encode_Seal_st + { + EVP_ENCODE_CTX encode; + EVP_MD_CTX md; + EVP_CIPHER_CTX cipher; + } PEM_ENCODE_SEAL_CTX; + +/* enc_type is one off */ +#define PEM_TYPE_ENCRYPTED 10 +#define PEM_TYPE_MIC_ONLY 20 +#define PEM_TYPE_MIC_CLEAR 30 +#define PEM_TYPE_CLEAR 40 + +typedef struct pem_recip_st + { + char *name; + X509_NAME *dn; + + int cipher; + int key_enc; + char iv[8]; + } PEM_USER; + +typedef struct pem_ctx_st + { + int type; /* what type of object */ + + struct { + int version; + int mode; + } proc_type; + + char *domain; + + struct { + int cipher; + unsigned char iv[8]; + } DEK_info; + + PEM_USER *originator; + + int num_recipient; + PEM_USER **recipient; + +#ifdef HEADER_STACK_H + STACK *x509_chain; /* certificate chain */ +#else + char *x509_chain; /* certificate chain */ +#endif + EVP_MD *md; /* signature type */ + + int md_enc; /* is the md encrypted or not? */ + int md_len; /* length of md_data */ + char *md_data; /* message digest, could be pkey encrypted */ + + EVP_CIPHER *dec; /* date encryption cipher */ + int key_len; /* key length */ + unsigned char *key; /* key */ + unsigned char iv[8]; /* the iv */ + + + int data_enc; /* is the data encrypted */ + int data_len; + unsigned char *data; + } PEM_CTX; + +#ifdef SSLEAY_MACROS + +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL) +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ + NULL,NULL,0,NULL) +#define PEM_write_X509_CRL(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ + fp,(char *)x, NULL,NULL,0,NULL) +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ + (char *)x,enc,kstr,klen,cb) +#define PEM_write_RSAPublicKey(fp,x) \ + PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ + PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ + (char *)x,enc,kstr,klen,cb) +#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_PKCS7(fp,x) \ + PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_DHparams(fp,x) \ + PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ + (char *)x,NULL,NULL,0,NULL) + +#define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb) +#define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \ + (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb) +#define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb) +#define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb) +#define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb) +#define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb) +#define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb) +#define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb) +#define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb) +#define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb) + +#define PEM_write_bio_SSL_SESSION(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_X509(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ + NULL,NULL,0,NULL) +#define PEM_write_bio_X509_CRL(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ + bp,(char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_bio_RSAPublicKey(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ + PEM_STRING_RSA_PUBLIC,\ + bp,(char *)x,NULL,NULL,0,NULL) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \ + PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb) +#define PEM_write_bio_PKCS7(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ + (char *)x, NULL,NULL,0,NULL) +#define PEM_write_bio_DHparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ + bp,(char *)x,NULL,NULL,0,NULL) +#define PEM_write_bio_DSAparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ + PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL) + +#define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb) +#define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb) +#define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb) +#define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb) +#define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb) +#define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb) + +#define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb) +#define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb) +#define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb) + +#endif + +#ifndef NOPROTO +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + int (*callback)()); + +#ifdef HEADER_BIO_H +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write_bio(BIO *bp,char *name,char *hdr,unsigned char *data, + long len); +char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x, + int (*cb)()); +int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x, + EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)()); +STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)()); +int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, + unsigned char *kstr, int klen, int (*cb)()); +#endif + +#ifndef WIN16 +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); +char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x, + int (*cb)()); +int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x, + EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)()); +STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)()); +#endif + +int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, + EVP_MD *md_type, unsigned char **ek, int *ekl, + unsigned char *iv, EVP_PKEY **pubk, int npubk); +void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, + unsigned char *in, int inl); +int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, + unsigned char *out, int *outl, EVP_PKEY *priv); + +void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +void ERR_load_PEM_strings(void); + +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, char *type, int len, char *str); + +#ifndef SSLEAY_MACROS + +#ifndef WIN16 +X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)()); +X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)()); +X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)()); +RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)()); +RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)()); +DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)()); +EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)()); +PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)()); +DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)()); +DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)()); +int PEM_write_X509(FILE *fp,X509 *x); +int PEM_write_X509_REQ(FILE *fp,X509_REQ *x); +int PEM_write_X509_CRL(FILE *fp,X509_CRL *x); +int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr, + int klen,int (*cb)()); +int PEM_write_RSAPublicKey(FILE *fp,RSA *x); +int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,EVP_CIPHER *enc,unsigned char *kstr, + int klen,int (*cb)()); +int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_PKCS7(FILE *fp,PKCS7 *x); +int PEM_write_DHparams(FILE *fp,DH *x); +int PEM_write_DSAparams(FILE *fp,DSA *x); +#endif + +#ifdef HEADER_BIO_H +X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)()); +X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)()); +X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)()); +RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)()); +RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)()); +DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)()); +EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)()); +PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)()); +DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)()); +DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)()); +int PEM_write_bio_X509(BIO *bp,X509 *x); +int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x); +int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x); +int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x); +int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc, + unsigned char *kstr,int klen,int (*cb)()); +int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x); +int PEM_write_bio_DHparams(BIO *bp,DH *x); +int PEM_write_bio_DSAparams(BIO *bp,DSA *x); +#endif + +#endif /* SSLEAY_MACROS */ + + +#else + +int PEM_get_EVP_CIPHER_INFO(); +int PEM_do_header(); +int PEM_read_bio(); +int PEM_write_bio(); +#ifndef WIN16 +int PEM_read(); +int PEM_write(); +STACK * PEM_X509_INFO_read(); +char * PEM_ASN1_read(); +int PEM_ASN1_write(); +#endif +STACK * PEM_X509_INFO_read_bio(); +int PEM_X509_INFO_write_bio(); +char * PEM_ASN1_read_bio(); +int PEM_ASN1_write_bio(); +int PEM_SealInit(); +void PEM_SealUpdate(); +int PEM_SealFinal(); +int PEM_SignFinal(); + +void ERR_load_PEM_strings(); + +void PEM_proc_type(); +void PEM_dek_info(); + +#ifndef SSLEAY_MACROS +#ifndef WIN16 +X509 *PEM_read_X509(); +X509_REQ *PEM_read_X509_REQ(); +X509_CRL *PEM_read_X509_CRL(); +RSA *PEM_read_RSAPrivateKey(); +RSA *PEM_read_RSAPublicKey(); +DSA *PEM_read_DSAPrivateKey(); +EVP_PKEY *PEM_read_PrivateKey(); +PKCS7 *PEM_read_PKCS7(); +DH *PEM_read_DHparams(); +DSA *PEM_read_DSAparams(); +int PEM_write_X509(); +int PEM_write_X509_REQ(); +int PEM_write_X509_CRL(); +int PEM_write_RSAPrivateKey(); +int PEM_write_RSAPublicKey(); +int PEM_write_DSAPrivateKey(); +int PEM_write_PrivateKey(); +int PEM_write_PKCS7(); +int PEM_write_DHparams(); +int PEM_write_DSAparams(); +#endif + +X509 *PEM_read_bio_X509(); +X509_REQ *PEM_read_bio_X509_REQ(); +X509_CRL *PEM_read_bio_X509_CRL(); +RSA *PEM_read_bio_RSAPrivateKey(); +RSA *PEM_read_bio_RSAPublicKey(); +DSA *PEM_read_bio_DSAPrivateKey(); +EVP_PKEY *PEM_read_bio_PrivateKey(); +PKCS7 *PEM_read_bio_PKCS7(); +DH *PEM_read_bio_DHparams(); +DSA *PEM_read_bio_DSAparams(); +int PEM_write_bio_X509(); +int PEM_write_bio_X509_REQ(); +int PEM_write_bio_X509_CRL(); +int PEM_write_bio_RSAPrivateKey(); +int PEM_write_bio_RSAPublicKey(); +int PEM_write_bio_DSAPrivateKey(); +int PEM_write_bio_PrivateKey(); +int PEM_write_bio_PKCS7(); +int PEM_write_bio_DHparams(); +int PEM_write_bio_DSAparams(); + +#endif /* SSLEAY_MACROS */ + +#endif + +/* BEGIN ERROR CODES */ +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_DEF_CALLBACK 100 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl new file mode 100644 index 0000000000..a88359b320 --- /dev/null +++ b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl @@ -0,0 +1,86 @@ +# +# SSLeay/crypto/asn1/Makefile +# + +DIR= pkcs7 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=pkcs7 +ERRC=pkcs7err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c +LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o + +SRC= $(LIBSRC) + +EXHEADER= pkcs7.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +test: + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/pkcs7/README b/src/lib/libssl/src/crypto/pkcs7/README new file mode 100644 index 0000000000..27001c6970 --- /dev/null +++ b/src/lib/libssl/src/crypto/pkcs7/README @@ -0,0 +1,5 @@ +WARNING + +Everything in this directory is experimental and is subject to change. + +Do not rely on the stuff in here not changing in the next release diff --git a/src/lib/libssl/src/crypto/pkcs7/mf.p7 b/src/lib/libssl/src/crypto/pkcs7/mf.p7 new file mode 100644 index 0000000000..524335b4b3 --- /dev/null +++ b/src/lib/libssl/src/crypto/pkcs7/mf.p7 @@ -0,0 +1,18 @@ +-----BEGIN PKCS7----- +MIAGCSqGSIb3DQEHAqCAMIIC2QIBATEMMAoGCCqGSIb3DQIFMIAGCSqGSIb3DQEH +AQAAoIIB7TCCAekwggFSAgEAMA0GCSqGSIb3DQEBBAUAMFsxCzAJBgNVBAYTAkFV +MRMwEQYDVQQIEwpRdWVlbnNsYW5kMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0 +ZDEbMBkGA1UEAxMSVGVzdCBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0NloX +DTk4MDYwOTEzNTc0NlowYzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xh +bmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMSMwIQYDVQQDExpTZXJ2ZXIg +dGVzdCBjZXJ0ICg1MTIgYml0KTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCfs8OE +J5X/EjFSDxXvRhHErYDmNlsP3YDXYY3g/HJFCTT+VWZFQ0xol2r+qKCl3194/+7X +ZLg/BMtv/yr+/rntAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAeEzEdgr2nChPcALL +vY8gl/GIlpoAjPmKD+pLeGZI9s+SEX5u1q8nCrJ6ZzkfrRnqgI5Anmev9+qPZfdU +bz5zdVSf4sUL9nX9ChXjK9NCJA3UzQHSFqhZErGUwGNkAHYHp2+zAdY6Ho6rmMzt +g0CDu/sKR4qzm6REsQGS8kgpjz4xgcUwgcICAQEwYDBbMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKUXVlZW5zbGFuZDEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQx +GzAZBgNVBAMTElRlc3QgQ0EgKDEwMjQgYml0KQIBADAKBggqhkiG9w0CBTANBgkq +hkiG9w0BAQQFAARALnrxJiOX9XZf2D+3vL8SKMQmMq55LltomwOLGUru/q1uVXzi +ARg7FSCegOpA1nunsTURMUGgrPXKK4XmL4IseQAAAAA= +-----END PKCS7----- diff --git a/src/lib/libssl/src/crypto/pkcs7/p7.tst b/src/lib/libssl/src/crypto/pkcs7/p7.tst new file mode 100644 index 0000000000..6d14dce163 --- /dev/null +++ b/src/lib/libssl/src/crypto/pkcs7/p7.tst @@ -0,0 +1,33 @@ +-----BEGIN PKCS7----- +MIAGCSqGSIb3DQEHAqCAMIIFsQIBATELMAkGBSsOAwIaBQAwgAYJKoZIhvcNAQcB +AACgggQdMIICJTCCAc+gAwIBAgIBIjANBgkqhkiG9w0BAQQFADCBgjELMAkGA1UE +BhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRow +GAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEUMBIGA1UECxMLZGV2ZWxvcG1lbnQx +GTAXBgNVBAMTEENyeXB0U29mdCBEZXYgQ0EwHhcNOTcwNjEzMTgxMDE3WhcNOTgw +NjEzMTgxMDE3WjCBiDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx +ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEU +MBIGA1UECxMLSUlTIHRlc3RpbmcxDjAMBgNVBAMTBXRlc3QxMQ8wDQYJKoZIhvcN +AQkBFgAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAxtWiv59VH42+rotrmFAyDxTc +J2osFt5uy/zEllx3vvjtwewqQxGUOwf6cjqFOTrnpEdVvwywpEhIQ5364bJqIwID +AQABoygwJjAkBglghkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0G +CSqGSIb3DQEBBAUAA0EAMnYkNV2AdpeHPy/qlcdZx6MDGIJgrLhklhcn6Or6KiAP +t9+nv9XdOGHyMyQr9ufsweuQfAgJ9yjKPZR2/adTjTCCAfAwggGaAgEAMA0GCSqG +SIb3DQEBBAUAMIGCMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDER +MA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRQw +EgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UEAxMQQ3J5cHRTb2Z0IERldiBDQTAe +Fw05NzAzMjIxMzM0MDRaFw05ODAzMjIxMzM0MDRaMIGCMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoT +EUNyeXB0U29mdCBQdHkgTHRkMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UE +AxMQQ3J5cHRTb2Z0IERldiBDQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgDgKq +IBuUMAJi4c8juAqEZ8f8FcuDWT+HcScvNztRJy9K8DnbGpiSrzzix4El6N4A7vbl +crwn/0CZmQJguZpfAgMBAAEwDQYJKoZIhvcNAQEEBQADQQA0UUvxlXXe6wKkVukn +ZoCyXbjlNsqt2rwbvfZEam6fQP3S7uq+o1Pnj+KDgE33WxWbQAA9h8fY1LWN7X3a +yTm/MYIBbTCCAWkCAQEwgYgwgYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVl +bnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0 +eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQg +RGV2IENBAgEiMAkGBSsOAwIaBQCgfTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcB +MCMGCSqGSIb3DQEJBDEWBBSUVhbGkNE+KGqpOK13+FkfOkaoizAcBgkqhkiG9w0B +CQUxDxcNOTcwNzAxMDE0MzM0WjAeBgkqhkiG9w0BCQ8xETAPMA0GCCqGSIb3DQMC +AgEoMA0GCSqGSIb3DQEBAQUABECa9Jpo4w/fZOc3Vy78wZFAVF8kvpn7il99Ldsr +AQ4JiBmcfiSwEBBY6WuKT+/SYtFwZl1oXkTwB5AVCFIC/IFNAAAAAA== +-----END PKCS7----- diff --git a/src/lib/libssl/src/crypto/pkcs7/pkcs7.err b/src/lib/libssl/src/crypto/pkcs7/pkcs7.err new file mode 100644 index 0000000000..91413aae43 --- /dev/null +++ b/src/lib/libssl/src/crypto/pkcs7/pkcs7.err @@ -0,0 +1,26 @@ +/* Error codes for the PKCS7 functions. */ + +/* Function codes. */ +#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 +#define PKCS7_F_PKCS7_ADD_CRL 101 +#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 +#define PKCS7_F_PKCS7_ADD_SIGNER 103 +#define PKCS7_F_PKCS7_CTRL 104 +#define PKCS7_F_PKCS7_DATAINIT 105 +#define PKCS7_F_PKCS7_DATASIGN 106 +#define PKCS7_F_PKCS7_DATAVERIFY 107 +#define PKCS7_F_PKCS7_SET_CIPHER 108 +#define PKCS7_F_PKCS7_SET_CONTENT 109 +#define PKCS7_F_PKCS7_SET_TYPE 110 + +/* Reason codes. */ +#define PKCS7_R_INTERNAL_ERROR 100 +#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 101 +#define PKCS7_R_SIGNATURE_FAILURE 102 +#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 103 +#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 104 +#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 105 +#define PKCS7_R_UNKNOWN_DIGEST_TYPE 106 +#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 107 +#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 108 +#define PKCS7_R_WRONG_CONTENT_TYPE 109 diff --git a/src/lib/libssl/src/crypto/rand/Makefile.ssl b/src/lib/libssl/src/crypto/rand/Makefile.ssl new file mode 100644 index 0000000000..d04f0a9b43 --- /dev/null +++ b/src/lib/libssl/src/crypto/rand/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/rand/Makefile +# + +DIR= rand +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= randtest.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=md_rand.c randfile.c +LIBOBJ=md_rand.o randfile.o + +SRC= $(LIBSRC) + +EXHEADER= rand.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/ranlib.sh b/src/lib/libssl/src/crypto/ranlib.sh new file mode 100644 index 0000000000..543f712c6b --- /dev/null +++ b/src/lib/libssl/src/crypto/ranlib.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cwd=`pwd` +cd /tmp + +if [ -s /bin/ranlib ] ; then + RL=/bin/ranlib +else if [ -s /usr/bin/ranlib ] ; then + RL=/usr/bin/ranlib +fi +fi + +if [ "x$RL" != "x" ] +then + case "$1" in + /*) + $RL "$1" + ;; + *) + $RL "$cwd/$1" + ;; + esac +fi diff --git a/src/lib/libssl/src/crypto/rc2/Makefile.ssl b/src/lib/libssl/src/crypto/rc2/Makefile.ssl new file mode 100644 index 0000000000..c5138f13e2 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc2/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/rc2/Makefile +# + +DIR= rc2 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc2test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc2.h +HEADER= rc2_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rc2/Makefile.uni b/src/lib/libssl/src/crypto/rc2/Makefile.uni new file mode 100644 index 0000000000..e50b3f2d19 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc2/Makefile.uni @@ -0,0 +1,72 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options + +DIR= rc2 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +IDEA_ENC=rc2_cbc.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc2test +APPS=rc2speed + +LIB=librc2.a +LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc2.h +HEADER= rc2_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rc2/rc2.org b/src/lib/libssl/src/crypto/rc2/rc2.org new file mode 100644 index 0000000000..37354cfa62 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc2/rc2.org @@ -0,0 +1,118 @@ +/* crypto/rc2/rc2.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify rc2.org since rc2.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_RC2_H +#define HEADER_RC2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define RC2_ENCRYPT 1 +#define RC2_DECRYPT 0 + +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned short + +#define RC2_BLOCK 8 +#define RC2_KEY_LENGTH 16 + +typedef struct rc2_key_st + { + RC2_INT data[64]; + } RC2_KEY; + +#ifndef NOPROTO + +void RC2_set_key(RC2_KEY *key, int len, unsigned char *data,int bits); +void RC2_ecb_encrypt(unsigned char *in,unsigned char *out,RC2_KEY *key, + int enc); +void RC2_encrypt(unsigned long *data,RC2_KEY *key); +void RC2_decrypt(unsigned long *data,RC2_KEY *key); +void RC2_cbc_encrypt(unsigned char *in, unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, int enc); +void RC2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + RC2_KEY *schedule, unsigned char *ivec, int *num, int enc); +void RC2_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + RC2_KEY *schedule, unsigned char *ivec, int *num); + +#else + +void RC2_set_key(); +void RC2_ecb_encrypt(); +void RC2_encrypt(); +void RC2_decrypt(); +void RC2_cbc_encrypt(); +void RC2_cfb64_encrypt(); +void RC2_ofb64_encrypt(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libssl/src/crypto/rc4/Makefile.ssl b/src/lib/libssl/src/crypto/rc4/Makefile.ssl new file mode 100644 index 0000000000..19c1e980f3 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc4/Makefile.ssl @@ -0,0 +1,108 @@ +# +# SSLeay/crypto/rc4/Makefile +# + +DIR= rc4 +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +RC4_ENC=rc4_enc.o +# or use +#RC4_ENC=asm/rx86-elf.o +#RC4_ENC=asm/rx86-out.o +#RC4_ENC=asm/rx86-sol.o +#RC4_ENC=asm/rx86bdsi.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc4test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=rc4_skey.c rc4_enc.c +LIBOBJ=rc4_skey.o $(RC4_ENC) + +SRC= $(LIBSRC) + +EXHEADER= rc4.h +HEADER= $(EXHEADER) rc4_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/rx86-elf.o: asm/rx86unix.cpp + $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o + +# solaris +asm/rx86-sol.o: asm/rx86unix.cpp + $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s + as -o asm/rx86-sol.o asm/rx86-sol.s + rm -f asm/rx86-sol.s + +# a.out +asm/rx86-out.o: asm/rx86unix.cpp + $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o + +# bsdi +asm/rx86bsdi.o: asm/rx86unix.cpp + $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o + +asm/rx86unix.cpp: + (cd asm; perl rc4-586.pl cpp >rx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rc4/Makefile.uni b/src/lib/libssl/src/crypto/rc4/Makefile.uni new file mode 100644 index 0000000000..79dc17b8d1 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc4/Makefile.uni @@ -0,0 +1,102 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= rc4 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +RC4_ENC=rc4_enc.o +# or use +#RC4_ENC=asm/rx86-elf.o +#RC4_ENC=asm/rx86-out.o +#RC4_ENC=asm/rx86-sol.o +#RC4_ENC=asm/rx86bdsi.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc4test +APPS=rc4speed + +LIB=librc4.a +LIBSRC=rc4_skey.c rc4_enc.c +LIBOBJ=rc4_skey.o $(RC4_ENC) + +SRC= $(LIBSRC) + +EXHEADER= rc4.h +HEADER= $(EXHEADER) rc4_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/rx86-elf.o: asm/rx86unix.cpp + $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o + +# solaris +asm/rx86-sol.o: asm/rx86unix.cpp + $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s + as -o asm/rx86-sol.o asm/rx86-sol.s + rm -f asm/rx86-sol.s + +# a.out +asm/rx86-out.o: asm/rx86unix.cpp + $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o + +# bsdi +asm/rx86bsdi.o: asm/rx86unix.cpp + $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o + +asm/rx86unix.cpp: + (cd asm; perl rc4-586.pl cpp >rx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm b/src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm new file mode 100644 index 0000000000..70b0f7484c --- /dev/null +++ b/src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm @@ -0,0 +1,314 @@ + ; Don't even think of reading this code + ; It was automatically generated by rc4-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE rc4-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _RC4 + +_RC4 PROC NEAR + ; + push ebp + push ebx + mov ebp, DWORD PTR 12[esp] + mov ebx, DWORD PTR 16[esp] + push esi + push edi + mov ecx, DWORD PTR [ebp] + mov edx, DWORD PTR 4[ebp] + mov esi, DWORD PTR 28[esp] + inc ecx + sub esp, 12 + add ebp, 8 + and ecx, 255 + lea ebx, DWORD PTR [esi+ebx-8] + mov edi, DWORD PTR 44[esp] + mov DWORD PTR 8[esp],ebx + mov eax, DWORD PTR [ecx*4+ebp] + cmp ebx, esi + jl $L000end +L001start: + add esi, 8 + ; Round 0 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR [esp], bl + ; Round 1 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 1[esp],bl + ; Round 2 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 2[esp],bl + ; Round 3 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 3[esp],bl + ; Round 4 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 4[esp],bl + ; Round 5 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 5[esp],bl + ; Round 6 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov BYTE PTR 6[esp],bl + ; Round 7 + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + add edi, 8 + mov BYTE PTR 7[esp],bl + ; apply the cipher text + mov eax, DWORD PTR [esp] + mov ebx, DWORD PTR [esi-8] + xor eax, ebx + mov ebx, DWORD PTR [esi-4] + mov DWORD PTR [edi-8],eax + mov eax, DWORD PTR 4[esp] + xor eax, ebx + mov ebx, DWORD PTR 8[esp] + mov DWORD PTR [edi-4],eax + mov eax, DWORD PTR [ecx*4+ebp] + cmp esi, ebx + jle L001start +$L000end: + ; Round 0 + add ebx, 8 + inc esi + cmp ebx, esi + jl $L002finished + mov DWORD PTR 8[esp],ebx + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR [edi], bl + ; Round 1 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 1[edi],bl + ; Round 2 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 2[edi],bl + ; Round 3 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 3[edi],bl + ; Round 4 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 4[edi],bl + ; Round 5 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov eax, DWORD PTR [ecx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 5[edi],bl + ; Round 6 + mov ebx, DWORD PTR 8[esp] + cmp ebx, esi + jle $L002finished + inc esi + add edx, eax + and edx, 255 + inc ecx + mov ebx, DWORD PTR [edx*4+ebp] + mov DWORD PTR [ecx*4+ebp-4],ebx + add ebx, eax + and ecx, 255 + and ebx, 255 + mov DWORD PTR [edx*4+ebp],eax + nop + mov ebx, DWORD PTR [ebx*4+ebp] + mov bh, BYTE PTR [esi-1] + xor bl, bh + mov BYTE PTR 6[edi],bl +$L002finished: + dec ecx + add esp, 12 + mov DWORD PTR [ebp-4],edx + mov BYTE PTR [ebp-8],cl + pop edi + pop esi + pop ebx + pop ebp + ret +_RC4 ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp b/src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp new file mode 100644 index 0000000000..ec1d72a110 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp @@ -0,0 +1,358 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define RC4 _RC4 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rc4-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "rc4-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl RC4 + TYPE(RC4,@function) +RC4: + + pushl %ebp + pushl %ebx + movl 12(%esp), %ebp + movl 16(%esp), %ebx + pushl %esi + pushl %edi + movl (%ebp), %ecx + movl 4(%ebp), %edx + movl 28(%esp), %esi + incl %ecx + subl $12, %esp + addl $8, %ebp + andl $255, %ecx + leal -8(%ebx,%esi,), %ebx + movl 44(%esp), %edi + movl %ebx, 8(%esp) + movl (%ebp,%ecx,4), %eax + cmpl %esi, %ebx + jl .L000end +.L001start: + addl $8, %esi + /* Round 0 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, (%esp) + /* Round 1 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 1(%esp) + /* Round 2 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 2(%esp) + /* Round 3 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 3(%esp) + /* Round 4 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 4(%esp) + /* Round 5 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 5(%esp) + /* Round 6 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb %bl, 6(%esp) + /* Round 7 */ + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + addl $8, %edi + movb %bl, 7(%esp) + /* apply the cipher text */ + movl (%esp), %eax + movl -8(%esi), %ebx + xorl %ebx, %eax + movl -4(%esi), %ebx + movl %eax, -8(%edi) + movl 4(%esp), %eax + xorl %ebx, %eax + movl 8(%esp), %ebx + movl %eax, -4(%edi) + movl (%ebp,%ecx,4), %eax + cmpl %ebx, %esi + jle .L001start +.L000end: + /* Round 0 */ + addl $8, %ebx + incl %esi + cmpl %esi, %ebx + jl .L002finished + movl %ebx, 8(%esp) + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, (%edi) + /* Round 1 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 1(%edi) + /* Round 2 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 2(%edi) + /* Round 3 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 3(%edi) + /* Round 4 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 4(%edi) + /* Round 5 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movl (%ebp,%ecx,4), %eax + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 5(%edi) + /* Round 6 */ + movl 8(%esp), %ebx + cmpl %esi, %ebx + jle .L002finished + incl %esi + addl %eax, %edx + andl $255, %edx + incl %ecx + movl (%ebp,%edx,4), %ebx + movl %ebx, -4(%ebp,%ecx,4) + addl %eax, %ebx + andl $255, %ecx + andl $255, %ebx + movl %eax, (%ebp,%edx,4) + nop + movl (%ebp,%ebx,4), %ebx + movb -1(%esi), %bh + xorb %bh, %bl + movb %bl, 6(%edi) +.L002finished: + decl %ecx + addl $12, %esp + movl %edx, -4(%ebp) + movb %cl, -8(%ebp) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.RC4_end: + SIZE(RC4,.RC4_end-RC4) +.ident "RC4" diff --git a/src/lib/libssl/src/crypto/rc4/rc4.org b/src/lib/libssl/src/crypto/rc4/rc4.org new file mode 100644 index 0000000000..c558651af8 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc4/rc4.org @@ -0,0 +1,103 @@ +/* crypto/rc4/rc4.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify rc4.org since rc4.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_RC4_H +#define HEADER_RC4_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +#define RC4_INT unsigned int + +typedef struct rc4_key_st + { + RC4_INT x,y; + RC4_INT data[256]; + } RC4_KEY; + +#ifndef NOPROTO + +char *RC4_options(void); +void RC4_set_key(RC4_KEY *key, int len, unsigned char *data); +void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata, + unsigned char *outdata); + +#else + +char *RC4_options(); +void RC4_set_key(); +void RC4(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/libssl/src/crypto/rc4/rc4_locl.org b/src/lib/libssl/src/crypto/rc4/rc4_locl.org new file mode 100644 index 0000000000..1ef4455fb7 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc4/rc4_locl.org @@ -0,0 +1,70 @@ +/* crypto/rc4/rc4_locl.org */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * Always modify bf_locl.org since bf_locl.h is automatically generated from + * it during SSLeay configuration. + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX + diff --git a/src/lib/libssl/src/crypto/rc5/Makefile.ssl b/src/lib/libssl/src/crypto/rc5/Makefile.ssl new file mode 100644 index 0000000000..5e98ee2348 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc5/Makefile.ssl @@ -0,0 +1,107 @@ +# +# SSLeay/crypto/rc5/Makefile +# + +DIR= rc5 +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +RC5_ENC= rc5_enc.o +# or use +#DES_ENC= r586-elf.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc5test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c +LIBOBJ=rc5_skey.o rc5_ecb.o $(RC5_ENC) rc5cfb64.o rc5ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc5.h +HEADER= rc5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/r586-elf.o: asm/r586unix.cpp + $(CPP) -DELF asm/r586unix.cpp | as -o asm/r586-elf.o + +# solaris +asm/r586-sol.o: asm/r586unix.cpp + $(CC) -E -DSOL asm/r586unix.cpp | sed 's/^#.*//' > asm/r586-sol.s + as -o asm/r586-sol.o asm/r586-sol.s + rm -f asm/r586-sol.s + +# a.out +asm/r586-out.o: asm/r586unix.cpp + $(CPP) -DOUT asm/r586unix.cpp | as -o asm/r586-out.o + +# bsdi +asm/r586bsdi.o: asm/r586unix.cpp + $(CPP) -DBSDI asm/r586unix.cpp | as -o asm/r586bsdi.o + +asm/r586unix.cpp: + (cd asm; perl rc5-586.pl cpp >r586unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/point.sh ../../doc/rc5.doc rc5.doc ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rc5/Makefile.uni b/src/lib/libssl/src/crypto/rc5/Makefile.uni new file mode 100644 index 0000000000..e50b3f2d19 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc5/Makefile.uni @@ -0,0 +1,72 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options + +DIR= rc2 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +IDEA_ENC=rc2_cbc.o + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rc2test +APPS=rc2speed + +LIB=librc2.a +LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c +LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o + +SRC= $(LIBSRC) + +EXHEADER= rc2.h +HEADER= rc2_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm b/src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm new file mode 100644 index 0000000000..f43d3711f0 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm @@ -0,0 +1,574 @@ + ; Don't even think of reading this code + ; It was automatically generated by rc5-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE rc5-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _RC5_32_encrypt + +_RC5_32_encrypt PROC NEAR + ; + push ebp + push esi + push edi + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 20[esp] + ; Load the 2 words + mov edi, DWORD PTR [edx] + mov esi, DWORD PTR 4[edx] + push ebx + mov ebx, DWORD PTR [ebp] + add edi, DWORD PTR 4[ebp] + add esi, DWORD PTR 8[ebp] + xor edi, esi + mov eax, DWORD PTR 12[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 16[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 20[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 24[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 28[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 32[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 36[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 40[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 44[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 48[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 52[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 56[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 60[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 64[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 68[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 72[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + cmp ebx, 8 + je $L000rc5_exit + xor edi, esi + mov eax, DWORD PTR 76[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 80[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 84[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 88[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 92[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 96[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 100[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 104[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + cmp ebx, 12 + je $L000rc5_exit + xor edi, esi + mov eax, DWORD PTR 108[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 112[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 116[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 120[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 124[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 128[ebp] + mov ecx, edi + rol esi, cl + add esi, eax + xor edi, esi + mov eax, DWORD PTR 132[ebp] + mov ecx, esi + rol edi, cl + add edi, eax + xor esi, edi + mov eax, DWORD PTR 136[ebp] + mov ecx, edi + rol esi, cl + add esi, eax +$L000rc5_exit: + mov DWORD PTR [edx],edi + mov DWORD PTR 4[edx],esi + pop ebx + pop edi + pop esi + pop ebp + ret +_RC5_32_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _RC5_32_decrypt + +_RC5_32_decrypt PROC NEAR + ; + push ebp + push esi + push edi + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 20[esp] + ; Load the 2 words + mov edi, DWORD PTR [edx] + mov esi, DWORD PTR 4[edx] + push ebx + mov ebx, DWORD PTR [ebp] + cmp ebx, 12 + je $L001rc5_dec_12 + cmp ebx, 8 + je $L002rc5_dec_8 + mov eax, DWORD PTR 136[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 132[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 128[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 124[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 120[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 116[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 112[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 108[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi +$L001rc5_dec_12: + mov eax, DWORD PTR 104[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 100[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 96[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 92[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 88[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 84[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 80[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 76[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi +$L002rc5_dec_8: + mov eax, DWORD PTR 72[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 68[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 64[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 60[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 56[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 52[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 48[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 44[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 40[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 36[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 32[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 28[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 24[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 20[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + mov eax, DWORD PTR 16[ebp] + sub esi, eax + mov ecx, edi + ror esi, cl + xor esi, edi + mov eax, DWORD PTR 12[ebp] + sub edi, eax + mov ecx, esi + ror edi, cl + xor edi, esi + sub esi, DWORD PTR 8[ebp] + sub edi, DWORD PTR 4[ebp] +L003rc5_exit: + mov DWORD PTR [edx],edi + mov DWORD PTR 4[edx],esi + pop ebx + pop edi + pop esi + pop ebp + ret +_RC5_32_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _RC5_32_cbc_encrypt + +_RC5_32_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L004decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L005encrypt_finish +L006encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L006encrypt_loop +$L005encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L007finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4] + jmp ebp +L009ej7: + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L010ej6: + mov dh, BYTE PTR 5[esi] +L011ej5: + mov dl, BYTE PTR 4[esi] +L012ej4: + mov ecx, DWORD PTR [esi] + jmp $L013ejend +L014ej3: + mov ch, BYTE PTR 2[esi] + shl ecx, 8 +L015ej2: + mov ch, BYTE PTR 1[esi] +L016ej1: + mov cl, BYTE PTR [esi] +$L013ejend: + xor eax, ecx + xor ebx, edx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L007finish +$L004decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L017decrypt_finish +L018decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L018decrypt_loop +$L017decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L007finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _RC5_32_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L019dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L020dj6: + mov BYTE PTR 5[edi],dh +L021dj5: + mov BYTE PTR 4[edi],dl +L022dj4: + mov DWORD PTR [edi],ecx + jmp $L023djend +L024dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L025dj2: + mov BYTE PTR 1[esi],ch +L026dj1: + mov BYTE PTR [esi], cl +$L023djend: + jmp $L007finish +$L007finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L008cbc_enc_jmp_table: + DD 0 + DD L016ej1 + DD L015ej2 + DD L014ej3 + DD L012ej4 + DD L011ej5 + DD L010ej6 + DD L009ej7 +L027cbc_dec_jmp_table: + DD 0 + DD L026dj1 + DD L025dj2 + DD L024dj3 + DD L022dj4 + DD L021dj5 + DD L020dj6 + DD L019dj7 +_RC5_32_cbc_encrypt ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp b/src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp new file mode 100644 index 0000000000..a25dd5a9a4 --- /dev/null +++ b/src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp @@ -0,0 +1,628 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define RC5_32_encrypt _RC5_32_encrypt +#define RC5_32_decrypt _RC5_32_decrypt +#define RC5_32_cbc_encrypt _RC5_32_cbc_encrypt + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rc5-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "rc5-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl RC5_32_encrypt + TYPE(RC5_32_encrypt,@function) +RC5_32_encrypt: + + pushl %ebp + pushl %esi + pushl %edi + movl 16(%esp), %edx + movl 20(%esp), %ebp + /* Load the 2 words */ + movl (%edx), %edi + movl 4(%edx), %esi + pushl %ebx + movl (%ebp), %ebx + addl 4(%ebp), %edi + addl 8(%ebp), %esi + xorl %esi, %edi + movl 12(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 16(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 20(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 24(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 28(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 32(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 36(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 40(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 44(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 48(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 52(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 56(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 60(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 64(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 68(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 72(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + cmpl $8, %ebx + je .L000rc5_exit + xorl %esi, %edi + movl 76(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 80(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 84(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 88(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 92(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 96(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 100(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 104(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + cmpl $12, %ebx + je .L000rc5_exit + xorl %esi, %edi + movl 108(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 112(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 116(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 120(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 124(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 128(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi + xorl %esi, %edi + movl 132(%ebp), %eax + movl %esi, %ecx + roll %cl, %edi + addl %eax, %edi + xorl %edi, %esi + movl 136(%ebp), %eax + movl %edi, %ecx + roll %cl, %esi + addl %eax, %esi +.L000rc5_exit: + movl %edi, (%edx) + movl %esi, 4(%edx) + popl %ebx + popl %edi + popl %esi + popl %ebp + ret +.RC5_32_encrypt_end: + SIZE(RC5_32_encrypt,.RC5_32_encrypt_end-RC5_32_encrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl RC5_32_decrypt + TYPE(RC5_32_decrypt,@function) +RC5_32_decrypt: + + pushl %ebp + pushl %esi + pushl %edi + movl 16(%esp), %edx + movl 20(%esp), %ebp + /* Load the 2 words */ + movl (%edx), %edi + movl 4(%edx), %esi + pushl %ebx + movl (%ebp), %ebx + cmpl $12, %ebx + je .L001rc5_dec_12 + cmpl $8, %ebx + je .L002rc5_dec_8 + movl 136(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 132(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 128(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 124(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 120(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 116(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 112(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 108(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi +.L001rc5_dec_12: + movl 104(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 100(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 96(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 92(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 88(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 84(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 80(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 76(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi +.L002rc5_dec_8: + movl 72(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 68(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 64(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 60(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 56(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 52(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 48(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 44(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 40(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 36(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 32(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 28(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 24(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 20(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + movl 16(%ebp), %eax + subl %eax, %esi + movl %edi, %ecx + rorl %cl, %esi + xorl %edi, %esi + movl 12(%ebp), %eax + subl %eax, %edi + movl %esi, %ecx + rorl %cl, %edi + xorl %esi, %edi + subl 8(%ebp), %esi + subl 4(%ebp), %edi +.L003rc5_exit: + movl %edi, (%edx) + movl %esi, 4(%edx) + popl %ebx + popl %edi + popl %esi + popl %ebp + ret +.RC5_32_decrypt_end: + SIZE(RC5_32_decrypt,.RC5_32_decrypt_end-RC5_32_decrypt) +.ident "desasm.pl" +.text + .align ALIGN +.globl RC5_32_cbc_encrypt + TYPE(RC5_32_cbc_encrypt,@function) +RC5_32_cbc_encrypt: + + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 28(%esp), %ebp + /* getting iv ptr from parameter 4 */ + movl 36(%esp), %ebx + movl (%ebx), %esi + movl 4(%ebx), %edi + pushl %edi + pushl %esi + pushl %edi + pushl %esi + movl %esp, %ebx + movl 36(%esp), %esi + movl 40(%esp), %edi + /* getting encrypt flag from parameter 5 */ + movl 56(%esp), %ecx + /* get and push parameter 3 */ + movl 48(%esp), %eax + pushl %eax + pushl %ebx + cmpl $0, %ecx + jz .L004decrypt + andl $4294967288, %ebp + movl 8(%esp), %eax + movl 12(%esp), %ebx + jz .L005encrypt_finish +.L006encrypt_loop: + movl (%esi), %ecx + movl 4(%esi), %edx + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L006encrypt_loop +.L005encrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L007finish + xorl %ecx, %ecx + xorl %edx, %edx + movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp + jmp *%ebp +.L009ej7: + movb 6(%esi), %dh + sall $8, %edx +.L010ej6: + movb 5(%esi), %dh +.L011ej5: + movb 4(%esi), %dl +.L012ej4: + movl (%esi), %ecx + jmp .L013ejend +.L014ej3: + movb 2(%esi), %ch + sall $8, %ecx +.L015ej2: + movb 1(%esi), %ch +.L016ej1: + movb (%esi), %cl +.L013ejend: + xorl %ecx, %eax + xorl %edx, %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_encrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl %eax, (%edi) + movl %ebx, 4(%edi) + jmp .L007finish +.align ALIGN +.L004decrypt: + andl $4294967288, %ebp + movl 16(%esp), %eax + movl 20(%esp), %ebx + jz .L017decrypt_finish +.L018decrypt_loop: + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx + movl %ecx, (%edi) + movl %edx, 4(%edi) + movl %eax, 16(%esp) + movl %ebx, 20(%esp) + addl $8, %esi + addl $8, %edi + subl $8, %ebp + jnz .L018decrypt_loop +.L017decrypt_finish: + movl 52(%esp), %ebp + andl $7, %ebp + jz .L007finish + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 8(%esp) + movl %ebx, 12(%esp) + call RC5_32_decrypt + movl 8(%esp), %eax + movl 12(%esp), %ebx + movl 16(%esp), %ecx + movl 20(%esp), %edx + xorl %eax, %ecx + xorl %ebx, %edx + movl (%esi), %eax + movl 4(%esi), %ebx +.L019dj7: + rorl $16, %edx + movb %dl, 6(%edi) + shrl $16, %edx +.L020dj6: + movb %dh, 5(%edi) +.L021dj5: + movb %dl, 4(%edi) +.L022dj4: + movl %ecx, (%edi) + jmp .L023djend +.L024dj3: + rorl $16, %ecx + movb %cl, 2(%edi) + sall $16, %ecx +.L025dj2: + movb %ch, 1(%esi) +.L026dj1: + movb %cl, (%esi) +.L023djend: + jmp .L007finish +.align ALIGN +.L007finish: + movl 60(%esp), %ecx + addl $24, %esp + movl %eax, (%ecx) + movl %ebx, 4(%ecx) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.align ALIGN +.L008cbc_enc_jmp_table: + .long 0 + .long .L016ej1 + .long .L015ej2 + .long .L014ej3 + .long .L012ej4 + .long .L011ej5 + .long .L010ej6 + .long .L009ej7 +.align ALIGN +.L027cbc_dec_jmp_table: + .long 0 + .long .L026dj1 + .long .L025dj2 + .long .L024dj3 + .long .L022dj4 + .long .L021dj5 + .long .L020dj6 + .long .L019dj7 +.RC5_32_cbc_encrypt_end: + SIZE(RC5_32_cbc_encrypt,.RC5_32_cbc_encrypt_end-RC5_32_cbc_encrypt) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl b/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl new file mode 100644 index 0000000000..172bd9ee1b --- /dev/null +++ b/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +push(@INC,"perlasm","../../perlasm"); +require "x86asm.pl"; +require "cbc.pl"; + +&asm_init($ARGV[0],"rc5-586.pl"); + +$RC5_MAX_ROUNDS=16; +$RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4; +$A="edi"; +$B="esi"; +$S="ebp"; +$tmp1="eax"; +$r="ebx"; +$tmpc="ecx"; +$tmp4="edx"; + +&RC5_32_encrypt("RC5_32_encrypt",1); +&RC5_32_encrypt("RC5_32_decrypt",0); +&cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1); +&asm_finish(); + +sub RC5_32_encrypt + { + local($name,$enc)=@_; + + &function_begin_B($name,""); + + &comment(""); + + &push("ebp"); + &push("esi"); + &push("edi"); + &mov($tmp4,&wparam(0)); + &mov($S,&wparam(1)); + + &comment("Load the 2 words"); + &mov($A,&DWP(0,$tmp4,"",0)); + &mov($B,&DWP(4,$tmp4,"",0)); + + &push($r); + &mov($r, &DWP(0,$S,"",0)); + + # encrypting part + + if ($enc) + { + &add($A, &DWP(4+0,$S,"",0)); + &add($B, &DWP(4+4,$S,"",0)); + + for ($i=0; $i<$RC5_MAX_ROUNDS; $i++) + { + &xor($A, $B); + &mov($tmp1, &DWP(12+$i*8,$S,"",0)); + &mov($tmpc, $B); + &rotl($A, &LB("ecx")); + &add($A, $tmp1); + + &xor($B, $A); + &mov($tmp1, &DWP(16+$i*8,$S,"",0)); + &mov($tmpc, $A); + &rotl($B, &LB("ecx")); + &add($B, $tmp1); + if (($i == 7) || ($i == 11)) + { + &cmp($r, $i+1); + &je(&label("rc5_exit")); + } + } + } + else + { + &cmp($r, 12); + &je(&label("rc5_dec_12")); + &cmp($r, 8); + &je(&label("rc5_dec_8")); + for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--) + { + &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8); + &mov($tmp1, &DWP($i*8+8,$S,"",0)); + &sub($B, $tmp1); + &mov($tmpc, $A); + &rotr($B, &LB("ecx")); + &xor($B, $A); + + &mov($tmp1, &DWP($i*8+4,$S,"",0)); + &sub($A, $tmp1); + &mov($tmpc, $B); + &rotr($A, &LB("ecx")); + &xor($A, $B); + } + &sub($B, &DWP(4+4,$S,"",0)); + &sub($A, &DWP(4+0,$S,"",0)); + } + + &set_label("rc5_exit"); + &mov(&DWP(0,$tmp4,"",0),$A); + &mov(&DWP(4,$tmp4,"",0),$B); + + &pop("ebx"); + &pop("edi"); + &pop("esi"); + &pop("ebp"); + &ret(); + &function_end_B($name); + } + + diff --git a/src/lib/libssl/src/crypto/ripemd/Makefile.ssl b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl new file mode 100644 index 0000000000..67d47ceb2c --- /dev/null +++ b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl @@ -0,0 +1,104 @@ +# +# SSLeay/crypto/ripemd/Makefile +# + +DIR= ripemd +TOP= ../.. +CC= cc +CPP= $(CC) -E +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +RIP_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=rmdtest.c +APPS=rmd160.c + +LIB=$(TOP)/libcrypto.a +LIBSRC=rmd_dgst.c rmd_one.c +LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= ripemd.h +HEADER= rmd_locl.h rmdconst.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/rm86-elf.o: asm/rm86unix.cpp + $(CPP) -DELF asm/rm86unix.cpp | as -o asm/rm86-elf.o + +# solaris +asm/rm86-sol.o: asm/rm86unix.cpp + $(CC) -E -DSOL asm/rm86unix.cpp | sed 's/^#.*//' > asm/rm86-sol.s + as -o asm/rm86-sol.o asm/rm86-sol.s + rm -f asm/rm86-sol.s + +# a.out +asm/rm86-out.o: asm/rm86unix.cpp + $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o + +# bsdi +asm/rm86bsdi.o: asm/rm86unix.cpp + $(CPP) -DBSDI asm/rm86unix.cpp | as -o asm/rm86bsdi.o + +asm/rm86unix.cpp: + (cd asm; perl rmd-586.pl cpp >rm86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/ripemd/Makefile.uni b/src/lib/libssl/src/crypto/ripemd/Makefile.uni new file mode 100644 index 0000000000..54685712db --- /dev/null +++ b/src/lib/libssl/src/crypto/ripemd/Makefile.uni @@ -0,0 +1,109 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= md5 +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +MD5_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=md5test +APPS=md5 + +LIB=libmd5.a +LIBSRC=md5_dgst.c md5_one.c +LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= md5.h +HEADER= md5_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/mx86-elf.o: asm/mx86unix.cpp + $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o + +# solaris +asm/mx86-sol.o: asm/mx86unix.cpp + $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s + as -o asm/mx86-sol.o asm/mx86-sol.s + rm -f asm/mx86-sol.s + +# a.out +asm/mx86-out.o: asm/mx86unix.cpp + $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o + +# bsdi +asm/mx86bsdi.o: asm/mx86unix.cpp + $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o + +asm/mx86unix.cpp: + (cd asm; perl md5-586.pl cpp >mx86unix.cpp) + +test: $(TEST) + ./$(TEST) + +$(TEST): $(TEST).c $(LIB) + $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB) + +$(APPS): $(APPS).c $(LIB) + $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-out: + $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-solaris: + $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-bdsi: + $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm b/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm new file mode 100644 index 0000000000..bd38791c13 --- /dev/null +++ b/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm @@ -0,0 +1,1972 @@ + ; Don't even think of reading this code + ; It was automatically generated by rmd-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE rmd-586.asm + .386 +.model FLAT +_TEXT SEGMENT +PUBLIC _ripemd160_block_x86 + +_ripemd160_block_x86 PROC NEAR + push esi + mov ecx, DWORD PTR 16[esp] + push edi + mov esi, DWORD PTR 16[esp] + push ebp + add ecx, esi + push ebx + sub ecx, 64 + sub esp, 88 + mov DWORD PTR [esp],ecx + mov edi, DWORD PTR 108[esp] +L000start: + ; + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR 4[esp],eax + mov DWORD PTR 8[esp],ebx + mov eax, DWORD PTR 8[esi] + mov ebx, DWORD PTR 12[esi] + mov DWORD PTR 12[esp],eax + mov DWORD PTR 16[esp],ebx + mov eax, DWORD PTR 16[esi] + mov ebx, DWORD PTR 20[esi] + mov DWORD PTR 20[esp],eax + mov DWORD PTR 24[esp],ebx + mov eax, DWORD PTR 24[esi] + mov ebx, DWORD PTR 28[esi] + mov DWORD PTR 28[esp],eax + mov DWORD PTR 32[esp],ebx + mov eax, DWORD PTR 32[esi] + mov ebx, DWORD PTR 36[esi] + mov DWORD PTR 36[esp],eax + mov DWORD PTR 40[esp],ebx + mov eax, DWORD PTR 40[esi] + mov ebx, DWORD PTR 44[esi] + mov DWORD PTR 44[esp],eax + mov DWORD PTR 48[esp],ebx + mov eax, DWORD PTR 48[esi] + mov ebx, DWORD PTR 52[esi] + mov DWORD PTR 52[esp],eax + mov DWORD PTR 56[esp],ebx + mov eax, DWORD PTR 56[esi] + mov ebx, DWORD PTR 60[esi] + mov DWORD PTR 60[esp],eax + mov DWORD PTR 64[esp],ebx + add esi, 64 + mov eax, DWORD PTR [edi] + mov DWORD PTR 112[esp],esi + mov ebx, DWORD PTR 4[edi] + mov ecx, DWORD PTR 8[edi] + mov edx, DWORD PTR 12[edi] + mov ebp, DWORD PTR 16[edi] + ; 0 + mov esi, ecx + xor esi, edx + mov edi, DWORD PTR 4[esp] + xor esi, ebx + add eax, edi + rol ecx, 10 + add eax, esi + mov esi, ebx + rol eax, 11 + add eax, ebp + ; 1 + xor esi, ecx + mov edi, DWORD PTR 8[esp] + xor esi, eax + add ebp, esi + mov esi, eax + rol ebx, 10 + add ebp, edi + xor esi, ebx + rol ebp, 14 + add ebp, edx + ; 2 + mov edi, DWORD PTR 12[esp] + xor esi, ebp + add edx, edi + rol eax, 10 + add edx, esi + mov esi, ebp + rol edx, 15 + add edx, ecx + ; 3 + xor esi, eax + mov edi, DWORD PTR 16[esp] + xor esi, edx + add ecx, esi + mov esi, edx + rol ebp, 10 + add ecx, edi + xor esi, ebp + rol ecx, 12 + add ecx, ebx + ; 4 + mov edi, DWORD PTR 20[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 5 + add ebx, eax + ; 5 + xor esi, edx + mov edi, DWORD PTR 24[esp] + xor esi, ebx + add eax, esi + mov esi, ebx + rol ecx, 10 + add eax, edi + xor esi, ecx + rol eax, 8 + add eax, ebp + ; 6 + mov edi, DWORD PTR 28[esp] + xor esi, eax + add ebp, edi + rol ebx, 10 + add ebp, esi + mov esi, eax + rol ebp, 7 + add ebp, edx + ; 7 + xor esi, ebx + mov edi, DWORD PTR 32[esp] + xor esi, ebp + add edx, esi + mov esi, ebp + rol eax, 10 + add edx, edi + xor esi, eax + rol edx, 9 + add edx, ecx + ; 8 + mov edi, DWORD PTR 36[esp] + xor esi, edx + add ecx, edi + rol ebp, 10 + add ecx, esi + mov esi, edx + rol ecx, 11 + add ecx, ebx + ; 9 + xor esi, ebp + mov edi, DWORD PTR 40[esp] + xor esi, ecx + add ebx, esi + mov esi, ecx + rol edx, 10 + add ebx, edi + xor esi, edx + rol ebx, 13 + add ebx, eax + ; 10 + mov edi, DWORD PTR 44[esp] + xor esi, ebx + add eax, edi + rol ecx, 10 + add eax, esi + mov esi, ebx + rol eax, 14 + add eax, ebp + ; 11 + xor esi, ecx + mov edi, DWORD PTR 48[esp] + xor esi, eax + add ebp, esi + mov esi, eax + rol ebx, 10 + add ebp, edi + xor esi, ebx + rol ebp, 15 + add ebp, edx + ; 12 + mov edi, DWORD PTR 52[esp] + xor esi, ebp + add edx, edi + rol eax, 10 + add edx, esi + mov esi, ebp + rol edx, 6 + add edx, ecx + ; 13 + xor esi, eax + mov edi, DWORD PTR 56[esp] + xor esi, edx + add ecx, esi + mov esi, edx + rol ebp, 10 + add ecx, edi + xor esi, ebp + rol ecx, 7 + add ecx, ebx + ; 14 + mov edi, DWORD PTR 60[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 9 + add ebx, eax + ; 15 + xor esi, edx + mov edi, DWORD PTR 64[esp] + xor esi, ebx + add eax, esi + mov esi, -1 + rol ecx, 10 + add eax, edi + mov edi, DWORD PTR 32[esp] + rol eax, 8 + add eax, ebp + ; 16 + add ebp, edi + mov edi, ebx + sub esi, eax + and edi, eax + and esi, ecx + or edi, esi + mov esi, DWORD PTR 20[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, -1 + rol ebp, 7 + add ebp, edx + ; 17 + add edx, esi + mov esi, eax + sub edi, ebp + and esi, ebp + and edi, ebx + or esi, edi + mov edi, DWORD PTR 56[esp] + rol eax, 10 + lea edx, DWORD PTR 1518500249[esi*1+edx] + mov esi, -1 + rol edx, 6 + add edx, ecx + ; 18 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1518500249[edi*1+ecx] + mov edi, -1 + rol ecx, 8 + add ecx, ebx + ; 19 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 44[esp] + rol edx, 10 + lea ebx, DWORD PTR 1518500249[esi*1+ebx] + mov esi, -1 + rol ebx, 13 + add ebx, eax + ; 20 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 28[esp] + rol ecx, 10 + lea eax, DWORD PTR 1518500249[edi*1+eax] + mov edi, -1 + rol eax, 11 + add eax, ebp + ; 21 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, DWORD PTR 64[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + mov esi, -1 + rol ebp, 9 + add ebp, edx + ; 22 + add edx, edi + mov edi, eax + sub esi, ebp + and edi, ebp + and esi, ebx + or edi, esi + mov esi, DWORD PTR 16[esp] + rol eax, 10 + lea edx, DWORD PTR 1518500249[edi*1+edx] + mov edi, -1 + rol edx, 7 + add edx, ecx + ; 23 + add ecx, esi + mov esi, ebp + sub edi, edx + and esi, edx + and edi, eax + or esi, edi + mov edi, DWORD PTR 52[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1518500249[esi*1+ecx] + mov esi, -1 + rol ecx, 15 + add ecx, ebx + ; 24 + add ebx, edi + mov edi, edx + sub esi, ecx + and edi, ecx + and esi, ebp + or edi, esi + mov esi, DWORD PTR 4[esp] + rol edx, 10 + lea ebx, DWORD PTR 1518500249[edi*1+ebx] + mov edi, -1 + rol ebx, 7 + add ebx, eax + ; 25 + add eax, esi + mov esi, ecx + sub edi, ebx + and esi, ebx + and edi, edx + or esi, edi + mov edi, DWORD PTR 40[esp] + rol ecx, 10 + lea eax, DWORD PTR 1518500249[esi*1+eax] + mov esi, -1 + rol eax, 12 + add eax, ebp + ; 26 + add ebp, edi + mov edi, ebx + sub esi, eax + and edi, eax + and esi, ecx + or edi, esi + mov esi, DWORD PTR 24[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, -1 + rol ebp, 15 + add ebp, edx + ; 27 + add edx, esi + mov esi, eax + sub edi, ebp + and esi, ebp + and edi, ebx + or esi, edi + mov edi, DWORD PTR 12[esp] + rol eax, 10 + lea edx, DWORD PTR 1518500249[esi*1+edx] + mov esi, -1 + rol edx, 9 + add edx, ecx + ; 28 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 60[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1518500249[edi*1+ecx] + mov edi, -1 + rol ecx, 11 + add ecx, ebx + ; 29 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 48[esp] + rol edx, 10 + lea ebx, DWORD PTR 1518500249[esi*1+ebx] + mov esi, -1 + rol ebx, 7 + add ebx, eax + ; 30 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 36[esp] + rol ecx, 10 + lea eax, DWORD PTR 1518500249[edi*1+eax] + mov edi, -1 + rol eax, 13 + add eax, ebp + ; 31 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + sub edi, eax + rol ebp, 12 + add ebp, edx + ; 32 + mov esi, DWORD PTR 16[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[edi*1+edx] + sub esi, ebp + rol edx, 11 + add edx, ecx + ; 33 + mov edi, DWORD PTR 44[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1859775393[esi*1+ecx] + sub edi, edx + rol ecx, 13 + add ecx, ebx + ; 34 + mov esi, DWORD PTR 60[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1859775393[edi*1+ebx] + sub esi, ecx + rol ebx, 6 + add ebx, eax + ; 35 + mov edi, DWORD PTR 20[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1859775393[esi*1+eax] + sub edi, ebx + rol eax, 7 + add eax, ebp + ; 36 + mov esi, DWORD PTR 40[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1859775393[edi*1+ebp] + sub esi, eax + rol ebp, 14 + add ebp, edx + ; 37 + mov edi, DWORD PTR 64[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[esi*1+edx] + sub edi, ebp + rol edx, 9 + add edx, ecx + ; 38 + mov esi, DWORD PTR 36[esp] + or edi, edx + add ecx, esi + xor edi, eax + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1859775393[edi*1+ecx] + sub esi, edx + rol ecx, 13 + add ecx, ebx + ; 39 + mov edi, DWORD PTR 8[esp] + or esi, ecx + add ebx, edi + xor esi, ebp + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1859775393[esi*1+ebx] + sub edi, ecx + rol ebx, 15 + add ebx, eax + ; 40 + mov esi, DWORD PTR 12[esp] + or edi, ebx + add eax, esi + xor edi, edx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1859775393[edi*1+eax] + sub esi, ebx + rol eax, 14 + add eax, ebp + ; 41 + mov edi, DWORD PTR 32[esp] + or esi, eax + add ebp, edi + xor esi, ecx + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1859775393[esi*1+ebp] + sub edi, eax + rol ebp, 8 + add ebp, edx + ; 42 + mov esi, DWORD PTR 4[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[edi*1+edx] + sub esi, ebp + rol edx, 13 + add edx, ecx + ; 43 + mov edi, DWORD PTR 28[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1859775393[esi*1+ecx] + sub edi, edx + rol ecx, 6 + add ecx, ebx + ; 44 + mov esi, DWORD PTR 56[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1859775393[edi*1+ebx] + sub esi, ecx + rol ebx, 5 + add ebx, eax + ; 45 + mov edi, DWORD PTR 48[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1859775393[esi*1+eax] + sub edi, ebx + rol eax, 12 + add eax, ebp + ; 46 + mov esi, DWORD PTR 24[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1859775393[edi*1+ebp] + sub esi, eax + rol ebp, 7 + add ebp, edx + ; 47 + mov edi, DWORD PTR 52[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1859775393[esi*1+edx] + mov esi, eax + rol edx, 5 + add edx, ecx + ; 48 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 11 + add ecx, ebx + ; 49 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 40[esp] + rol edx, 10 + lea ebx, DWORD PTR 2400959708[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 12 + add ebx, eax + ; 50 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 48[esp] + rol ecx, 10 + lea eax, DWORD PTR 2400959708[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 14 + add eax, ebp + ; 51 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 44[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2400959708[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 15 + add ebp, edx + ; 52 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 4[esp] + rol eax, 10 + lea edx, DWORD PTR 2400959708[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 14 + add edx, ecx + ; 53 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 36[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 15 + add ecx, ebx + ; 54 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 52[esp] + rol edx, 10 + lea ebx, DWORD PTR 2400959708[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 9 + add ebx, eax + ; 55 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 20[esp] + rol ecx, 10 + lea eax, DWORD PTR 2400959708[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 8 + add eax, ebp + ; 56 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 56[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2400959708[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 9 + add ebp, edx + ; 57 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 16[esp] + rol eax, 10 + lea edx, DWORD PTR 2400959708[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 14 + add edx, ecx + ; 58 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 32[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 5 + add ecx, ebx + ; 59 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 64[esp] + rol edx, 10 + lea ebx, DWORD PTR 2400959708[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 6 + add ebx, eax + ; 60 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 60[esp] + rol ecx, 10 + lea eax, DWORD PTR 2400959708[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 8 + add eax, ebp + ; 61 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 24[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2400959708[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 6 + add ebp, edx + ; 62 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 28[esp] + rol eax, 10 + lea edx, DWORD PTR 2400959708[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 5 + add edx, ecx + ; 63 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 12[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2400959708[edi+ecx] + mov edi, -1 + add ecx, esi + sub edi, ebp + rol ecx, 12 + add ecx, ebx + ; 64 + mov esi, DWORD PTR 20[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 2840853838[edi*1+ebx] + sub esi, edx + rol ebx, 9 + add ebx, eax + ; 65 + mov edi, DWORD PTR 4[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 2840853838[esi*1+eax] + sub edi, ecx + rol eax, 15 + add eax, ebp + ; 66 + mov esi, DWORD PTR 24[esp] + or edi, ebx + add ebp, esi + xor edi, eax + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 2840853838[edi*1+ebp] + sub esi, ebx + rol ebp, 5 + add ebp, edx + ; 67 + mov edi, DWORD PTR 40[esp] + or esi, eax + add edx, edi + xor esi, ebp + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 2840853838[esi*1+edx] + sub edi, eax + rol edx, 11 + add edx, ecx + ; 68 + mov esi, DWORD PTR 32[esp] + or edi, ebp + add ecx, esi + xor edi, edx + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 2840853838[edi*1+ecx] + sub esi, ebp + rol ecx, 6 + add ecx, ebx + ; 69 + mov edi, DWORD PTR 52[esp] + or esi, edx + add ebx, edi + xor esi, ecx + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 2840853838[esi*1+ebx] + sub edi, edx + rol ebx, 8 + add ebx, eax + ; 70 + mov esi, DWORD PTR 12[esp] + or edi, ecx + add eax, esi + xor edi, ebx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 2840853838[edi*1+eax] + sub esi, ecx + rol eax, 13 + add eax, ebp + ; 71 + mov edi, DWORD PTR 44[esp] + or esi, ebx + add ebp, edi + xor esi, eax + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 2840853838[esi*1+ebp] + sub edi, ebx + rol ebp, 12 + add ebp, edx + ; 72 + mov esi, DWORD PTR 60[esp] + or edi, eax + add edx, esi + xor edi, ebp + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 2840853838[edi*1+edx] + sub esi, eax + rol edx, 5 + add edx, ecx + ; 73 + mov edi, DWORD PTR 8[esp] + or esi, ebp + add ecx, edi + xor esi, edx + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 2840853838[esi*1+ecx] + sub edi, ebp + rol ecx, 12 + add ecx, ebx + ; 74 + mov esi, DWORD PTR 16[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 2840853838[edi*1+ebx] + sub esi, edx + rol ebx, 13 + add ebx, eax + ; 75 + mov edi, DWORD PTR 36[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 2840853838[esi*1+eax] + sub edi, ecx + rol eax, 14 + add eax, ebp + ; 76 + mov esi, DWORD PTR 48[esp] + or edi, ebx + add ebp, esi + xor edi, eax + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 2840853838[edi*1+ebp] + sub esi, ebx + rol ebp, 11 + add ebp, edx + ; 77 + mov edi, DWORD PTR 28[esp] + or esi, eax + add edx, edi + xor esi, ebp + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 2840853838[esi*1+edx] + sub edi, eax + rol edx, 8 + add edx, ecx + ; 78 + mov esi, DWORD PTR 64[esp] + or edi, ebp + add ecx, esi + xor edi, edx + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 2840853838[edi*1+ecx] + sub esi, ebp + rol ecx, 5 + add ecx, ebx + ; 79 + mov edi, DWORD PTR 56[esp] + or esi, edx + add ebx, edi + xor esi, ecx + mov edi, DWORD PTR 108[esp] + rol edx, 10 + lea ebx, DWORD PTR 2840853838[esi*1+ebx] + mov DWORD PTR 68[esp],eax + rol ebx, 6 + add ebx, eax + mov eax, DWORD PTR [edi] + mov DWORD PTR 72[esp],ebx + mov DWORD PTR 76[esp],ecx + mov ebx, DWORD PTR 4[edi] + mov DWORD PTR 80[esp],edx + mov ecx, DWORD PTR 8[edi] + mov DWORD PTR 84[esp],ebp + mov edx, DWORD PTR 12[edi] + mov ebp, DWORD PTR 16[edi] + ; 80 + mov edi, -1 + sub edi, edx + mov esi, DWORD PTR 24[esp] + or edi, ecx + add eax, esi + xor edi, ebx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[edi*1+eax] + sub esi, ecx + rol eax, 8 + add eax, ebp + ; 81 + mov edi, DWORD PTR 60[esp] + or esi, ebx + add ebp, edi + xor esi, eax + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1352829926[esi*1+ebp] + sub edi, ebx + rol ebp, 9 + add ebp, edx + ; 82 + mov esi, DWORD PTR 32[esp] + or edi, eax + add edx, esi + xor edi, ebp + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1352829926[edi*1+edx] + sub esi, eax + rol edx, 9 + add edx, ecx + ; 83 + mov edi, DWORD PTR 4[esp] + or esi, ebp + add ecx, edi + xor esi, edx + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1352829926[esi*1+ecx] + sub edi, ebp + rol ecx, 11 + add ecx, ebx + ; 84 + mov esi, DWORD PTR 40[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1352829926[edi*1+ebx] + sub esi, edx + rol ebx, 13 + add ebx, eax + ; 85 + mov edi, DWORD PTR 12[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[esi*1+eax] + sub edi, ecx + rol eax, 15 + add eax, ebp + ; 86 + mov esi, DWORD PTR 48[esp] + or edi, ebx + add ebp, esi + xor edi, eax + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1352829926[edi*1+ebp] + sub esi, ebx + rol ebp, 15 + add ebp, edx + ; 87 + mov edi, DWORD PTR 20[esp] + or esi, eax + add edx, edi + xor esi, ebp + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1352829926[esi*1+edx] + sub edi, eax + rol edx, 5 + add edx, ecx + ; 88 + mov esi, DWORD PTR 56[esp] + or edi, ebp + add ecx, esi + xor edi, edx + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1352829926[edi*1+ecx] + sub esi, ebp + rol ecx, 7 + add ecx, ebx + ; 89 + mov edi, DWORD PTR 28[esp] + or esi, edx + add ebx, edi + xor esi, ecx + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1352829926[esi*1+ebx] + sub edi, edx + rol ebx, 7 + add ebx, eax + ; 90 + mov esi, DWORD PTR 64[esp] + or edi, ecx + add eax, esi + xor edi, ebx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[edi*1+eax] + sub esi, ecx + rol eax, 8 + add eax, ebp + ; 91 + mov edi, DWORD PTR 36[esp] + or esi, ebx + add ebp, edi + xor esi, eax + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1352829926[esi*1+ebp] + sub edi, ebx + rol ebp, 11 + add ebp, edx + ; 92 + mov esi, DWORD PTR 8[esp] + or edi, eax + add edx, esi + xor edi, ebp + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1352829926[edi*1+edx] + sub esi, eax + rol edx, 14 + add edx, ecx + ; 93 + mov edi, DWORD PTR 44[esp] + or esi, ebp + add ecx, edi + xor esi, edx + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1352829926[esi*1+ecx] + sub edi, ebp + rol ecx, 14 + add ecx, ebx + ; 94 + mov esi, DWORD PTR 16[esp] + or edi, edx + add ebx, esi + xor edi, ecx + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1352829926[edi*1+ebx] + sub esi, edx + rol ebx, 12 + add ebx, eax + ; 95 + mov edi, DWORD PTR 52[esp] + or esi, ecx + add eax, edi + xor esi, ebx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1352829926[esi*1+eax] + mov esi, ecx + rol eax, 6 + add eax, ebp + ; 96 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 28[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 9 + add ebp, edx + ; 97 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 48[esp] + rol eax, 10 + lea edx, DWORD PTR 1548603684[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 13 + add edx, ecx + ; 98 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 16[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1548603684[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 15 + add ecx, ebx + ; 99 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 32[esp] + rol edx, 10 + lea ebx, DWORD PTR 1548603684[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 7 + add ebx, eax + ; 100 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 4[esp] + rol ecx, 10 + lea eax, DWORD PTR 1548603684[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 12 + add eax, ebp + ; 101 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 56[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 8 + add ebp, edx + ; 102 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 24[esp] + rol eax, 10 + lea edx, DWORD PTR 1548603684[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 9 + add edx, ecx + ; 103 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 44[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1548603684[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 11 + add ecx, ebx + ; 104 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 60[esp] + rol edx, 10 + lea ebx, DWORD PTR 1548603684[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 7 + add ebx, eax + ; 105 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 64[esp] + rol ecx, 10 + lea eax, DWORD PTR 1548603684[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 7 + add eax, ebp + ; 106 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 36[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + mov esi, ebx + rol ebp, 12 + add ebp, edx + ; 107 + sub edi, ebx + and esi, ebp + and edi, eax + or edi, esi + mov esi, DWORD PTR 52[esp] + rol eax, 10 + lea edx, DWORD PTR 1548603684[edi+edx] + mov edi, -1 + add edx, esi + mov esi, eax + rol edx, 7 + add edx, ecx + ; 108 + sub edi, eax + and esi, edx + and edi, ebp + or edi, esi + mov esi, DWORD PTR 20[esp] + rol ebp, 10 + lea ecx, DWORD PTR 1548603684[edi+ecx] + mov edi, -1 + add ecx, esi + mov esi, ebp + rol ecx, 6 + add ecx, ebx + ; 109 + sub edi, ebp + and esi, ecx + and edi, edx + or edi, esi + mov esi, DWORD PTR 40[esp] + rol edx, 10 + lea ebx, DWORD PTR 1548603684[edi+ebx] + mov edi, -1 + add ebx, esi + mov esi, edx + rol ebx, 15 + add ebx, eax + ; 110 + sub edi, edx + and esi, ebx + and edi, ecx + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ecx, 10 + lea eax, DWORD PTR 1548603684[edi+eax] + mov edi, -1 + add eax, esi + mov esi, ecx + rol eax, 13 + add eax, ebp + ; 111 + sub edi, ecx + and esi, eax + and edi, ebx + or edi, esi + mov esi, DWORD PTR 12[esp] + rol ebx, 10 + lea ebp, DWORD PTR 1548603684[edi+ebp] + mov edi, -1 + add ebp, esi + sub edi, eax + rol ebp, 11 + add ebp, edx + ; 112 + mov esi, DWORD PTR 64[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1836072691[edi*1+edx] + sub esi, ebp + rol edx, 9 + add edx, ecx + ; 113 + mov edi, DWORD PTR 24[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1836072691[esi*1+ecx] + sub edi, edx + rol ecx, 7 + add ecx, ebx + ; 114 + mov esi, DWORD PTR 8[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1836072691[edi*1+ebx] + sub esi, ecx + rol ebx, 15 + add ebx, eax + ; 115 + mov edi, DWORD PTR 16[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1836072691[esi*1+eax] + sub edi, ebx + rol eax, 11 + add eax, ebp + ; 116 + mov esi, DWORD PTR 32[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1836072691[edi*1+ebp] + sub esi, eax + rol ebp, 8 + add ebp, edx + ; 117 + mov edi, DWORD PTR 60[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, -1 + rol eax, 10 + lea edx, DWORD PTR 1836072691[esi*1+edx] + sub edi, ebp + rol edx, 6 + add edx, ecx + ; 118 + mov esi, DWORD PTR 28[esp] + or edi, edx + add ecx, esi + xor edi, eax + mov esi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1836072691[edi*1+ecx] + sub esi, edx + rol ecx, 6 + add ecx, ebx + ; 119 + mov edi, DWORD PTR 40[esp] + or esi, ecx + add ebx, edi + xor esi, ebp + mov edi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1836072691[esi*1+ebx] + sub edi, ecx + rol ebx, 14 + add ebx, eax + ; 120 + mov esi, DWORD PTR 48[esp] + or edi, ebx + add eax, esi + xor edi, edx + mov esi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1836072691[edi*1+eax] + sub esi, ebx + rol eax, 12 + add eax, ebp + ; 121 + mov edi, DWORD PTR 36[esp] + or esi, eax + add ebp, edi + xor esi, ecx + mov edi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1836072691[esi*1+ebp] + sub edi, eax + rol ebp, 13 + add ebp, edx + ; 122 + mov esi, DWORD PTR 52[esp] + or edi, ebp + add edx, esi + xor edi, ebx + mov esi, -1 + rol eax, 10 + lea edx, DWORD PTR 1836072691[edi*1+edx] + sub esi, ebp + rol edx, 5 + add edx, ecx + ; 123 + mov edi, DWORD PTR 12[esp] + or esi, edx + add ecx, edi + xor esi, eax + mov edi, -1 + rol ebp, 10 + lea ecx, DWORD PTR 1836072691[esi*1+ecx] + sub edi, edx + rol ecx, 14 + add ecx, ebx + ; 124 + mov esi, DWORD PTR 44[esp] + or edi, ecx + add ebx, esi + xor edi, ebp + mov esi, -1 + rol edx, 10 + lea ebx, DWORD PTR 1836072691[edi*1+ebx] + sub esi, ecx + rol ebx, 13 + add ebx, eax + ; 125 + mov edi, DWORD PTR 4[esp] + or esi, ebx + add eax, edi + xor esi, edx + mov edi, -1 + rol ecx, 10 + lea eax, DWORD PTR 1836072691[esi*1+eax] + sub edi, ebx + rol eax, 13 + add eax, ebp + ; 126 + mov esi, DWORD PTR 20[esp] + or edi, eax + add ebp, esi + xor edi, ecx + mov esi, -1 + rol ebx, 10 + lea ebp, DWORD PTR 1836072691[edi*1+ebp] + sub esi, eax + rol ebp, 7 + add ebp, edx + ; 127 + mov edi, DWORD PTR 56[esp] + or esi, ebp + add edx, edi + xor esi, ebx + mov edi, DWORD PTR 36[esp] + rol eax, 10 + lea edx, DWORD PTR 1836072691[esi*1+edx] + mov esi, -1 + rol edx, 5 + add edx, ecx + ; 128 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 28[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[edi*1+ecx] + mov edi, -1 + rol ecx, 15 + add ecx, ebx + ; 129 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 20[esp] + rol edx, 10 + lea ebx, DWORD PTR 2053994217[esi*1+ebx] + mov esi, -1 + rol ebx, 5 + add ebx, eax + ; 130 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 8[esp] + rol ecx, 10 + lea eax, DWORD PTR 2053994217[edi*1+eax] + mov edi, -1 + rol eax, 8 + add eax, ebp + ; 131 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, DWORD PTR 16[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2053994217[esi*1+ebp] + mov esi, -1 + rol ebp, 11 + add ebp, edx + ; 132 + add edx, edi + mov edi, eax + sub esi, ebp + and edi, ebp + and esi, ebx + or edi, esi + mov esi, DWORD PTR 48[esp] + rol eax, 10 + lea edx, DWORD PTR 2053994217[edi*1+edx] + mov edi, -1 + rol edx, 14 + add edx, ecx + ; 133 + add ecx, esi + mov esi, ebp + sub edi, edx + and esi, edx + and edi, eax + or esi, edi + mov edi, DWORD PTR 64[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[esi*1+ecx] + mov esi, -1 + rol ecx, 14 + add ecx, ebx + ; 134 + add ebx, edi + mov edi, edx + sub esi, ecx + and edi, ecx + and esi, ebp + or edi, esi + mov esi, DWORD PTR 4[esp] + rol edx, 10 + lea ebx, DWORD PTR 2053994217[edi*1+ebx] + mov edi, -1 + rol ebx, 6 + add ebx, eax + ; 135 + add eax, esi + mov esi, ecx + sub edi, ebx + and esi, ebx + and edi, edx + or esi, edi + mov edi, DWORD PTR 24[esp] + rol ecx, 10 + lea eax, DWORD PTR 2053994217[esi*1+eax] + mov esi, -1 + rol eax, 14 + add eax, ebp + ; 136 + add ebp, edi + mov edi, ebx + sub esi, eax + and edi, eax + and esi, ecx + or edi, esi + mov esi, DWORD PTR 52[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2053994217[edi*1+ebp] + mov edi, -1 + rol ebp, 6 + add ebp, edx + ; 137 + add edx, esi + mov esi, eax + sub edi, ebp + and esi, ebp + and edi, ebx + or esi, edi + mov edi, DWORD PTR 12[esp] + rol eax, 10 + lea edx, DWORD PTR 2053994217[esi*1+edx] + mov esi, -1 + rol edx, 9 + add edx, ecx + ; 138 + add ecx, edi + mov edi, ebp + sub esi, edx + and edi, edx + and esi, eax + or edi, esi + mov esi, DWORD PTR 56[esp] + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[edi*1+ecx] + mov edi, -1 + rol ecx, 12 + add ecx, ebx + ; 139 + add ebx, esi + mov esi, edx + sub edi, ecx + and esi, ecx + and edi, ebp + or esi, edi + mov edi, DWORD PTR 40[esp] + rol edx, 10 + lea ebx, DWORD PTR 2053994217[esi*1+ebx] + mov esi, -1 + rol ebx, 9 + add ebx, eax + ; 140 + add eax, edi + mov edi, ecx + sub esi, ebx + and edi, ebx + and esi, edx + or edi, esi + mov esi, DWORD PTR 32[esp] + rol ecx, 10 + lea eax, DWORD PTR 2053994217[edi*1+eax] + mov edi, -1 + rol eax, 12 + add eax, ebp + ; 141 + add ebp, esi + mov esi, ebx + sub edi, eax + and esi, eax + and edi, ecx + or esi, edi + mov edi, DWORD PTR 44[esp] + rol ebx, 10 + lea ebp, DWORD PTR 2053994217[esi*1+ebp] + mov esi, -1 + rol ebp, 5 + add ebp, edx + ; 142 + add edx, edi + mov edi, eax + sub esi, ebp + and edi, ebp + and esi, ebx + or edi, esi + mov esi, DWORD PTR 60[esp] + rol eax, 10 + lea edx, DWORD PTR 2053994217[edi*1+edx] + mov edi, -1 + rol edx, 15 + add edx, ecx + ; 143 + add ecx, esi + mov esi, ebp + sub edi, edx + and esi, edx + and edi, eax + or edi, esi + mov esi, edx + rol ebp, 10 + lea ecx, DWORD PTR 2053994217[edi*1+ecx] + xor esi, ebp + rol ecx, 8 + add ecx, ebx + ; 144 + mov edi, DWORD PTR 52[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 8 + add ebx, eax + ; 145 + xor esi, edx + mov edi, DWORD PTR 64[esp] + xor esi, ebx + add eax, esi + mov esi, ebx + rol ecx, 10 + add eax, edi + xor esi, ecx + rol eax, 5 + add eax, ebp + ; 146 + mov edi, DWORD PTR 44[esp] + xor esi, eax + add ebp, edi + rol ebx, 10 + add ebp, esi + mov esi, eax + rol ebp, 12 + add ebp, edx + ; 147 + xor esi, ebx + mov edi, DWORD PTR 20[esp] + xor esi, ebp + add edx, esi + mov esi, ebp + rol eax, 10 + add edx, edi + xor esi, eax + rol edx, 9 + add edx, ecx + ; 148 + mov edi, DWORD PTR 8[esp] + xor esi, edx + add ecx, edi + rol ebp, 10 + add ecx, esi + mov esi, edx + rol ecx, 12 + add ecx, ebx + ; 149 + xor esi, ebp + mov edi, DWORD PTR 24[esp] + xor esi, ecx + add ebx, esi + mov esi, ecx + rol edx, 10 + add ebx, edi + xor esi, edx + rol ebx, 5 + add ebx, eax + ; 150 + mov edi, DWORD PTR 36[esp] + xor esi, ebx + add eax, edi + rol ecx, 10 + add eax, esi + mov esi, ebx + rol eax, 14 + add eax, ebp + ; 151 + xor esi, ecx + mov edi, DWORD PTR 32[esp] + xor esi, eax + add ebp, esi + mov esi, eax + rol ebx, 10 + add ebp, edi + xor esi, ebx + rol ebp, 6 + add ebp, edx + ; 152 + mov edi, DWORD PTR 28[esp] + xor esi, ebp + add edx, edi + rol eax, 10 + add edx, esi + mov esi, ebp + rol edx, 8 + add edx, ecx + ; 153 + xor esi, eax + mov edi, DWORD PTR 12[esp] + xor esi, edx + add ecx, esi + mov esi, edx + rol ebp, 10 + add ecx, edi + xor esi, ebp + rol ecx, 13 + add ecx, ebx + ; 154 + mov edi, DWORD PTR 56[esp] + xor esi, ecx + add ebx, edi + rol edx, 10 + add ebx, esi + mov esi, ecx + rol ebx, 6 + add ebx, eax + ; 155 + xor esi, edx + mov edi, DWORD PTR 60[esp] + xor esi, ebx + add eax, esi + mov esi, ebx + rol ecx, 10 + add eax, edi + xor esi, ecx + rol eax, 5 + add eax, ebp + ; 156 + mov edi, DWORD PTR 4[esp] + xor esi, eax + add ebp, edi + rol ebx, 10 + add ebp, esi + mov esi, eax + rol ebp, 15 + add ebp, edx + ; 157 + xor esi, ebx + mov edi, DWORD PTR 16[esp] + xor esi, ebp + add edx, esi + mov esi, ebp + rol eax, 10 + add edx, edi + xor esi, eax + rol edx, 13 + add edx, ecx + ; 158 + mov edi, DWORD PTR 40[esp] + xor esi, edx + add ecx, edi + rol ebp, 10 + add ecx, esi + mov esi, edx + rol ecx, 11 + add ecx, ebx + ; 159 + xor esi, ebp + mov edi, DWORD PTR 48[esp] + xor esi, ecx + add ebx, esi + rol edx, 10 + add ebx, edi + mov edi, DWORD PTR 108[esp] + rol ebx, 11 + add ebx, eax + mov esi, DWORD PTR 4[edi] + add edx, esi + mov esi, DWORD PTR 76[esp] + add edx, esi + mov esi, DWORD PTR 8[edi] + add ebp, esi + mov esi, DWORD PTR 80[esp] + add ebp, esi + mov esi, DWORD PTR 12[edi] + add eax, esi + mov esi, DWORD PTR 84[esp] + add eax, esi + mov esi, DWORD PTR 16[edi] + add ebx, esi + mov esi, DWORD PTR 68[esp] + add ebx, esi + mov esi, DWORD PTR [edi] + add ecx, esi + mov esi, DWORD PTR 72[esp] + add ecx, esi + mov DWORD PTR [edi],edx + mov DWORD PTR 4[edi],ebp + mov DWORD PTR 8[edi],eax + mov DWORD PTR 12[edi],ebx + mov DWORD PTR 16[edi],ecx + mov edi, DWORD PTR [esp] + mov esi, DWORD PTR 112[esp] + cmp edi, esi + mov edi, DWORD PTR 108[esp] + jge L000start + add esp, 88 + pop ebx + pop ebp + pop edi + pop esi + ret +_ripemd160_block_x86 ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp b/src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp new file mode 100644 index 0000000000..f90f6f2fd6 --- /dev/null +++ b/src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp @@ -0,0 +1,2016 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define ripemd160_block_x86 _ripemd160_block_x86 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by rmd-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "rmd-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl ripemd160_block_x86 + TYPE(ripemd160_block_x86,@function) +ripemd160_block_x86: + pushl %esi + movl 16(%esp), %ecx + pushl %edi + movl 16(%esp), %esi + pushl %ebp + addl %esi, %ecx + pushl %ebx + subl $64, %ecx + subl $88, %esp + movl %ecx, (%esp) + movl 108(%esp), %edi +.L000start: + + movl (%esi), %eax + movl 4(%esi), %ebx + movl %eax, 4(%esp) + movl %ebx, 8(%esp) + movl 8(%esi), %eax + movl 12(%esi), %ebx + movl %eax, 12(%esp) + movl %ebx, 16(%esp) + movl 16(%esi), %eax + movl 20(%esi), %ebx + movl %eax, 20(%esp) + movl %ebx, 24(%esp) + movl 24(%esi), %eax + movl 28(%esi), %ebx + movl %eax, 28(%esp) + movl %ebx, 32(%esp) + movl 32(%esi), %eax + movl 36(%esi), %ebx + movl %eax, 36(%esp) + movl %ebx, 40(%esp) + movl 40(%esi), %eax + movl 44(%esi), %ebx + movl %eax, 44(%esp) + movl %ebx, 48(%esp) + movl 48(%esi), %eax + movl 52(%esi), %ebx + movl %eax, 52(%esp) + movl %ebx, 56(%esp) + movl 56(%esi), %eax + movl 60(%esi), %ebx + movl %eax, 60(%esp) + movl %ebx, 64(%esp) + addl $64, %esi + movl (%edi), %eax + movl %esi, 112(%esp) + movl 4(%edi), %ebx + movl 8(%edi), %ecx + movl 12(%edi), %edx + movl 16(%edi), %ebp + /* 0 */ + movl %ecx, %esi + xorl %edx, %esi + movl 4(%esp), %edi + xorl %ebx, %esi + addl %edi, %eax + roll $10, %ecx + addl %esi, %eax + movl %ebx, %esi + roll $11, %eax + addl %ebp, %eax + /* 1 */ + xorl %ecx, %esi + movl 8(%esp), %edi + xorl %eax, %esi + addl %esi, %ebp + movl %eax, %esi + roll $10, %ebx + addl %edi, %ebp + xorl %ebx, %esi + roll $14, %ebp + addl %edx, %ebp + /* 2 */ + movl 12(%esp), %edi + xorl %ebp, %esi + addl %edi, %edx + roll $10, %eax + addl %esi, %edx + movl %ebp, %esi + roll $15, %edx + addl %ecx, %edx + /* 3 */ + xorl %eax, %esi + movl 16(%esp), %edi + xorl %edx, %esi + addl %esi, %ecx + movl %edx, %esi + roll $10, %ebp + addl %edi, %ecx + xorl %ebp, %esi + roll $12, %ecx + addl %ebx, %ecx + /* 4 */ + movl 20(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $5, %ebx + addl %eax, %ebx + /* 5 */ + xorl %edx, %esi + movl 24(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl %ebx, %esi + roll $10, %ecx + addl %edi, %eax + xorl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 6 */ + movl 28(%esp), %edi + xorl %eax, %esi + addl %edi, %ebp + roll $10, %ebx + addl %esi, %ebp + movl %eax, %esi + roll $7, %ebp + addl %edx, %ebp + /* 7 */ + xorl %ebx, %esi + movl 32(%esp), %edi + xorl %ebp, %esi + addl %esi, %edx + movl %ebp, %esi + roll $10, %eax + addl %edi, %edx + xorl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 8 */ + movl 36(%esp), %edi + xorl %edx, %esi + addl %edi, %ecx + roll $10, %ebp + addl %esi, %ecx + movl %edx, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 9 */ + xorl %ebp, %esi + movl 40(%esp), %edi + xorl %ecx, %esi + addl %esi, %ebx + movl %ecx, %esi + roll $10, %edx + addl %edi, %ebx + xorl %edx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 10 */ + movl 44(%esp), %edi + xorl %ebx, %esi + addl %edi, %eax + roll $10, %ecx + addl %esi, %eax + movl %ebx, %esi + roll $14, %eax + addl %ebp, %eax + /* 11 */ + xorl %ecx, %esi + movl 48(%esp), %edi + xorl %eax, %esi + addl %esi, %ebp + movl %eax, %esi + roll $10, %ebx + addl %edi, %ebp + xorl %ebx, %esi + roll $15, %ebp + addl %edx, %ebp + /* 12 */ + movl 52(%esp), %edi + xorl %ebp, %esi + addl %edi, %edx + roll $10, %eax + addl %esi, %edx + movl %ebp, %esi + roll $6, %edx + addl %ecx, %edx + /* 13 */ + xorl %eax, %esi + movl 56(%esp), %edi + xorl %edx, %esi + addl %esi, %ecx + movl %edx, %esi + roll $10, %ebp + addl %edi, %ecx + xorl %ebp, %esi + roll $7, %ecx + addl %ebx, %ecx + /* 14 */ + movl 60(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $9, %ebx + addl %eax, %ebx + /* 15 */ + xorl %edx, %esi + movl 64(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl $-1, %esi + roll $10, %ecx + addl %edi, %eax + movl 32(%esp), %edi + roll $8, %eax + addl %ebp, %eax + /* 16 */ + addl %edi, %ebp + movl %ebx, %edi + subl %eax, %esi + andl %eax, %edi + andl %ecx, %esi + orl %esi, %edi + movl 20(%esp), %esi + roll $10, %ebx + leal 1518500249(%ebp,%edi,1),%ebp + movl $-1, %edi + roll $7, %ebp + addl %edx, %ebp + /* 17 */ + addl %esi, %edx + movl %eax, %esi + subl %ebp, %edi + andl %ebp, %esi + andl %ebx, %edi + orl %edi, %esi + movl 56(%esp), %edi + roll $10, %eax + leal 1518500249(%edx,%esi,1),%edx + movl $-1, %esi + roll $6, %edx + addl %ecx, %edx + /* 18 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ebp + leal 1518500249(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $8, %ecx + addl %ebx, %ecx + /* 19 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 44(%esp), %edi + roll $10, %edx + leal 1518500249(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $13, %ebx + addl %eax, %ebx + /* 20 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %ecx + leal 1518500249(%eax,%edi,1),%eax + movl $-1, %edi + roll $11, %eax + addl %ebp, %eax + /* 21 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl 64(%esp), %edi + roll $10, %ebx + leal 1518500249(%ebp,%esi,1),%ebp + movl $-1, %esi + roll $9, %ebp + addl %edx, %ebp + /* 22 */ + addl %edi, %edx + movl %eax, %edi + subl %ebp, %esi + andl %ebp, %edi + andl %ebx, %esi + orl %esi, %edi + movl 16(%esp), %esi + roll $10, %eax + leal 1518500249(%edx,%edi,1),%edx + movl $-1, %edi + roll $7, %edx + addl %ecx, %edx + /* 23 */ + addl %esi, %ecx + movl %ebp, %esi + subl %edx, %edi + andl %edx, %esi + andl %eax, %edi + orl %edi, %esi + movl 52(%esp), %edi + roll $10, %ebp + leal 1518500249(%ecx,%esi,1),%ecx + movl $-1, %esi + roll $15, %ecx + addl %ebx, %ecx + /* 24 */ + addl %edi, %ebx + movl %edx, %edi + subl %ecx, %esi + andl %ecx, %edi + andl %ebp, %esi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %edx + leal 1518500249(%ebx,%edi,1),%ebx + movl $-1, %edi + roll $7, %ebx + addl %eax, %ebx + /* 25 */ + addl %esi, %eax + movl %ecx, %esi + subl %ebx, %edi + andl %ebx, %esi + andl %edx, %edi + orl %edi, %esi + movl 40(%esp), %edi + roll $10, %ecx + leal 1518500249(%eax,%esi,1),%eax + movl $-1, %esi + roll $12, %eax + addl %ebp, %eax + /* 26 */ + addl %edi, %ebp + movl %ebx, %edi + subl %eax, %esi + andl %eax, %edi + andl %ecx, %esi + orl %esi, %edi + movl 24(%esp), %esi + roll $10, %ebx + leal 1518500249(%ebp,%edi,1),%ebp + movl $-1, %edi + roll $15, %ebp + addl %edx, %ebp + /* 27 */ + addl %esi, %edx + movl %eax, %esi + subl %ebp, %edi + andl %ebp, %esi + andl %ebx, %edi + orl %edi, %esi + movl 12(%esp), %edi + roll $10, %eax + leal 1518500249(%edx,%esi,1),%edx + movl $-1, %esi + roll $9, %edx + addl %ecx, %edx + /* 28 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %ebp + leal 1518500249(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $11, %ecx + addl %ebx, %ecx + /* 29 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 48(%esp), %edi + roll $10, %edx + leal 1518500249(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $7, %ebx + addl %eax, %ebx + /* 30 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 36(%esp), %esi + roll $10, %ecx + leal 1518500249(%eax,%edi,1),%eax + movl $-1, %edi + roll $13, %eax + addl %ebp, %eax + /* 31 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl $-1, %edi + roll $10, %ebx + leal 1518500249(%ebp,%esi,1),%ebp + subl %eax, %edi + roll $12, %ebp + addl %edx, %ebp + /* 32 */ + movl 16(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1859775393(%edx,%edi,1),%edx + subl %ebp, %esi + roll $11, %edx + addl %ecx, %edx + /* 33 */ + movl 44(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1859775393(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $13, %ecx + addl %ebx, %ecx + /* 34 */ + movl 60(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1859775393(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $6, %ebx + addl %eax, %ebx + /* 35 */ + movl 20(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1859775393(%eax,%esi,1),%eax + subl %ebx, %edi + roll $7, %eax + addl %ebp, %eax + /* 36 */ + movl 40(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1859775393(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $14, %ebp + addl %edx, %ebp + /* 37 */ + movl 64(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl $-1, %edi + roll $10, %eax + leal 1859775393(%edx,%esi,1),%edx + subl %ebp, %edi + roll $9, %edx + addl %ecx, %edx + /* 38 */ + movl 36(%esp), %esi + orl %edx, %edi + addl %esi, %ecx + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebp + leal 1859775393(%ecx,%edi,1),%ecx + subl %edx, %esi + roll $13, %ecx + addl %ebx, %ecx + /* 39 */ + movl 8(%esp), %edi + orl %ecx, %esi + addl %edi, %ebx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %edx + leal 1859775393(%ebx,%esi,1),%ebx + subl %ecx, %edi + roll $15, %ebx + addl %eax, %ebx + /* 40 */ + movl 12(%esp), %esi + orl %ebx, %edi + addl %esi, %eax + xorl %edx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1859775393(%eax,%edi,1),%eax + subl %ebx, %esi + roll $14, %eax + addl %ebp, %eax + /* 41 */ + movl 32(%esp), %edi + orl %eax, %esi + addl %edi, %ebp + xorl %ecx, %esi + movl $-1, %edi + roll $10, %ebx + leal 1859775393(%ebp,%esi,1),%ebp + subl %eax, %edi + roll $8, %ebp + addl %edx, %ebp + /* 42 */ + movl 4(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1859775393(%edx,%edi,1),%edx + subl %ebp, %esi + roll $13, %edx + addl %ecx, %edx + /* 43 */ + movl 28(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1859775393(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $6, %ecx + addl %ebx, %ecx + /* 44 */ + movl 56(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1859775393(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $5, %ebx + addl %eax, %ebx + /* 45 */ + movl 48(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1859775393(%eax,%esi,1),%eax + subl %ebx, %edi + roll $12, %eax + addl %ebp, %eax + /* 46 */ + movl 24(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1859775393(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $7, %ebp + addl %edx, %ebp + /* 47 */ + movl 52(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl $-1, %edi + roll $10, %eax + leal 1859775393(%edx,%esi,1),%edx + movl %eax, %esi + roll $5, %edx + addl %ecx, %edx + /* 48 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 49 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 40(%esp), %esi + roll $10, %edx + leal 2400959708(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $12, %ebx + addl %eax, %ebx + /* 50 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 48(%esp), %esi + roll $10, %ecx + leal 2400959708(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $14, %eax + addl %ebp, %eax + /* 51 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 44(%esp), %esi + roll $10, %ebx + leal 2400959708(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $15, %ebp + addl %edx, %ebp + /* 52 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %eax + leal 2400959708(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $14, %edx + addl %ecx, %edx + /* 53 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 36(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $15, %ecx + addl %ebx, %ecx + /* 54 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 52(%esp), %esi + roll $10, %edx + leal 2400959708(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $9, %ebx + addl %eax, %ebx + /* 55 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 20(%esp), %esi + roll $10, %ecx + leal 2400959708(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 56 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 56(%esp), %esi + roll $10, %ebx + leal 2400959708(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $9, %ebp + addl %edx, %ebp + /* 57 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 16(%esp), %esi + roll $10, %eax + leal 2400959708(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $14, %edx + addl %ecx, %edx + /* 58 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 32(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $5, %ecx + addl %ebx, %ecx + /* 59 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 64(%esp), %esi + roll $10, %edx + leal 2400959708(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $6, %ebx + addl %eax, %ebx + /* 60 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %ecx + leal 2400959708(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 61 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 24(%esp), %esi + roll $10, %ebx + leal 2400959708(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $6, %ebp + addl %edx, %ebp + /* 62 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %eax + leal 2400959708(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $5, %edx + addl %ecx, %edx + /* 63 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 12(%esp), %esi + roll $10, %ebp + leal 2400959708(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + subl %ebp, %edi + roll $12, %ecx + addl %ebx, %ecx + /* 64 */ + movl 20(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 2840853838(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $9, %ebx + addl %eax, %ebx + /* 65 */ + movl 4(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 2840853838(%eax,%esi,1),%eax + subl %ecx, %edi + roll $15, %eax + addl %ebp, %eax + /* 66 */ + movl 24(%esp), %esi + orl %ebx, %edi + addl %esi, %ebp + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebx + leal 2840853838(%ebp,%edi,1),%ebp + subl %ebx, %esi + roll $5, %ebp + addl %edx, %ebp + /* 67 */ + movl 40(%esp), %edi + orl %eax, %esi + addl %edi, %edx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %eax + leal 2840853838(%edx,%esi,1),%edx + subl %eax, %edi + roll $11, %edx + addl %ecx, %edx + /* 68 */ + movl 32(%esp), %esi + orl %ebp, %edi + addl %esi, %ecx + xorl %edx, %edi + movl $-1, %esi + roll $10, %ebp + leal 2840853838(%ecx,%edi,1),%ecx + subl %ebp, %esi + roll $6, %ecx + addl %ebx, %ecx + /* 69 */ + movl 52(%esp), %edi + orl %edx, %esi + addl %edi, %ebx + xorl %ecx, %esi + movl $-1, %edi + roll $10, %edx + leal 2840853838(%ebx,%esi,1),%ebx + subl %edx, %edi + roll $8, %ebx + addl %eax, %ebx + /* 70 */ + movl 12(%esp), %esi + orl %ecx, %edi + addl %esi, %eax + xorl %ebx, %edi + movl $-1, %esi + roll $10, %ecx + leal 2840853838(%eax,%edi,1),%eax + subl %ecx, %esi + roll $13, %eax + addl %ebp, %eax + /* 71 */ + movl 44(%esp), %edi + orl %ebx, %esi + addl %edi, %ebp + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebx + leal 2840853838(%ebp,%esi,1),%ebp + subl %ebx, %edi + roll $12, %ebp + addl %edx, %ebp + /* 72 */ + movl 60(%esp), %esi + orl %eax, %edi + addl %esi, %edx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %eax + leal 2840853838(%edx,%edi,1),%edx + subl %eax, %esi + roll $5, %edx + addl %ecx, %edx + /* 73 */ + movl 8(%esp), %edi + orl %ebp, %esi + addl %edi, %ecx + xorl %edx, %esi + movl $-1, %edi + roll $10, %ebp + leal 2840853838(%ecx,%esi,1),%ecx + subl %ebp, %edi + roll $12, %ecx + addl %ebx, %ecx + /* 74 */ + movl 16(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 2840853838(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 75 */ + movl 36(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 2840853838(%eax,%esi,1),%eax + subl %ecx, %edi + roll $14, %eax + addl %ebp, %eax + /* 76 */ + movl 48(%esp), %esi + orl %ebx, %edi + addl %esi, %ebp + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebx + leal 2840853838(%ebp,%edi,1),%ebp + subl %ebx, %esi + roll $11, %ebp + addl %edx, %ebp + /* 77 */ + movl 28(%esp), %edi + orl %eax, %esi + addl %edi, %edx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %eax + leal 2840853838(%edx,%esi,1),%edx + subl %eax, %edi + roll $8, %edx + addl %ecx, %edx + /* 78 */ + movl 64(%esp), %esi + orl %ebp, %edi + addl %esi, %ecx + xorl %edx, %edi + movl $-1, %esi + roll $10, %ebp + leal 2840853838(%ecx,%edi,1),%ecx + subl %ebp, %esi + roll $5, %ecx + addl %ebx, %ecx + /* 79 */ + movl 56(%esp), %edi + orl %edx, %esi + addl %edi, %ebx + xorl %ecx, %esi + movl 108(%esp), %edi + roll $10, %edx + leal 2840853838(%ebx,%esi,1),%ebx + movl %eax, 68(%esp) + roll $6, %ebx + addl %eax, %ebx + movl (%edi), %eax + movl %ebx, 72(%esp) + movl %ecx, 76(%esp) + movl 4(%edi), %ebx + movl %edx, 80(%esp) + movl 8(%edi), %ecx + movl %ebp, 84(%esp) + movl 12(%edi), %edx + movl 16(%edi), %ebp + /* 80 */ + movl $-1, %edi + subl %edx, %edi + movl 24(%esp), %esi + orl %ecx, %edi + addl %esi, %eax + xorl %ebx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1352829926(%eax,%edi,1),%eax + subl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 81 */ + movl 60(%esp), %edi + orl %ebx, %esi + addl %edi, %ebp + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebx + leal 1352829926(%ebp,%esi,1),%ebp + subl %ebx, %edi + roll $9, %ebp + addl %edx, %ebp + /* 82 */ + movl 32(%esp), %esi + orl %eax, %edi + addl %esi, %edx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %eax + leal 1352829926(%edx,%edi,1),%edx + subl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 83 */ + movl 4(%esp), %edi + orl %ebp, %esi + addl %edi, %ecx + xorl %edx, %esi + movl $-1, %edi + roll $10, %ebp + leal 1352829926(%ecx,%esi,1),%ecx + subl %ebp, %edi + roll $11, %ecx + addl %ebx, %ecx + /* 84 */ + movl 40(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 1352829926(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 85 */ + movl 12(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1352829926(%eax,%esi,1),%eax + subl %ecx, %edi + roll $15, %eax + addl %ebp, %eax + /* 86 */ + movl 48(%esp), %esi + orl %ebx, %edi + addl %esi, %ebp + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebx + leal 1352829926(%ebp,%edi,1),%ebp + subl %ebx, %esi + roll $15, %ebp + addl %edx, %ebp + /* 87 */ + movl 20(%esp), %edi + orl %eax, %esi + addl %edi, %edx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %eax + leal 1352829926(%edx,%esi,1),%edx + subl %eax, %edi + roll $5, %edx + addl %ecx, %edx + /* 88 */ + movl 56(%esp), %esi + orl %ebp, %edi + addl %esi, %ecx + xorl %edx, %edi + movl $-1, %esi + roll $10, %ebp + leal 1352829926(%ecx,%edi,1),%ecx + subl %ebp, %esi + roll $7, %ecx + addl %ebx, %ecx + /* 89 */ + movl 28(%esp), %edi + orl %edx, %esi + addl %edi, %ebx + xorl %ecx, %esi + movl $-1, %edi + roll $10, %edx + leal 1352829926(%ebx,%esi,1),%ebx + subl %edx, %edi + roll $7, %ebx + addl %eax, %ebx + /* 90 */ + movl 64(%esp), %esi + orl %ecx, %edi + addl %esi, %eax + xorl %ebx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1352829926(%eax,%edi,1),%eax + subl %ecx, %esi + roll $8, %eax + addl %ebp, %eax + /* 91 */ + movl 36(%esp), %edi + orl %ebx, %esi + addl %edi, %ebp + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebx + leal 1352829926(%ebp,%esi,1),%ebp + subl %ebx, %edi + roll $11, %ebp + addl %edx, %ebp + /* 92 */ + movl 8(%esp), %esi + orl %eax, %edi + addl %esi, %edx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %eax + leal 1352829926(%edx,%edi,1),%edx + subl %eax, %esi + roll $14, %edx + addl %ecx, %edx + /* 93 */ + movl 44(%esp), %edi + orl %ebp, %esi + addl %edi, %ecx + xorl %edx, %esi + movl $-1, %edi + roll $10, %ebp + leal 1352829926(%ecx,%esi,1),%ecx + subl %ebp, %edi + roll $14, %ecx + addl %ebx, %ecx + /* 94 */ + movl 16(%esp), %esi + orl %edx, %edi + addl %esi, %ebx + xorl %ecx, %edi + movl $-1, %esi + roll $10, %edx + leal 1352829926(%ebx,%edi,1),%ebx + subl %edx, %esi + roll $12, %ebx + addl %eax, %ebx + /* 95 */ + movl 52(%esp), %edi + orl %ecx, %esi + addl %edi, %eax + xorl %ebx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1352829926(%eax,%esi,1),%eax + movl %ecx, %esi + roll $6, %eax + addl %ebp, %eax + /* 96 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $9, %ebp + addl %edx, %ebp + /* 97 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 48(%esp), %esi + roll $10, %eax + leal 1548603684(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $13, %edx + addl %ecx, %edx + /* 98 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 16(%esp), %esi + roll $10, %ebp + leal 1548603684(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $15, %ecx + addl %ebx, %ecx + /* 99 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 32(%esp), %esi + roll $10, %edx + leal 1548603684(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $7, %ebx + addl %eax, %ebx + /* 100 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %ecx + leal 1548603684(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $12, %eax + addl %ebp, %eax + /* 101 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 56(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $8, %ebp + addl %edx, %ebp + /* 102 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 24(%esp), %esi + roll $10, %eax + leal 1548603684(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 103 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 44(%esp), %esi + roll $10, %ebp + leal 1548603684(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 104 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %edx + leal 1548603684(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $7, %ebx + addl %eax, %ebx + /* 105 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 64(%esp), %esi + roll $10, %ecx + leal 1548603684(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $7, %eax + addl %ebp, %eax + /* 106 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 36(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + movl %ebx, %esi + roll $12, %ebp + addl %edx, %ebp + /* 107 */ + subl %ebx, %edi + andl %ebp, %esi + andl %eax, %edi + orl %esi, %edi + movl 52(%esp), %esi + roll $10, %eax + leal 1548603684(%edx,%edi,),%edx + movl $-1, %edi + addl %esi, %edx + movl %eax, %esi + roll $7, %edx + addl %ecx, %edx + /* 108 */ + subl %eax, %edi + andl %edx, %esi + andl %ebp, %edi + orl %esi, %edi + movl 20(%esp), %esi + roll $10, %ebp + leal 1548603684(%ecx,%edi,),%ecx + movl $-1, %edi + addl %esi, %ecx + movl %ebp, %esi + roll $6, %ecx + addl %ebx, %ecx + /* 109 */ + subl %ebp, %edi + andl %ecx, %esi + andl %edx, %edi + orl %esi, %edi + movl 40(%esp), %esi + roll $10, %edx + leal 1548603684(%ebx,%edi,),%ebx + movl $-1, %edi + addl %esi, %ebx + movl %edx, %esi + roll $15, %ebx + addl %eax, %ebx + /* 110 */ + subl %edx, %edi + andl %ebx, %esi + andl %ecx, %edi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ecx + leal 1548603684(%eax,%edi,),%eax + movl $-1, %edi + addl %esi, %eax + movl %ecx, %esi + roll $13, %eax + addl %ebp, %eax + /* 111 */ + subl %ecx, %edi + andl %eax, %esi + andl %ebx, %edi + orl %esi, %edi + movl 12(%esp), %esi + roll $10, %ebx + leal 1548603684(%ebp,%edi,),%ebp + movl $-1, %edi + addl %esi, %ebp + subl %eax, %edi + roll $11, %ebp + addl %edx, %ebp + /* 112 */ + movl 64(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1836072691(%edx,%edi,1),%edx + subl %ebp, %esi + roll $9, %edx + addl %ecx, %edx + /* 113 */ + movl 24(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1836072691(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $7, %ecx + addl %ebx, %ecx + /* 114 */ + movl 8(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1836072691(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $15, %ebx + addl %eax, %ebx + /* 115 */ + movl 16(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1836072691(%eax,%esi,1),%eax + subl %ebx, %edi + roll $11, %eax + addl %ebp, %eax + /* 116 */ + movl 32(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1836072691(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $8, %ebp + addl %edx, %ebp + /* 117 */ + movl 60(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl $-1, %edi + roll $10, %eax + leal 1836072691(%edx,%esi,1),%edx + subl %ebp, %edi + roll $6, %edx + addl %ecx, %edx + /* 118 */ + movl 28(%esp), %esi + orl %edx, %edi + addl %esi, %ecx + xorl %eax, %edi + movl $-1, %esi + roll $10, %ebp + leal 1836072691(%ecx,%edi,1),%ecx + subl %edx, %esi + roll $6, %ecx + addl %ebx, %ecx + /* 119 */ + movl 40(%esp), %edi + orl %ecx, %esi + addl %edi, %ebx + xorl %ebp, %esi + movl $-1, %edi + roll $10, %edx + leal 1836072691(%ebx,%esi,1),%ebx + subl %ecx, %edi + roll $14, %ebx + addl %eax, %ebx + /* 120 */ + movl 48(%esp), %esi + orl %ebx, %edi + addl %esi, %eax + xorl %edx, %edi + movl $-1, %esi + roll $10, %ecx + leal 1836072691(%eax,%edi,1),%eax + subl %ebx, %esi + roll $12, %eax + addl %ebp, %eax + /* 121 */ + movl 36(%esp), %edi + orl %eax, %esi + addl %edi, %ebp + xorl %ecx, %esi + movl $-1, %edi + roll $10, %ebx + leal 1836072691(%ebp,%esi,1),%ebp + subl %eax, %edi + roll $13, %ebp + addl %edx, %ebp + /* 122 */ + movl 52(%esp), %esi + orl %ebp, %edi + addl %esi, %edx + xorl %ebx, %edi + movl $-1, %esi + roll $10, %eax + leal 1836072691(%edx,%edi,1),%edx + subl %ebp, %esi + roll $5, %edx + addl %ecx, %edx + /* 123 */ + movl 12(%esp), %edi + orl %edx, %esi + addl %edi, %ecx + xorl %eax, %esi + movl $-1, %edi + roll $10, %ebp + leal 1836072691(%ecx,%esi,1),%ecx + subl %edx, %edi + roll $14, %ecx + addl %ebx, %ecx + /* 124 */ + movl 44(%esp), %esi + orl %ecx, %edi + addl %esi, %ebx + xorl %ebp, %edi + movl $-1, %esi + roll $10, %edx + leal 1836072691(%ebx,%edi,1),%ebx + subl %ecx, %esi + roll $13, %ebx + addl %eax, %ebx + /* 125 */ + movl 4(%esp), %edi + orl %ebx, %esi + addl %edi, %eax + xorl %edx, %esi + movl $-1, %edi + roll $10, %ecx + leal 1836072691(%eax,%esi,1),%eax + subl %ebx, %edi + roll $13, %eax + addl %ebp, %eax + /* 126 */ + movl 20(%esp), %esi + orl %eax, %edi + addl %esi, %ebp + xorl %ecx, %edi + movl $-1, %esi + roll $10, %ebx + leal 1836072691(%ebp,%edi,1),%ebp + subl %eax, %esi + roll $7, %ebp + addl %edx, %ebp + /* 127 */ + movl 56(%esp), %edi + orl %ebp, %esi + addl %edi, %edx + xorl %ebx, %esi + movl 36(%esp), %edi + roll $10, %eax + leal 1836072691(%edx,%esi,1),%edx + movl $-1, %esi + roll $5, %edx + addl %ecx, %edx + /* 128 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 28(%esp), %esi + roll $10, %ebp + leal 2053994217(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $15, %ecx + addl %ebx, %ecx + /* 129 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 20(%esp), %edi + roll $10, %edx + leal 2053994217(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $5, %ebx + addl %eax, %ebx + /* 130 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 8(%esp), %esi + roll $10, %ecx + leal 2053994217(%eax,%edi,1),%eax + movl $-1, %edi + roll $8, %eax + addl %ebp, %eax + /* 131 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl 16(%esp), %edi + roll $10, %ebx + leal 2053994217(%ebp,%esi,1),%ebp + movl $-1, %esi + roll $11, %ebp + addl %edx, %ebp + /* 132 */ + addl %edi, %edx + movl %eax, %edi + subl %ebp, %esi + andl %ebp, %edi + andl %ebx, %esi + orl %esi, %edi + movl 48(%esp), %esi + roll $10, %eax + leal 2053994217(%edx,%edi,1),%edx + movl $-1, %edi + roll $14, %edx + addl %ecx, %edx + /* 133 */ + addl %esi, %ecx + movl %ebp, %esi + subl %edx, %edi + andl %edx, %esi + andl %eax, %edi + orl %edi, %esi + movl 64(%esp), %edi + roll $10, %ebp + leal 2053994217(%ecx,%esi,1),%ecx + movl $-1, %esi + roll $14, %ecx + addl %ebx, %ecx + /* 134 */ + addl %edi, %ebx + movl %edx, %edi + subl %ecx, %esi + andl %ecx, %edi + andl %ebp, %esi + orl %esi, %edi + movl 4(%esp), %esi + roll $10, %edx + leal 2053994217(%ebx,%edi,1),%ebx + movl $-1, %edi + roll $6, %ebx + addl %eax, %ebx + /* 135 */ + addl %esi, %eax + movl %ecx, %esi + subl %ebx, %edi + andl %ebx, %esi + andl %edx, %edi + orl %edi, %esi + movl 24(%esp), %edi + roll $10, %ecx + leal 2053994217(%eax,%esi,1),%eax + movl $-1, %esi + roll $14, %eax + addl %ebp, %eax + /* 136 */ + addl %edi, %ebp + movl %ebx, %edi + subl %eax, %esi + andl %eax, %edi + andl %ecx, %esi + orl %esi, %edi + movl 52(%esp), %esi + roll $10, %ebx + leal 2053994217(%ebp,%edi,1),%ebp + movl $-1, %edi + roll $6, %ebp + addl %edx, %ebp + /* 137 */ + addl %esi, %edx + movl %eax, %esi + subl %ebp, %edi + andl %ebp, %esi + andl %ebx, %edi + orl %edi, %esi + movl 12(%esp), %edi + roll $10, %eax + leal 2053994217(%edx,%esi,1),%edx + movl $-1, %esi + roll $9, %edx + addl %ecx, %edx + /* 138 */ + addl %edi, %ecx + movl %ebp, %edi + subl %edx, %esi + andl %edx, %edi + andl %eax, %esi + orl %esi, %edi + movl 56(%esp), %esi + roll $10, %ebp + leal 2053994217(%ecx,%edi,1),%ecx + movl $-1, %edi + roll $12, %ecx + addl %ebx, %ecx + /* 139 */ + addl %esi, %ebx + movl %edx, %esi + subl %ecx, %edi + andl %ecx, %esi + andl %ebp, %edi + orl %edi, %esi + movl 40(%esp), %edi + roll $10, %edx + leal 2053994217(%ebx,%esi,1),%ebx + movl $-1, %esi + roll $9, %ebx + addl %eax, %ebx + /* 140 */ + addl %edi, %eax + movl %ecx, %edi + subl %ebx, %esi + andl %ebx, %edi + andl %edx, %esi + orl %esi, %edi + movl 32(%esp), %esi + roll $10, %ecx + leal 2053994217(%eax,%edi,1),%eax + movl $-1, %edi + roll $12, %eax + addl %ebp, %eax + /* 141 */ + addl %esi, %ebp + movl %ebx, %esi + subl %eax, %edi + andl %eax, %esi + andl %ecx, %edi + orl %edi, %esi + movl 44(%esp), %edi + roll $10, %ebx + leal 2053994217(%ebp,%esi,1),%ebp + movl $-1, %esi + roll $5, %ebp + addl %edx, %ebp + /* 142 */ + addl %edi, %edx + movl %eax, %edi + subl %ebp, %esi + andl %ebp, %edi + andl %ebx, %esi + orl %esi, %edi + movl 60(%esp), %esi + roll $10, %eax + leal 2053994217(%edx,%edi,1),%edx + movl $-1, %edi + roll $15, %edx + addl %ecx, %edx + /* 143 */ + addl %esi, %ecx + movl %ebp, %esi + subl %edx, %edi + andl %edx, %esi + andl %eax, %edi + orl %esi, %edi + movl %edx, %esi + roll $10, %ebp + leal 2053994217(%ecx,%edi,1),%ecx + xorl %ebp, %esi + roll $8, %ecx + addl %ebx, %ecx + /* 144 */ + movl 52(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $8, %ebx + addl %eax, %ebx + /* 145 */ + xorl %edx, %esi + movl 64(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl %ebx, %esi + roll $10, %ecx + addl %edi, %eax + xorl %ecx, %esi + roll $5, %eax + addl %ebp, %eax + /* 146 */ + movl 44(%esp), %edi + xorl %eax, %esi + addl %edi, %ebp + roll $10, %ebx + addl %esi, %ebp + movl %eax, %esi + roll $12, %ebp + addl %edx, %ebp + /* 147 */ + xorl %ebx, %esi + movl 20(%esp), %edi + xorl %ebp, %esi + addl %esi, %edx + movl %ebp, %esi + roll $10, %eax + addl %edi, %edx + xorl %eax, %esi + roll $9, %edx + addl %ecx, %edx + /* 148 */ + movl 8(%esp), %edi + xorl %edx, %esi + addl %edi, %ecx + roll $10, %ebp + addl %esi, %ecx + movl %edx, %esi + roll $12, %ecx + addl %ebx, %ecx + /* 149 */ + xorl %ebp, %esi + movl 24(%esp), %edi + xorl %ecx, %esi + addl %esi, %ebx + movl %ecx, %esi + roll $10, %edx + addl %edi, %ebx + xorl %edx, %esi + roll $5, %ebx + addl %eax, %ebx + /* 150 */ + movl 36(%esp), %edi + xorl %ebx, %esi + addl %edi, %eax + roll $10, %ecx + addl %esi, %eax + movl %ebx, %esi + roll $14, %eax + addl %ebp, %eax + /* 151 */ + xorl %ecx, %esi + movl 32(%esp), %edi + xorl %eax, %esi + addl %esi, %ebp + movl %eax, %esi + roll $10, %ebx + addl %edi, %ebp + xorl %ebx, %esi + roll $6, %ebp + addl %edx, %ebp + /* 152 */ + movl 28(%esp), %edi + xorl %ebp, %esi + addl %edi, %edx + roll $10, %eax + addl %esi, %edx + movl %ebp, %esi + roll $8, %edx + addl %ecx, %edx + /* 153 */ + xorl %eax, %esi + movl 12(%esp), %edi + xorl %edx, %esi + addl %esi, %ecx + movl %edx, %esi + roll $10, %ebp + addl %edi, %ecx + xorl %ebp, %esi + roll $13, %ecx + addl %ebx, %ecx + /* 154 */ + movl 56(%esp), %edi + xorl %ecx, %esi + addl %edi, %ebx + roll $10, %edx + addl %esi, %ebx + movl %ecx, %esi + roll $6, %ebx + addl %eax, %ebx + /* 155 */ + xorl %edx, %esi + movl 60(%esp), %edi + xorl %ebx, %esi + addl %esi, %eax + movl %ebx, %esi + roll $10, %ecx + addl %edi, %eax + xorl %ecx, %esi + roll $5, %eax + addl %ebp, %eax + /* 156 */ + movl 4(%esp), %edi + xorl %eax, %esi + addl %edi, %ebp + roll $10, %ebx + addl %esi, %ebp + movl %eax, %esi + roll $15, %ebp + addl %edx, %ebp + /* 157 */ + xorl %ebx, %esi + movl 16(%esp), %edi + xorl %ebp, %esi + addl %esi, %edx + movl %ebp, %esi + roll $10, %eax + addl %edi, %edx + xorl %eax, %esi + roll $13, %edx + addl %ecx, %edx + /* 158 */ + movl 40(%esp), %edi + xorl %edx, %esi + addl %edi, %ecx + roll $10, %ebp + addl %esi, %ecx + movl %edx, %esi + roll $11, %ecx + addl %ebx, %ecx + /* 159 */ + xorl %ebp, %esi + movl 48(%esp), %edi + xorl %ecx, %esi + addl %esi, %ebx + roll $10, %edx + addl %edi, %ebx + movl 108(%esp), %edi + roll $11, %ebx + addl %eax, %ebx + movl 4(%edi), %esi + addl %esi, %edx + movl 76(%esp), %esi + addl %esi, %edx + movl 8(%edi), %esi + addl %esi, %ebp + movl 80(%esp), %esi + addl %esi, %ebp + movl 12(%edi), %esi + addl %esi, %eax + movl 84(%esp), %esi + addl %esi, %eax + movl 16(%edi), %esi + addl %esi, %ebx + movl 68(%esp), %esi + addl %esi, %ebx + movl (%edi), %esi + addl %esi, %ecx + movl 72(%esp), %esi + addl %esi, %ecx + movl %edx, (%edi) + movl %ebp, 4(%edi) + movl %eax, 8(%edi) + movl %ebx, 12(%edi) + movl %ecx, 16(%edi) + movl (%esp), %edi + movl 112(%esp), %esi + cmpl %esi, %edi + movl 108(%esp), %edi + jge .L000start + addl $88, %esp + popl %ebx + popl %ebp + popl %edi + popl %esi + ret +.ripemd160_block_x86_end: + SIZE(ripemd160_block_x86,.ripemd160_block_x86_end-ripemd160_block_x86) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/rsa/Makefile.ssl b/src/lib/libssl/src/crypto/rsa/Makefile.ssl new file mode 100644 index 0000000000..d52f2e609e --- /dev/null +++ b/src/lib/libssl/src/crypto/rsa/Makefile.ssl @@ -0,0 +1,86 @@ +# +# SSLeay/crypto/rsa/Makefile +# + +DIR= rsa +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=rsa +ERRC=rsa_err +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c $(ERRC).c \ + rsa_pk1.c rsa_ssl.c rsa_none.c +LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o $(ERRC).o \ + rsa_pk1.o rsa_ssl.o rsa_none.o + +SRC= $(LIBSRC) + +EXHEADER= rsa.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/rsa/rsa.err b/src/lib/libssl/src/crypto/rsa/rsa.err new file mode 100644 index 0000000000..5ded1b5fa2 --- /dev/null +++ b/src/lib/libssl/src/crypto/rsa/rsa.err @@ -0,0 +1,45 @@ +/* Error codes for the RSA functions. */ + +/* Function codes. */ +#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 100 +#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 101 +#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 102 +#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 103 +#define RSA_F_RSA_GENERATE_KEY 104 +#define RSA_F_RSA_NEW_METHOD 105 +#define RSA_F_RSA_PADDING_ADD_NONE 106 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 108 +#define RSA_F_RSA_PADDING_ADD_SSLV23 109 +#define RSA_F_RSA_PADDING_CHECK_NONE 110 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 112 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 113 +#define RSA_F_RSA_PRINT 114 +#define RSA_F_RSA_PRINT_FP 115 +#define RSA_F_RSA_SIGN 116 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 117 +#define RSA_F_RSA_VERIFY 118 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 119 + +/* Reason codes. */ +#define RSA_R_ALGORITHM_MISMATCH 100 +#define RSA_R_BAD_E_VALUE 101 +#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +#define RSA_R_BAD_PAD_BYTE_COUNT 103 +#define RSA_R_BAD_SIGNATURE 104 +#define RSA_R_BAD_ZERO_BYTE 105 +#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +#define RSA_R_DATA_TOO_LARGE 109 +#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +#define RSA_R_DATA_TOO_SMALL 111 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +#define RSA_R_UNKNOWN_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 diff --git a/src/lib/libssl/src/crypto/sha/Makefile.ssl b/src/lib/libssl/src/crypto/sha/Makefile.ssl new file mode 100644 index 0000000000..eeb545d140 --- /dev/null +++ b/src/lib/libssl/src/crypto/sha/Makefile.ssl @@ -0,0 +1,103 @@ +# +# SSLeay/crypto/sha/Makefile +# + +DIR= sha +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +SHA1_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST=shatest.c sha1test.c +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA1_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= sha.h +HEADER= sha_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +# elf +asm/sx86-elf.o: asm/sx86unix.cpp + $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o + +# solaris +asm/sx86-sol.o: asm/sx86unix.cpp + $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s + as -o asm/sx86-sol.o asm/sx86-sol.s + rm -f asm/sx86-sol.s + +# a.out +asm/sx86-out.o: asm/sx86unix.cpp + $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o + +# bsdi +asm/sx86bsdi.o: asm/sx86unix.cpp + $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o + +asm/sx86unix.cpp: + (cd asm; perl sha1-586.pl cpp >sx86unix.cpp) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/sha/Makefile.uni b/src/lib/libssl/src/crypto/sha/Makefile.uni new file mode 100644 index 0000000000..f3236755b2 --- /dev/null +++ b/src/lib/libssl/src/crypto/sha/Makefile.uni @@ -0,0 +1,122 @@ +# Targets +# make - twidle the options yourself :-) +# make cc - standard cc options +# make gcc - standard gcc options +# make x86-elf - linux-elf etc +# make x86-out - linux-a.out, FreeBSD etc +# make x86-solaris +# make x86-bdsi + +DIR= sha +TOP= . +CC= gcc +CFLAG= -O3 -fomit-frame-pointer + +CPP= $(CC) -E +INCLUDES= +INSTALLTOP=/usr/local/lib +MAKE= make +MAKEDEPEND= makedepend +MAKEFILE= Makefile.uni +AR= ar r + +SHA_ASM_OBJ= + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile + +TEST1=shatest +TEST2=sha1test +APP1=sha +APP2=sha1 + +TEST=$(TEST1) $(TEST2) +APPS=$(APP1) $(APP2) + +LIB=libsha.a +LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c +LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA_ASM_OBJ) + +SRC= $(LIBSRC) + +EXHEADER= sha.h +HEADER= sha_locl.h $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +all: $(LIB) $(TEST) $(APPS) + +$(LIB): $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/ranlib.sh $(LIB) + +# elf +asm/sx86-elf.o: asm/sx86unix.cpp + $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o + +# solaris +asm/sx86-sol.o: asm/sx86unix.cpp + $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s + as -o asm/sx86-sol.o asm/sx86-sol.s + rm -f asm/sx86-sol.s + +# a.out +asm/sx86-out.o: asm/sx86unix.cpp + $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o + +# bsdi +asm/sx86bsdi.o: asm/sx86unix.cpp + $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o + +asm/sx86unix.cpp: + (cd asm; perl sha1-586.pl cpp >sx86unix.cpp) + +test: $(TEST) + ./$(TEST1) + ./$(TEST2) + +$(TEST1): $(TEST1).c $(LIB) + $(CC) -o $(TEST1) $(CFLAGS) $(TEST1).c $(LIB) + +$(TEST2): $(TEST2).c $(LIB) + $(CC) -o $(TEST2) $(CFLAGS) $(TEST2).c $(LIB) + +$(APP1): $(APP1).c $(LIB) + $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB) + +$(APP2): $(APP2).c $(LIB) + $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +cc: + $(MAKE) SHA_ASM_OBJ="" CC="cc" CFLAG="-O" all + +gcc: + $(MAKE) SHA_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all + +x86-elf: + $(MAKE) SHA_ASM_OBJ="asm/sx86-elf.o" CFLAG="-DELF -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-out: + $(MAKE) SHA_ASM_OBJ="asm/sx86-out.o" CFLAG="-DOUT -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-solaris: + $(MAKE) SHA_ASM_OBJ="asm/sx86-sol.o" CFLAG="-DSOL -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +x86-bdsi: + $(MAKE) SHA_ASM_OBJ="asm/sx86-bdsi.o" CFLAG="-DBDSI -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm b/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm new file mode 100644 index 0000000000..61335666b9 --- /dev/null +++ b/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm @@ -0,0 +1,1664 @@ + ; Don't even think of reading this code + ; It was automatically generated by sha1-586.pl + ; Which is a perl program used to generate the x86 assember for + ; any of elf, a.out, BSDI,Win32, or Solaris + ; eric + ; + TITLE sha1-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _sha1_block_x86 + +_sha1_block_x86 PROC NEAR + push esi + push ebp + mov eax, DWORD PTR 20[esp] + mov esi, DWORD PTR 16[esp] + add eax, esi + mov ebp, DWORD PTR 12[esp] + push ebx + sub eax, 64 + push edi + mov ebx, DWORD PTR 4[ebp] + sub esp, 72 + mov edx, DWORD PTR 12[ebp] + mov edi, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 8[ebp] + mov DWORD PTR 68[esp],eax + ; First we need to setup the X array + mov eax, DWORD PTR [esi] +L000start: + ; First, load the words onto the stack in network byte order + bswap eax + mov DWORD PTR [esp],eax + mov eax, DWORD PTR 4[esi] + bswap eax + mov DWORD PTR 4[esp],eax + mov eax, DWORD PTR 8[esi] + bswap eax + mov DWORD PTR 8[esp],eax + mov eax, DWORD PTR 12[esi] + bswap eax + mov DWORD PTR 12[esp],eax + mov eax, DWORD PTR 16[esi] + bswap eax + mov DWORD PTR 16[esp],eax + mov eax, DWORD PTR 20[esi] + bswap eax + mov DWORD PTR 20[esp],eax + mov eax, DWORD PTR 24[esi] + bswap eax + mov DWORD PTR 24[esp],eax + mov eax, DWORD PTR 28[esi] + bswap eax + mov DWORD PTR 28[esp],eax + mov eax, DWORD PTR 32[esi] + bswap eax + mov DWORD PTR 32[esp],eax + mov eax, DWORD PTR 36[esi] + bswap eax + mov DWORD PTR 36[esp],eax + mov eax, DWORD PTR 40[esi] + bswap eax + mov DWORD PTR 40[esp],eax + mov eax, DWORD PTR 44[esi] + bswap eax + mov DWORD PTR 44[esp],eax + mov eax, DWORD PTR 48[esi] + bswap eax + mov DWORD PTR 48[esp],eax + mov eax, DWORD PTR 52[esi] + bswap eax + mov DWORD PTR 52[esp],eax + mov eax, DWORD PTR 56[esi] + bswap eax + mov DWORD PTR 56[esp],eax + mov eax, DWORD PTR 60[esi] + bswap eax + mov DWORD PTR 60[esp],eax + ; We now have the X array on the stack + ; starting at sp-4 + mov DWORD PTR 64[esp],esi + ; + ; Start processing + mov eax, DWORD PTR [ebp] + ; 00_15 0 + mov esi, ecx + mov ebp, eax + xor esi, edx + rol ebp, 5 + and esi, ebx + add ebp, edi + ror ebx, 1 + mov edi, DWORD PTR [esp] + ror ebx, 1 + xor esi, edx + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, ebx + add esi, ebp + xor edi, ecx + mov ebp, esi + and edi, eax + rol ebp, 5 + add ebp, edx + mov edx, DWORD PTR 4[esp] + ror eax, 1 + xor edi, ecx + ror eax, 1 + lea ebp, DWORD PTR 1518500249[edx*1+ebp] + add edi, ebp + ; 00_15 2 + mov edx, eax + mov ebp, edi + xor edx, ebx + rol ebp, 5 + and edx, esi + add ebp, ecx + ror esi, 1 + mov ecx, DWORD PTR 8[esp] + ror esi, 1 + xor edx, ebx + lea ebp, DWORD PTR 1518500249[ecx*1+ebp] + mov ecx, esi + add edx, ebp + xor ecx, eax + mov ebp, edx + and ecx, edi + rol ebp, 5 + add ebp, ebx + mov ebx, DWORD PTR 12[esp] + ror edi, 1 + xor ecx, eax + ror edi, 1 + lea ebp, DWORD PTR 1518500249[ebx*1+ebp] + add ecx, ebp + ; 00_15 4 + mov ebx, edi + mov ebp, ecx + xor ebx, esi + rol ebp, 5 + and ebx, edx + add ebp, eax + ror edx, 1 + mov eax, DWORD PTR 16[esp] + ror edx, 1 + xor ebx, esi + lea ebp, DWORD PTR 1518500249[eax*1+ebp] + mov eax, edx + add ebx, ebp + xor eax, edi + mov ebp, ebx + and eax, ecx + rol ebp, 5 + add ebp, esi + mov esi, DWORD PTR 20[esp] + ror ecx, 1 + xor eax, edi + ror ecx, 1 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + add eax, ebp + ; 00_15 6 + mov esi, ecx + mov ebp, eax + xor esi, edx + rol ebp, 5 + and esi, ebx + add ebp, edi + ror ebx, 1 + mov edi, DWORD PTR 24[esp] + ror ebx, 1 + xor esi, edx + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, ebx + add esi, ebp + xor edi, ecx + mov ebp, esi + and edi, eax + rol ebp, 5 + add ebp, edx + mov edx, DWORD PTR 28[esp] + ror eax, 1 + xor edi, ecx + ror eax, 1 + lea ebp, DWORD PTR 1518500249[edx*1+ebp] + add edi, ebp + ; 00_15 8 + mov edx, eax + mov ebp, edi + xor edx, ebx + rol ebp, 5 + and edx, esi + add ebp, ecx + ror esi, 1 + mov ecx, DWORD PTR 32[esp] + ror esi, 1 + xor edx, ebx + lea ebp, DWORD PTR 1518500249[ecx*1+ebp] + mov ecx, esi + add edx, ebp + xor ecx, eax + mov ebp, edx + and ecx, edi + rol ebp, 5 + add ebp, ebx + mov ebx, DWORD PTR 36[esp] + ror edi, 1 + xor ecx, eax + ror edi, 1 + lea ebp, DWORD PTR 1518500249[ebx*1+ebp] + add ecx, ebp + ; 00_15 10 + mov ebx, edi + mov ebp, ecx + xor ebx, esi + rol ebp, 5 + and ebx, edx + add ebp, eax + ror edx, 1 + mov eax, DWORD PTR 40[esp] + ror edx, 1 + xor ebx, esi + lea ebp, DWORD PTR 1518500249[eax*1+ebp] + mov eax, edx + add ebx, ebp + xor eax, edi + mov ebp, ebx + and eax, ecx + rol ebp, 5 + add ebp, esi + mov esi, DWORD PTR 44[esp] + ror ecx, 1 + xor eax, edi + ror ecx, 1 + lea ebp, DWORD PTR 1518500249[esi*1+ebp] + add eax, ebp + ; 00_15 12 + mov esi, ecx + mov ebp, eax + xor esi, edx + rol ebp, 5 + and esi, ebx + add ebp, edi + ror ebx, 1 + mov edi, DWORD PTR 48[esp] + ror ebx, 1 + xor esi, edx + lea ebp, DWORD PTR 1518500249[edi*1+ebp] + mov edi, ebx + add esi, ebp + xor edi, ecx + mov ebp, esi + and edi, eax + rol ebp, 5 + add ebp, edx + mov edx, DWORD PTR 52[esp] + ror eax, 1 + xor edi, ecx + ror eax, 1 + lea ebp, DWORD PTR 1518500249[edx*1+ebp] + add edi, ebp + ; 00_15 14 + mov edx, eax + mov ebp, edi + xor edx, ebx + rol ebp, 5 + and edx, esi + add ebp, ecx + ror esi, 1 + mov ecx, DWORD PTR 56[esp] + ror esi, 1 + xor edx, ebx + lea ebp, DWORD PTR 1518500249[ecx*1+ebp] + mov ecx, esi + add edx, ebp + xor ecx, eax + mov ebp, edx + and ecx, edi + rol ebp, 5 + add ebp, ebx + mov ebx, DWORD PTR 60[esp] + ror edi, 1 + xor ecx, eax + ror edi, 1 + lea ebp, DWORD PTR 1518500249[ebx*1+ebp] + add ecx, ebp + ; 16_19 16 + nop + mov ebp, DWORD PTR [esp] + mov ebx, DWORD PTR 8[esp] + xor ebx, ebp + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 52[esp] + xor ebx, ebp + mov ebp, edi + rol ebx, 1 + xor ebp, esi + mov DWORD PTR [esp],ebx + and ebp, edx + lea ebx, DWORD PTR 1518500249[eax*1+ebx] + xor ebp, esi + mov eax, ecx + add ebx, ebp + rol eax, 5 + ror edx, 1 + add ebx, eax + mov eax, DWORD PTR 4[esp] + mov ebp, DWORD PTR 12[esp] + xor eax, ebp + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 56[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, edx + xor ebp, edi + mov DWORD PTR 4[esp],eax + and ebp, ecx + lea eax, DWORD PTR 1518500249[esi*1+eax] + xor ebp, edi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add eax, esi + ror ecx, 1 + add eax, ebp + ; 16_19 18 + mov ebp, DWORD PTR 8[esp] + mov esi, DWORD PTR 16[esp] + xor esi, ebp + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR 60[esp] + xor esi, ebp + mov ebp, ecx + rol esi, 1 + xor ebp, edx + mov DWORD PTR 8[esp],esi + and ebp, ebx + lea esi, DWORD PTR 1518500249[edi*1+esi] + xor ebp, edx + mov edi, eax + add esi, ebp + rol edi, 5 + ror ebx, 1 + add esi, edi + mov edi, DWORD PTR 12[esp] + mov ebp, DWORD PTR 20[esp] + xor edi, ebp + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR [esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, ebx + xor ebp, ecx + mov DWORD PTR 12[esp],edi + and ebp, eax + lea edi, DWORD PTR 1518500249[edx*1+edi] + xor ebp, ecx + mov edx, esi + rol edx, 5 + ror eax, 1 + add edi, edx + ror eax, 1 + add edi, ebp + ; 20_39 20 + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor edx, ebp + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 4[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 16[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 21 + mov ecx, DWORD PTR 20[esp] + mov ebp, DWORD PTR 28[esp] + xor ecx, ebp + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 8[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 20[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 22 + mov ebx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 12[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 24[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 1859775393[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 23 + mov eax, DWORD PTR 28[esp] + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 16[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 28[esp],eax + xor ebp, edi + lea eax, DWORD PTR 1859775393[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 24 + mov esi, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 20[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 32[esp],esi + xor ebp, edx + lea esi, DWORD PTR 1859775393[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 25 + mov edi, DWORD PTR 36[esp] + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 36[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 1859775393[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 26 + mov edx, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 8[esp] + xor edx, ebp + mov ebp, DWORD PTR 28[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 40[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 27 + mov ecx, DWORD PTR 44[esp] + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 12[esp] + xor ecx, ebp + mov ebp, DWORD PTR 32[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 44[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 28 + mov ebx, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 16[esp] + xor ebx, ebp + mov ebp, DWORD PTR 36[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 48[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 1859775393[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 29 + mov eax, DWORD PTR 52[esp] + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 20[esp] + xor eax, ebp + mov ebp, DWORD PTR 40[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 52[esp],eax + xor ebp, edi + lea eax, DWORD PTR 1859775393[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 30 + mov esi, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + xor esi, ebp + mov ebp, DWORD PTR 44[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 56[esp],esi + xor ebp, edx + lea esi, DWORD PTR 1859775393[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 31 + mov edi, DWORD PTR 60[esp] + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + xor edi, ebp + mov ebp, DWORD PTR 48[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 60[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 1859775393[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 32 + mov edx, DWORD PTR [esp] + mov ebp, DWORD PTR 8[esp] + xor edx, ebp + mov ebp, DWORD PTR 32[esp] + xor edx, ebp + mov ebp, DWORD PTR 52[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR [esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 33 + mov ecx, DWORD PTR 4[esp] + mov ebp, DWORD PTR 12[esp] + xor ecx, ebp + mov ebp, DWORD PTR 36[esp] + xor ecx, ebp + mov ebp, DWORD PTR 56[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 4[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 34 + mov ebx, DWORD PTR 8[esp] + mov ebp, DWORD PTR 16[esp] + xor ebx, ebp + mov ebp, DWORD PTR 40[esp] + xor ebx, ebp + mov ebp, DWORD PTR 60[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 8[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 1859775393[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 35 + mov eax, DWORD PTR 12[esp] + mov ebp, DWORD PTR 20[esp] + xor eax, ebp + mov ebp, DWORD PTR 44[esp] + xor eax, ebp + mov ebp, DWORD PTR [esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 12[esp],eax + xor ebp, edi + lea eax, DWORD PTR 1859775393[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 36 + mov esi, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor esi, ebp + mov ebp, DWORD PTR 48[esp] + xor esi, ebp + mov ebp, DWORD PTR 4[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 16[esp],esi + xor ebp, edx + lea esi, DWORD PTR 1859775393[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 37 + mov edi, DWORD PTR 20[esp] + mov ebp, DWORD PTR 28[esp] + xor edi, ebp + mov ebp, DWORD PTR 52[esp] + xor edi, ebp + mov ebp, DWORD PTR 8[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 20[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 1859775393[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 38 + mov edx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor edx, ebp + mov ebp, DWORD PTR 56[esp] + xor edx, ebp + mov ebp, DWORD PTR 12[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 24[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 1859775393[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 39 + mov ecx, DWORD PTR 28[esp] + mov ebp, DWORD PTR 36[esp] + xor ecx, ebp + mov ebp, DWORD PTR 60[esp] + xor ecx, ebp + mov ebp, DWORD PTR 16[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 28[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 1859775393[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 40_59 40 + mov ebx, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor ebx, ebp + mov ebp, DWORD PTR [esp] + xor ebx, ebp + mov ebp, DWORD PTR 20[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 32[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 36[esp] + add ebx, ebp + mov ebp, DWORD PTR 44[esp] + xor eax, ebp + mov ebp, DWORD PTR 4[esp] + xor eax, ebp + mov ebp, DWORD PTR 24[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 36[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 41 + ; 40_59 42 + mov esi, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor esi, ebp + mov ebp, DWORD PTR 8[esp] + xor esi, ebp + mov ebp, DWORD PTR 28[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + or ebp, ecx + mov DWORD PTR 40[esp],esi + and ebp, edx + lea esi, DWORD PTR 2400959708[edi*1+esi] + mov edi, ebx + ror ebx, 1 + and edi, ecx + or ebp, edi + mov edi, eax + rol edi, 5 + add ebp, edi + mov edi, DWORD PTR 44[esp] + add esi, ebp + mov ebp, DWORD PTR 52[esp] + xor edi, ebp + mov ebp, DWORD PTR 12[esp] + xor edi, ebp + mov ebp, DWORD PTR 32[esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, eax + mov DWORD PTR 44[esp],edi + or ebp, ebx + lea edi, DWORD PTR 2400959708[edx*1+edi] + mov edx, eax + and ebp, ecx + and edx, ebx + or ebp, edx + mov edx, esi + rol edx, 5 + ror eax, 1 + add ebp, edx + ror eax, 1 + add edi, ebp + ; 40_59 43 + ; 40_59 44 + mov edx, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor edx, ebp + mov ebp, DWORD PTR 16[esp] + xor edx, ebp + mov ebp, DWORD PTR 36[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + or ebp, eax + mov DWORD PTR 48[esp],edx + and ebp, ebx + lea edx, DWORD PTR 2400959708[ecx*1+edx] + mov ecx, esi + ror esi, 1 + and ecx, eax + or ebp, ecx + mov ecx, edi + rol ecx, 5 + add ebp, ecx + mov ecx, DWORD PTR 52[esp] + add edx, ebp + mov ebp, DWORD PTR 60[esp] + xor ecx, ebp + mov ebp, DWORD PTR 20[esp] + xor ecx, ebp + mov ebp, DWORD PTR 40[esp] + ror esi, 1 + xor ecx, ebp + rol ecx, 1 + mov ebp, edi + mov DWORD PTR 52[esp],ecx + or ebp, esi + lea ecx, DWORD PTR 2400959708[ebx*1+ecx] + mov ebx, edi + and ebp, eax + and ebx, esi + or ebp, ebx + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebp, ebx + ror edi, 1 + add ecx, ebp + ; 40_59 45 + ; 40_59 46 + mov ebx, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor ebx, ebp + mov ebp, DWORD PTR 24[esp] + xor ebx, ebp + mov ebp, DWORD PTR 44[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 56[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 60[esp] + add ebx, ebp + mov ebp, DWORD PTR 4[esp] + xor eax, ebp + mov ebp, DWORD PTR 28[esp] + xor eax, ebp + mov ebp, DWORD PTR 48[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 60[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 47 + ; 40_59 48 + mov esi, DWORD PTR [esp] + mov ebp, DWORD PTR 8[esp] + xor esi, ebp + mov ebp, DWORD PTR 32[esp] + xor esi, ebp + mov ebp, DWORD PTR 52[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + or ebp, ecx + mov DWORD PTR [esp],esi + and ebp, edx + lea esi, DWORD PTR 2400959708[edi*1+esi] + mov edi, ebx + ror ebx, 1 + and edi, ecx + or ebp, edi + mov edi, eax + rol edi, 5 + add ebp, edi + mov edi, DWORD PTR 4[esp] + add esi, ebp + mov ebp, DWORD PTR 12[esp] + xor edi, ebp + mov ebp, DWORD PTR 36[esp] + xor edi, ebp + mov ebp, DWORD PTR 56[esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, eax + mov DWORD PTR 4[esp],edi + or ebp, ebx + lea edi, DWORD PTR 2400959708[edx*1+edi] + mov edx, eax + and ebp, ecx + and edx, ebx + or ebp, edx + mov edx, esi + rol edx, 5 + ror eax, 1 + add ebp, edx + ror eax, 1 + add edi, ebp + ; 40_59 49 + ; 40_59 50 + mov edx, DWORD PTR 8[esp] + mov ebp, DWORD PTR 16[esp] + xor edx, ebp + mov ebp, DWORD PTR 40[esp] + xor edx, ebp + mov ebp, DWORD PTR 60[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + or ebp, eax + mov DWORD PTR 8[esp],edx + and ebp, ebx + lea edx, DWORD PTR 2400959708[ecx*1+edx] + mov ecx, esi + ror esi, 1 + and ecx, eax + or ebp, ecx + mov ecx, edi + rol ecx, 5 + add ebp, ecx + mov ecx, DWORD PTR 12[esp] + add edx, ebp + mov ebp, DWORD PTR 20[esp] + xor ecx, ebp + mov ebp, DWORD PTR 44[esp] + xor ecx, ebp + mov ebp, DWORD PTR [esp] + ror esi, 1 + xor ecx, ebp + rol ecx, 1 + mov ebp, edi + mov DWORD PTR 12[esp],ecx + or ebp, esi + lea ecx, DWORD PTR 2400959708[ebx*1+ecx] + mov ebx, edi + and ebp, eax + and ebx, esi + or ebp, ebx + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebp, ebx + ror edi, 1 + add ecx, ebp + ; 40_59 51 + ; 40_59 52 + mov ebx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor ebx, ebp + mov ebp, DWORD PTR 48[esp] + xor ebx, ebp + mov ebp, DWORD PTR 4[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 16[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 20[esp] + add ebx, ebp + mov ebp, DWORD PTR 28[esp] + xor eax, ebp + mov ebp, DWORD PTR 52[esp] + xor eax, ebp + mov ebp, DWORD PTR 8[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 20[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 53 + ; 40_59 54 + mov esi, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor esi, ebp + mov ebp, DWORD PTR 56[esp] + xor esi, ebp + mov ebp, DWORD PTR 12[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + or ebp, ecx + mov DWORD PTR 24[esp],esi + and ebp, edx + lea esi, DWORD PTR 2400959708[edi*1+esi] + mov edi, ebx + ror ebx, 1 + and edi, ecx + or ebp, edi + mov edi, eax + rol edi, 5 + add ebp, edi + mov edi, DWORD PTR 28[esp] + add esi, ebp + mov ebp, DWORD PTR 36[esp] + xor edi, ebp + mov ebp, DWORD PTR 60[esp] + xor edi, ebp + mov ebp, DWORD PTR 16[esp] + ror ebx, 1 + xor edi, ebp + rol edi, 1 + mov ebp, eax + mov DWORD PTR 28[esp],edi + or ebp, ebx + lea edi, DWORD PTR 2400959708[edx*1+edi] + mov edx, eax + and ebp, ecx + and edx, ebx + or ebp, edx + mov edx, esi + rol edx, 5 + ror eax, 1 + add ebp, edx + ror eax, 1 + add edi, ebp + ; 40_59 55 + ; 40_59 56 + mov edx, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor edx, ebp + mov ebp, DWORD PTR [esp] + xor edx, ebp + mov ebp, DWORD PTR 20[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + or ebp, eax + mov DWORD PTR 32[esp],edx + and ebp, ebx + lea edx, DWORD PTR 2400959708[ecx*1+edx] + mov ecx, esi + ror esi, 1 + and ecx, eax + or ebp, ecx + mov ecx, edi + rol ecx, 5 + add ebp, ecx + mov ecx, DWORD PTR 36[esp] + add edx, ebp + mov ebp, DWORD PTR 44[esp] + xor ecx, ebp + mov ebp, DWORD PTR 4[esp] + xor ecx, ebp + mov ebp, DWORD PTR 24[esp] + ror esi, 1 + xor ecx, ebp + rol ecx, 1 + mov ebp, edi + mov DWORD PTR 36[esp],ecx + or ebp, esi + lea ecx, DWORD PTR 2400959708[ebx*1+ecx] + mov ebx, edi + and ebp, eax + and ebx, esi + or ebp, ebx + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebp, ebx + ror edi, 1 + add ecx, ebp + ; 40_59 57 + ; 40_59 58 + mov ebx, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor ebx, ebp + mov ebp, DWORD PTR 8[esp] + xor ebx, ebp + mov ebp, DWORD PTR 28[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + or ebp, edi + mov DWORD PTR 40[esp],ebx + and ebp, esi + lea ebx, DWORD PTR 2400959708[eax*1+ebx] + mov eax, edx + ror edx, 1 + and eax, edi + or ebp, eax + mov eax, ecx + rol eax, 5 + add ebp, eax + mov eax, DWORD PTR 44[esp] + add ebx, ebp + mov ebp, DWORD PTR 52[esp] + xor eax, ebp + mov ebp, DWORD PTR 12[esp] + xor eax, ebp + mov ebp, DWORD PTR 32[esp] + ror edx, 1 + xor eax, ebp + rol eax, 1 + mov ebp, ecx + mov DWORD PTR 44[esp],eax + or ebp, edx + lea eax, DWORD PTR 2400959708[esi*1+eax] + mov esi, ecx + and ebp, edi + and esi, edx + or ebp, esi + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add ebp, esi + ror ecx, 1 + add eax, ebp + ; 40_59 59 + ; 20_39 60 + mov esi, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor esi, ebp + mov ebp, DWORD PTR 16[esp] + xor esi, ebp + mov ebp, DWORD PTR 36[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 48[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 61 + mov edi, DWORD PTR 52[esp] + mov ebp, DWORD PTR 60[esp] + xor edi, ebp + mov ebp, DWORD PTR 20[esp] + xor edi, ebp + mov ebp, DWORD PTR 40[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 52[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 62 + mov edx, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor edx, ebp + mov ebp, DWORD PTR 24[esp] + xor edx, ebp + mov ebp, DWORD PTR 44[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 56[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 3395469782[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 63 + mov ecx, DWORD PTR 60[esp] + mov ebp, DWORD PTR 4[esp] + xor ecx, ebp + mov ebp, DWORD PTR 28[esp] + xor ecx, ebp + mov ebp, DWORD PTR 48[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 60[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 3395469782[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 64 + mov ebx, DWORD PTR [esp] + mov ebp, DWORD PTR 8[esp] + xor ebx, ebp + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 52[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR [esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 3395469782[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 65 + mov eax, DWORD PTR 4[esp] + mov ebp, DWORD PTR 12[esp] + xor eax, ebp + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 56[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 4[esp],eax + xor ebp, edi + lea eax, DWORD PTR 3395469782[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 66 + mov esi, DWORD PTR 8[esp] + mov ebp, DWORD PTR 16[esp] + xor esi, ebp + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR 60[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 8[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 67 + mov edi, DWORD PTR 12[esp] + mov ebp, DWORD PTR 20[esp] + xor edi, ebp + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR [esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 12[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 68 + mov edx, DWORD PTR 16[esp] + mov ebp, DWORD PTR 24[esp] + xor edx, ebp + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 4[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 16[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 3395469782[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 69 + mov ecx, DWORD PTR 20[esp] + mov ebp, DWORD PTR 28[esp] + xor ecx, ebp + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 8[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 20[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 3395469782[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 70 + mov ebx, DWORD PTR 24[esp] + mov ebp, DWORD PTR 32[esp] + xor ebx, ebp + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 12[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 24[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 3395469782[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 71 + mov eax, DWORD PTR 28[esp] + mov ebp, DWORD PTR 36[esp] + xor eax, ebp + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 16[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 28[esp],eax + xor ebp, edi + lea eax, DWORD PTR 3395469782[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 72 + mov esi, DWORD PTR 32[esp] + mov ebp, DWORD PTR 40[esp] + xor esi, ebp + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 20[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 32[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 73 + mov edi, DWORD PTR 36[esp] + mov ebp, DWORD PTR 44[esp] + xor edi, ebp + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 24[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 36[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + ror eax, 1 + add edx, ebp + ror eax, 1 + add edi, edx + ; 20_39 74 + mov edx, DWORD PTR 40[esp] + mov ebp, DWORD PTR 48[esp] + xor edx, ebp + mov ebp, DWORD PTR 8[esp] + xor edx, ebp + mov ebp, DWORD PTR 28[esp] + xor edx, ebp + mov ebp, esi + rol edx, 1 + xor ebp, eax + mov DWORD PTR 40[esp],edx + xor ebp, ebx + lea edx, DWORD PTR 3395469782[ecx*1+edx] + mov ecx, edi + rol ecx, 5 + ror esi, 1 + add ecx, ebp + ror esi, 1 + add edx, ecx + ; 20_39 75 + mov ecx, DWORD PTR 44[esp] + mov ebp, DWORD PTR 52[esp] + xor ecx, ebp + mov ebp, DWORD PTR 12[esp] + xor ecx, ebp + mov ebp, DWORD PTR 32[esp] + xor ecx, ebp + mov ebp, edi + rol ecx, 1 + xor ebp, esi + mov DWORD PTR 44[esp],ecx + xor ebp, eax + lea ecx, DWORD PTR 3395469782[ebx*1+ecx] + mov ebx, edx + rol ebx, 5 + ror edi, 1 + add ebx, ebp + ror edi, 1 + add ecx, ebx + ; 20_39 76 + mov ebx, DWORD PTR 48[esp] + mov ebp, DWORD PTR 56[esp] + xor ebx, ebp + mov ebp, DWORD PTR 16[esp] + xor ebx, ebp + mov ebp, DWORD PTR 36[esp] + xor ebx, ebp + mov ebp, edx + rol ebx, 1 + xor ebp, edi + mov DWORD PTR 48[esp],ebx + xor ebp, esi + lea ebx, DWORD PTR 3395469782[eax*1+ebx] + mov eax, ecx + rol eax, 5 + ror edx, 1 + add eax, ebp + ror edx, 1 + add ebx, eax + ; 20_39 77 + mov eax, DWORD PTR 52[esp] + mov ebp, DWORD PTR 60[esp] + xor eax, ebp + mov ebp, DWORD PTR 20[esp] + xor eax, ebp + mov ebp, DWORD PTR 40[esp] + xor eax, ebp + mov ebp, ecx + rol eax, 1 + xor ebp, edx + mov DWORD PTR 52[esp],eax + xor ebp, edi + lea eax, DWORD PTR 3395469782[esi*1+eax] + mov esi, ebx + rol esi, 5 + ror ecx, 1 + add esi, ebp + ror ecx, 1 + add eax, esi + ; 20_39 78 + mov esi, DWORD PTR 56[esp] + mov ebp, DWORD PTR [esp] + xor esi, ebp + mov ebp, DWORD PTR 24[esp] + xor esi, ebp + mov ebp, DWORD PTR 44[esp] + xor esi, ebp + mov ebp, ebx + rol esi, 1 + xor ebp, ecx + mov DWORD PTR 56[esp],esi + xor ebp, edx + lea esi, DWORD PTR 3395469782[edi*1+esi] + mov edi, eax + rol edi, 5 + ror ebx, 1 + add edi, ebp + ror ebx, 1 + add esi, edi + ; 20_39 79 + mov edi, DWORD PTR 60[esp] + mov ebp, DWORD PTR 4[esp] + xor edi, ebp + mov ebp, DWORD PTR 28[esp] + xor edi, ebp + mov ebp, DWORD PTR 48[esp] + xor edi, ebp + mov ebp, eax + rol edi, 1 + xor ebp, ebx + mov DWORD PTR 60[esp],edi + xor ebp, ecx + lea edi, DWORD PTR 3395469782[edx*1+edi] + mov edx, esi + rol edx, 5 + add edx, ebp + mov ebp, DWORD PTR 92[esp] + ror eax, 1 + add edi, edx + ror eax, 1 + ; End processing + ; + mov edx, DWORD PTR 12[ebp] + add edx, ebx + mov ebx, DWORD PTR 4[ebp] + add ebx, esi + mov esi, eax + mov eax, DWORD PTR [ebp] + mov DWORD PTR 12[ebp],edx + add eax, edi + mov edi, DWORD PTR 16[ebp] + add edi, ecx + mov ecx, DWORD PTR 8[ebp] + add ecx, esi + mov DWORD PTR [ebp],eax + mov esi, DWORD PTR 64[esp] + mov DWORD PTR 8[ebp],ecx + add esi, 64 + mov eax, DWORD PTR 68[esp] + mov DWORD PTR 16[ebp],edi + cmp eax, esi + mov DWORD PTR 4[ebp],ebx + jl $L001end + mov eax, DWORD PTR [esi] + jmp L000start +$L001end: + add esp, 72 + pop edi + pop ebx + pop ebp + pop esi + ret +_sha1_block_x86 ENDP +_TEXT ENDS +END diff --git a/src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp b/src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp new file mode 100644 index 0000000000..8366664a39 --- /dev/null +++ b/src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp @@ -0,0 +1,1948 @@ +/* Run the C pre-processor over this file with one of the following defined + * ELF - elf object files, + * OUT - a.out object files, + * BSDI - BSDI style a.out object files + * SOL - Solaris style elf + */ + +#define TYPE(a,b) .type a,b +#define SIZE(a,b) .size a,b + +#if defined(OUT) || defined(BSDI) +#define sha1_block_x86 _sha1_block_x86 + +#endif + +#ifdef OUT +#define OK 1 +#define ALIGN 4 +#endif + +#ifdef BSDI +#define OK 1 +#define ALIGN 4 +#undef SIZE +#undef TYPE +#define SIZE(a,b) +#define TYPE(a,b) +#endif + +#if defined(ELF) || defined(SOL) +#define OK 1 +#define ALIGN 16 +#endif + +#ifndef OK +You need to define one of +ELF - elf systems - linux-elf, NetBSD and DG-UX +OUT - a.out systems - linux-a.out and FreeBSD +SOL - solaris systems, which are elf with strange comment lines +BSDI - a.out with a very primative version of as. +#endif + +/* Let the Assembler begin :-) */ + /* Don't even think of reading this code */ + /* It was automatically generated by sha1-586.pl */ + /* Which is a perl program used to generate the x86 assember for */ + /* any of elf, a.out, BSDI,Win32, or Solaris */ + /* eric */ + + .file "sha1-586.s" + .version "01.01" +gcc2_compiled.: +.text + .align ALIGN +.globl sha1_block_x86 + TYPE(sha1_block_x86,@function) +sha1_block_x86: + pushl %esi + pushl %ebp + movl 20(%esp), %eax + movl 16(%esp), %esi + addl %esi, %eax + movl 12(%esp), %ebp + pushl %ebx + subl $64, %eax + pushl %edi + movl 4(%ebp), %ebx + subl $72, %esp + movl 12(%ebp), %edx + movl 16(%ebp), %edi + movl 8(%ebp), %ecx + movl %eax, 68(%esp) + /* First we need to setup the X array */ + movl (%esi), %eax +.L000start: + /* First, load the words onto the stack in network byte order */ +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, (%esp) + movl 4(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 4(%esp) + movl 8(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 8(%esp) + movl 12(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 12(%esp) + movl 16(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 16(%esp) + movl 20(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 20(%esp) + movl 24(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 24(%esp) + movl 28(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 28(%esp) + movl 32(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 32(%esp) + movl 36(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 36(%esp) + movl 40(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 40(%esp) + movl 44(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 44(%esp) + movl 48(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 48(%esp) + movl 52(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 52(%esp) + movl 56(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 56(%esp) + movl 60(%esi), %eax +.byte 15 +.byte 200 /* bswapl %eax */ + movl %eax, 60(%esp) + /* We now have the X array on the stack */ + /* starting at sp-4 */ + movl %esi, 64(%esp) + + /* Start processing */ + movl (%ebp), %eax + /* 00_15 0 */ + movl %ecx, %esi + movl %eax, %ebp + xorl %edx, %esi + roll $5, %ebp + andl %ebx, %esi + addl %edi, %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + movl (%esp), %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + movl %ebx, %edi + addl %ebp, %esi + xorl %ecx, %edi + movl %esi, %ebp + andl %eax, %edi + roll $5, %ebp + addl %edx, %ebp + movl 4(%esp), %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + xorl %ecx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + /* 00_15 2 */ + movl %eax, %edx + movl %edi, %ebp + xorl %ebx, %edx + roll $5, %ebp + andl %esi, %edx + addl %ecx, %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl 8(%esp), %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebx, %edx + leal 1518500249(%ebp,%ecx,1),%ebp + movl %esi, %ecx + addl %ebp, %edx + xorl %eax, %ecx + movl %edx, %ebp + andl %edi, %ecx + roll $5, %ebp + addl %ebx, %ebp + movl 12(%esp), %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + xorl %eax, %ecx +.byte 209 +.byte 207 /* rorl $1 %edi */ + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %ecx + /* 00_15 4 */ + movl %edi, %ebx + movl %ecx, %ebp + xorl %esi, %ebx + roll $5, %ebp + andl %edx, %ebx + addl %eax, %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + movl 16(%esp), %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %esi, %ebx + leal 1518500249(%ebp,%eax,1),%ebp + movl %edx, %eax + addl %ebp, %ebx + xorl %edi, %eax + movl %ebx, %ebp + andl %ecx, %eax + roll $5, %ebp + addl %esi, %ebp + movl 20(%esp), %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + xorl %edi, %eax +.byte 209 +.byte 201 /* rorl $1 %ecx */ + leal 1518500249(%ebp,%esi,1),%ebp + addl %ebp, %eax + /* 00_15 6 */ + movl %ecx, %esi + movl %eax, %ebp + xorl %edx, %esi + roll $5, %ebp + andl %ebx, %esi + addl %edi, %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + movl 24(%esp), %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + movl %ebx, %edi + addl %ebp, %esi + xorl %ecx, %edi + movl %esi, %ebp + andl %eax, %edi + roll $5, %ebp + addl %edx, %ebp + movl 28(%esp), %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + xorl %ecx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + /* 00_15 8 */ + movl %eax, %edx + movl %edi, %ebp + xorl %ebx, %edx + roll $5, %ebp + andl %esi, %edx + addl %ecx, %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl 32(%esp), %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebx, %edx + leal 1518500249(%ebp,%ecx,1),%ebp + movl %esi, %ecx + addl %ebp, %edx + xorl %eax, %ecx + movl %edx, %ebp + andl %edi, %ecx + roll $5, %ebp + addl %ebx, %ebp + movl 36(%esp), %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + xorl %eax, %ecx +.byte 209 +.byte 207 /* rorl $1 %edi */ + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %ecx + /* 00_15 10 */ + movl %edi, %ebx + movl %ecx, %ebp + xorl %esi, %ebx + roll $5, %ebp + andl %edx, %ebx + addl %eax, %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + movl 40(%esp), %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %esi, %ebx + leal 1518500249(%ebp,%eax,1),%ebp + movl %edx, %eax + addl %ebp, %ebx + xorl %edi, %eax + movl %ebx, %ebp + andl %ecx, %eax + roll $5, %ebp + addl %esi, %ebp + movl 44(%esp), %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + xorl %edi, %eax +.byte 209 +.byte 201 /* rorl $1 %ecx */ + leal 1518500249(%ebp,%esi,1),%ebp + addl %ebp, %eax + /* 00_15 12 */ + movl %ecx, %esi + movl %eax, %ebp + xorl %edx, %esi + roll $5, %ebp + andl %ebx, %esi + addl %edi, %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + movl 48(%esp), %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %edx, %esi + leal 1518500249(%ebp,%edi,1),%ebp + movl %ebx, %edi + addl %ebp, %esi + xorl %ecx, %edi + movl %esi, %ebp + andl %eax, %edi + roll $5, %ebp + addl %edx, %ebp + movl 52(%esp), %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + xorl %ecx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + leal 1518500249(%ebp,%edx,1),%ebp + addl %ebp, %edi + /* 00_15 14 */ + movl %eax, %edx + movl %edi, %ebp + xorl %ebx, %edx + roll $5, %ebp + andl %esi, %edx + addl %ecx, %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + movl 56(%esp), %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebx, %edx + leal 1518500249(%ebp,%ecx,1),%ebp + movl %esi, %ecx + addl %ebp, %edx + xorl %eax, %ecx + movl %edx, %ebp + andl %edi, %ecx + roll $5, %ebp + addl %ebx, %ebp + movl 60(%esp), %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + xorl %eax, %ecx +.byte 209 +.byte 207 /* rorl $1 %edi */ + leal 1518500249(%ebp,%ebx,1),%ebp + addl %ebp, %ecx + /* 16_19 16 */ + nop + movl (%esp), %ebp + movl 8(%esp), %ebx + xorl %ebp, %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 52(%esp), %ebp + xorl %ebp, %ebx + movl %edi, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %esi, %ebp + movl %ebx, (%esp) + andl %edx, %ebp + leal 1518500249(%ebx,%eax,1),%ebx + xorl %esi, %ebp + movl %ecx, %eax + addl %ebp, %ebx + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + movl 4(%esp), %eax + movl 12(%esp), %ebp + xorl %ebp, %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 56(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %edx, %ebp + xorl %edi, %ebp + movl %eax, 4(%esp) + andl %ecx, %ebp + leal 1518500249(%eax,%esi,1),%eax + xorl %edi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 16_19 18 */ + movl 8(%esp), %ebp + movl 16(%esp), %esi + xorl %ebp, %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl 60(%esp), %ebp + xorl %ebp, %esi + movl %ecx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %edx, %ebp + movl %esi, 8(%esp) + andl %ebx, %ebp + leal 1518500249(%esi,%edi,1),%esi + xorl %edx, %ebp + movl %eax, %edi + addl %ebp, %esi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + movl 12(%esp), %edi + movl 20(%esp), %ebp + xorl %ebp, %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl (%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %ebx, %ebp + xorl %ecx, %ebp + movl %edi, 12(%esp) + andl %eax, %ebp + leal 1518500249(%edi,%edx,1),%edi + xorl %ecx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 20_39 20 */ + movl 16(%esp), %edx + movl 24(%esp), %ebp + xorl %ebp, %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 4(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 16(%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 21 */ + movl 20(%esp), %ecx + movl 28(%esp), %ebp + xorl %ebp, %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 8(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 20(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 22 */ + movl 24(%esp), %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 12(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 24(%esp) + xorl %esi, %ebp + leal 1859775393(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 23 */ + movl 28(%esp), %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 16(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 28(%esp) + xorl %edi, %ebp + leal 1859775393(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 24 */ + movl 32(%esp), %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 20(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 32(%esp) + xorl %edx, %ebp + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 25 */ + movl 36(%esp), %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 36(%esp) + xorl %ecx, %ebp + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 26 */ + movl 40(%esp), %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 8(%esp), %ebp + xorl %ebp, %edx + movl 28(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 40(%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 27 */ + movl 44(%esp), %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 12(%esp), %ebp + xorl %ebp, %ecx + movl 32(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 44(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 28 */ + movl 48(%esp), %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 16(%esp), %ebp + xorl %ebp, %ebx + movl 36(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 48(%esp) + xorl %esi, %ebp + leal 1859775393(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 29 */ + movl 52(%esp), %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 20(%esp), %ebp + xorl %ebp, %eax + movl 40(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 52(%esp) + xorl %edi, %ebp + leal 1859775393(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 30 */ + movl 56(%esp), %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + xorl %ebp, %esi + movl 44(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 56(%esp) + xorl %edx, %ebp + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 31 */ + movl 60(%esp), %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + xorl %ebp, %edi + movl 48(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 60(%esp) + xorl %ecx, %ebp + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 32 */ + movl (%esp), %edx + movl 8(%esp), %ebp + xorl %ebp, %edx + movl 32(%esp), %ebp + xorl %ebp, %edx + movl 52(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, (%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 33 */ + movl 4(%esp), %ecx + movl 12(%esp), %ebp + xorl %ebp, %ecx + movl 36(%esp), %ebp + xorl %ebp, %ecx + movl 56(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 4(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 34 */ + movl 8(%esp), %ebx + movl 16(%esp), %ebp + xorl %ebp, %ebx + movl 40(%esp), %ebp + xorl %ebp, %ebx + movl 60(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 8(%esp) + xorl %esi, %ebp + leal 1859775393(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 35 */ + movl 12(%esp), %eax + movl 20(%esp), %ebp + xorl %ebp, %eax + movl 44(%esp), %ebp + xorl %ebp, %eax + movl (%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 12(%esp) + xorl %edi, %ebp + leal 1859775393(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 36 */ + movl 16(%esp), %esi + movl 24(%esp), %ebp + xorl %ebp, %esi + movl 48(%esp), %ebp + xorl %ebp, %esi + movl 4(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 16(%esp) + xorl %edx, %ebp + leal 1859775393(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 37 */ + movl 20(%esp), %edi + movl 28(%esp), %ebp + xorl %ebp, %edi + movl 52(%esp), %ebp + xorl %ebp, %edi + movl 8(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 20(%esp) + xorl %ecx, %ebp + leal 1859775393(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 38 */ + movl 24(%esp), %edx + movl 32(%esp), %ebp + xorl %ebp, %edx + movl 56(%esp), %ebp + xorl %ebp, %edx + movl 12(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 24(%esp) + xorl %ebx, %ebp + leal 1859775393(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 39 */ + movl 28(%esp), %ecx + movl 36(%esp), %ebp + xorl %ebp, %ecx + movl 60(%esp), %ebp + xorl %ebp, %ecx + movl 16(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 28(%esp) + xorl %eax, %ebp + leal 1859775393(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 40_59 40 */ + movl 32(%esp), %ebx + movl 40(%esp), %ebp + xorl %ebp, %ebx + movl (%esp), %ebp + xorl %ebp, %ebx + movl 20(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 32(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 36(%esp), %eax + addl %ebp, %ebx + movl 44(%esp), %ebp + xorl %ebp, %eax + movl 4(%esp), %ebp + xorl %ebp, %eax + movl 24(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 36(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 41 */ + /* 40_59 42 */ + movl 40(%esp), %esi + movl 48(%esp), %ebp + xorl %ebp, %esi + movl 8(%esp), %ebp + xorl %ebp, %esi + movl 28(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + orl %ecx, %ebp + movl %esi, 40(%esp) + andl %edx, %ebp + leal 2400959708(%esi,%edi,1),%esi + movl %ebx, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + andl %ecx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + movl 44(%esp), %edi + addl %ebp, %esi + movl 52(%esp), %ebp + xorl %ebp, %edi + movl 12(%esp), %ebp + xorl %ebp, %edi + movl 32(%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %eax, %ebp + movl %edi, 44(%esp) + orl %ebx, %ebp + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + andl %ecx, %ebp + andl %ebx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 40_59 43 */ + /* 40_59 44 */ + movl 48(%esp), %edx + movl 56(%esp), %ebp + xorl %ebp, %edx + movl 16(%esp), %ebp + xorl %ebp, %edx + movl 36(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + orl %eax, %ebp + movl %edx, 48(%esp) + andl %ebx, %ebp + leal 2400959708(%edx,%ecx,1),%edx + movl %esi, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + andl %eax, %ecx + orl %ecx, %ebp + movl %edi, %ecx + roll $5, %ecx + addl %ecx, %ebp + movl 52(%esp), %ecx + addl %ebp, %edx + movl 60(%esp), %ebp + xorl %ebp, %ecx + movl 20(%esp), %ebp + xorl %ebp, %ecx + movl 40(%esp), %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebp, %ecx +.byte 209 +.byte 193 /* roll $1 %ecx */ + movl %edi, %ebp + movl %ecx, 52(%esp) + orl %esi, %ebp + leal 2400959708(%ecx,%ebx,1),%ecx + movl %edi, %ebx + andl %eax, %ebp + andl %esi, %ebx + orl %ebx, %ebp + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ebp +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ecx + /* 40_59 45 */ + /* 40_59 46 */ + movl 56(%esp), %ebx + movl (%esp), %ebp + xorl %ebp, %ebx + movl 24(%esp), %ebp + xorl %ebp, %ebx + movl 44(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 56(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 60(%esp), %eax + addl %ebp, %ebx + movl 4(%esp), %ebp + xorl %ebp, %eax + movl 28(%esp), %ebp + xorl %ebp, %eax + movl 48(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 60(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 47 */ + /* 40_59 48 */ + movl (%esp), %esi + movl 8(%esp), %ebp + xorl %ebp, %esi + movl 32(%esp), %ebp + xorl %ebp, %esi + movl 52(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + orl %ecx, %ebp + movl %esi, (%esp) + andl %edx, %ebp + leal 2400959708(%esi,%edi,1),%esi + movl %ebx, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + andl %ecx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + movl 4(%esp), %edi + addl %ebp, %esi + movl 12(%esp), %ebp + xorl %ebp, %edi + movl 36(%esp), %ebp + xorl %ebp, %edi + movl 56(%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %eax, %ebp + movl %edi, 4(%esp) + orl %ebx, %ebp + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + andl %ecx, %ebp + andl %ebx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 40_59 49 */ + /* 40_59 50 */ + movl 8(%esp), %edx + movl 16(%esp), %ebp + xorl %ebp, %edx + movl 40(%esp), %ebp + xorl %ebp, %edx + movl 60(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + orl %eax, %ebp + movl %edx, 8(%esp) + andl %ebx, %ebp + leal 2400959708(%edx,%ecx,1),%edx + movl %esi, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + andl %eax, %ecx + orl %ecx, %ebp + movl %edi, %ecx + roll $5, %ecx + addl %ecx, %ebp + movl 12(%esp), %ecx + addl %ebp, %edx + movl 20(%esp), %ebp + xorl %ebp, %ecx + movl 44(%esp), %ebp + xorl %ebp, %ecx + movl (%esp), %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebp, %ecx +.byte 209 +.byte 193 /* roll $1 %ecx */ + movl %edi, %ebp + movl %ecx, 12(%esp) + orl %esi, %ebp + leal 2400959708(%ecx,%ebx,1),%ecx + movl %edi, %ebx + andl %eax, %ebp + andl %esi, %ebx + orl %ebx, %ebp + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ebp +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ecx + /* 40_59 51 */ + /* 40_59 52 */ + movl 16(%esp), %ebx + movl 24(%esp), %ebp + xorl %ebp, %ebx + movl 48(%esp), %ebp + xorl %ebp, %ebx + movl 4(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 16(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 20(%esp), %eax + addl %ebp, %ebx + movl 28(%esp), %ebp + xorl %ebp, %eax + movl 52(%esp), %ebp + xorl %ebp, %eax + movl 8(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 20(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 53 */ + /* 40_59 54 */ + movl 24(%esp), %esi + movl 32(%esp), %ebp + xorl %ebp, %esi + movl 56(%esp), %ebp + xorl %ebp, %esi + movl 12(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + orl %ecx, %ebp + movl %esi, 24(%esp) + andl %edx, %ebp + leal 2400959708(%esi,%edi,1),%esi + movl %ebx, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + andl %ecx, %edi + orl %edi, %ebp + movl %eax, %edi + roll $5, %edi + addl %edi, %ebp + movl 28(%esp), %edi + addl %ebp, %esi + movl 36(%esp), %ebp + xorl %ebp, %edi + movl 60(%esp), %ebp + xorl %ebp, %edi + movl 16(%esp), %ebp +.byte 209 +.byte 203 /* rorl $1 %ebx */ + xorl %ebp, %edi +.byte 209 +.byte 199 /* roll $1 %edi */ + movl %eax, %ebp + movl %edi, 28(%esp) + orl %ebx, %ebp + leal 2400959708(%edi,%edx,1),%edi + movl %eax, %edx + andl %ecx, %ebp + andl %ebx, %edx + orl %edx, %ebp + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edi + /* 40_59 55 */ + /* 40_59 56 */ + movl 32(%esp), %edx + movl 40(%esp), %ebp + xorl %ebp, %edx + movl (%esp), %ebp + xorl %ebp, %edx + movl 20(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + orl %eax, %ebp + movl %edx, 32(%esp) + andl %ebx, %ebp + leal 2400959708(%edx,%ecx,1),%edx + movl %esi, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + andl %eax, %ecx + orl %ecx, %ebp + movl %edi, %ecx + roll $5, %ecx + addl %ecx, %ebp + movl 36(%esp), %ecx + addl %ebp, %edx + movl 44(%esp), %ebp + xorl %ebp, %ecx + movl 4(%esp), %ebp + xorl %ebp, %ecx + movl 24(%esp), %ebp +.byte 209 +.byte 206 /* rorl $1 %esi */ + xorl %ebp, %ecx +.byte 209 +.byte 193 /* roll $1 %ecx */ + movl %edi, %ebp + movl %ecx, 36(%esp) + orl %esi, %ebp + leal 2400959708(%ecx,%ebx,1),%ecx + movl %edi, %ebx + andl %eax, %ebp + andl %esi, %ebx + orl %ebx, %ebp + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ebp +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ecx + /* 40_59 57 */ + /* 40_59 58 */ + movl 40(%esp), %ebx + movl 48(%esp), %ebp + xorl %ebp, %ebx + movl 8(%esp), %ebp + xorl %ebp, %ebx + movl 28(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + orl %edi, %ebp + movl %ebx, 40(%esp) + andl %esi, %ebp + leal 2400959708(%ebx,%eax,1),%ebx + movl %edx, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + andl %edi, %eax + orl %eax, %ebp + movl %ecx, %eax + roll $5, %eax + addl %eax, %ebp + movl 44(%esp), %eax + addl %ebp, %ebx + movl 52(%esp), %ebp + xorl %ebp, %eax + movl 12(%esp), %ebp + xorl %ebp, %eax + movl 32(%esp), %ebp +.byte 209 +.byte 202 /* rorl $1 %edx */ + xorl %ebp, %eax +.byte 209 +.byte 192 /* roll $1 %eax */ + movl %ecx, %ebp + movl %eax, 44(%esp) + orl %edx, %ebp + leal 2400959708(%eax,%esi,1),%eax + movl %ecx, %esi + andl %edi, %ebp + andl %edx, %esi + orl %esi, %ebp + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %ebp +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %eax + /* 40_59 59 */ + /* 20_39 60 */ + movl 48(%esp), %esi + movl 56(%esp), %ebp + xorl %ebp, %esi + movl 16(%esp), %ebp + xorl %ebp, %esi + movl 36(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 48(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 61 */ + movl 52(%esp), %edi + movl 60(%esp), %ebp + xorl %ebp, %edi + movl 20(%esp), %ebp + xorl %ebp, %edi + movl 40(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 52(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 62 */ + movl 56(%esp), %edx + movl (%esp), %ebp + xorl %ebp, %edx + movl 24(%esp), %ebp + xorl %ebp, %edx + movl 44(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 56(%esp) + xorl %ebx, %ebp + leal 3395469782(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 63 */ + movl 60(%esp), %ecx + movl 4(%esp), %ebp + xorl %ebp, %ecx + movl 28(%esp), %ebp + xorl %ebp, %ecx + movl 48(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 60(%esp) + xorl %eax, %ebp + leal 3395469782(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 64 */ + movl (%esp), %ebx + movl 8(%esp), %ebp + xorl %ebp, %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 52(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, (%esp) + xorl %esi, %ebp + leal 3395469782(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 65 */ + movl 4(%esp), %eax + movl 12(%esp), %ebp + xorl %ebp, %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 56(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 4(%esp) + xorl %edi, %ebp + leal 3395469782(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 66 */ + movl 8(%esp), %esi + movl 16(%esp), %ebp + xorl %ebp, %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl 60(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 8(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 67 */ + movl 12(%esp), %edi + movl 20(%esp), %ebp + xorl %ebp, %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl (%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 12(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 68 */ + movl 16(%esp), %edx + movl 24(%esp), %ebp + xorl %ebp, %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 4(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 16(%esp) + xorl %ebx, %ebp + leal 3395469782(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 69 */ + movl 20(%esp), %ecx + movl 28(%esp), %ebp + xorl %ebp, %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 8(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 20(%esp) + xorl %eax, %ebp + leal 3395469782(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 70 */ + movl 24(%esp), %ebx + movl 32(%esp), %ebp + xorl %ebp, %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 12(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 24(%esp) + xorl %esi, %ebp + leal 3395469782(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 71 */ + movl 28(%esp), %eax + movl 36(%esp), %ebp + xorl %ebp, %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 16(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 28(%esp) + xorl %edi, %ebp + leal 3395469782(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 72 */ + movl 32(%esp), %esi + movl 40(%esp), %ebp + xorl %ebp, %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 20(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 32(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 73 */ + movl 36(%esp), %edi + movl 44(%esp), %ebp + xorl %ebp, %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 24(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 36(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %ebp, %edx +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi + /* 20_39 74 */ + movl 40(%esp), %edx + movl 48(%esp), %ebp + xorl %ebp, %edx + movl 8(%esp), %ebp + xorl %ebp, %edx + movl 28(%esp), %ebp + xorl %ebp, %edx + movl %esi, %ebp +.byte 209 +.byte 194 /* roll $1 %edx */ + xorl %eax, %ebp + movl %edx, 40(%esp) + xorl %ebx, %ebp + leal 3395469782(%edx,%ecx,1),%edx + movl %edi, %ecx + roll $5, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ebp, %ecx +.byte 209 +.byte 206 /* rorl $1 %esi */ + addl %ecx, %edx + /* 20_39 75 */ + movl 44(%esp), %ecx + movl 52(%esp), %ebp + xorl %ebp, %ecx + movl 12(%esp), %ebp + xorl %ebp, %ecx + movl 32(%esp), %ebp + xorl %ebp, %ecx + movl %edi, %ebp +.byte 209 +.byte 193 /* roll $1 %ecx */ + xorl %esi, %ebp + movl %ecx, 44(%esp) + xorl %eax, %ebp + leal 3395469782(%ecx,%ebx,1),%ecx + movl %edx, %ebx + roll $5, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebp, %ebx +.byte 209 +.byte 207 /* rorl $1 %edi */ + addl %ebx, %ecx + /* 20_39 76 */ + movl 48(%esp), %ebx + movl 56(%esp), %ebp + xorl %ebp, %ebx + movl 16(%esp), %ebp + xorl %ebp, %ebx + movl 36(%esp), %ebp + xorl %ebp, %ebx + movl %edx, %ebp +.byte 209 +.byte 195 /* roll $1 %ebx */ + xorl %edi, %ebp + movl %ebx, 48(%esp) + xorl %esi, %ebp + leal 3395469782(%ebx,%eax,1),%ebx + movl %ecx, %eax + roll $5, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %ebp, %eax +.byte 209 +.byte 202 /* rorl $1 %edx */ + addl %eax, %ebx + /* 20_39 77 */ + movl 52(%esp), %eax + movl 60(%esp), %ebp + xorl %ebp, %eax + movl 20(%esp), %ebp + xorl %ebp, %eax + movl 40(%esp), %ebp + xorl %ebp, %eax + movl %ecx, %ebp +.byte 209 +.byte 192 /* roll $1 %eax */ + xorl %edx, %ebp + movl %eax, 52(%esp) + xorl %edi, %ebp + leal 3395469782(%eax,%esi,1),%eax + movl %ebx, %esi + roll $5, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %ebp, %esi +.byte 209 +.byte 201 /* rorl $1 %ecx */ + addl %esi, %eax + /* 20_39 78 */ + movl 56(%esp), %esi + movl (%esp), %ebp + xorl %ebp, %esi + movl 24(%esp), %ebp + xorl %ebp, %esi + movl 44(%esp), %ebp + xorl %ebp, %esi + movl %ebx, %ebp +.byte 209 +.byte 198 /* roll $1 %esi */ + xorl %ecx, %ebp + movl %esi, 56(%esp) + xorl %edx, %ebp + leal 3395469782(%esi,%edi,1),%esi + movl %eax, %edi + roll $5, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %ebp, %edi +.byte 209 +.byte 203 /* rorl $1 %ebx */ + addl %edi, %esi + /* 20_39 79 */ + movl 60(%esp), %edi + movl 4(%esp), %ebp + xorl %ebp, %edi + movl 28(%esp), %ebp + xorl %ebp, %edi + movl 48(%esp), %ebp + xorl %ebp, %edi + movl %eax, %ebp +.byte 209 +.byte 199 /* roll $1 %edi */ + xorl %ebx, %ebp + movl %edi, 60(%esp) + xorl %ecx, %ebp + leal 3395469782(%edi,%edx,1),%edi + movl %esi, %edx + roll $5, %edx + addl %ebp, %edx + movl 92(%esp), %ebp +.byte 209 +.byte 200 /* rorl $1 %eax */ + addl %edx, %edi +.byte 209 +.byte 200 /* rorl $1 %eax */ + /* End processing */ + + movl 12(%ebp), %edx + addl %ebx, %edx + movl 4(%ebp), %ebx + addl %esi, %ebx + movl %eax, %esi + movl (%ebp), %eax + movl %edx, 12(%ebp) + addl %edi, %eax + movl 16(%ebp), %edi + addl %ecx, %edi + movl 8(%ebp), %ecx + addl %esi, %ecx + movl %eax, (%ebp) + movl 64(%esp), %esi + movl %ecx, 8(%ebp) + addl $64, %esi + movl 68(%esp), %eax + movl %edi, 16(%ebp) + cmpl %esi, %eax + movl %ebx, 4(%ebp) + jl .L001end + movl (%esi), %eax + jmp .L000start +.L001end: + addl $72, %esp + popl %edi + popl %ebx + popl %ebp + popl %esi + ret +.sha1_block_x86_end: + SIZE(sha1_block_x86,.sha1_block_x86_end-sha1_block_x86) +.ident "desasm.pl" diff --git a/src/lib/libssl/src/crypto/sha/sha_sgst.c b/src/lib/libssl/src/crypto/sha/sha_sgst.c new file mode 100644 index 0000000000..8a16801328 --- /dev/null +++ b/src/lib/libssl/src/crypto/sha/sha_sgst.c @@ -0,0 +1,246 @@ +/* crypto/sha/sha_sgst.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include + +#ifdef undef +/* one or the other needs to be defined */ +#ifndef SHA_1 /* FIPE 180-1 */ +#define SHA_0 /* FIPS 180 */ +#endif +#endif + +#define ULONG unsigned long +#define UCHAR unsigned char +#define UINT unsigned int + +#ifdef NOCONST +#define const +#endif + +#undef c2nl +#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++))) )) + +#undef p_c2nl +#define p_c2nl(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + case 3: l|=((unsigned long)(*((c)++))); \ + } \ + } + +#undef c2nl_p +/* NOTE the pointer is not incremented at the end of this */ +#define c2nl_p(c,l,n) { \ + l=0; \ + (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<< 8; \ + case 2: l|=((unsigned long)(*(--(c))))<<16; \ + case 1: l|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +#undef p_c2nl_p +#define p_c2nl_p(c,l,sc,len) { \ + switch (sc) \ + { \ + case 0: l =((unsigned long)(*((c)++)))<<24; \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<<16; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<< 8; \ + } \ + } + +#undef nl2c +#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#undef c2l +#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<<24)) + +#undef p_c2l +#define p_c2l(c,l,n) { \ + switch (n) { \ + case 0: l =((unsigned long)(*((c)++))); \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + case 3: l|=((unsigned long)(*((c)++)))<<24; \ + } \ + } + +#undef c2l_p +/* NOTE the pointer is not incremented at the end of this */ +#define c2l_p(c,l,n) { \ + l=0; \ + (c)+=n; \ + switch (n) { \ + case 3: l =((unsigned long)(*(--(c))))<<16; \ + case 2: l|=((unsigned long)(*(--(c))))<< 8; \ + case 1: l|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef p_c2l_p +#define p_c2l_p(c,l,sc,len) { \ + switch (sc) \ + { \ + case 0: l =((unsigned long)(*((c)++))); \ + if (--len == 0) break; \ + case 1: l|=((unsigned long)(*((c)++)))<< 8; \ + if (--len == 0) break; \ + case 2: l|=((unsigned long)(*((c)++)))<<16; \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff)) + +#undef ROTATE +#if defined(WIN32) +#define ROTATE(a,n) _lrotl(a,n) +#else +#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) +#endif + +/* A nice byte order reversal from Wei Dai */ +#if defined(WIN32) +/* 5 instructions with rotate instruction, else 9 */ +#define Endian_Reverse32(a) \ + { \ + unsigned long l=(a); \ + (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \ + } +#else +/* 6 instructions with rotate instruction, else 8 */ +#define Endian_Reverse32(a) \ + { \ + unsigned long l=(a); \ + l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \ + (a)=ROTATE(l,16L); \ + } +#endif + +/* As pointed out by Wei Dai , F() below can be + * simplified to the code in F_00_19. Wei attributes these optimisations + * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. + * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) + * I've just become aware of another tweak to be made, again from Wei Dai, + * in F_40_59, (x&a)|(y&a) -> (x|y)&a + */ +#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) +#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) +#define F_60_79(b,c,d) F_20_39(b,c,d) + +#ifdef SHA_0 +#undef Xupdate +#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\ + (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]); +#endif +#ifdef SHA_1 +#undef Xupdate +#define Xupdate(a,i,ia,ib,ic,id) (a)=\ + (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\ + X[(i)&0x0f]=(a)=ROTATE((a),1); +#endif + +#define BODY_00_15(i,a,b,c,d,e,f,xa) \ + (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,i,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_32_39(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_40_59(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ + (b)=ROTATE((b),30); + +#define BODY_60_79(i,a,b,c,d,e,f,xa) \ + Xupdate(f,i,xa,xa,xa,xa); \ + (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ + (b)=ROTATE((b),30); + diff --git a/src/lib/libssl/src/crypto/stack/Makefile.ssl b/src/lib/libssl/src/crypto/stack/Makefile.ssl new file mode 100644 index 0000000000..0d232c08cf --- /dev/null +++ b/src/lib/libssl/src/crypto/stack/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/stack/Makefile +# + +DIR= stack +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=stack.c +LIBOBJ=stack.o + +SRC= $(LIBSRC) + +EXHEADER= stack.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/txt_db/Makefile.ssl b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl new file mode 100644 index 0000000000..76e511534f --- /dev/null +++ b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl @@ -0,0 +1,80 @@ +# +# SSLeay/crypto/txt_db/Makefile +# + +DIR= txt_db +TOP= ../.. +CC= cc +INCLUDES= +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC=txt_db.c +LIBOBJ=txt_db.o + +SRC= $(LIBSRC) + +EXHEADER= txt_db.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/x509/Makefile.ssl b/src/lib/libssl/src/crypto/x509/Makefile.ssl new file mode 100644 index 0000000000..1c1ca2ffa0 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/Makefile.ssl @@ -0,0 +1,96 @@ +# +# SSLeay/crypto/x509/Makefile +# + +DIR= x509 +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=x509 +ERRC=x509_err +GENERAL=Makefile README +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \ + x509_obj.c x509_req.c x509_vfy.c \ + x509_set.c x509rset.c $(ERRC).c \ + x509name.c x509_v3.c x509_ext.c x509pack.c \ + x509type.c x509_lu.c x_all.c x509_txt.c \ + by_file.c by_dir.c \ + v3_net.c v3_x509.c +LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \ + x509_obj.o x509_req.o x509_vfy.o \ + x509_set.o x509rset.o $(ERRC).o \ + x509name.o x509_v3.o x509_ext.o x509pack.o \ + x509type.o x509_lu.o x_all.o x509_txt.o \ + by_file.o by_dir.o \ + v3_net.o v3_x509.o + +SRC= $(LIBSRC) + +EXHEADER= x509.h x509_vfy.h +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../../include $(EXHEADER) + $(TOP)/util/mklink.sh ../../test $(TEST) + $(TOP)/util/mklink.sh ../../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/crypto/x509/attrib b/src/lib/libssl/src/crypto/x509/attrib new file mode 100644 index 0000000000..37f6cd755f --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/attrib @@ -0,0 +1,38 @@ + +PKCS7 + STACK of X509_ATTRIBUTES + ASN1_OBJECT + STACK of ASN1_TYPE + +So it is + +p7.xa[].obj +p7.xa[].data[] + +get_obj_by_nid(STACK , nid) +get_num_by_nid(STACK , nid) +get_data_by_nid(STACK , nid, index) + +X509_ATTRIBUTE *X509_ATTRIBUTE_new(void ); +void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a); + +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **ex, + int nid, STACK *value); + +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **ex, + int nid, STACK *value); + +int X509_ATTRIBUTE_set_object(X509_ATTRIBUTE *ex,ASN1_OBJECT *obj); +int X509_ATTRIBUTE_add_data(X509_ATTRIBUTE *ex, int index, + ASN1_TYPE *value); + +ASN1_OBJECT * X509_ATTRIBUTE_get_object(X509_ATTRIBUTE *ex); +int X509_ATTRIBUTE_get_num(X509_ATTRIBUTE *ne); +ASN1_TYPE * X509_ATTRIBUTE_get_data(X509_ATTRIBUTE *ne,int index); + +ASN1_TYPE * X509_ATTRIBUTE_get_data_by_NID(X509_ATTRIBUTE *ne, + ASN1_OBJECT *obj); + +X509_ATTRUBUTE *PKCS7_get_s_att_by_NID(PKCS7 *p7,int nid); +X509_ATTRUBUTE *PKCS7_get_u_att_by_NID(PKCS7 *p7,int nid); + diff --git a/src/lib/libssl/src/crypto/x509/v3_net.c b/src/lib/libssl/src/crypto/x509/v3_net.c new file mode 100644 index 0000000000..0c2d276d13 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/v3_net.c @@ -0,0 +1,87 @@ +/* crypto/x509/v3_net.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "stack.h" +#include "cryptlib.h" +#include "asn1.h" +#include "objects.h" +#include "x509.h" + +#define NETSCAPE_X509_EXT_NUM 8 + +static X509_EXTENSION_METHOD netscape_x509_ext[NETSCAPE_X509_EXT_NUM]={ +{NID_netscape_ca_policy_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_ssl_server_name, V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_revocation_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_base_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_cert_type,V_ASN1_BIT_STRING,X509_EXT_PACK_STRING}, +{NID_netscape_ca_revocation_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_renewal_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, +{NID_netscape_comment,V_ASN1_IA5STRING,X509_EXT_PACK_STRING}, + }; + +int X509v3_add_netscape_extensions() + { + int i; + + for (i=0; i +#include +#include "stack.h" +#include "cryptlib.h" +#include "bio.h" +#include "asn1.h" +#include "objects.h" +#include "x509.h" + +#if 0 +static int i2a_key_usage(BIO *bp, X509 *x); +static int a2i_key_usage(X509 *x, char *str, int len); +#endif + +int X509v3_get_key_usage(X509 *x); +int X509v3_set_key_usage(X509 *x,unsigned int use); +int i2a_X509v3_key_usage(BIO *bp, unsigned int use); +unsigned int a2i_X509v3_key_usage(char *p); + +#define STD_X509_EXT_NUM 9 + +#if 0 +static X509_OBJECTS std_x509_ext[STD_X509_EXT_NUM]={ +{NID_subject_key_identifier, NULL,NULL}, +{NID_key_usage, a2i_key_usage,i2a_key_usage}, /**/ +{NID_private_key_usage_period, NULL,NULL}, +{NID_subject_alt_name, NULL,NULL}, +{NID_issuer_alt_name, NULL,NULL}, +{NID_basic_constraints, NULL,NULL}, +{NID_crl_number, NULL,NULL}, +{NID_certificate_policies, NULL,NULL}, +{NID_authority_key_identifier, NULL,NULL}, + }; +#endif + +int X509v3_add_standard_extensions() + { + +#if 0 + for (i=0; i 0) + { + i=1; + data[0]=use&0xff; + } + if (use > 0xff) + { + i=2; + data[1]=(use>>8)&0xff; + } + return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1); + } + diff --git a/src/lib/libssl/src/crypto/x509/x509.doc b/src/lib/libssl/src/crypto/x509/x509.doc new file mode 100644 index 0000000000..73cfc9f034 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/x509.doc @@ -0,0 +1,27 @@ +X509_verify() +X509_sign() + +X509_get_version() +X509_get_serialNumber() +X509_get_issuer() +X509_get_subject() +X509_get_notBefore() +X509_get_notAfter() +X509_get_pubkey() + +X509_set_version() +X509_set_serialNumber() +X509_set_issuer() +X509_set_subject() +X509_set_notBefore() +X509_set_notAfter() +X509_set_pubkey() + +X509_get_extensions() +X509_set_extensions() + +X509_EXTENSIONS_clear() +X509_EXTENSIONS_retrieve() +X509_EXTENSIONS_add() +X509_EXTENSIONS_delete() + diff --git a/src/lib/libssl/src/crypto/x509/x509.err b/src/lib/libssl/src/crypto/x509/x509.err new file mode 100644 index 0000000000..8d0862d7d1 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/x509.err @@ -0,0 +1,46 @@ +/* Error codes for the X509 functions. */ + +/* Function codes. */ +#define X509_F_ADD_CERT_DIR 100 +#define X509_F_BY_FILE_CTRL 101 +#define X509_F_DIR_CTRL 102 +#define X509_F_GET_CERT_BY_SUBJECT 103 +#define X509_F_X509V3_ADD_EXT 104 +#define X509_F_X509V3_ADD_EXTENSION 105 +#define X509_F_X509V3_PACK_STRING 106 +#define X509_F_X509V3_UNPACK_STRING 107 +#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 +#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 +#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 +#define X509_F_X509_LOAD_CERT_FILE 111 +#define X509_F_X509_LOAD_CRL_FILE 112 +#define X509_F_X509_NAME_ADD_ENTRY 113 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 +#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 +#define X509_F_X509_NAME_ONELINE 116 +#define X509_F_X509_NAME_PRINT 117 +#define X509_F_X509_PRINT_FP 118 +#define X509_F_X509_PUBKEY_GET 119 +#define X509_F_X509_PUBKEY_SET 120 +#define X509_F_X509_REQ_PRINT 121 +#define X509_F_X509_REQ_PRINT_FP 122 +#define X509_F_X509_REQ_TO_X509 123 +#define X509_F_X509_STORE_ADD_CERT 124 +#define X509_F_X509_STORE_ADD_CRL 125 +#define X509_F_X509_TO_X509_REQ 126 +#define X509_F_X509_VERIFY_CERT 127 + +/* Reason codes. */ +#define X509_R_BAD_X509_FILETYPE 100 +#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +#define X509_R_ERR_ASN1_LIB 102 +#define X509_R_LOADING_CERT_DIR 103 +#define X509_R_LOADING_DEFAULTS 104 +#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +#define X509_R_SHOULD_RETRY 106 +#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +#define X509_R_UNKNOWN_NID 109 +#define X509_R_UNKNOWN_STRING_TYPE 110 +#define X509_R_UNSUPPORTED_ALGORITHM 111 +#define X509_R_WRONG_LOOKUP_TYPE 112 diff --git a/src/lib/libssl/src/crypto/x509/x509pack.c b/src/lib/libssl/src/crypto/x509/x509pack.c new file mode 100644 index 0000000000..846f125859 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/x509pack.c @@ -0,0 +1,157 @@ +/* crypto/x509/x509pack.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include "stack.h" +#include "cryptlib.h" +#include "asn1.h" +#include "objects.h" +#include "evp.h" +#include "x509.h" + +ASN1_OCTET_STRING *X509v3_pack_string(ex,type,bytes,len) +ASN1_OCTET_STRING **ex; +int type; +unsigned char *bytes; +int len; + { + ASN1_OCTET_STRING *os; + ASN1_STRING str; + unsigned char *p; + int i; + + if ((ex == NULL) || (*ex == NULL)) + os=ASN1_OCTET_STRING_new(); + else + os= *ex; + + if (len < 0) len=strlen((char *)bytes); + str.length=len; + str.type=type; + str.data=bytes; + + /* str now holds the data, we just have to copy it into ->value */ + + switch (type) + { + case V_ASN1_BIT_STRING: + i=i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,NULL); + if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i)) + goto err; + p=(unsigned char *)os->data; + i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,&p); + break; + case V_ASN1_OCTET_STRING: + i=i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,NULL); + if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i)) + goto err; + p=(unsigned char *)os->data; + i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,&p); + break; + case V_ASN1_IA5STRING: + case V_ASN1_PRINTABLESTRING: + case V_ASN1_T61STRING: + i=i2d_ASN1_bytes(&str,NULL,type,V_ASN1_UNIVERSAL); + if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i)) + goto err; + p=(unsigned char *)os->data; + i=i2d_ASN1_bytes(&str,&p,type,V_ASN1_UNIVERSAL); + break; + default: + X509err(X509_F_X509V3_PACK_STRING,X509_R_UNKNOWN_STRING_TYPE); + goto err; + } + os->length=i; + + if ((ex != NULL) && (os != *ex)) + *ex=os; + return(os); +err: + return(NULL); + } + +ASN1_STRING *X509v3_unpack_string(ex,type,os) +ASN1_STRING **ex; +int type; +ASN1_OCTET_STRING *os; + { + unsigned char *p; + ASN1_STRING *ret=NULL; + + p=os->data; + switch (type) + { + case V_ASN1_BIT_STRING: + ret=(ASN1_STRING *)d2i_ASN1_BIT_STRING( + (ASN1_BIT_STRING **)ex,&p,os->length); + break; + case V_ASN1_OCTET_STRING: + ret=(ASN1_STRING *)d2i_ASN1_OCTET_STRING( + (ASN1_BIT_STRING **)ex,&p,os->length); + break; + case V_ASN1_IA5STRING: + case V_ASN1_PRINTABLESTRING: + case V_ASN1_T61STRING: + ret=(ASN1_STRING *)d2i_ASN1_PRINTABLE(ex,&p,os->length); + break; + default: + X509err(X509_F_X509V3_UNPACK_STRING,X509_R_UNKNOWN_STRING_TYPE); + } + return(ret); + } + diff --git a/src/lib/libssl/src/crypto/x509/x509v3.doc b/src/lib/libssl/src/crypto/x509/x509v3.doc new file mode 100644 index 0000000000..1e760a9469 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509/x509v3.doc @@ -0,0 +1,24 @@ +The 'new' system. + +The X509_EXTENSION_METHOD includes extensions and attributes and/or names. +Basically everthing that can be added to an X509 with an OID identifying it. + +It operates via 2 methods per object id. +int a2i_XXX(X509 *x,char *str,int len); +int i2a_XXX(BIO *bp,X509 *x); + +The a2i_XXX function will add the object with a value converted from the +string into the X509. Len can be -1 in which case the length is calculated +via strlen(str). Applications can always use direct knowledge to load and +unload the relevent objects themselves. + +i2a_XXX will print to the passed BIO, a text representation of the +relevet object. Use a memory BIO if you want it printed to a buffer :-). + +X509_add_by_NID(X509 *x,int nid,char *str,int len); +X509_add_by_OBJ(X509 *x,ASN1_OBJECT *obj,char *str,int len); + +X509_print_by_name(BIO *bp,X509 *x); +X509_print_by_NID(BIO *bp,X509 *x); +X509_print_by_OBJ(BIO *bp,X509 *x); + diff --git a/src/lib/libssl/src/crypto/x509v3/format b/src/lib/libssl/src/crypto/x509v3/format new file mode 100644 index 0000000000..3307978121 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509v3/format @@ -0,0 +1,92 @@ +AuthorityKeyIdentifier + { + keyIdentifier [0] OCTET_STRING OPTIONAL + authorityCertIssuer [1] GeneralNames OPTIONAL + authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL + } + +SubjectKeyIdentifier OCTET_STRING + +KeyUsage + { + BIT_STRING + digitalSignature 0 + nonRepudiation 1 + keyEncipherment 2 + dataEncipherment 3 + keyAgreement 4 + keyCertSign 5 + cRLSign 6 + encipherOnly 7 + decipherOnly 8 + } + +extKeyUsage + { + SEQUENCE of OBJECT_IDENTIFIER + } + +privateKeyUsagePeriod + { + notBefore [0] GeneralizedTime OPTIONAL + notAfter [1] GeneralizedTime OPTIONAL + } + +certificatePoliciesSyntax + SEQUENCE of PoliciesInformation + +PoliciesInformation XXX +policyMappings XXX +supportedAlgorithms XXX + +subjectAltName + GeneralNames sequence of GeneralName + +GeneralName + { + otherName [0] INSTANCE OF OTHER-NAME + rfc882Name [1] IA5String + dNSName [2] IA5String + x400Address [3] ORAddress + directoryName [4] Name + ediPartyName [5] + { + nameAssigner [0] DirectoryString OPTIONAL + partyName [1] DirectoryString + } + uniformResourceIdentifier [6] IA5String + iPAddress [7] OCTET_STRING + registeredID [8] OBJECT_IDENTIFIER + } + +issuerAltName + GeneralNames sequence of GeneralName + +subjectDirectoryAttribute SEQUENCE of Attribute + +basicConstraints + { + cA BOOLEAN default FALSE + pathLenConstraint INTEGER OPTIONAL + } + +nameConstraints + { + permittedSubtrees [0] sequence of GeneralSubtree OPTIONAL + excludedSubtrees [1] sequence of GeneralSubtree OPTIONAL + } + +GeneralSubtree + { + base GeneralName + minimum [0] BaseDistance DEFAULT 0 + maximum [1] BaseDistance OPTIONAL + } + +PolicyConstraints + { + requiredExplicitPolicy [0] SkipCerts OPTIONAL + inhibitPolicyMapping [1] SkipCerts OPTIONAL + } +SkipCerts == INTEGER + diff --git a/src/lib/libssl/src/crypto/x509v3/header b/src/lib/libssl/src/crypto/x509v3/header new file mode 100644 index 0000000000..3d791ca3dd --- /dev/null +++ b/src/lib/libssl/src/crypto/x509v3/header @@ -0,0 +1,6 @@ +int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size) +int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a) +int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp) +ASN1_INTEGER * d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,long length) + + diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ku.c b/src/lib/libssl/src/crypto/x509v3/v3_ku.c new file mode 100644 index 0000000000..87c7402f43 --- /dev/null +++ b/src/lib/libssl/src/crypto/x509v3/v3_ku.c @@ -0,0 +1,318 @@ +/* crypto/x509v3/v3_ku.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include "stack.h" +#include "cryptlib.h" +#include "bio.h" +#include "asn1.h" +#include "objects.h" +#include "x509.h" + +X509_EXTENSION_METHOD X509v3_key_usage_method= + { + NID_key_usage, + ku_clear, + ex_get_bool, + ex_set_bool, + NULL, + NULL, + NULL, + NULL, + ku_a2i, + ku_i2a, + }; + +static void ku_clear(a) +X509_EXTENSION *a; + { + } + +static int ku_expand(a) +X509_EXTENSION *a; + { + ASN1_BIT_STRING *bs; + + if (a->argp == NULL) + { + bs=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,value); + if (bs == NULL) return(0); + a->argp=(char *)bs; + a->ex_free=ASN1_STRING_free; + } + return(1); + } + +static int ku_get_bool(a,num) +X509_EXTENSION *a; +int num; + { + int ret; + ASN1_BIT_STRING *bs; + + if ((a->argp == NULL) && !ku_expand(a)) + return(-1); + bs=(ASN1_BIT_STRING *)a->argp; + ret=ASN1_BIT_STRING_get_bit(bs,num); + return(ret); + } + +static int ku_set_bool(a,num,value) +X509_EXTENSION *a; +int num; +int value; + { + ASN1_BIT_STRING *a; + + if ((a->argp == NULL) && !ku_expand(a)) + return(0); + bs=(ASN1_BIT_STRING *)a->argp; + ret=ASN1_BIT_STRING_set_bit(bs,num,value); + } + +static int ku_a2i(bio,a,buf,len) +BIO *bio; +X509_EXTENSION *a; +char *buf; +int len; + { + get token + } + +static char ku_names[X509v3_N_KU_NUM]={ + X509v3_S_KU_digitalSignature, + X509v3_S_KU_nonRepudiation, + X509v3_S_KU_keyEncipherment, + X509v3_S_KU_dataEncipherment, + X509v3_S_KU_keyAgreement, + X509v3_S_KU_keyCertSign, + X509v3_S_KU_cRLSign, + X509v3_S_KU_encipherOnly, + X509v3_S_KU_decipherOnly, + }; + +static int ku_i2a(bio,a); +BIO *bio; +X509_EXTENSION *a; + { + int i,first=1; + char *c; + + for (i=0; i 0) + { + BIO_printf(bio,"%s%s",((first)?"":" "),ku_names[i]); + first=0; + } + } + } + +/***********************/ + +int X509v3_get_key_usage(x,ret) +STACK *x; +unsigned long *ret; + { + X509_EXTENSION *ext; + ASN1_STRING *st; + char *p; + int i; + + i=X509_get_ext_by_NID(x,NID_key_usage,-1); + if (i < 0) return(X509v3_KU_UNDEF); + ext=X509_get_ext(x,i); + st=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING, + X509_EXTENSION_get_data(X509_get_ext(x,i))); + + p=ASN1_STRING_data(st); + if (ASN1_STRING_length(st) == 1) + i=p[0]; + else if (ASN1_STRING_length(st) == 2) + i=p[0]|(p[1]<<8); + else + i=0; + return(i); + } + +static struct + { + char *name; + unsigned int value; + } key_usage_data[] ={ + {"digitalSignature", X509v3_KU_DIGITAL_SIGNATURE}, + {"nonRepudiation", X509v3_KU_NON_REPUDIATION}, + {"keyEncipherment", X509v3_KU_KEY_ENCIPHERMENT}, + {"dataEncipherment", X509v3_KU_DATA_ENCIPHERMENT}, + {"keyAgreement", X509v3_KU_KEY_AGREEMENT}, + {"keyCertSign", X509v3_KU_KEY_CERT_SIGN}, + {"cRLSign", X509v3_KU_CRL_SIGN}, + {"encipherOnly", X509v3_KU_ENCIPHER_ONLY}, + {"decipherOnly", X509v3_KU_DECIPHER_ONLY}, + {NULL,0}, + }; + +#if 0 +static int a2i_key_usage(x,str,len) +X509 *x; +char *str; +int len; + { + return(X509v3_set_key_usage(x,a2i_X509v3_key_usage(str))); + } + +static int i2a_key_usage(bp,x) +BIO *bp; +X509 *x; + { + return(i2a_X509v3_key_usage(bp,X509v3_get_key_usage(x))); + } +#endif + +int i2a_X509v3_key_usage(bp,use) +BIO *bp; +unsigned int use; + { + int i=0,first=1; + + for (;;) + { + if (use | key_usage_data[i].value) + { + BIO_printf(bp,"%s%s",((first)?"":" "), + key_usage_data[i].name); + first=0; + } + } + return(1); + } + +unsigned int a2i_X509v3_key_usage(p) +char *p; + { + unsigned int ret=0; + char *q,*s; + int i,n; + + q=p; + for (;;) + { + while ((*q != '\0') && isalnum(*q)) + q++; + if (*q == '\0') break; + s=q++; + while (isalnum(*q)) + q++; + n=q-s; + i=0; + for (;;) + { + if (strncmp(key_usage_data[i].name,s,n) == 0) + { + ret|=key_usage_data[i].value; + break; + } + i++; + if (key_usage_data[i].name == NULL) + return(X509v3_KU_UNDEF); + } + } + return(ret); + } + +int X509v3_set_key_usage(x,use) +X509 *x; +unsigned int use; + { + ASN1_OCTET_STRING *os; + X509_EXTENSION *ext; + int i; + unsigned char data[4]; + + i=X509_get_ext_by_NID(x,NID_key_usage,-1); + if (i < 0) + { + i=X509_get_ext_count(x)+1; + if ((ext=X509_EXTENSION_new()) == NULL) return(0); + if (!X509_add_ext(x,ext,i)) + { + X509_EXTENSION_free(ext); + return(0); + } + } + else + ext=X509_get_ext(x,i); + + /* fill in 'ext' */ + os=X509_EXTENSION_get_data(ext); + + i=0; + if (use > 0) + { + i=1; + data[0]=use&0xff; + } + if (use > 0xff) + { + i=2; + data[1]=(use>>8)&0xff; + } + return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1); + } + diff --git a/src/lib/libssl/src/dep/crypto.txt b/src/lib/libssl/src/dep/crypto.txt new file mode 100644 index 0000000000..9e5144fec6 --- /dev/null +++ b/src/lib/libssl/src/dep/crypto.txt @@ -0,0 +1,1043 @@ +ASN1_BIT_STRING_asn1_meth +ASN1_BIT_STRING_get_bit +ASN1_BIT_STRING_set_bit +ASN1_HEADER_free +ASN1_HEADER_new +ASN1_IA5STRING_asn1_meth +ASN1_INTEGER_get +ASN1_INTEGER_set +ASN1_INTEGER_to_BN +ASN1_OBJECT_create +ASN1_OBJECT_free +ASN1_OBJECT_new +ASN1_PRINTABLE_type +ASN1_STRING_cmp +ASN1_STRING_dup +ASN1_STRING_free +ASN1_STRING_new +ASN1_STRING_print +ASN1_STRING_set +ASN1_STRING_type_new +ASN1_TYPE_free +ASN1_TYPE_get +ASN1_TYPE_new +ASN1_TYPE_set +ASN1_UNIVERSALSTRING_to_string +ASN1_UTCTIME_check +ASN1_UTCTIME_print +ASN1_UTCTIME_set +ASN1_check_infinite_end +ASN1_d2i_bio +ASN1_d2i_fp +ASN1_digest +ASN1_dup +ASN1_get_object +ASN1_i2d_bio +ASN1_i2d_fp +ASN1_object_size +ASN1_parse +ASN1_put_object +ASN1_sign +ASN1_verify +BF_cbc_encrypt +BF_cfb64_encrypt +BF_decrypt +BF_ecb_encrypt +BF_encrypt +BF_ofb64_encrypt +BF_options +BF_set_key +BIO_ACCEPT_free +BIO_ACCEPT_new +BIO_CONNECT_free +BIO_CONNECT_new +BIO_accept +BIO_copy_next_retry +BIO_ctrl +BIO_ctrl_int +BIO_debug_callback +BIO_dump +BIO_dup_chain +BIO_f_base64 +BIO_f_buffer +BIO_f_cipher +BIO_f_md +BIO_f_nbio_test +BIO_f_null +BIO_f_proxy_server +BIO_fd_non_fatal_error +BIO_fd_should_retry +BIO_find_type +BIO_free +BIO_free_all +BIO_get_accept_socket +BIO_get_ex_data +BIO_get_ex_new_index +BIO_get_filter_bio +BIO_get_host_ip +BIO_get_port +BIO_get_retry_BIO +BIO_get_retry_reason +BIO_gethostbyname +BIO_gets +BIO_ghbn_ctrl +BIO_new +BIO_new_accept +BIO_new_connect +BIO_new_fd +BIO_new_file +BIO_new_fp +BIO_new_socket +BIO_pop +BIO_printf +BIO_ptr_ctrl +BIO_push +BIO_puts +BIO_read +BIO_s_accept +BIO_s_connect +BIO_s_fd +BIO_s_file +BIO_s_mem +BIO_s_null +BIO_s_proxy_client +BIO_s_socket +BIO_set +BIO_set_cipher +BIO_set_ex_data +BIO_set_tcp_ndelay +BIO_sock_cleanup +BIO_sock_error +BIO_sock_init +BIO_sock_non_fatal_error +BIO_sock_should_retry +BIO_socket_ioctl +BIO_write +BN_BLINDING_convert +BN_BLINDING_free +BN_BLINDING_invert +BN_BLINDING_new +BN_BLINDING_update +BN_CTX_free +BN_CTX_new +BN_MONT_CTX_free +BN_MONT_CTX_new +BN_MONT_CTX_set +BN_add +BN_add_word +BN_bin2bn +BN_bn2bin +BN_bn2dec +BN_bn2hex +BN_bn2mpi +BN_clear +BN_clear_bit +BN_clear_free +BN_cmp +BN_copy +BN_dec2bn +BN_div +BN_div_word +BN_dup +BN_exp +BN_free +BN_from_montgomery +BN_gcd +BN_generate_prime +BN_get_word +BN_hex2bn +BN_is_bit_set +BN_is_prime +BN_lshift +BN_lshift1 +BN_mask_bits +BN_mod +BN_mod_exp +BN_mod_exp_mont +BN_mod_exp_recp +BN_mod_exp_simple +BN_mod_inverse +BN_mod_mul +BN_mod_mul_montgomery +BN_mod_mul_reciprocal +BN_mod_word +BN_mpi2bn +BN_mul +BN_mul_word +BN_new +BN_num_bits +BN_num_bits_word +BN_options +BN_print +BN_print_fp +BN_rand +BN_reciprocal +BN_rshift +BN_rshift1 +BN_set_bit +BN_set_word +BN_sqr +BN_sub +BN_sub_word +BN_to_ASN1_INTEGER +BN_ucmp +BN_value_one +BUF_MEM_free +BUF_MEM_grow +BUF_MEM_new +BUF_strdup +CAST_cbc_encrypt +CAST_cfb64_encrypt +CAST_decrypt +CAST_ecb_encrypt +CAST_encrypt +CAST_ofb64_encrypt +CAST_set_key +CONF_free +CONF_get_number +CONF_get_section +CONF_get_string +CONF_load +CRYPTO_add_lock +CRYPTO_dbg_free +CRYPTO_dbg_malloc +CRYPTO_dbg_realloc +CRYPTO_dbg_remalloc +CRYPTO_dup_ex_data +CRYPTO_free +CRYPTO_free_ex_data +CRYPTO_get_add_lock_callback +CRYPTO_get_ex_data +CRYPTO_get_ex_new_index +CRYPTO_get_id_callback +CRYPTO_get_lock_name +CRYPTO_get_locking_callback +CRYPTO_get_mem_functions +CRYPTO_get_new_lockid +CRYPTO_lock +CRYPTO_malloc +CRYPTO_mem_ctrl +CRYPTO_mem_leaks +CRYPTO_mem_leaks_cb +CRYPTO_mem_leaks_fp +CRYPTO_new_ex_data +CRYPTO_realloc +CRYPTO_remalloc +CRYPTO_set_add_lock_callback +CRYPTO_set_ex_data +CRYPTO_set_id_callback +CRYPTO_set_locking_callback +CRYPTO_set_mem_functions +CRYPTO_thread_id +DH_check +DH_compute_key +DH_free +DH_generate_key +DH_generate_parameters +DH_new +DH_size +DHparams_print +DHparams_print_fp +DSA_free +DSA_generate_key +DSA_generate_parameters +DSA_is_prime +DSA_new +DSA_print +DSA_print_fp +DSA_sign +DSA_sign_setup +DSA_size +DSA_verify +DSAparams_print +DSAparams_print_fp +ERR_clear_error +ERR_error_string +ERR_free_strings +ERR_func_error_string +ERR_get_err_state_table +ERR_get_error +ERR_get_error_line +ERR_get_next_error_library +ERR_get_state +ERR_get_string_table +ERR_lib_error_string +ERR_load_ASN1_strings +ERR_load_BIO_strings +ERR_load_BN_strings +ERR_load_BUF_strings +ERR_load_CONF_strings +ERR_load_CRYPTO_strings +ERR_load_DH_strings +ERR_load_DSA_strings +ERR_load_ERR_strings +ERR_load_EVP_strings +ERR_load_OBJ_strings +ERR_load_PEM_strings +ERR_load_PKCS7_strings +ERR_load_PROXY_strings +ERR_load_RSA_strings +ERR_load_X509_strings +ERR_load_crypto_strings +ERR_load_strings +ERR_peek_error +ERR_peek_error_line +ERR_print_errors +ERR_print_errors_fp +ERR_put_error +ERR_reason_error_string +ERR_remove_state +EVP_BytesToKey +EVP_CIPHER_CTX_cleanup +EVP_CIPHER_CTX_init +EVP_CipherFinal +EVP_CipherInit +EVP_CipherUpdate +EVP_DecodeBlock +EVP_DecodeFinal +EVP_DecodeInit +EVP_DecodeUpdate +EVP_DecryptFinal +EVP_DecryptInit +EVP_DecryptUpdate +EVP_DigestFinal +EVP_DigestInit +EVP_DigestUpdate +EVP_EncodeBlock +EVP_EncodeFinal +EVP_EncodeInit +EVP_EncodeUpdate +EVP_EncryptFinal +EVP_EncryptInit +EVP_EncryptUpdate +EVP_OpenFinal +EVP_OpenInit +EVP_PKEY_assign +EVP_PKEY_bits +EVP_PKEY_cmp_parameters +EVP_PKEY_copy_parameters +EVP_PKEY_free +EVP_PKEY_missing_parameters +EVP_PKEY_new +EVP_PKEY_save_parameters +EVP_PKEY_size +EVP_PKEY_type +EVP_SealFinal +EVP_SealInit +EVP_SignFinal +EVP_VerifyFinal +EVP_add_alias +EVP_add_cipher +EVP_add_digest +EVP_bf_cbc +EVP_bf_cfb +EVP_bf_ecb +EVP_bf_ofb +EVP_cast5_cbc +EVP_cast5_cfb +EVP_cast5_ecb +EVP_cast5_ofb +EVP_cleanup +EVP_delete_alias +EVP_des_cbc +EVP_des_cfb +EVP_des_ecb +EVP_des_ede +EVP_des_ede3 +EVP_des_ede3_cbc +EVP_des_ede3_cfb +EVP_des_ede3_ofb +EVP_des_ede_cbc +EVP_des_ede_cfb +EVP_des_ede_ofb +EVP_des_ofb +EVP_desx_cbc +EVP_dss +EVP_dss1 +EVP_enc_null +EVP_get_cipherbyname +EVP_get_digestbyname +EVP_get_pw_prompt +EVP_idea_cbc +EVP_idea_cfb +EVP_idea_ecb +EVP_idea_ofb +EVP_md2 +EVP_md5 +EVP_md_null +EVP_mdc2 +EVP_rc2_40_cbc +EVP_rc2_cbc +EVP_rc2_cfb +EVP_rc2_ecb +EVP_rc2_ofb +EVP_rc4 +EVP_rc4_40 +EVP_read_pw_string +EVP_set_pw_prompt +EVP_sha +EVP_sha1 +HMAC +HMAC_Final +HMAC_Init +HMAC_Update +HMAC_cleanup +MD2 +MD2_Final +MD2_Init +MD2_Update +MD2_options +MD5 +MD5_Final +MD5_Init +MD5_Transform +MD5_Update +MDC2 +MDC2_Final +MDC2_Init +MDC2_Update +NETSCAPE_SPKAC_free +NETSCAPE_SPKAC_new +NETSCAPE_SPKI_free +NETSCAPE_SPKI_new +NETSCAPE_SPKI_sign +NETSCAPE_SPKI_verify +OBJ_add_object +OBJ_bsearch +OBJ_cleanup +OBJ_cmp +OBJ_create +OBJ_create_objects +OBJ_dup +OBJ_ln2nid +OBJ_new_nid +OBJ_nid2ln +OBJ_nid2obj +OBJ_nid2sn +OBJ_obj2nid +OBJ_sn2nid +OBJ_txt2nid +PEM_ASN1_read +PEM_ASN1_read_bio +PEM_ASN1_write +PEM_ASN1_write_bio +PEM_SealFinal +PEM_SealInit +PEM_SealUpdate +PEM_SignFinal +PEM_SignInit +PEM_SignUpdate +PEM_X509_INFO_read +PEM_X509_INFO_read_bio +PEM_X509_INFO_write_bio +PEM_dek_info +PEM_do_header +PEM_get_EVP_CIPHER_INFO +PEM_proc_type +PEM_read +PEM_read_DHparams +PEM_read_DSAPrivateKey +PEM_read_DSAparams +PEM_read_PKCS7 +PEM_read_PrivateKey +PEM_read_RSAPrivateKey +PEM_read_RSAPublicKey +PEM_read_X509 +PEM_read_X509_CRL +PEM_read_X509_REQ +PEM_read_bio +PEM_read_bio_DHparams +PEM_read_bio_DSAPrivateKey +PEM_read_bio_DSAparams +PEM_read_bio_PKCS7 +PEM_read_bio_PrivateKey +PEM_read_bio_RSAPrivateKey +PEM_read_bio_RSAPublicKey +PEM_read_bio_X509 +PEM_read_bio_X509_CRL +PEM_read_bio_X509_REQ +PEM_write +PEM_write_DHparams +PEM_write_DSAPrivateKey +PEM_write_DSAparams +PEM_write_PKCS7 +PEM_write_PrivateKey +PEM_write_RSAPrivateKey +PEM_write_RSAPublicKey +PEM_write_X509 +PEM_write_X509_CRL +PEM_write_X509_REQ +PEM_write_bio +PEM_write_bio_DHparams +PEM_write_bio_DSAPrivateKey +PEM_write_bio_DSAparams +PEM_write_bio_PKCS7 +PEM_write_bio_PrivateKey +PEM_write_bio_RSAPrivateKey +PEM_write_bio_RSAPublicKey +PEM_write_bio_X509 +PEM_write_bio_X509_CRL +PEM_write_bio_X509_REQ +PKCS7_DIGEST_free +PKCS7_DIGEST_new +PKCS7_ENCRYPT_free +PKCS7_ENCRYPT_new +PKCS7_ENC_CONTENT_free +PKCS7_ENC_CONTENT_new +PKCS7_ENVELOPE_free +PKCS7_ENVELOPE_new +PKCS7_ISSUER_AND_SERIAL_digest +PKCS7_ISSUER_AND_SERIAL_free +PKCS7_ISSUER_AND_SERIAL_new +PKCS7_RECIP_INFO_free +PKCS7_RECIP_INFO_new +PKCS7_SIGNED_free +PKCS7_SIGNED_new +PKCS7_SIGNER_INFO_free +PKCS7_SIGNER_INFO_new +PKCS7_SIGNER_INFO_set +PKCS7_SIGN_ENVELOPE_free +PKCS7_SIGN_ENVELOPE_new +PKCS7_add_certificate +PKCS7_add_crl +PKCS7_add_signature +PKCS7_add_signer +PKCS7_cert_from_signer_info +PKCS7_content_free +PKCS7_content_new +PKCS7_ctrl +PKCS7_dataInit +PKCS7_dataSign +PKCS7_dataVerify +PKCS7_dup +PKCS7_free +PKCS7_get_signer_info +PKCS7_new +PKCS7_set_content +PKCS7_set_type +PROXY_ENTRY_add_noproxy +PROXY_ENTRY_clear_noproxy +PROXY_ENTRY_free +PROXY_ENTRY_get_noproxy +PROXY_ENTRY_new +PROXY_ENTRY_set_server +PROXY_add_noproxy +PROXY_add_server +PROXY_check_by_host +PROXY_check_url +PROXY_clear_noproxy +PROXY_free +PROXY_get_noproxy +PROXY_get_proxies +PROXY_get_proxy_entry +PROXY_load_conf +PROXY_new +PROXY_print +RAND_bytes +RAND_cleanup +RAND_file_name +RAND_load_file +RAND_seed +RAND_write_file +RC2_cbc_encrypt +RC2_cfb64_encrypt +RC2_decrypt +RC2_ecb_encrypt +RC2_encrypt +RC2_ofb64_encrypt +RC2_set_key +RC4 +RC4_options +RC4_set_key +RC5_32_cbc_encrypt +RC5_32_cfb64_encrypt +RC5_32_decrypt +RC5_32_ecb_encrypt +RC5_32_encrypt +RC5_32_ofb64_encrypt +RC5_32_set_key +RIPEMD160 +RIPEMD160_Final +RIPEMD160_Init +RIPEMD160_Transform +RIPEMD160_Update +RSAPrivateKey_asn1_meth +RSAPrivateKey_dup +RSAPublicKey_dup +RSA_PKCS1_SSLeay +RSA_blinding_off +RSA_blinding_on +RSA_flags +RSA_free +RSA_generate_key +RSA_get_ex_data +RSA_get_ex_new_index +RSA_new +RSA_new_method +RSA_padding_add_PKCS1_type_1 +RSA_padding_add_PKCS1_type_2 +RSA_padding_add_SSLv23 +RSA_padding_add_none +RSA_padding_check_PKCS1_type_1 +RSA_padding_check_PKCS1_type_2 +RSA_padding_check_SSLv23 +RSA_padding_check_none +RSA_print +RSA_print_fp +RSA_private_decrypt +RSA_private_encrypt +RSA_public_decrypt +RSA_public_encrypt +RSA_set_default_method +RSA_set_ex_data +RSA_sign +RSA_sign_ASN1_OCTET_STRING +RSA_size +RSA_verify +RSA_verify_ASN1_OCTET_STRING +SHA +SHA1 +SHA1_Final +SHA1_Init +SHA1_Transform +SHA1_Update +SHA_Final +SHA_Init +SHA_Transform +SHA_Update +SSLeay +SSLeay_add_all_algorithms +SSLeay_add_all_ciphers +SSLeay_add_all_digests +SSLeay_version +TXT_DB_create_index +TXT_DB_free +TXT_DB_get_by_index +TXT_DB_insert +TXT_DB_read +TXT_DB_write +X509_ALGOR_free +X509_ALGOR_new +X509_ATTRIBUTE_free +X509_ATTRIBUTE_new +X509_CINF_free +X509_CINF_new +X509_CRL_INFO_free +X509_CRL_INFO_new +X509_CRL_add_ext +X509_CRL_cmp +X509_CRL_delete_ext +X509_CRL_dup +X509_CRL_free +X509_CRL_get_ext +X509_CRL_get_ext_by_NID +X509_CRL_get_ext_by_OBJ +X509_CRL_get_ext_by_critical +X509_CRL_get_ext_count +X509_CRL_new +X509_CRL_sign +X509_CRL_verify +X509_EXTENSION_create_by_NID +X509_EXTENSION_create_by_OBJ +X509_EXTENSION_dup +X509_EXTENSION_free +X509_EXTENSION_get_critical +X509_EXTENSION_get_data +X509_EXTENSION_get_object +X509_EXTENSION_new +X509_EXTENSION_set_critical +X509_EXTENSION_set_data +X509_EXTENSION_set_object +X509_INFO_free +X509_INFO_new +X509_LOOKUP_by_alias +X509_LOOKUP_by_fingerprint +X509_LOOKUP_by_issuer_serial +X509_LOOKUP_by_subject +X509_LOOKUP_ctrl +X509_LOOKUP_file +X509_LOOKUP_free +X509_LOOKUP_hash_dir +X509_LOOKUP_init +X509_LOOKUP_new +X509_LOOKUP_shutdown +X509_NAME_ENTRY_create_by_NID +X509_NAME_ENTRY_create_by_OBJ +X509_NAME_ENTRY_dup +X509_NAME_ENTRY_free +X509_NAME_ENTRY_get_data +X509_NAME_ENTRY_get_object +X509_NAME_ENTRY_new +X509_NAME_ENTRY_set_data +X509_NAME_ENTRY_set_object +X509_NAME_add_entry +X509_NAME_cmp +X509_NAME_delete_entry +X509_NAME_digest +X509_NAME_dup +X509_NAME_entry_count +X509_NAME_free +X509_NAME_get_entry +X509_NAME_get_index_by_NID +X509_NAME_get_index_by_OBJ +X509_NAME_get_text_by_NID +X509_NAME_get_text_by_OBJ +X509_NAME_hash +X509_NAME_new +X509_NAME_oneline +X509_NAME_print +X509_NAME_set +X509_OBJECT_free_contents +X509_OBJECT_retrive_by_subject +X509_OBJECT_up_ref_count +X509_PKEY_free +X509_PKEY_new +X509_PUBKEY_free +X509_PUBKEY_get +X509_PUBKEY_new +X509_PUBKEY_set +X509_REQ_INFO_free +X509_REQ_INFO_new +X509_REQ_dup +X509_REQ_free +X509_REQ_get_pubkey +X509_REQ_new +X509_REQ_print +X509_REQ_print_fp +X509_REQ_set_pubkey +X509_REQ_set_subject_name +X509_REQ_set_version +X509_REQ_sign +X509_REQ_to_X509 +X509_REQ_verify +X509_REVOKED_add_ext +X509_REVOKED_delete_ext +X509_REVOKED_free +X509_REVOKED_get_ext +X509_REVOKED_get_ext_by_NID +X509_REVOKED_get_ext_by_OBJ +X509_REVOKED_get_ext_by_critical +X509_REVOKED_get_ext_count +X509_REVOKED_new +X509_SIG_free +X509_SIG_new +X509_STORE_CTX_cleanup +X509_STORE_CTX_get_chain +X509_STORE_CTX_get_current_cert +X509_STORE_CTX_get_error +X509_STORE_CTX_get_error_depth +X509_STORE_CTX_get_ex_data +X509_STORE_CTX_get_ex_new_index +X509_STORE_CTX_init +X509_STORE_CTX_set_cert +X509_STORE_CTX_set_chain +X509_STORE_CTX_set_error +X509_STORE_CTX_set_ex_data +X509_STORE_add_cert +X509_STORE_add_crl +X509_STORE_add_lookup +X509_STORE_free +X509_STORE_get_by_subject +X509_STORE_load_locations +X509_STORE_new +X509_STORE_set_default_paths +X509_VAL_free +X509_VAL_new +X509_add_ext +X509_asn1_meth +X509_certificate_type +X509_check_private_key +X509_cmp_current_time +X509_delete_ext +X509_digest +X509_dup +X509_find_by_issuer_and_serial +X509_find_by_subject +X509_free +X509_get_default_cert_area +X509_get_default_cert_dir +X509_get_default_cert_dir_env +X509_get_default_cert_file +X509_get_default_cert_file_env +X509_get_default_private_dir +X509_get_ext +X509_get_ext_by_NID +X509_get_ext_by_OBJ +X509_get_ext_by_critical +X509_get_ext_count +X509_get_issuer_name +X509_get_pubkey +X509_get_pubkey_parameters +X509_get_serialNumber +X509_get_subject_name +X509_gmtime_adj +X509_issuer_and_serial_cmp +X509_issuer_and_serial_hash +X509_issuer_name_cmp +X509_issuer_name_hash +X509_load_cert_file +X509_load_crl_file +X509_new +X509_print +X509_print_fp +X509_set_issuer_name +X509_set_notAfter +X509_set_notBefore +X509_set_pubkey +X509_set_serialNumber +X509_set_subject_name +X509_set_version +X509_sign +X509_subject_name_cmp +X509_subject_name_hash +X509_to_X509_REQ +X509_verify +X509_verify_cert +X509_verify_cert_error_string +X509v3_add_ext +X509v3_add_extension +X509v3_add_netscape_extensions +X509v3_add_standard_extensions +X509v3_cleanup_extensions +X509v3_data_type_by_NID +X509v3_data_type_by_OBJ +X509v3_delete_ext +X509v3_get_ext +X509v3_get_ext_by_NID +X509v3_get_ext_by_OBJ +X509v3_get_ext_by_critical +X509v3_get_ext_count +X509v3_get_key_usage +X509v3_pack_string +X509v3_pack_type_by_NID +X509v3_pack_type_by_OBJ +X509v3_set_key_usage +X509v3_unpack_string +_des_crypt +a2d_ASN1_OBJECT +a2i_ASN1_INTEGER +a2i_ASN1_STRING +a2i_X509v3_key_usage +asn1_Finish +asn1_GetSequence +bn_add_words +bn_div64 +bn_expand2 +bn_mul_add_words +bn_mul_words +bn_qadd +bn_qsub +bn_sqr_words +crypt +d2i_ASN1_BIT_STRING +d2i_ASN1_BOOLEAN +d2i_ASN1_HEADER +d2i_ASN1_IA5STRING +d2i_ASN1_INTEGER +d2i_ASN1_OBJECT +d2i_ASN1_OCTET_STRING +d2i_ASN1_PRINTABLE +d2i_ASN1_PRINTABLESTRING +d2i_ASN1_SET +d2i_ASN1_T61STRING +d2i_ASN1_TYPE +d2i_ASN1_UTCTIME +d2i_ASN1_bytes +d2i_ASN1_type_bytes +d2i_DHparams +d2i_DSAPrivateKey +d2i_DSAPrivateKey_bio +d2i_DSAPrivateKey_fp +d2i_DSAPublicKey +d2i_DSAparams +d2i_NETSCAPE_SPKAC +d2i_NETSCAPE_SPKI +d2i_Netscape_RSA +d2i_Netscape_RSA_2 +d2i_PKCS7 +d2i_PKCS7_DIGEST +d2i_PKCS7_ENCRYPT +d2i_PKCS7_ENC_CONTENT +d2i_PKCS7_ENVELOPE +d2i_PKCS7_ISSUER_AND_SERIAL +d2i_PKCS7_RECIP_INFO +d2i_PKCS7_SIGNED +d2i_PKCS7_SIGNER_INFO +d2i_PKCS7_SIGN_ENVELOPE +d2i_PKCS7_bio +d2i_PKCS7_fp +d2i_PrivateKey +d2i_PublicKey +d2i_RSAPrivateKey +d2i_RSAPrivateKey_bio +d2i_RSAPrivateKey_fp +d2i_RSAPublicKey +d2i_RSAPublicKey_bio +d2i_RSAPublicKey_fp +d2i_X509 +d2i_X509_ALGOR +d2i_X509_ATTRIBUTE +d2i_X509_CINF +d2i_X509_CRL +d2i_X509_CRL_INFO +d2i_X509_CRL_bio +d2i_X509_CRL_fp +d2i_X509_EXTENSION +d2i_X509_NAME +d2i_X509_NAME_ENTRY +d2i_X509_PKEY +d2i_X509_PUBKEY +d2i_X509_REQ +d2i_X509_REQ_INFO +d2i_X509_REQ_bio +d2i_X509_REQ_fp +d2i_X509_REVOKED +d2i_X509_SIG +d2i_X509_VAL +d2i_X509_bio +d2i_X509_fp +des_cbc_cksum +des_cbc_encrypt +des_cblock_print_file +des_cfb64_encrypt +des_cfb_encrypt +des_decrypt3 +des_ecb3_encrypt +des_ecb_encrypt +des_ede3_cbc_encrypt +des_ede3_cfb64_encrypt +des_ede3_ofb64_encrypt +des_enc_read +des_enc_write +des_encrypt +des_encrypt2 +des_encrypt3 +des_fcrypt +des_is_weak_key +des_key_sched +des_ncbc_encrypt +des_ofb64_encrypt +des_ofb_encrypt +des_options +des_pcbc_encrypt +des_quad_cksum +des_random_key +des_random_seed +des_read_2passwords +des_read_password +des_read_pw +des_read_pw_string +des_set_key +des_set_odd_parity +des_string_to_2keys +des_string_to_key +des_xcbc_encrypt +des_xwhite_in2out +fcrypt_body +i2a_ASN1_INTEGER +i2a_ASN1_OBJECT +i2a_ASN1_STRING +i2a_X509v3_key_usage +i2d_ASN1_BIT_STRING +i2d_ASN1_BOOLEAN +i2d_ASN1_HEADER +i2d_ASN1_IA5STRING +i2d_ASN1_INTEGER +i2d_ASN1_OBJECT +i2d_ASN1_OCTET_STRING +i2d_ASN1_PRINTABLE +i2d_ASN1_SET +i2d_ASN1_TYPE +i2d_ASN1_UTCTIME +i2d_ASN1_bytes +i2d_DHparams +i2d_DSAPrivateKey +i2d_DSAPrivateKey_bio +i2d_DSAPrivateKey_fp +i2d_DSAPublicKey +i2d_DSAparams +i2d_NETSCAPE_SPKAC +i2d_NETSCAPE_SPKI +i2d_Netscape_RSA +i2d_PKCS7 +i2d_PKCS7_DIGEST +i2d_PKCS7_ENCRYPT +i2d_PKCS7_ENC_CONTENT +i2d_PKCS7_ENVELOPE +i2d_PKCS7_ISSUER_AND_SERIAL +i2d_PKCS7_RECIP_INFO +i2d_PKCS7_SIGNED +i2d_PKCS7_SIGNER_INFO +i2d_PKCS7_SIGN_ENVELOPE +i2d_PKCS7_bio +i2d_PKCS7_fp +i2d_PrivateKey +i2d_PublicKey +i2d_RSAPrivateKey +i2d_RSAPrivateKey_bio +i2d_RSAPrivateKey_fp +i2d_RSAPublicKey +i2d_RSAPublicKey_bio +i2d_RSAPublicKey_fp +i2d_X509 +i2d_X509_ALGOR +i2d_X509_ATTRIBUTE +i2d_X509_CINF +i2d_X509_CRL +i2d_X509_CRL_INFO +i2d_X509_CRL_bio +i2d_X509_CRL_fp +i2d_X509_EXTENSION +i2d_X509_NAME +i2d_X509_NAME_ENTRY +i2d_X509_PKEY +i2d_X509_PUBKEY +i2d_X509_REQ +i2d_X509_REQ_INFO +i2d_X509_REQ_bio +i2d_X509_REQ_fp +i2d_X509_REVOKED +i2d_X509_SIG +i2d_X509_VAL +i2d_X509_bio +i2d_X509_fp +i2t_ASN1_OBJECT +idea_cbc_encrypt +idea_cfb64_encrypt +idea_ecb_encrypt +idea_encrypt +idea_ofb64_encrypt +idea_options +idea_set_decrypt_key +idea_set_encrypt_key +lh_delete +lh_doall +lh_doall_arg +lh_free +lh_insert +lh_new +lh_node_stats +lh_node_stats_bio +lh_node_usage_stats +lh_node_usage_stats_bio +lh_retrieve +lh_stats +lh_stats_bio +lh_strhash +ripemd160_block +sha1_block +sha_block +sk_delete +sk_delete_ptr +sk_dup +sk_find +sk_free +sk_insert +sk_new +sk_pop +sk_pop_free +sk_push +sk_set_cmp_func +sk_shift +sk_unshift +sk_zero diff --git a/src/lib/libssl/src/dep/files b/src/lib/libssl/src/dep/files new file mode 100644 index 0000000000..8c5550c37c --- /dev/null +++ b/src/lib/libssl/src/dep/files @@ -0,0 +1,574 @@ +./e_os.h + +./crypto/cryptall.h CRYPTO +./crypto/cryptlib.h CRYPTO +./crypto/crypto.c CRYPTO +./crypto/cversion.c CRYPTO +./crypto/date.h CRYPTO +./crypto/mem.c CRYPTO +./crypto/cpt_err.c CRYPTO +./crypto/ex_data.c CRYPTO +./crypto/crypto.h CRYPTO +./crypto/cryptlib.c CRYPTO +./crypto/tmdiff.c CRYPTO + +./crypto/asn1/asn1.h ASN1 +./crypto/asn1/asn1_mac.h ASN1 +./crypto/asn1/asn1_err.c ASN1 +./crypto/asn1/asn1_lib.c ASN1 +./crypto/asn1/asn1_par.c ASN1 +./crypto/asn1/a_bitstr.c ASN1 +./crypto/asn1/a_bmp.c ASN1 +./crypto/asn1/a_bool.c ASN1 +./crypto/asn1/a_bytes.c ASN1 +./crypto/asn1/a_d2i_fp.c ASN1 +./crypto/asn1/a_digest.c ASN1 +./crypto/asn1/a_dup.c ASN1 +./crypto/asn1/a_hdr.c ASN1 +./crypto/asn1/a_i2d_fp.c ASN1 +./crypto/asn1/a_int.c ASN1 +./crypto/asn1/a_meth.c ASN1 +./crypto/asn1/a_object.c ASN1 +./crypto/asn1/a_octet.c ASN1 +./crypto/asn1/a_print.c ASN1 +./crypto/asn1/a_set.c ASN1 +./crypto/asn1/a_sign.c ASN1 +./crypto/asn1/a_type.c ASN1 +./crypto/asn1/a_utctm.c ASN1 +./crypto/asn1/a_verify.c ASN1 +./crypto/asn1/d2i_dhp.c ASN1 +./crypto/asn1/d2i_dsap.c ASN1 +./crypto/asn1/d2i_pr.c ASN1 +./crypto/asn1/d2i_pu.c ASN1 +./crypto/asn1/d2i_r_pr.c ASN1 +./crypto/asn1/d2i_r_pu.c ASN1 +./crypto/asn1/d2i_s_pr.c ASN1 +./crypto/asn1/d2i_s_pu.c ASN1 +./crypto/asn1/f_int.c ASN1 +./crypto/asn1/f_string.c ASN1 +./crypto/asn1/i2d_dhp.c ASN1 +./crypto/asn1/i2d_dsap.c ASN1 +./crypto/asn1/i2d_pr.c ASN1 +./crypto/asn1/i2d_pu.c ASN1 +./crypto/asn1/i2d_r_pr.c ASN1 +./crypto/asn1/i2d_r_pu.c ASN1 +./crypto/asn1/i2d_s_pr.c ASN1 +./crypto/asn1/i2d_s_pu.c ASN1 +./crypto/asn1/n_pkey.c ASN1 +./crypto/asn1/p7_dgst.c ASN1 +./crypto/asn1/p7_enc.c ASN1 +./crypto/asn1/p7_enc_c.c ASN1 +./crypto/asn1/p7_evp.c ASN1 +./crypto/asn1/p7_i_s.c ASN1 +./crypto/asn1/p7_lib.c ASN1 +./crypto/asn1/p7_recip.c ASN1 +./crypto/asn1/p7_signd.c ASN1 +./crypto/asn1/p7_signi.c ASN1 +./crypto/asn1/p7_s_e.c ASN1 +./crypto/asn1/pk.c ASN1 +./crypto/asn1/pkcs8.c ASN1 +./crypto/asn1/t_pkey.c ASN1 +./crypto/asn1/t_req.c ASN1 +./crypto/asn1/t_x509.c ASN1 +./crypto/asn1/x_algor.c ASN1 +./crypto/asn1/x_attrib.c ASN1 +./crypto/asn1/x_cinf.c ASN1 +./crypto/asn1/x_crl.c ASN1 +./crypto/asn1/x_exten.c ASN1 +./crypto/asn1/x_info.c ASN1 +./crypto/asn1/x_name.c ASN1 +./crypto/asn1/x_pkey.c ASN1 +./crypto/asn1/x_pubkey.c ASN1 +./crypto/asn1/x_req.c ASN1 +./crypto/asn1/x_sig.c ASN1 +./crypto/asn1/x_spki.c ASN1 +./crypto/asn1/x_val.c ASN1 +./crypto/asn1/x_x509.c ASN1 + +./crypto/bf/blowfish.h BF +./crypto/bf/bf_pi.h BF +./crypto/bf/bf_locl.h BF +./crypto/bf/bfspeed.c BF +./crypto/bf/bftest.c BF +./crypto/bf/bf_cbc.c BF +./crypto/bf/bf_cfb64.c BF +./crypto/bf/bf_ecb.c BF +./crypto/bf/bf_enc.c BF +./crypto/bf/bf_ofb64.c BF +./crypto/bf/bf_opts.c BF +./crypto/bf/bf_skey.c BF + +./crypto/bio/bio.h BIO +./crypto/bio/bf_buff.c BIO +./crypto/bio/bf_nbio.c BIO +./crypto/bio/bf_null.c BIO +./crypto/bio/bio_cb.c BIO +./crypto/bio/bio_err.c BIO +./crypto/bio/bio_lib.c BIO +./crypto/bio/bss_acpt.c BIO +./crypto/bio/bss_conn.c BIO +./crypto/bio/bss_fd.c BIO +./crypto/bio/bss_file.c BIO +./crypto/bio/bss_mem.c BIO +./crypto/bio/bss_null.c BIO +./crypto/bio/bss_rtcp.c BIO +./crypto/bio/bss_sock.c BIO +./crypto/bio/b_dump.c BIO +./crypto/bio/b_print.c BIO +./crypto/bio/b_sock.c BIO + +./crypto/bn/bn.h BN +./crypto/bn/bn_lcl.h BN +./crypto/bn/bn_prime.h BN +./crypto/bn/bnspeed.c BN +./crypto/bn/bntest.c BN +./crypto/bn/bn_add.c BN +./crypto/bn/bn_bld.c BN +./crypto/bn/bn_blind.c BN +./crypto/bn/bn_div.c BN +./crypto/bn/bn_err.c BN +./crypto/bn/bn_exp.c BN +./crypto/bn/bn_gcd.c BN +./crypto/bn/bn_lib.c BN +./crypto/bn/bn_mod.c BN +./crypto/bn/bn_mont.c BN +./crypto/bn/bn_mul.c BN +./crypto/bn/bn_mulw.c BN +./crypto/bn/bn_prime.c BN +./crypto/bn/bn_print.c BN +./crypto/bn/bn_rand.c BN +./crypto/bn/bn_recp.c BN +./crypto/bn/bn_shift.c BN +./crypto/bn/bn_sqr.c BN +./crypto/bn/bn_sub.c BN +./crypto/bn/bn_word.c BN +./crypto/bn/bn_m.c BN +./crypto/bn/m.c BN +./crypto/bn/expspeed.c BN +./crypto/bn/bn_mpi.c BN +./crypto/bn/exptest.c BN + +./crypto/buffer/buffer.c BUFF +./crypto/buffer/buffer.h BUFF +./crypto/buffer/buf_err.c BUFF + +./crypto/cast/cast.h CAST +./crypto/cast/castopts.c CAST +./crypto/cast/casttest.c CAST +./crypto/cast/cast_lcl.h CAST +./crypto/cast/cast_s.h CAST +./crypto/cast/cast_spd.c CAST +./crypto/cast/c_cfb64.c CAST +./crypto/cast/c_ecb.c CAST +./crypto/cast/c_enc.c CAST +./crypto/cast/c_ofb64.c CAST +./crypto/cast/c_skey.c CAST + +./crypto/conf/conf_lcl.h CONF +./crypto/conf/cnf_save.c CONF +./crypto/conf/conf.c CONF +./crypto/conf/conf.h CONF +./crypto/conf/conf_err.c CONF + +./crypto/des/des.h DES +./crypto/des/des_locl.h DES +./crypto/des/spr.h DES +./crypto/des/podd.h DES +./crypto/des/sk.h DES +./crypto/des/cbc3_enc.c DES +./crypto/des/cbc_cksm.c DES +./crypto/des/cbc_enc.c DES +./crypto/des/cfb64ede.c DES +./crypto/des/cfb64enc.c DES +./crypto/des/cfb_enc.c DES +./crypto/des/des.c DES +./crypto/des/destest.c DES +./crypto/des/des_enc.c DES +./crypto/des/des_opts.c DES +./crypto/des/des_ver.h DES +./crypto/des/ecb3_enc.c DES +./crypto/des/ecb_enc.c DES +./crypto/des/ede_enc.c DES +./crypto/des/enc_read.c DES +./crypto/des/enc_writ.c DES +./crypto/des/fcrypt.c DES +./crypto/des/fcrypt_b.c DES +./crypto/des/ncbc_enc.c DES +./crypto/des/ofb64ede.c DES +./crypto/des/ofb64enc.c DES +./crypto/des/ofb_enc.c DES +./crypto/des/pcbc_enc.c DES +./crypto/des/qud_cksm.c DES +./crypto/des/rand_key.c DES +./crypto/des/read2pwd.c DES +./crypto/des/read_pwd.c DES +./crypto/des/rpc_des.h DES +./crypto/des/rpc_enc.c DES +./crypto/des/rpw.c DES +./crypto/des/set_key.c DES +./crypto/des/str2key.c DES +./crypto/des/supp.c DES +./crypto/des/xcbc_enc.c DES + +./crypto/dh/dh.h DH +./crypto/dh/dh_check.c DH +./crypto/dh/dh_err.c DH +./crypto/dh/dh_gen.c DH +./crypto/dh/dh_key.c DH +./crypto/dh/dh_lib.c DH +./crypto/dh/p1024.c DH +./crypto/dh/p192.c DH +./crypto/dh/p512.c DH +./crypto/dh/dhtest.c DH + +./crypto/dsa/dsa.h DSA +./crypto/dsa/dsagen.c DSA +./crypto/dsa/dsa_err.c DSA +./crypto/dsa/dsa_gen.c DSA +./crypto/dsa/dsa_key.c DSA +./crypto/dsa/dsa_lib.c DSA +./crypto/dsa/dsa_sign.c DSA +./crypto/dsa/dsa_vrf.c DSA +./crypto/dsa/dsatest.c DSA + +./crypto/err/err.c ERR +./crypto/err/err.h ERR +./crypto/err/err_all.c ERR +./crypto/err/err_prn.c ERR + +./crypto/evp/evp.h EVP +./crypto/evp/bio_b64.c EVP +./crypto/evp/bio_enc.c EVP +./crypto/evp/bio_md.c EVP +./crypto/evp/c_all.c EVP +./crypto/evp/digest.c EVP +./crypto/evp/encode.c EVP +./crypto/evp/evp_enc.c EVP +./crypto/evp/evp_err.c EVP +./crypto/evp/evp_key.c EVP +./crypto/evp/e_cbc_3d.c EVP +./crypto/evp/e_cbc_bf.c EVP +./crypto/evp/e_cbc_c.c EVP +./crypto/evp/e_cbc_d.c EVP +./crypto/evp/e_cbc_i.c EVP +./crypto/evp/e_cbc_r2.c EVP +./crypto/evp/e_cfb_3d.c EVP +./crypto/evp/e_cfb_bf.c EVP +./crypto/evp/e_cfb_c.c EVP +./crypto/evp/e_cfb_d.c EVP +./crypto/evp/e_cfb_i.c EVP +./crypto/evp/e_cfb_r2.c EVP +./crypto/evp/e_dsa.c EVP +./crypto/evp/e_ecb_3d.c EVP +./crypto/evp/e_ecb_bf.c EVP +./crypto/evp/e_ecb_c.c EVP +./crypto/evp/e_ecb_d.c EVP +./crypto/evp/e_ecb_i.c EVP +./crypto/evp/e_ecb_r2.c EVP +./crypto/evp/e_null.c EVP +./crypto/evp/e_ofb_3d.c EVP +./crypto/evp/e_ofb_bf.c EVP +./crypto/evp/e_ofb_c.c EVP +./crypto/evp/e_ofb_d.c EVP +./crypto/evp/e_ofb_i.c EVP +./crypto/evp/e_ofb_r2.c EVP +./crypto/evp/e_rc4.c EVP +./crypto/evp/e_xcbc_d.c EVP +./crypto/evp/m_dss.c EVP +./crypto/evp/m_dss1.c EVP +./crypto/evp/m_md2.c EVP +./crypto/evp/m_md5.c EVP +./crypto/evp/m_mdc2.c EVP +./crypto/evp/m_null.c EVP +./crypto/evp/m_sha.c EVP +./crypto/evp/m_sha1.c EVP +./crypto/evp/names.c EVP +./crypto/evp/p_lib.c EVP +./crypto/evp/p_open.c EVP +./crypto/evp/p_seal.c EVP +./crypto/evp/p_sign.c EVP +./crypto/evp/p_verify.c EVP + +./crypto/hmac/hmac.c HMAC +./crypto/hmac/hmac.h HMAC +./crypto/hmac/hmactest.c HMAC + +./crypto/idea/ideatest.c IDEA +./crypto/idea/idea_lcl.h IDEA +./crypto/idea/idea_spd.c IDEA +./crypto/idea/i_cbc.c IDEA +./crypto/idea/i_cfb64.c IDEA +./crypto/idea/i_ecb.c IDEA +./crypto/idea/i_ofb64.c IDEA +./crypto/idea/i_skey.c IDEA +./crypto/idea/idea.h IDEA + +./crypto/lhash/lhash.c LHASH +./crypto/lhash/lhash.h LHASH +./crypto/lhash/lh_stats.c LHASH +./crypto/lhash/lh_test.c LHASH + +./crypto/md2/md2.c MD2 +./crypto/md2/md2test.c MD2 +./crypto/md2/md2_dgst.c MD2 +./crypto/md2/md2_one.c MD2 +./crypto/md2/md2.h MD2 + +./crypto/md5/md5.c MD5 +./crypto/md5/md5.h MD5 +./crypto/md5/md5test.c MD5 +./crypto/md5/md5_dgst.c MD5 +./crypto/md5/md5_locl.h MD5 +./crypto/md5/md5_one.c MD5 + +./crypto/mdc2/mdc2.h MDC2 +./crypto/mdc2/mdc2dgst.c MDC2 +./crypto/mdc2/mdc2test.c MDC2 +./crypto/mdc2/mdc2_one.c MDC2 + +./crypto/objects/objects.h OBJ +./crypto/objects/obj_dat.c OBJ +./crypto/objects/obj_dat.h OBJ +./crypto/objects/obj_err.c OBJ +./crypto/objects/obj_lib.c OBJ + +./crypto/pem/ctx_size.c PEM +./crypto/pem/pem.h PEM +./crypto/pem/pem_all.c PEM +./crypto/pem/pem_err.c PEM +./crypto/pem/pem_info.c PEM +./crypto/pem/pem_lib.c PEM +./crypto/pem/pem_seal.c PEM +./crypto/pem/pem_sign.c PEM + +./crypto/pkcs7/pk7_dgst.c PKCS7 +./crypto/pkcs7/pk7_doit.c PKCS7 +./crypto/pkcs7/pk7_enc.c PKCS7 +./crypto/pkcs7/pk7_lib.c PKCS7 +./crypto/pkcs7/pkcs7.h PKCS7 +./crypto/pkcs7/pkcs7err.c PKCS7 +./crypto/pkcs7/sign.c PKCS7 + +./crypto/proxy/bf_proxy.c PROXY +./crypto/proxy/p2test.c PROXY +./crypto/proxy/p3test.c PROXY +./crypto/proxy/paccept.c PROXY +./crypto/proxy/proxy.c PROXY +./crypto/proxy/proxy.h PROXY +./crypto/proxy/ptest.c PROXY +./crypto/proxy/pxy_conf.c PROXY +./crypto/proxy/pxy_err.c PROXY +./crypto/proxy/pxy_txt.c PROXY + +./crypto/rand/md_rand.c RAND +./crypto/rand/rand.h RAND +./crypto/rand/randfile.c RAND +./crypto/rand/randtest.c RAND + +./crypto/rc2/rc2cfb64.c RC2 +./crypto/rc2/rc2ofb64.c RC2 +./crypto/rc2/rc2speed.c RC2 +./crypto/rc2/rc2test.c RC2 +./crypto/rc2/rc2_cbc.c RC2 +./crypto/rc2/rc2_ecb.c RC2 +./crypto/rc2/rc2_locl.h RC2 +./crypto/rc2/rc2_skey.c RC2 +./crypto/rc2/rc2.h RC2 + +./crypto/rc4/rc4.c RC4 +./crypto/rc4/rc4speed.c RC4 +./crypto/rc4/rc4test.c RC4 +./crypto/rc4/rc4_enc.c RC4 +./crypto/rc4/rc4_skey.c RC4 +./crypto/rc4/rc4.h RC4 +./crypto/rc4/rc4_locl.h RC4 + +./crypto/rsa/rsa.h RSA +./crypto/rsa/rsa_eay.c RSA +./crypto/rsa/rsa_err.c RSA +./crypto/rsa/rsa_gen.c RSA +./crypto/rsa/rsa_lib.c RSA +./crypto/rsa/rsa_saos.c RSA +./crypto/rsa/rsa_sign.c RSA +./crypto/rsa/rsa_ssl.c RSA +./crypto/rsa/rsa_pk1.c RSA +./crypto/rsa/rsa_none.c RSA + +./crypto/sha/sha.h SHA +./crypto/sha/sha_locl.h SHA +./crypto/sha/sha.c SHA0 +./crypto/sha/sha_dgst.c SHA0 +./crypto/sha/sha_one.c SHA0 +./crypto/sha/sha_sgst.c SHA0 +./crypto/sha/shatest.c SHA0 +./crypto/sha/sha1.c SHA1 +./crypto/sha/sha1dgst.c SHA1 +./crypto/sha/sha1_one.c SHA1 +./crypto/sha/sha1test.c SHA1 + +./crypto/stack/stack.c STACK +./crypto/stack/stack.h STACK + +./crypto/txt_db/txt_db.c TXTDB +./crypto/txt_db/txt_db.h TXTDB + +./crypto/x509/by_dir.c X509 +./crypto/x509/by_file.c X509 +./crypto/x509/v3_net.c X509 +./crypto/x509/v3_x509.c X509 +./crypto/x509/x509.h X509 +./crypto/x509/x509name.c X509 +./crypto/x509/x509pack.c X509 +./crypto/x509/x509rset.c X509 +./crypto/x509/x509type.c X509 +./crypto/x509/x509_cmp.c X509 +./crypto/x509/x509_d2.c X509 +./crypto/x509/x509_def.c X509 +./crypto/x509/x509_err.c X509 +./crypto/x509/x509_ext.c X509 +./crypto/x509/x509_lu.c X509 +./crypto/x509/x509_obj.c X509 +./crypto/x509/x509_r2x.c X509 +./crypto/x509/x509_req.c X509 +./crypto/x509/x509_set.c X509 +./crypto/x509/x509_txt.c X509 +./crypto/x509/x509_v3.c X509 +./crypto/x509/x509_vfy.c X509 +./crypto/x509/x_all.c X509 +./crypto/x509/x509_vfy.h X509 +./crypto/x509v3/v3_ku.c X509 +./crypto/x509v3/x509v3.h X509 + +./crypto/threads/mttest.c THREADS +./crypto/threads/th-lock.c THREADS + +./crypto/ripemd/rmdtest.c RMD160 +./crypto/ripemd/ripemd.h RMD160 +./crypto/ripemd/rmdconst.h RMD160 +./crypto/ripemd/rmd_locl.h RMD160 +./crypto/ripemd/rmd_one.c RMD160 +./crypto/ripemd/rmd160.c RMD160 +./crypto/ripemd/rmd_dgst.c RMD160 + +./crypto/rc5/rc5_ecb.c RC5 +./crypto/rc5/rc5cfb64.c RC5 +./crypto/rc5/rc5ofb64.c RC5 +./crypto/rc5/rc5speed.c RC5 +./crypto/rc5/rc5test.c RC5 +./crypto/rc5/rc5_enc.c RC5 +./crypto/rc5/rc5.h RC5 +./crypto/rc5/rc5_locl.h RC5 +./crypto/rc5/rc5_skey.c RC5 + +./ssl/bio_ssl.c SSL +./ssl/pxy_ssl.c SSL +./ssl/s23_clnt.c SSL +./ssl/s23_lib.c SSL +./ssl/s23_meth.c SSL +./ssl/s23_pkt.c SSL +./ssl/s23_srvr.c SSL +./ssl/s2_clnt.c SSL +./ssl/s2_enc.c SSL +./ssl/s2_lib.c SSL +./ssl/s2_meth.c SSL +./ssl/s2_pkt.c SSL +./ssl/s2_srvr.c SSL +./ssl/s3_both.c SSL +./ssl/s3_clnt.c SSL +./ssl/s3_enc.c SSL +./ssl/s3_lib.c SSL +./ssl/s3_meth.c SSL +./ssl/s3_pkt.c SSL +./ssl/s3_srvr.c SSL +./ssl/ssl.c SSL +./ssl/ssl2.h SSL +./ssl/ssl23.h SSL +./ssl/ssl3.h SSL +./ssl/ssl_algs.c SSL +./ssl/ssl_asn1.c SSL +./ssl/ssl_cert.c SSL +./ssl/ssl_ciph.c SSL +./ssl/ssl_err.c SSL +./ssl/ssl_err2.c SSL +./ssl/ssl_lib.c SSL +./ssl/ssl_locl.h SSL +./ssl/ssl_rsa.c SSL +./ssl/ssl_sess.c SSL +./ssl/ssl_stat.c SSL +./ssl/ssl_task.c SSL +./ssl/ssl_txt.c SSL +./ssl/tls1.h SSL +./ssl/t1_lib.c SSL +./ssl/t1_enc.c SSL +./ssl/t1_meth.c SSL +./ssl/t1_srvr.c SSL +./ssl/t1_clnt.c SSL +./ssl/ssl.h SSL +./ssl/ssltest.c SSL + +./rsaref/rsaref.c RSAREF +./rsaref/rsaref.h RSAREF +./rsaref/rsar_err.c RSAREF + +./apps/apps.c APPS +./apps/apps.h APPS +./apps/asn1pars.c APPS +./apps/bf_perm.c APPS +./apps/bf_perm.h APPS +./apps/ca.c APPS +./apps/ciphers.c APPS +./apps/crl.c APPS +./apps/crl2p7.c APPS +./apps/dgst.c APPS +./apps/dh.c APPS +./apps/dsa.c APPS +./apps/dsaparam.c APPS +./apps/eay.c APPS +./apps/enc.c APPS +./apps/errstr.c APPS +./apps/speed.c APPS +./apps/gendh.c APPS +./apps/gendsa.c APPS +./apps/genrsa.c APPS +./apps/mybio_cb.c APPS +./apps/pem_mail.c APPS +./apps/pkcs7.c APPS +./apps/progs.h APPS +./apps/req.c APPS +./apps/rsa.c APPS +./apps/sess_id.c APPS +./apps/s_apps.h APPS +./apps/s_args.c APPS +./apps/s_cache.c APPS +./apps/s_cb.c APPS +./apps/s_client.c APPS +./apps/s_eio.c APPS +./apps/s_eio.h APPS +./apps/s_filter.c APPS +./apps/s_filter.h APPS +./apps/s_server.c APPS +./apps/s_socket.c APPS +./apps/s_state.c APPS +./apps/s_state.h APPS +./apps/s_time.c APPS +./apps/testdsa.h APPS +./apps/testrsa.h APPS +./apps/verify.c APPS +./apps/version.c APPS +./apps/x509.c APPS +./apps/ssleay.c APPS +./apps/sp.c APPS + +./demos/b64.c DEMO +./demos/bio/saccept.c DEMO +./demos/bio/sconnect.c DEMO +./demos/maurice/example1.c DEMO +./demos/maurice/example2.c DEMO +./demos/maurice/example3.c DEMO +./demos/maurice/example4.c DEMO +./demos/maurice/loadkeys.c DEMO +./demos/maurice/loadkeys.h DEMO +./demos/prime/prime.c DEMO +./demos/selfsign.c DEMO +./demos/spkigen.c DEMO + diff --git a/src/lib/libssl/src/dep/gen.pl b/src/lib/libssl/src/dep/gen.pl new file mode 100644 index 0000000000..35490f2794 --- /dev/null +++ b/src/lib/libssl/src/dep/gen.pl @@ -0,0 +1,113 @@ +#!/usr/bin/perl + +require 'getopts.pl'; + +$files="files"; +%have=(); +%missing=(); +%name=(); +%func=(); + +&Getopts('Ff:'); + +&load_file("files"); +foreach $file (@ARGV) + { &do_nm($file); } + +if (defined($opt_f)) + { + %a=(); + $r=&list_files($opt_f,"",*a); + if ($opt_F) + { + foreach (sort split(/\n/,$r)) + { print "$_\n"; } + } + else + { print $r; } + } +else + { + for (sort keys %have) + { + print "$_:$have{$_}\n"; + } + } + +sub list_files + { + local($f,$o,*done)=@_; + local($a,$_,$ff,$ret); + + return if $f =~ /^\s*$/; + + $done{$f}=1; + $ret.=$f."\n" if $opt_F; + foreach (split(/ /,$have{$f})) + { + $ret.="$o$f:$_\n" unless $opt_F; + } + + foreach (split(/ /,$missing{$f})) + { + $ff=$func{$_}; + next if defined($done{$ff}); + $ret.=&list_files($ff,$o." "); + } + $ret; + } + +sub do_nm + { + local($file)=@_; + local($fname)=""; + + open(IN,"nm $file|") || die "unable to run 'nm $file|':$!\n"; + while () + { + chop; + next if /^\s*$/; + if (/^(.*)\.o:\s*$/) + { + $fname="$1.c"; + next; + } + ($type,$name)=/^.{8} (.) (.+)/; +# print "$fname $type $name\n"; + + if ($type eq "T") + { + $have{$fname}.="$name "; + $func{$name}=$fname; + } + elsif ($type eq "U") + { + $missing{$fname}.="$name "; + } + } + close(IN); + } + +sub load_file + { + local($file)=@_; + + open(IN,"<$files") || die "unable to open $files:$!\n"; + + while () + { + chop; + next if /^\s*$/; + ($n)=/\/([^\/\s]+)\s+/; + ($fn)=/^(\S+)\s/; +# print "$n - $fn\n"; + if (defined($name{$n})) + { print "$n already exists\n"; } + else + { $name{$n}=$fn; } + } + close(IN); + @name=%name; + } + + diff --git a/src/lib/libssl/src/dep/ssl.txt b/src/lib/libssl/src/dep/ssl.txt new file mode 100644 index 0000000000..7cd125a0d1 --- /dev/null +++ b/src/lib/libssl/src/dep/ssl.txt @@ -0,0 +1,156 @@ +BIO_f_ssl +BIO_new_buffer_ssl_connect +BIO_new_ssl +BIO_new_ssl_connect +BIO_proxy_ssl_copy_session_id +BIO_ssl_copy_session_id +BIO_ssl_shutdown +ERR_load_SSL_strings +SSL_CIPHER_description +SSL_CIPHER_get_bits +SSL_CIPHER_get_name +SSL_CIPHER_get_version +SSL_CTX_add_client_CA +SSL_CTX_add_session +SSL_CTX_check_private_key +SSL_CTX_ctrl +SSL_CTX_flush_sessions +SSL_CTX_free +SSL_CTX_get_client_CA_list +SSL_CTX_get_ex_data +SSL_CTX_get_ex_new_index +SSL_CTX_get_quiet_shutdown +SSL_CTX_get_verify_callback +SSL_CTX_get_verify_mode +SSL_CTX_load_verify_locations +SSL_CTX_new +SSL_CTX_remove_session +SSL_CTX_set_cert_verify_cb +SSL_CTX_set_cipher_list +SSL_CTX_set_client_CA_list +SSL_CTX_set_default_passwd_cb +SSL_CTX_set_default_verify_paths +SSL_CTX_set_ex_data +SSL_CTX_set_quiet_shutdown +SSL_CTX_set_ssl_version +SSL_CTX_set_verify +SSL_CTX_use_PrivateKey +SSL_CTX_use_PrivateKey_ASN1 +SSL_CTX_use_PrivateKey_file +SSL_CTX_use_RSAPrivateKey +SSL_CTX_use_RSAPrivateKey_ASN1 +SSL_CTX_use_RSAPrivateKey_file +SSL_CTX_use_certificate +SSL_CTX_use_certificate_ASN1 +SSL_CTX_use_certificate_file +SSL_SESSION_cmp +SSL_SESSION_free +SSL_SESSION_get_ex_data +SSL_SESSION_get_ex_new_index +SSL_SESSION_get_time +SSL_SESSION_get_timeout +SSL_SESSION_hash +SSL_SESSION_new +SSL_SESSION_print +SSL_SESSION_print_fp +SSL_SESSION_set_ex_data +SSL_SESSION_set_time +SSL_SESSION_set_timeout +SSL_accept +SSL_add_client_CA +SSL_alert_desc_string +SSL_alert_desc_string_long +SSL_alert_type_string +SSL_alert_type_string_long +SSL_check_private_key +SSL_clear +SSL_connect +SSL_copy_session_id +SSL_ctrl +SSL_do_handshake +SSL_dup +SSL_dup_CA_list +SSL_free +SSL_get_SSL_CTX +SSL_get_certificate +SSL_get_cipher_list +SSL_get_ciphers +SSL_get_client_CA_list +SSL_get_current_cipher +SSL_get_default_timeout +SSL_get_error +SSL_get_ex_data +SSL_get_ex_new_index +SSL_get_fd +SSL_get_info_callback +SSL_get_peer_cert_chain +SSL_get_peer_certificate +SSL_get_privatekey +SSL_get_quiet_shutdown +SSL_get_rbio +SSL_get_read_ahead +SSL_get_session +SSL_get_shared_ciphers +SSL_get_shutdown +SSL_get_ssl_method +SSL_get_verify_callback +SSL_get_verify_mode +SSL_get_verify_result +SSL_get_version +SSL_get_wbio +SSL_load_client_CA_file +SSL_load_error_strings +SSL_new +SSL_peek +SSL_pending +SSL_read +SSL_renegotiate +SSL_rstate_string +SSL_rstate_string_long +SSL_set_accept_state +SSL_set_bio +SSL_set_cipher_list +SSL_set_client_CA_list +SSL_set_connect_state +SSL_set_ex_data +SSL_set_fd +SSL_set_info_callback +SSL_set_quiet_shutdown +SSL_set_read_ahead +SSL_set_rfd +SSL_set_session +SSL_set_shutdown +SSL_set_ssl_method +SSL_set_verify +SSL_set_verify_result +SSL_set_wfd +SSL_shutdown +SSL_state +SSL_state_string +SSL_state_string_long +SSL_use_PrivateKey +SSL_use_PrivateKey_ASN1 +SSL_use_PrivateKey_file +SSL_use_RSAPrivateKey +SSL_use_RSAPrivateKey_ASN1 +SSL_use_RSAPrivateKey_file +SSL_use_certificate +SSL_use_certificate_ASN1 +SSL_use_certificate_file +SSL_version +SSL_write +SSLeay_add_ssl_algorithms +SSLv23_client_method +SSLv23_method +SSLv23_server_method +SSLv2_client_method +SSLv2_method +SSLv2_server_method +SSLv3_client_method +SSLv3_method +SSLv3_server_method +TLSv1_client_method +TLSv1_method +TLSv1_server_method +d2i_SSL_SESSION +i2d_SSL_SESSION diff --git a/src/lib/libssl/src/doc/API.doc b/src/lib/libssl/src/doc/API.doc new file mode 100644 index 0000000000..fe2820259a --- /dev/null +++ b/src/lib/libssl/src/doc/API.doc @@ -0,0 +1,24 @@ +SSL - SSLv2/v3/v23 etc. + +BIO - methods and how they plug together + +MEM - memory allocation callback + +CRYPTO - locking for threads + +EVP - Ciphers/Digests/signatures + +RSA - methods + +X509 - certificate retrieval + +X509 - validation + +X509 - X509v3 extensions + +Objects - adding object identifiers + +ASN.1 - parsing + +PEM - parsing + diff --git a/src/lib/libssl/src/doc/a_verify.doc b/src/lib/libssl/src/doc/a_verify.doc new file mode 100644 index 0000000000..06eec17c2b --- /dev/null +++ b/src/lib/libssl/src/doc/a_verify.doc @@ -0,0 +1,85 @@ +From eay@mincom.com Fri Oct 4 18:29:06 1996 +Received: by orb.mincom.oz.au id AA29080 + (5.65c/IDA-1.4.4 for eay); Fri, 4 Oct 1996 08:29:07 +1000 +Date: Fri, 4 Oct 1996 08:29:06 +1000 (EST) +From: Eric Young +X-Sender: eay@orb +To: wplatzer +Cc: Eric Young , SSL Mailing List +Subject: Re: Netscape's Public Key +In-Reply-To: <19961003134837.NTM0049@iaik.tu-graz.ac.at> +Message-Id: +Mime-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +Status: RO +X-Status: + +On Thu, 3 Oct 1996, wplatzer wrote: +> I get Public Key from Netscape (Gold 3.0b4), but cannot do anything +> with it... It looks like (asn1parse): +> +> 0:d=0 hl=3 l=180 cons: SEQUENCE +> 3:d=1 hl=2 l= 96 cons: SEQUENCE +> 5:d=2 hl=2 l= 92 cons: SEQUENCE +> 7:d=3 hl=2 l= 13 cons: SEQUENCE +> 9:d=4 hl=2 l= 9 prim: OBJECT :rsaEncryption +> 20:d=4 hl=2 l= 0 prim: NULL +> 22:d=3 hl=2 l= 75 prim: BIT STRING +> 99:d=2 hl=2 l= 0 prim: IA5STRING : +> 101:d=1 hl=2 l= 13 cons: SEQUENCE +> 103:d=2 hl=2 l= 9 prim: OBJECT :md5withRSAEncryption +> 114:d=2 hl=2 l= 0 prim: NULL +> 116:d=1 hl=2 l= 65 prim: BIT STRING +> +> The first BIT STRING is the public key and the second BIT STRING is +> the signature. +> But a public key consists of the public exponent and the modulus. Are +> both numbers in the first BIT STRING? +> Is there a document simply describing this coding stuff (checking +> signature, get the public key, etc.)? + +Minimal in SSLeay. If you want to see what the modulus and exponent are, +try asn1parse -offset 25 -length 75 next_bio list. + + + +Extra commands are normally implemented as macros calling BIO_ctrl(). +- BIO_number_read(BIO *bio) - the number of bytes processed + by BIO_read(bio,.). +- BIO_number_written(BIO *bio) - the number of bytes written + by BIO_write(bio,.). +- BIO_reset(BIO *bio) - 'reset' the BIO. +- BIO_eof(BIO *bio) - non zero if we are at the current end + of input. +- BIO_set_close(BIO *bio, int close_flag) - set the close flag. +- BIO_get_close(BIO *bio) - return the close flag. + BIO_pending(BIO *bio) - return the number of bytes waiting + to be read (normally buffered internally). +- BIO_flush(BIO *bio) - output any data waiting to be output. +- BIO_should_retry(BIO *io) - after a BIO_read/BIO_write + operation returns 0 or -1, a call to this function will + return non zero if you should retry the call later (this + is for non-blocking IO). +- BIO_should_read(BIO *io) - we should retry when data can + be read. +- BIO_should_write(BIO *io) - we should retry when data can + be written. +- BIO_method_name(BIO *io) - return a string for the method name. +- BIO_method_type(BIO *io) - return the unique ID of the BIO method. +- BIO_set_callback(BIO *io, long (*callback)(BIO *io, int + cmd, char *argp, int argi, long argl, long ret); - sets + the debug callback. +- BIO_get_callback(BIO *io) - return the assigned function + as mentioned above. +- BIO_set_callback_arg(BIO *io, char *arg) - assign some + data against the BIO. This is normally used by the debug + callback but could in reality be used for anything. To + get an idea of how all this works, have a look at the code + in the default debug callback mentioned above. The + callback can modify the return values. + +Details of the BIO_METHOD structure. +typedef struct bio_method_st + { + int type; + char *name; + int (*bwrite)(); + int (*bread)(); + int (*bputs)(); + int (*bgets)(); + long (*ctrl)(); + int (*create)(); + int (*destroy)(); + } BIO_METHOD; + +The 'type' is the numeric type of the BIO, these are listed in buffer.h; +'Name' is a textual representation of the BIO 'type'. +The 7 function pointers point to the respective function +methods, some of which can be NULL if not implemented. +The BIO structure +typedef struct bio_st + { + BIO_METHOD *method; + long (*callback)(BIO * bio, int mode, char *argp, int + argi, long argl, long ret); + char *cb_arg; /* first argument for the callback */ + int init; + int shutdown; + int flags; /* extra storage */ + int num; + char *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + int references; + unsigned long num_read; + unsigned long num_write; + } BIO; + +- 'Method' is the BIO method. +- 'callback', when configured, is called before and after + each BIO method is called for that particular BIO. This + is intended primarily for debugging and of informational feedback. +- 'init' is 0 when the BIO can be used for operation. + Often, after a BIO is created, a number of operations may + need to be performed before it is available for use. An + example is for BIO_s_sock(). A socket needs to be + assigned to the BIO before it can be used. +- 'shutdown', this flag indicates if the underlying + comunication primative being used should be closed/freed + when the BIO is closed. +- 'flags' is used to hold extra state. It is primarily used + to hold information about why a non-blocking operation + failed and to record startup protocol information for the + SSL BIO. +- 'num' and 'ptr' are used to hold instance specific state + like file descriptors or local data structures. +- 'next_bio' is used by filter BIOs to hold the pointer of the + next BIO in the chain. written data is sent to this BIO and + data read is taken from it. +- 'references' is used to indicate the number of pointers to + this structure. This needs to be '1' before a call to + BIO_free() is made if the BIO_free() function is to + actually free() the structure, otherwise the reference + count is just decreased. The actual BIO subsystem does + not really use this functionality but it is useful when + used in more advanced applicaion. +- num_read and num_write are the total number of bytes + read/written via the 'read()' and 'write()' methods. + +BIO_ctrl operations. +The following is the list of standard commands passed as the +second parameter to BIO_ctrl() and should be supported by +all BIO as best as possible. Some are optional, some are +manditory, in any case, where is makes sense, a filter BIO +should pass such requests to underlying BIO's. +- BIO_CTRL_RESET - Reset the BIO back to an initial state. +- BIO_CTRL_EOF - return 0 if we are not at the end of input, + non 0 if we are. +- BIO_CTRL_INFO - BIO specific special command, normal + information return. +- BIO_CTRL_SET - set IO specific parameter. +- BIO_CTRL_GET - get IO specific parameter. +- BIO_CTRL_GET_CLOSE - Get the close on BIO_free() flag, one + of BIO_CLOSE or BIO_NOCLOSE. +- BIO_CTRL_SET_CLOSE - Set the close on BIO_free() flag. +- BIO_CTRL_PENDING - Return the number of bytes available + for instant reading +- BIO_CTRL_FLUSH - Output pending data, return number of bytes output. +- BIO_CTRL_SHOULD_RETRY - After an IO error (-1 returned) + should we 'retry' when IO is possible on the underlying IO object. +- BIO_CTRL_RETRY_TYPE - What kind of IO are we waiting on. + +The following command is a special BIO_s_file() specific option. +- BIO_CTRL_SET_FILENAME - specify a file to open for IO. + +The BIO_CTRL_RETRY_TYPE needs a little more explanation. +When performing non-blocking IO, or say reading on a memory +BIO, when no data is present (or cannot be written), +BIO_read() and/or BIO_write() will return -1. +BIO_should_retry(bio) will return true if this is due to an +IO condition rather than an actual error. In the case of +BIO_s_mem(), a read when there is no data will return -1 and +a should retry when there is more 'read' data. +The retry type is deduced from 2 macros +BIO_should_read(bio) and BIO_should_write(bio). +Now while it may appear obvious that a BIO_read() failure +should indicate that a retry should be performed when more +read data is available, this is often not true when using +things like an SSL BIO. During the SSL protocol startup +multiple reads and writes are performed, triggered by any +SSL_read or SSL_write. +So to write code that will transparently handle either a +socket or SSL BIO, + i=BIO_read(bio,..) + if (I == -1) + { + if (BIO_should_retry(bio)) + { + if (BIO_should_read(bio)) + { + /* call us again when BIO can be read */ + } + if (BIO_should_write(bio)) + { + /* call us again when BIO can be written */ + } + } + } + +At this point in time only read and write conditions can be +used but in the future I can see the situation for other +conditions, specifically with SSL there could be a condition +of a X509 certificate lookup taking place and so the non- +blocking BIO_read would require a retry when the certificate +lookup subsystem has finished it's lookup. This is all +makes more sense and is easy to use in a event loop type +setup. +When using the SSL BIO, either SSL_read() or SSL_write()s +can be called during the protocol startup and things will +still work correctly. +The nice aspect of the use of the BIO_should_retry() macro +is that all the errno codes that indicate a non-fatal error +are encapsulated in one place. The Windows specific error +codes and WSAGetLastError() calls are also hidden from the +application. + +Notes on each BIO method. +Normally buffer.h is just required but depending on the +BIO_METHOD, ssl.h or evp.h will also be required. + +BIO_METHOD *BIO_s_mem(void); +- BIO_set_mem_buf(BIO *bio, BUF_MEM *bm, int close_flag) - + set the underlying BUF_MEM structure for the BIO to use. +- BIO_get_mem_ptr(BIO *bio, char **pp) - if pp is not NULL, + set it to point to the memory array and return the number + of bytes available. +A read/write BIO. Any data written is appended to the +memory array and any read is read from the front. This BIO +can be used for read/write at the same time. BIO_gets() is +supported in the fgets() sense. +BIO_CTRL_INFO can be used to retrieve pointers to the memory +buffer and it's length. + +BIO_METHOD *BIO_s_file(void); +- BIO_set_fp(BIO *bio, FILE *fp, int close_flag) - set 'FILE *' to use. +- BIO_get_fp(BIO *bio, FILE **fp) - get the 'FILE *' in use. +- BIO_read_filename(BIO *bio, char *name) - read from file. +- BIO_write_filename(BIO *bio, char *name) - write to file. +- BIO_append_filename(BIO *bio, char *name) - append to file. +This BIO sits over the normal system fread()/fgets() type +functions. Gets() is supported. This BIO in theory could be +used for read and write but it is best to think of each BIO +of this type as either a read or a write BIO, not both. + +BIO_METHOD *BIO_s_socket(void); +BIO_METHOD *BIO_s_fd(void); +- BIO_sock_should_retry(int i) - the underlying function + used to determine if a call should be retried; the + argument is the '0' or '-1' returned by the previous BIO + operation. +- BIO_fd_should_retry(int i) - same as the +- BIO_sock_should_retry() except that it is different internally. +- BIO_set_fd(BIO *bio, int fd, int close_flag) - set the + file descriptor to use +- BIO_get_fd(BIO *bio, int *fd) - get the file descriptor. +These two methods are very similar. Gets() is not +supported, if you want this functionality, put a +BIO_f_buffer() onto it. This BIO is bi-directional if the +underlying file descriptor is. This is normally the case +for sockets but not the case for stdio descriptors. + +BIO_METHOD *BIO_s_null(void); +Read and write as much data as you like, it all disappears +into this BIO. + +BIO_METHOD *BIO_f_buffer(void); +- BIO_get_buffer_num_lines(BIO *bio) - return the number of + complete lines in the buffer. +- BIO_set_buffer_size(BIO *bio, long size) - set the size of + the buffers. +This type performs input and output buffering. It performs +both at the same time. The size of the buffer can be set +via the set buffer size option. Data buffered for output is +only written when the buffer fills. + +BIO_METHOD *BIO_f_ssl(void); +- BIO_set_ssl(BIO *bio, SSL *ssl, int close_flag) - the SSL + structure to use. +- BIO_get_ssl(BIO *bio, SSL **ssl) - get the SSL structure + in use. +The SSL bio is a little different from normal BIOs because +the underlying SSL structure is a little different. A SSL +structure performs IO via a read and write BIO. These can +be different and are normally set via the +SSL_set_rbio()/SSL_set_wbio() calls. The SSL_set_fd() calls +are just wrappers that create socket BIOs and then call +SSL_set_bio() where the read and write BIOs are the same. +The BIO_push() operation makes the SSLs IO BIOs the same, so +make sure the BIO pushed is capable of two directional +traffic. If it is not, you will have to install the BIOs +via the more conventional SSL_set_bio() call. BIO_pop() will retrieve +the 'SSL read' BIO. + +BIO_METHOD *BIO_f_md(void); +- BIO_set_md(BIO *bio, EVP_MD *md) - set the message digest + to use. +- BIO_get_md(BIO *bio, EVP_MD **mdp) - return the digest + method in use in mdp, return 0 if not set yet. +- BIO_reset() reinitializes the digest (EVP_DigestInit()) + and passes the reset to the underlying BIOs. +All data read or written via BIO_read() or BIO_write() to +this BIO will be added to the calculated digest. This +implies that this BIO is only one directional. If read and +write operations are performed, two separate BIO_f_md() BIOs +are reuqired to generate digests on both the input and the +output. BIO_gets(BIO *bio, char *md, int size) will place the +generated digest into 'md' and return the number of bytes. +The EVP_MAX_MD_SIZE should probably be used to size the 'md' +array. Reading the digest will also reset it. + +BIO_METHOD *BIO_f_cipher(void); +- BIO_reset() reinitializes the cipher. +- BIO_flush() should be called when the last bytes have been + output to flush the final block of block ciphers. +- BIO_get_cipher_status(BIO *b), when called after the last + read from a cipher BIO, returns non-zero if the data + decrypted correctly, otherwise, 0. +- BIO_set_cipher(BIO *b, EVP_CIPHER *c, unsigned char *key, + unsigned char *iv, int encrypt) This function is used to + setup a cipher BIO. The length of key and iv are + specified by the choice of EVP_CIPHER. Encrypt is 1 to + encrypt and 0 to decrypt. + +BIO_METHOD *BIO_f_base64(void); +- BIO_flush() should be called when the last bytes have been output. +This BIO base64 encodes when writing and base64 decodes when +reading. It will scan the input until a suitable begin line +is found. After reading data, BIO_reset() will reset the +BIO to start scanning again. Do not mix reading and writing +on the same base64 BIO. It is meant as a single stream BIO. + +Directions type +both BIO_s_mem() +one/both BIO_s_file() +both BIO_s_fd() +both BIO_s_socket() +both BIO_s_null() +both BIO_f_buffer() +one BIO_f_md() +one BIO_f_cipher() +one BIO_f_base64() +both BIO_f_ssl() + +It is easy to mix one and two directional BIOs, all one has +to do is to keep two separate BIO pointers for reading and +writing and be careful about usage of underlying BIOs. The +SSL bio by it's very nature has to be two directional but +the BIO_push() command will push the one BIO into the SSL +BIO for both reading and writing. + +The best example program to look at is apps/enc.c and/or perhaps apps/dgst.c. + diff --git a/src/lib/libssl/src/doc/blowfish.doc b/src/lib/libssl/src/doc/blowfish.doc new file mode 100644 index 0000000000..8a7f425b32 --- /dev/null +++ b/src/lib/libssl/src/doc/blowfish.doc @@ -0,0 +1,146 @@ +The Blowfish library. + +Blowfish is a block cipher that operates on 64bit (8 byte) quantities. It +uses variable size key, but 128bit (16 byte) key would normally be considered +good. It can be used in all the modes that DES can be used. This +library implements the ecb, cbc, cfb64, ofb64 modes. + +Blowfish is quite a bit faster that DES, and much faster than IDEA or +RC2. It is one of the faster block ciphers. + +For all calls that have an 'input' and 'output' variables, they can be the +same. + +This library requires the inclusion of 'blowfish.h'. + +All of the encryption functions take what is called an BF_KEY as an +argument. An BF_KEY is an expanded form of the Blowfish key. +For all modes of the Blowfish algorithm, the BF_KEY used for +decryption is the same one that was used for encryption. + +The define BF_ENCRYPT is passed to specify encryption for the functions +that require an encryption/decryption flag. BF_DECRYPT is passed to +specify decryption. + +Please note that any of the encryption modes specified in my DES library +could be used with Blowfish. I have only implemented ecb, cbc, cfb64 and +ofb64 for the following reasons. +- ecb is the basic Blowfish encryption. +- cbc is the normal 'chaining' form for block ciphers. +- cfb64 can be used to encrypt single characters, therefore input and output + do not need to be a multiple of 8. +- ofb64 is similar to cfb64 but is more like a stream cipher, not as + secure (not cipher feedback) but it does not have an encrypt/decrypt mode. +- If you want triple Blowfish, thats 384 bits of key and you must be totally + obsessed with security. Still, if you want it, it is simple enough to + copy the function from the DES library and change the des_encrypt to + BF_encrypt; an exercise left for the paranoid reader :-). + +The functions are as follows: + +void BF_set_key( +BF_KEY *ks; +int len; +unsigned char *key; + BF_set_key converts an 'len' byte key into a BF_KEY. + A 'ks' is an expanded form of the 'key' which is used to + perform actual encryption. It can be regenerated from the Blowfish key + so it only needs to be kept when encryption or decryption is about + to occur. Don't save or pass around BF_KEY's since they + are CPU architecture dependent, 'key's are not. Blowfish is an + interesting cipher in that it can be used with a variable length + key. 'len' is the length of 'key' to be used as the key. + A 'len' of 16 is recomended by me, but blowfish can use upto + 72 bytes. As a warning, blowfish has a very very slow set_key + function, it actually runs BF_encrypt 521 times. + +void BF_encrypt(unsigned long *data, BF_KEY *key); +void BF_decrypt(unsigned long *data, BF_KEY *key); + These are the Blowfish encryption function that gets called by just + about every other Blowfish routine in the library. You should not + use this function except to implement 'modes' of Blowfish. + I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. + Data is a pointer to 2 unsigned long's and key is the + BF_KEY to use. + +void BF_ecb_encrypt( +unsigned char *in, +unsigned char *out, +BF_KEY *key, +int encrypt); + This is the basic Electronic Code Book form of Blowfish (in DES this + mode is called Electronic Code Book so I'm going to use the term + for blowfish as well. + Input is encrypted into output using the key represented by + key. Depending on the encrypt, encryption or + decryption occurs. Input is 8 bytes long and output is 8 bytes. + +void BF_cbc_encrypt( +unsigned char *in, +unsigned char *out, +long length, +BF_KEY *ks, +unsigned char *ivec, +int encrypt); + This routine implements Blowfish in Cipher Block Chaining mode. + Input, which should be a multiple of 8 bytes is encrypted + (or decrypted) to output which will also be a multiple of 8 bytes. + The number of bytes is in length (and from what I've said above, + should be a multiple of 8). If length is not a multiple of 8, bad + things will probably happen. ivec is the initialisation vector. + This function updates iv after each call so that it can be passed to + the next call to BF_cbc_encrypt(). + +void BF_cfb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +BF_KEY *schedule, +unsigned char *ivec, +int *num, +int encrypt); + This is one of the more useful functions in this Blowfish library, it + implements CFB mode of Blowfish with 64bit feedback. + This allows you to encrypt an arbitrary number of bytes, + you do not require 8 byte padding. Each call to this + routine will encrypt the input bytes to output and then update ivec + and num. Num contains 'how far' we are though ivec. + 'Encrypt' is used to indicate encryption or decryption. + CFB64 mode operates by using the cipher to generate a stream + of bytes which is used to encrypt the plain text. + The cipher text is then encrypted to generate the next 64 bits to + be xored (incrementally) with the next 64 bits of plain + text. As can be seen from this, to encrypt or decrypt, + the same 'cipher stream' needs to be generated but the way the next + block of data is gathered for encryption is different for + encryption and decryption. + +void BF_ofb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +BF_KEY *schedule, +unsigned char *ivec, +int *num); + This functions implements OFB mode of Blowfish with 64bit feedback. + This allows you to encrypt an arbitrary number of bytes, + you do not require 8 byte padding. Each call to this + routine will encrypt the input bytes to output and then update ivec + and num. Num contains 'how far' we are though ivec. + This is in effect a stream cipher, there is no encryption or + decryption mode. + +For reading passwords, I suggest using des_read_pw_string() from my DES library. +To generate a password from a text string, I suggest using MD5 (or MD2) to +produce a 16 byte message digest that can then be passed directly to +BF_set_key(). + +===== +For more information about the specific Blowfish modes in this library +(ecb, cbc, cfb and ofb), read the section entitled 'Modes of DES' from the +documentation on my DES library. What is said about DES is directly +applicable for Blowfish. + diff --git a/src/lib/libssl/src/doc/bn.doc b/src/lib/libssl/src/doc/bn.doc new file mode 100644 index 0000000000..47be23b6ea --- /dev/null +++ b/src/lib/libssl/src/doc/bn.doc @@ -0,0 +1,381 @@ +The Big Number library. + +#include "bn.h" when using this library. + +This big number library was written for use in implementing the RSA and DH +public key encryption algorithms. As such, features such as negative +numbers have not been extensively tested but they should work as expected. +This library uses dynamic memory allocation for storing its data structures +and so there are no limit on the size of the numbers manipulated by these +routines but there is always the requirement to check return codes from +functions just in case a memory allocation error has occurred. + +The basic object in this library is a BIGNUM. It is used to hold a single +large integer. This type should be considered opaque and fields should not +be modified or accessed directly. +typedef struct bignum_st + { + int top; /* Index of last used d. */ + BN_ULONG *d; /* Pointer to an array of 'BITS2' bit chunks. */ + int max; /* Size of the d array. */ + int neg; + } BIGNUM; +The big number is stored in a malloced array of BN_ULONG's. A BN_ULONG can +be either 16, 32 or 64 bits in size, depending on the 'number of bits' +specified in bn.h. +The 'd' field is this array. 'max' is the size of the 'd' array that has +been allocated. 'top' is the 'last' entry being used, so for a value of 4, +bn.d[0]=4 and bn.top=1. 'neg' is 1 if the number is negative. +When a BIGNUM is '0', the 'd' field can be NULL and top == 0. + +Various routines in this library require the use of 'temporary' BIGNUM +variables during their execution. Due to the use of dynamic memory +allocation to create BIGNUMs being rather expensive when used in +conjunction with repeated subroutine calls, the BN_CTX structure is +used. This structure contains BN_CTX BIGNUMs. BN_CTX +is the maximum number of temporary BIGNUMs any publicly exported +function will use. + +#define BN_CTX 12 +typedef struct bignum_ctx + { + int tos; /* top of stack */ + BIGNUM *bn[BN_CTX]; /* The variables */ + } BN_CTX; + +The functions that follow have been grouped according to function. Most +arithmetic functions return a result in the first argument, sometimes this +first argument can also be an input parameter, sometimes it cannot. These +restrictions are documented. + +extern BIGNUM *BN_value_one; +There is one variable defined by this library, a BIGNUM which contains the +number 1. This variable is useful for use in comparisons and assignment. + +Get Size functions. + +int BN_num_bits(BIGNUM *a); + This function returns the size of 'a' in bits. + +int BN_num_bytes(BIGNUM *a); + This function (macro) returns the size of 'a' in bytes. + For conversion of BIGNUMs to byte streams, this is the number of + bytes the output string will occupy. If the output byte + format specifies that the 'top' bit indicates if the number is + signed, so an extra '0' byte is required if the top bit on a + positive number is being written, it is upto the application to + make this adjustment. Like I said at the start, I don't + really support negative numbers :-). + +Creation/Destruction routines. + +BIGNUM *BN_new(); + Return a new BIGNUM object. The number initially has a value of 0. If + there is an error, NULL is returned. + +void BN_free(BIGNUM *a); + Free()s a BIGNUM. + +void BN_clear(BIGNUM *a); + Sets 'a' to a value of 0 and also zeros all unused allocated + memory. This function is used to clear a variable of 'sensitive' + data that was held in it. + +void BN_clear_free(BIGNUM *a); + This function zeros the memory used by 'a' and then free()'s it. + This function should be used to BN_free() BIGNUMS that have held + sensitive numeric values like RSA private key values. Both this + function and BN_clear tend to only be used by RSA and DH routines. + +BN_CTX *BN_CTX_new(void); + Returns a new BN_CTX. NULL on error. + +void BN_CTX_free(BN_CTX *c); + Free a BN_CTX structure. The BIGNUMs in 'c' are BN_clear_free()ed. + +BIGNUM *bn_expand(BIGNUM *b, int bits); + This is an internal function that should not normally be used. It + ensures that 'b' has enough room for a 'bits' bit number. It is + mostly used by the various BIGNUM routines. If there is an error, + NULL is returned. if not, 'b' is returned. + +BIGNUM *BN_copy(BIGNUM *to, BIGNUM *from); + The 'from' is copied into 'to'. NULL is returned if there is an + error, otherwise 'to' is returned. + +BIGNUM *BN_dup(BIGNUM *a); + A new BIGNUM is created and returned containing the value of 'a'. + NULL is returned on error. + +Comparison and Test Functions. + +int BN_is_zero(BIGNUM *a) + Return 1 if 'a' is zero, else 0. + +int BN_is_one(a) + Return 1 is 'a' is one, else 0. + +int BN_is_word(a,w) + Return 1 if 'a' == w, else 0. 'w' is a BN_ULONG. + +int BN_cmp(BIGNUM *a, BIGNUM *b); + Return -1 if 'a' is less than 'b', 0 if 'a' and 'b' are the same + and 1 is 'a' is greater than 'b'. This is a signed comparison. + +int BN_ucmp(BIGNUM *a, BIGNUM *b); + This function is the same as BN_cmp except that the comparison + ignores the sign of the numbers. + +Arithmetic Functions +For all of these functions, 0 is returned if there is an error and 1 is +returned for success. The return value should always be checked. eg. +if (!BN_add(r,a,b)) goto err; +Unless explicitly mentioned, the 'return' value can be one of the +'parameters' to the function. + +int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); + Add 'a' and 'b' and return the result in 'r'. This is r=a+b. + +int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b); + Subtract 'a' from 'b' and put the result in 'r'. This is r=a-b. + +int BN_lshift(BIGNUM *r, BIGNUM *a, int n); + Shift 'a' left by 'n' bits. This is r=a*(2^n). + +int BN_lshift1(BIGNUM *r, BIGNUM *a); + Shift 'a' left by 1 bit. This form is more efficient than + BN_lshift(r,a,1). This is r=a*2. + +int BN_rshift(BIGNUM *r, BIGNUM *a, int n); + Shift 'a' right by 'n' bits. This is r=int(a/(2^n)). + +int BN_rshift1(BIGNUM *r, BIGNUM *a); + Shift 'a' right by 1 bit. This form is more efficient than + BN_rshift(r,a,1). This is r=int(a/2). + +int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b); + Multiply a by b and return the result in 'r'. 'r' must not be + either 'a' or 'b'. It has to be a different BIGNUM. + This is r=a*b. + +int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx); + Multiply a by a and return the result in 'r'. 'r' must not be + 'a'. This function is alot faster than BN_mul(r,a,a). This is r=a*a. + +int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); + Divide 'm' by 'd' and return the result in 'dv' and the remainder + in 'rem'. Either of 'dv' or 'rem' can be NULL in which case that + value is not returned. 'ctx' needs to be passed as a source of + temporary BIGNUM variables. + This is dv=int(m/d), rem=m%d. + +int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx); + Find the remainder of 'm' divided by 'd' and return it in 'rem'. + 'ctx' holds the temporary BIGNUMs required by this function. + This function is more efficient than BN_div(NULL,rem,m,d,ctx); + This is rem=m%d. + +int BN_mod_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *m,BN_CTX *ctx); + Multiply 'a' by 'b' and return the remainder when divided by 'm'. + 'ctx' holds the temporary BIGNUMs required by this function. + This is r=(a*b)%m. + +int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx); + Raise 'a' to the 'p' power and return the remainder when divided by + 'm'. 'ctx' holds the temporary BIGNUMs required by this function. + This is r=(a^p)%m. + +int BN_reciprocal(BIGNUM *r, BIGNUM *m, BN_CTX *ctx); + Return the reciprocal of 'm'. 'ctx' holds the temporary variables + required. This function returns -1 on error, otherwise it returns + the number of bits 'r' is shifted left to make 'r' into an integer. + This number of bits shifted is required in BN_mod_mul_reciprocal(). + This is r=(1/m)<<(BN_num_bits(m)+1). + +int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BIGNUM *m, + BIGNUM *i, int nb, BN_CTX *ctx); + This function is used to perform an efficient BN_mod_mul() + operation. If one is going to repeatedly perform BN_mod_mul() with + the same modulus is worth calculating the reciprocal of the modulus + and then using this function. This operation uses the fact that + a/b == a*r where r is the reciprocal of b. On modern computers + multiplication is very fast and big number division is very slow. + 'x' is multiplied by 'y' and then divided by 'm' and the remainder + is returned. 'i' is the reciprocal of 'm' and 'nb' is the number + of bits as returned from BN_reciprocal(). Normal usage is as follows. + bn=BN_reciprocal(i,m); + for (...) + { BN_mod_mul_reciprocal(r,x,y,m,i,bn,ctx); } + This is r=(x*y)%m. Internally it is approximately + r=(x*y)-m*(x*y/m) or r=(x*y)-m*((x*y*i) >> bn) + This function is used in BN_mod_exp() and BN_is_prime(). + +Assignment Operations + +int BN_one(BIGNUM *a) + Set 'a' to hold the value one. + This is a=1. + +int BN_zero(BIGNUM *a) + Set 'a' to hold the value zero. + This is a=0. + +int BN_set_word(BIGNUM *a, unsigned long w); + Set 'a' to hold the value of 'w'. 'w' is an unsigned long. + This is a=w. + +unsigned long BN_get_word(BIGNUM *a); + Returns 'a' in an unsigned long. Not remarkably, often 'a' will + be biger than a word, in which case 0xffffffffL is returned. + +Word Operations +These functions are much more efficient that the normal bignum arithmetic +operations. + +BN_ULONG BN_mod_word(BIGNUM *a, unsigned long w); + Return the remainder of 'a' divided by 'w'. + This is return(a%w). + +int BN_add_word(BIGNUM *a, unsigned long w); + Add 'w' to 'a'. This function does not take the sign of 'a' into + account. This is a+=w; + +Bit operations. + +int BN_is_bit_set(BIGNUM *a, int n); + This function return 1 if bit 'n' is set in 'a' else 0. + +int BN_set_bit(BIGNUM *a, int n); + This function sets bit 'n' to 1 in 'a'. + This is a&= ~(1< +X-Sender: eay@orb +To: sameer +Cc: ssleay@mincom.oz.au +Subject: Re: 'ca' +In-Reply-To: <199512230440.UAA23410@infinity.c2.org> +Message-Id: +Mime-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +Status: RO +X-Status: + +On Fri, 22 Dec 1995, sameer wrote: +> I could use documentation on 'ca'. Thanks. + +Very quickly. +The ca program uses the ssleay.conf file for most of its configuration + +./ca -help + + -verbose - Talk alot while doing things + -config file - A config file. If you don't want to use the + default config file + -name arg - The particular CA definition to use + In the config file, the section to use for parameters. This lets + multiple setups to be contained in the one file. By default, the + default_ca variable is looked up in the [ ca ] section. So in the + shipped ssleay.conf, the CA definition used is CA_default. It could be + any other name. + -gencrl days - Generate a new CRL, days is when the next CRL is due + This will generate a new certificate revocion list. + -days arg - number of days to certify the certificate for + When certifiying certificates, this is the number of days to use. + -md arg - md to use, one of md2, md5, sha or sha1 + -policy arg - The CA 'policy' to support + I'll describe this later, but there are 2 policies definied in the + shipped ssleay.conf + -keyfile arg - PEM RSA private key file + -key arg - key to decode the RSA private key if it is encrypted + since we need to keep the CA's RSA key encrypted + -cert - The CA certificate + -in file - The input PEM encoded certificate request(s) + -out file - Where to put the output file(s) + -outdir dir - Where to put output certificates + The -out options concatinates all the output certificied + certificates to one file, -outdir puts them in a directory, + named by serial number. + -infiles .... - The last argument, requests to process + The certificate requests to process, -in is the same. + +Just about all the above have default values defined in ssleay.conf. + +The key variables in ssleay.conf are (for the pariticular '-name' being +used, in the default, it is CA_default). + +dir is where all the CA database stuff is kept. +certs is where all the previously issued certificates are kept. +The database is a simple text database containing the following tab separated +fields. +status: a value of 'R' - revoked, 'E' -expired or 'V' valid. +issued date: When the certificate was certified. +revoked date: When it was revoked, blank if not revoked. +serial number: The certificate serial number. +certificate: Where the certificate is located. +CN: The name of the certificate. + +The demo file has quite a few made up values it it. The last 2 were +added by the ca program and are acurate. +The CA program does not update the 'certificate' file correctly right now. +The serial field should be unique as should the CN/status combination. +The ca program checks these at startup. What still needs to be +wrtten is a program to 'regenerate' the data base file from the issued +certificate list (and a CRL list). + +Back to the CA_default variables. + +Most of the variables are commented. + +policy is the default policy. + +Ok for policies, they define the order and which fields must be present +in the certificate request and what gets filled in. + +So a value of +countryName = match +means that the country name must match the CA certificate. +organizationalUnitName = optional +The org.Unit,Name does not have to be present and +commonName = supplied +commonName must be supplied in the certificate request. + +For the 'policy_match' polocy, the order of the attributes in the +generated certiticate would be +countryName +stateOrProvinceName +organizationName +organizationalUnitName +commonName +emailAddress + +Have a play, it sort of makes sense. If you think about how the persona +requests operate, it is similar to the 'policy_match' policy and the +'policy_anything' is similar to what versign is doing. + +I hope this helps a bit. Some backend scripts are definitly needed to +update the database and to make certificate revocion easy. All +certificates issued should also be kept forever (or until they expire?) + +hope this helps +eric (who has to run off an buy some cheap knee pads for the caving in 4 +days time :-) + +-- +Eric Young | Signature removed since it was generating +AARNet: eay@mincom.oz.au | more followups than the message contents :-) + + diff --git a/src/lib/libssl/src/doc/callback.doc b/src/lib/libssl/src/doc/callback.doc new file mode 100644 index 0000000000..7ad0f7f7d2 --- /dev/null +++ b/src/lib/libssl/src/doc/callback.doc @@ -0,0 +1,240 @@ +Callback functions used in SSLeay. + +-------------------------- +The BIO library. + +Each BIO structure can have a callback defined against it. This callback is +called 2 times for each BIO 'function'. It is passed 6 parameters. +BIO_debug_callback() is an example callback which is defined in +crypto/buffer/bio_cb.c and is used in apps/dgst.c This is intended mostly +for debuging or to notify the application of IO. + +long BIO_debug_callback(BIO *bio,int cmd,char *argp,int argi,long argl, + long ret); +bio is the BIO being called, cmd is the type of BIO function being called. +Look at the BIO_CB_* defines in buffer.h. Argp and argi are the arguments +passed to BIO_read(), BIO_write, BIO_gets(), BIO_puts(). In the case of +BIO_ctrl(), argl is also defined. The first time the callback is called, +before the underlying function has been executed, 0 is passed as 'ret', and +if the return code from the callback is not > 0, the call is aborted +and the returned <= 0 value is returned. +The second time the callback is called, the 'cmd' value also has +BIO_CB_RETURN logically 'or'ed with it. The 'ret' value is the value returned +from the actuall function call and whatever the callback returns is returned +from the BIO function. + +BIO_set_callback(b,cb) can be used to set the callback function +(b is a BIO), and BIO_set_callback_arg(b,arg) can be used to +set the cb_arg argument in the BIO strucutre. This field is only intended +to be used by application, primarily in the callback function since it is +accessable since the BIO is passed. + +-------------------------- +The PEM library. + +The pem library only really uses one type of callback, +static int def_callback(char *buf, int num, int verify); +which is used to return a password string if required. +'buf' is the buffer to put the string in. 'num' is the size of 'buf' +and 'verify' is used to indicate that the password should be checked. +This last flag is mostly used when reading a password for encryption. + +For all of these functions, a NULL callback will call the above mentioned +default callback. This default function does not work under Windows 3.1. +For other machines, it will use an application defined prompt string +(EVP_set_pw_prompt(), which defines a library wide prompt string) +if defined, otherwise it will use it's own PEM password prompt. +It will then call EVP_read_pw_string() to get a password from the console. +If your application wishes to use nice fancy windows to retrieve passwords, +replace this function. The callback should return the number of bytes read +into 'buf'. If the number of bytes <= 0, it is considered an error. + +Functions that take this callback are listed below. For the 'read' type +functions, the callback will only be required if the PEM data is encrypted. + +For the Write functions, normally a password can be passed in 'kstr', of +'klen' bytes which will be used if the 'enc' cipher is not NULL. If +'kstr' is NULL, the callback will be used to retrieve a password. + +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + int (*callback)()); +char *PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x,int (*cb)()); +char *PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,int (*cb)()); +int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x, + EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)()); +int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x, + EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)()); +STACK *PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)()); +STACK *PEM_X509_INFO_read_bio(BIO *fp, STACK *sk, int (*cb)()); + +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) +#define PEM_read_SSL_SESSION(fp,x,cb) +#define PEM_read_X509(fp,x,cb) +#define PEM_read_X509_REQ(fp,x,cb) +#define PEM_read_X509_CRL(fp,x,cb) +#define PEM_read_RSAPrivateKey(fp,x,cb) +#define PEM_read_DSAPrivateKey(fp,x,cb) +#define PEM_read_PrivateKey(fp,x,cb) +#define PEM_read_PKCS7(fp,x,cb) +#define PEM_read_DHparams(fp,x,cb) +#define PEM_read_bio_SSL_SESSION(bp,x,cb) +#define PEM_read_bio_X509(bp,x,cb) +#define PEM_read_bio_X509_REQ(bp,x,cb) +#define PEM_read_bio_X509_CRL(bp,x,cb) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb) +#define PEM_read_bio_PrivateKey(bp,x,cb) +#define PEM_read_bio_PKCS7(bp,x,cb) +#define PEM_read_bio_DHparams(bp,x,cb) +int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); +RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()); + +Now you will notice that macros like +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL) +Don't do encryption normally. If you want to PEM encrypt your X509 structure, +either just call PEM_ASN1_write directly or just define you own +macro variant. As you can see, this macro just sets all encryption related +parameters to NULL. + + +-------------------------- +The SSL library. + +#define SSL_set_info_callback(ssl,cb) +#define SSL_CTX_set_info_callback(ctx,cb) +void callback(SSL *ssl,int location,int ret) +This callback is called each time around the SSL_connect()/SSL_accept() +state machine. So it will be called each time the SSL protocol progresses. +It is mostly present for use when debugging. When SSL_connect() or +SSL_accept() return, the location flag is SSL_CB_ACCEPT_EXIT or +SSL_CB_CONNECT_EXIT and 'ret' is the value about to be returned. +Have a look at the SSL_CB_* defines in ssl.h. If an info callback is defined +against the SSL_CTX, it is called unless there is one set against the SSL. +Have a look at +void client_info_callback() in apps/s_client() for an example. + +Certificate verification. +void SSL_set_verify(SSL *s, int mode, int (*callback) ()); +void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*callback)()); +This callback is used to help verify client and server X509 certificates. +It is actually passed to X509_cert_verify(), along with the SSL structure +so you have to read about X509_cert_verify() :-). The SSL_CTX version is used +if the SSL version is not defined. X509_cert_verify() is the function used +by the SSL part of the library to verify certificates. This function is +nearly always defined by the application. + +void SSL_CTX_set_cert_verify_cb(SSL_CTX *ctx, int (*cb)(),char *arg); +int callback(char *arg,SSL *s,X509 *xs,STACK *cert_chain); +This call is used to replace the SSLeay certificate verification code. +The 'arg' is kept in the SSL_CTX and is passed to the callback. +If the callback returns 0, the certificate is rejected, otherwise it +is accepted. The callback is replacing the X509_cert_verify() call. +This feature is not often used, but if you wished to implement +some totally different certificate authentication system, this 'hook' is +vital. + +SSLeay keeps a cache of session-ids against each SSL_CTX. These callbacks can +be used to notify the application when a SSL_SESSION is added to the cache +or to retrieve a SSL_SESSION that is not in the cache from the application. +#define SSL_CTX_sess_set_get_cb(ctx,cb) +SSL_SESSION *callback(SSL *s,char *session_id,int session_id_len,int *copy); +If defined, this callback is called to return the SESSION_ID for the +session-id in 'session_id', of 'session_id_len' bytes. 'copy' is set to 1 +if the server is to 'take a copy' of the SSL_SESSION structure. It is 0 +if the SSL_SESSION is being 'passed in' so the SSLeay library is now +responsible for 'free()ing' the structure. Basically it is used to indicate +if the reference count on the SSL_SESSION structure needs to be incremented. + +#define SSL_CTX_sess_set_new_cb(ctx,cb) +int callback(SSL *s, SSL_SESSION *sess); +When a new connection is established, if the SSL_SESSION is going to be added +to the cache, this callback is called. Return 1 if a 'copy' is required, +otherwise, return 0. This return value just causes the reference count +to be incremented (on return of a 1), this means the application does +not need to worry about incrementing the refernece count (and the +locking that implies in a multi-threaded application). + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx,int (*cb)()); +This sets the SSL password reading function. +It is mostly used for windowing applications +and used by PEM_read_bio_X509() and PEM_read_bio_RSAPrivateKey() +calls inside the SSL library. The only reason this is present is because the +calls to PEM_* functions is hidden in the SSLeay library so you have to +pass in the callback some how. + +#define SSL_CTX_set_client_cert_cb(ctx,cb) +int callback(SSL *s,X509 **x509, EVP_PKEY **pkey); +Called when a client certificate is requested but there is not one set +against the SSL_CTX or the SSL. If the callback returns 1, x509 and +pkey need to point to valid data. The library will free these when +required so if the application wants to keep these around, increment +their reference counts. If 0 is returned, no client cert is +available. If -1 is returned, it is assumed that the callback needs +to be called again at a later point in time. SSL_connect will return +-1 and SSL_want_x509_lookup(ssl) returns true. Remember that +application data can be attached to an SSL structure via the +SSL_set_app_data(SSL *ssl,char *data) call. + +-------------------------- +The X509 library. + +int X509_cert_verify(CERTIFICATE_CTX *ctx,X509 *xs, int (*cb)(), + int *error,char *arg,STACK *cert_chain); +int verify_callback(int ok,X509 *xs,X509 *xi,int depth,int error,char *arg, + STACK *cert_chain); + +X509_cert_verify() is used to authenticate X509 certificates. The 'ctx' holds +the details of the various caches and files used to locate certificates. +'xs' is the certificate to verify and 'cb' is the application callback (more +detail later). 'error' will be set to the error code and 'arg' is passed +to the 'cb' callback. Look at the VERIFY_* defines in crypto/x509/x509.h + +When ever X509_cert_verify() makes a 'negative' decision about a +certitificate, the callback is called. If everything checks out, the +callback is called with 'VERIFY_OK' or 'VERIFY_ROOT_OK' (for a self +signed cert that is not the passed certificate). + +The callback is passed the X509_cert_verify opinion of the certificate +in 'ok', the certificate in 'xs', the issuer certificate in 'xi', +the 'depth' of the certificate in the verification 'chain', the +VERIFY_* code in 'error' and the argument passed to X509_cert_verify() +in 'arg'. cert_chain is a list of extra certs to use if they are not +in the cache. + +The callback can be used to look at the error reason, and then return 0 +for an 'error' or '1' for ok. This will override the X509_cert_verify() +opinion of the certificates validity. Processing will continue depending on +the return value. If one just wishes to use the callback for informational +reason, just return the 'ok' parameter. + +-------------------------- +The BN and DH library. + +BIGNUM *BN_generate_prime(int bits,int strong,BIGNUM *add, + BIGNUM *rem,void (*callback)(int,int)); +int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int), + +Read doc/bn.doc for the description of these 2. + +DH *DH_generate_parameters(int prime_len,int generator, + void (*callback)(int,int)); +Read doc/bn.doc for the description of the callback, since it is just passed +to BN_generate_prime(), except that it is also called as +callback(3,0) by this function. + +-------------------------- +The CRYPTO library. + +void CRYPTO_set_locking_callback(void (*func)(int mode,int type,char *file, + int line)); +void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount, + int type,char *file, int line)); +void CRYPTO_set_id_callback(unsigned long (*func)(void)); + +Read threads.doc for info on these ones. + diff --git a/src/lib/libssl/src/doc/cipher.doc b/src/lib/libssl/src/doc/cipher.doc new file mode 100644 index 0000000000..d49ba78c5c --- /dev/null +++ b/src/lib/libssl/src/doc/cipher.doc @@ -0,0 +1,345 @@ +The Cipher subroutines. + +These routines require "evp.h" to be included. + +These functions are a higher level interface to the various cipher +routines found in this library. As such, they allow the same code to be +used to encrypt and decrypt via different ciphers with only a change +in an initial parameter. These routines also provide buffering for block +ciphers. + +These routines all take a pointer to the following structure to specify +which cipher to use. If you wish to use a new cipher with these routines, +you would probably be best off looking an how an existing cipher is +implemented and copying it. At this point in time, I'm not going to go +into many details. This structure should be considered opaque + +typedef struct pem_cipher_st + { + int type; + int block_size; + int key_len; + int iv_len; + void (*enc_init)(); /* init for encryption */ + void (*dec_init)(); /* init for decryption */ + void (*do_cipher)(); /* encrypt data */ + } EVP_CIPHER; + +The type field is the object NID of the cipher type +(read the section on Objects for an explanation of what a NID is). +The cipher block_size is how many bytes need to be passed +to the cipher at a time. Key_len is the +length of the key the cipher requires and iv_len is the length of the +initialisation vector required. enc_init is the function +called to initialise the ciphers context for encryption and dec_init is the +function to initialise for decryption (they need to be different, especially +for the IDEA cipher). + +One reason for specifying the Cipher via a pointer to a structure +is that if you only use des-cbc, only the des-cbc routines will +be included when you link the program. If you passed an integer +that specified which cipher to use, the routine that mapped that +integer to a set of cipher functions would cause all the ciphers +to be link into the code. This setup also allows new ciphers +to be added by the application (with some restrictions). + +The thirteen ciphers currently defined in this library are + +EVP_CIPHER *EVP_des_ecb(); /* DES in ecb mode, iv=0, block=8, key= 8 */ +EVP_CIPHER *EVP_des_ede(); /* DES in ecb ede mode, iv=0, block=8, key=16 */ +EVP_CIPHER *EVP_des_ede3(); /* DES in ecb ede mode, iv=0, block=8, key=24 */ +EVP_CIPHER *EVP_des_cfb(); /* DES in cfb mode, iv=8, block=1, key= 8 */ +EVP_CIPHER *EVP_des_ede_cfb(); /* DES in ede cfb mode, iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_des_ede3_cfb();/* DES in ede cfb mode, iv=8, block=1, key=24 */ +EVP_CIPHER *EVP_des_ofb(); /* DES in ofb mode, iv=8, block=1, key= 8 */ +EVP_CIPHER *EVP_des_ede_ofb(); /* DES in ede ofb mode, iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_des_ede3_ofb();/* DES in ede ofb mode, iv=8, block=1, key=24 */ +EVP_CIPHER *EVP_des_cbc(); /* DES in cbc mode, iv=8, block=8, key= 8 */ +EVP_CIPHER *EVP_des_ede_cbc(); /* DES in cbc ede mode, iv=8, block=8, key=16 */ +EVP_CIPHER *EVP_des_ede3_cbc();/* DES in cbc ede mode, iv=8, block=8, key=24 */ +EVP_CIPHER *EVP_desx_cbc(); /* DES in desx cbc mode,iv=8, block=8, key=24 */ +EVP_CIPHER *EVP_rc4(); /* RC4, iv=0, block=1, key=16 */ +EVP_CIPHER *EVP_idea_ecb(); /* IDEA in ecb mode, iv=0, block=8, key=16 */ +EVP_CIPHER *EVP_idea_cfb(); /* IDEA in cfb mode, iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_idea_ofb(); /* IDEA in ofb mode, iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_idea_cbc(); /* IDEA in cbc mode, iv=8, block=8, key=16 */ +EVP_CIPHER *EVP_rc2_ecb(); /* RC2 in ecb mode, iv=0, block=8, key=16 */ +EVP_CIPHER *EVP_rc2_cfb(); /* RC2 in cfb mode, iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_rc2_ofb(); /* RC2 in ofb mode, iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_rc2_cbc(); /* RC2 in cbc mode, iv=8, block=8, key=16 */ +EVP_CIPHER *EVP_bf_ecb(); /* Blowfish in ecb mode,iv=0, block=8, key=16 */ +EVP_CIPHER *EVP_bf_cfb(); /* Blowfish in cfb mode,iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_bf_ofb(); /* Blowfish in ofb mode,iv=8, block=1, key=16 */ +EVP_CIPHER *EVP_bf_cbc(); /* Blowfish in cbc mode,iv=8, block=8, key=16 */ + +The meaning of the compound names is as follows. +des The base cipher is DES. +idea The base cipher is IDEA +rc4 The base cipher is RC4-128 +rc2 The base cipher is RC2-128 +ecb Electronic Code Book form of the cipher. +cbc Cipher Block Chaining form of the cipher. +cfb 64 bit Cipher Feedback form of the cipher. +ofb 64 bit Output Feedback form of the cipher. +ede The cipher is used in Encrypt, Decrypt, Encrypt mode. The first + and last keys are the same. +ede3 The cipher is used in Encrypt, Decrypt, Encrypt mode. + +All the Cipher routines take a EVP_CIPHER_CTX pointer as an argument. +The state of the cipher is kept in this structure. + +typedef struct EVP_CIPHER_Ctx_st + { + EVP_CIPHER *cipher; + int encrypt; /* encrypt or decrypt */ + int buf_len; /* number we have left */ + unsigned char buf[8]; + union { + .... /* cipher specific stuff */ + } c; + } EVP_CIPHER_CTX; + +Cipher is a pointer the the EVP_CIPHER for the current context. The encrypt +flag indicates encryption or decryption. buf_len is the number of bytes +currently being held in buf. +The 'c' union holds the cipher specify context. + +The following functions are to be used. + +int EVP_read_pw_string( +char *buf, +int len, +char *prompt, +int verify, + This function is the same as des_read_pw_string() (des.doc). + +void EVP_set_pw_prompt(char *prompt); + This function sets the 'default' prompt to use to use in + EVP_read_pw_string when the prompt parameter is NULL. If the + prompt parameter is NULL, this 'default prompt' feature is turned + off. Be warned, this is a global variable so weird things + will happen if it is used under Win16 and care must be taken + with a multi-threaded version of the library. + +char *EVP_get_pw_prompt(); + This returns a pointer to the default prompt string. NULL + if it is not set. + +int EVP_BytesToKey( +EVP_CIPHER *type, +EVP_MD *md, +unsigned char *salt, +unsigned char *data, +int datal, +int count, +unsigned char *key, +unsigned char *iv); + This function is used to generate a key and an initialisation vector + for a specified cipher from a key string and a salt. Type + specifies the cipher the 'key' is being generated for. Md is the + message digest algorithm to use to generate the key and iv. The salt + is an optional 8 byte object that is used to help seed the key + generator. + If the salt value is NULL, it is just not used. Datal is the + number of bytes to use from 'data' in the key generation. + This function returns the key size for the specified cipher, if + data is NULL, this value is returns and no other + computation is performed. Count is + the number of times to loop around the key generator. I would + suggest leaving it's value as 1. Key and iv are the structures to + place the returning iv and key in. If they are NULL, no value is + generated for that particular value. + The algorithm used is as follows + + /* M[] is an array of message digests + * MD() is the message digest function */ + M[0]=MD(data . salt); + for (i=1; i key=M[0.. 8], iv=M[ 9 .. 16]. + For key=16, iv=0 => key=M[0..16]. + For key=16, iv=8 => key=M[0..16], iv=M[17 .. 24]. + For key=24, iv=8 => key=M[0..24], iv=M[25 .. 32]. + + This routine will produce DES-CBC keys and iv that are compatible + with the PKCS-5 standard when md2 or md5 are used. If md5 is + used, the salt is NULL and count is 1, this routine will produce + the password to key mapping normally used with RC4. + I have attempted to logically extend the PKCS-5 standard to + generate keys and iv for ciphers that require more than 16 bytes, + if anyone knows what the correct standard is, please inform me. + When using sha or sha1, things are a bit different under this scheme, + since sha produces a 20 byte digest. So for ciphers requiring + 24 bits of data, 20 will come from the first MD and 4 will + come from the second. + + I have considered having a separate function so this 'routine' + can be used without the requirement of passing a EVP_CIPHER *, + but I have decided to not bother. If you wish to use the + function without official EVP_CIPHER structures, just declare + a local one and set the key_len and iv_len fields to the + length you desire. + +The following routines perform encryption and decryption 'by parts'. By +this I mean that there are groups of 3 routines. An Init function that is +used to specify a cipher and initialise data structures. An Update routine +that does encryption/decryption, one 'chunk' at a time. And finally a +'Final' function that finishes the encryption/decryption process. +All these functions take a EVP_CIPHER pointer to specify which cipher to +encrypt/decrypt with. They also take a EVP_CIPHER_CTX object as an +argument. This structure is used to hold the state information associated +with the operation in progress. + +void EVP_EncryptInit( +EVP_CIPHER_CTX *ctx, +EVP_CIPHER *type, +unsigned char *key, +unsigned char *iv); + This function initialise a EVP_CIPHER_CTX for encryption using the + cipher passed in the 'type' field. The cipher is initialised to use + 'key' as the key and 'iv' for the initialisation vector (if one is + required). If the type, key or iv is NULL, the value currently in the + EVP_CIPHER_CTX is reused. So to perform several decrypt + using the same cipher, key and iv, initialise with the cipher, + key and iv the first time and then for subsequent calls, + reuse 'ctx' but pass NULL for type, key and iv. You must make sure + to pass a key that is large enough for a particular cipher. I + would suggest using the EVP_BytesToKey() function. + +void EVP_EncryptUpdate( +EVP_CIPHER_CTX *ctx, +unsigned char *out, +int *outl, +unsigned char *in, +int inl); + This function takes 'inl' bytes from 'in' and outputs bytes + encrypted by the cipher 'ctx' was initialised with into 'out'. The + number of bytes written to 'out' is put into outl. If a particular + cipher encrypts in blocks, less or more bytes than input may be + output. Currently the largest block size used by supported ciphers + is 8 bytes, so 'out' should have room for 'inl+7' bytes. Normally + EVP_EncryptInit() is called once, followed by lots and lots of + calls to EVP_EncryptUpdate, followed by a single EVP_EncryptFinal + call. + +void EVP_EncryptFinal( +EVP_CIPHER_CTX *ctx, +unsigned char *out, +int *outl); + Because quite a large number of ciphers are block ciphers, there is + often an incomplete block to write out at the end of the + encryption. EVP_EncryptFinal() performs processing on this last + block. The last block in encoded in such a way that it is possible + to determine how many bytes in the last block are valid. For 8 byte + block size ciphers, if only 5 bytes in the last block are valid, the + last three bytes will be filled with the value 3. If only 2 were + valid, the other 6 would be filled with sixes. If all 8 bytes are + valid, a extra 8 bytes are appended to the cipher stream containing + nothing but 8 eights. These last bytes are output into 'out' and + the number of bytes written is put into 'outl' These last bytes + are output into 'out' and the number of bytes written is put into + 'outl'. This form of block cipher finalisation is compatible with + PKCS-5. Please remember that even if you are using ciphers like + RC4 that has no blocking and so the function will not write + anything into 'out', it would still be a good idea to pass a + variable for 'out' that can hold 8 bytes just in case the cipher is + changed some time in the future. It should also be remembered + that the EVP_CIPHER_CTX contains the password and so when one has + finished encryption with a particular EVP_CIPHER_CTX, it is good + practice to zero the structure + (ie. memset(ctx,0,sizeof(EVP_CIPHER_CTX)). + +void EVP_DecryptInit( +EVP_CIPHER_CTX *ctx, +EVP_CIPHER *type, +unsigned char *key, +unsigned char *iv); + This function is basically the same as EVP_EncryptInit() accept that + is prepares the EVP_CIPHER_CTX for decryption. + +void EVP_DecryptUpdate( +EVP_CIPHER_CTX *ctx, +unsigned char *out, +int *outl, +unsigned char *in, +int inl); + This function is basically the same as EVP_EncryptUpdate() + except that it performs decryption. There is one + fundamental difference though. 'out' can not be the same as + 'in' for any ciphers with a block size greater than 1 if more + than one call to EVP_DecryptUpdate() will be made. This + is because this routine can hold a 'partial' block between + calls. When a partial block is decrypted (due to more bytes + being passed via this function, they will be written to 'out' + overwriting the input bytes in 'in' that have not been read + yet. From this it should also be noted that 'out' should + be at least one 'block size' larger than 'inl'. This problem + only occurs on the second and subsequent call to + EVP_DecryptUpdate() when using a block cipher. + +int EVP_DecryptFinal( +EVP_CIPHER_CTX *ctx, +unsigned char *out, +int *outl); + This function is different to EVP_EncryptFinal in that it 'removes' + any padding bytes appended when the data was encrypted. Due to the + way in which 1 to 8 bytes may have been appended when encryption + using a block cipher, 'out' can end up with 0 to 7 bytes being put + into it. When decoding the padding bytes, it is possible to detect + an incorrect decryption. If the decryption appears to be wrong, 0 + is returned. If everything seems ok, 1 is returned. For ciphers + with a block size of 1 (RC4), this function would normally not + return any bytes and would always return 1. Just because this + function returns 1 does not mean the decryption was correct. It + would normally be wrong due to either the wrong key/iv or + corruption of the cipher data fed to EVP_DecryptUpdate(). + As for EVP_EncryptFinal, it is a good idea to zero the + EVP_CIPHER_CTX after use since the structure contains the key used + to decrypt the data. + +The following Cipher routines are convenience routines that call either +EVP_EncryptXxx or EVP_DecryptXxx depending on weather the EVP_CIPHER_CTX +was setup to encrypt or decrypt. + +void EVP_CipherInit( +EVP_CIPHER_CTX *ctx, +EVP_CIPHER *type, +unsigned char *key, +unsigned char *iv, +int enc); + This function take arguments that are the same as EVP_EncryptInit() + and EVP_DecryptInit() except for the extra 'enc' flag. If 1, the + EVP_CIPHER_CTX is setup for encryption, if 0, decryption. + +void EVP_CipherUpdate( +EVP_CIPHER_CTX *ctx, +unsigned char *out, +int *outl, +unsigned char *in, +int inl); + Again this function calls either EVP_EncryptUpdate() or + EVP_DecryptUpdate() depending on state in the 'ctx' structure. + As noted for EVP_DecryptUpdate(), when this routine is used + for decryption with block ciphers, 'out' should not be the + same as 'in'. + +int EVP_CipherFinal( +EVP_CIPHER_CTX *ctx, +unsigned char *outm, +int *outl); + This routine call EVP_EncryptFinal() or EVP_DecryptFinal() + depending on the state information in 'ctx'. 1 is always returned + if the mode is encryption, otherwise the return value is the return + value of EVP_DecryptFinal(). diff --git a/src/lib/libssl/src/doc/cipher.m b/src/lib/libssl/src/doc/cipher.m new file mode 100644 index 0000000000..9f74917135 --- /dev/null +++ b/src/lib/libssl/src/doc/cipher.m @@ -0,0 +1,128 @@ +From ssl-lists-owner@mincom.com Tue Oct 15 18:16:14 1996 +Received: from cygnus.mincom.oz.au by orb.mincom.oz.au with SMTP id AA11550 + (5.65c/IDA-1.4.4 for eay); Tue, 15 Oct 1996 08:17:41 +1000 +Received: (from daemon@localhost) by cygnus.mincom.oz.au (8.7.5/8.7.3) id IAA12472 for ssl-users-outgoing; Tue, 15 Oct 1996 08:16:35 +1000 (EST) +Received: from orb.mincom.oz.au (eay@orb.mincom.oz.au [192.55.197.1]) by cygnus.mincom.oz.au (8.7.5/8.7.3) with SMTP id IAA12463 for ; Tue, 15 Oct 1996 08:16:32 +1000 (EST) +Received: by orb.mincom.oz.au id AA11544 + (5.65c/IDA-1.4.4 for ssl-users@listserv.mincom.oz.au); Tue, 15 Oct 1996 08:16:15 +1000 +Date: Tue, 15 Oct 1996 08:16:14 +1000 (EST) +From: Eric Young +X-Sender: eay@orb +To: Roland Haring +Cc: ssl-users@mincom.com +Subject: Re: Symmetric encryption with ssleay +In-Reply-To: +Message-Id: +Mime-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +Sender: ssl-lists-owner@mincom.com +Precedence: bulk +Status: RO +X-Status: + + +On Fri, 11 Oct 1996, Roland Haring wrote: +> THE_POINT: +> Would somebody be so kind to give me the minimum basic +> calls I need to do to libcrypto.a to get some text encrypted +> and decrypted again? ...hopefully with code included to do +> base64 encryption and decryption ... e.g. that sign-it.c code +> posted some while ago was a big help :-) (please, do not point +> me to apps/enc.c where I suspect my Heissenbug to be hidden :-) + +Ok, the base64 encoding stuff in 'enc.c' does the wrong thing sometimes +when the data is less than a line long (this is for decoding). I'll dig +up the exact fix today and post it. I am taking longer on 0.6.5 than I +intended so I'll just post this patch. + +The documentation to read is in +doc/cipher.doc, +doc/encode.doc (very sparse :-). +and perhaps +doc/digest.doc, + +The basic calls to encrypt with say triple DES are + +Given +char key[EVP_MAX_KEY_LENGTH]; +char iv[EVP_MAX_IV_LENGTH]; +EVP_CIPHER_CTX ctx; +unsigned char out[512+8]; +int outl; + +/* optional generation of key/iv data from text password using md5 + * via an upward compatable verson of PKCS#5. */ +EVP_BytesToKey(EVP_des_ede3_cbc,EVP_md5,NULL,passwd,strlen(passwd), + key,iv); + +/* Initalise the EVP_CIPHER_CTX */ +EVP_EncryptInit(ctx,EVP_des_ede3_cbc,key,iv); + +while (....) + { + /* This is processing 512 bytes at a time, the bytes are being + * copied into 'out', outl bytes are output. 'out' should not be the + * same as 'in' for reasons mentioned in the documentation. */ + EVP_EncryptUpdate(ctx,out,&outl,in,512); + } + +/* Output the last 'block'. If the cipher is a block cipher, the last + * block is encoded in such a way so that a wrong decryption will normally be + * detected - again, one of the PKCS standards. */ + +EVP_EncryptFinal(ctx,out,&outl); + +To decrypt, use the EVP_DecryptXXXXX functions except that EVP_DecryptFinal() +will return 0 if the decryption fails (only detectable on block ciphers). + +You can also use +EVP_CipherInit() +EVP_CipherUpdate() +EVP_CipherFinal() +which does either encryption or decryption depending on an extra +parameter to EVP_CipherInit(). + + +To do the base64 encoding, +EVP_EncodeInit() +EVP_EncodeUpdate() +EVP_EncodeFinal() + +EVP_DecodeInit() +EVP_DecodeUpdate() +EVP_DecodeFinal() + +where the encoding is quite simple, but the decoding can be a bit more +fun (due to dud input). + +EVP_DecodeUpdate() returns -1 for an error on an input line, 0 if the +'last line' was just processed, and 1 if more lines should be submitted. + +EVP_DecodeFinal() returns -1 for an error or 1 if things are ok. + +So the loop becomes +EVP_DecodeInit(....) +for (;;) + { + i=EVP_DecodeUpdate(....); + if (i < 0) goto err; + + /* process the data */ + + if (i == 0) break; + } +EVP_DecodeFinal(....); +/* process the data */ + +The problem in 'enc.c' is that I was stuff the processing up after the +EVP_DecodeFinal(...) when the for(..) loop was not being run (one line of +base64 data) and this was because 'enc.c' tries to scan over a file until +it hits the first valid base64 encoded line. + +hope this helps a bit. +eric +-- +Eric Young | BOOL is tri-state according to Bill Gates. +AARNet: eay@mincom.oz.au | RTFM Win32 GetMessage(). + + diff --git a/src/lib/libssl/src/doc/conf.doc b/src/lib/libssl/src/doc/conf.doc new file mode 100644 index 0000000000..f12fe884f5 --- /dev/null +++ b/src/lib/libssl/src/doc/conf.doc @@ -0,0 +1,89 @@ +The CONF library. + +The CONF library is a simple set of routines that can be used to configure +programs. It is a superset of the genenv() function with some extra +structure. + +The library consists of 5 functions. + +LHASH *CONF_load(LHASH *config,char *file); +This function is called to load in a configuration file. Multiple +configuration files can be loaded, with each subsequent 'load' overwriting +any already defined 'variables'. If there is an error, NULL is returned. +If config is NULL, a new LHASH structure is created and returned, otherwise +the new data in the 'file' is loaded into the 'config' structure. + +void CONF_free(LHASH *config); +This function free()s the data in config. + +char *CONF_get_string(LHASH *config,char *section,char *name); +This function returns the string found in 'config' that corresponds to the +'section' and 'name' specified. Classes and the naming system used will be +discussed later in this document. If the variable is not defined, an NULL +is returned. + +long CONF_get_long(LHASH *config,char *section, char *name); +This function is the same as CONF_get_string() except that it converts the +string to an long and returns it. If variable is not a number or the +variable does not exist, 0 is returned. This is a little problematic but I +don't know of a simple way around it. + +STACK *CONF_get_section(LHASH *config, char *section); +This function returns a 'stack' of CONF_VALUE items that are all the +items defined in a particular section. DO NOT free() any of the +variable returned. They will disappear when CONF_free() is called. + +The 'lookup' model. +The configuration file is divided into 'sections'. Each section is started by +a line of the form '[ section ]'. All subsequent variable definitions are +of this section. A variable definition is a simple alpha-numeric name +followed by an '=' and then the data. A section or variable name can be +described by a regular expression of the following form '[A-Za-z0-9_]+'. +The value of the variable is the text after the '=' until the end of the +line, stripped of leading and trailing white space. +At this point I should mention that a '#' is a comment character, \ is the +escape character, and all three types of quote can be used to stop any +special interpretation of the data. +Now when the data is being loaded, variable expansion can occur. This is +done by expanding any $NAME sequences into the value represented by the +variable NAME. If the variable is not in the current section, the different +section can be specified by using the $SECTION::NAME form. The ${NAME} form +also works and is very useful for expanding variables inside strings. + +When a variable is looked up, there are 2 special section. 'default', which +is the initial section, and 'ENV' which is the processes environment +variables (accessed via getenv()). When a variable is looked up, it is +first 'matched' with it's section (if one was specified), if this fails, the +'default' section is matched. +If the 'lhash' variable passed was NULL, the environment is searched. + +Now why do we bother with sections? So we can have multiple programs using +the same configuration file, or multiple instances of the same program +using different variables. It also provides a nice mechanism to override +the processes environment variables (eg ENV::HOME=/tmp). If there is a +program specific variable missing, we can have default values. +Multiple configuration files can be loaded, with each new value clearing +any predefined values. A system config file can provide 'default' values, +and application/usr specific files can provide overriding values. + +Examples + +# This is a simple example +SSLEAY_HOME = /usr/local/ssl +ENV::PATH = $SSLEAY_HOME/bin:$PATH # override my path + +[X509] +cert_dir = $SSLEAY_HOME/certs # /usr/local/ssl/certs + +[SSL] +CIPHER = DES-EDE-MD5:RC4-MD5 +USER_CERT = $HOME/${USER}di'r 5' # /home/eay/eaydir 5 +USER_CERT = $HOME/\${USER}di\'r # /home/eay/${USER}di'r +USER_CERT = "$HOME/${US"ER}di\'r # $HOME/${USER}di'r + +TEST = 1234\ +5678\ +9ab # TEST=123456789ab +TTT = 1234\n\n # TTT=1234 + + diff --git a/src/lib/libssl/src/doc/des.doc b/src/lib/libssl/src/doc/des.doc new file mode 100644 index 0000000000..5879d968f3 --- /dev/null +++ b/src/lib/libssl/src/doc/des.doc @@ -0,0 +1,505 @@ +The DES library. + +Please note that this library was originally written to operate with +eBones, a version of Kerberos that had had encryption removed when it left +the USA and then put back in. As such there are some routines that I will +advise not using but they are still in the library for historical reasons. +For all calls that have an 'input' and 'output' variables, they can be the +same. + +This library requires the inclusion of 'des.h'. + +All of the encryption functions take what is called a des_key_schedule as an +argument. A des_key_schedule is an expanded form of the des key. +A des_key is 8 bytes of odd parity, the type used to hold the key is a +des_cblock. A des_cblock is an array of 8 bytes, often in this library +description I will refer to input bytes when the function specifies +des_cblock's as input or output, this just means that the variable should +be a multiple of 8 bytes. + +The define DES_ENCRYPT is passed to specify encryption, DES_DECRYPT to +specify decryption. The functions and global variable are as follows: + +int des_check_key; + DES keys are supposed to be odd parity. If this variable is set to + a non-zero value, des_set_key() will check that the key has odd + parity and is not one of the known weak DES keys. By default this + variable is turned off; + +void des_set_odd_parity( +des_cblock *key ); + This function takes a DES key (8 bytes) and sets the parity to odd. + +int des_is_weak_key( +des_cblock *key ); + This function returns a non-zero value if the DES key passed is a + weak, DES key. If it is a weak key, don't use it, try a different + one. If you are using 'random' keys, the chances of hitting a weak + key are 1/2^52 so it is probably not worth checking for them. + +int des_set_key( +des_cblock *key, +des_key_schedule schedule); + Des_set_key converts an 8 byte DES key into a des_key_schedule. + A des_key_schedule is an expanded form of the key which is used to + perform actual encryption. It can be regenerated from the DES key + so it only needs to be kept when encryption or decryption is about + to occur. Don't save or pass around des_key_schedule's since they + are CPU architecture dependent, DES keys are not. If des_check_key + is non zero, zero is returned if the key has the wrong parity or + the key is a weak key, else 1 is returned. + +int des_key_sched( +des_cblock *key, +des_key_schedule schedule); + An alternative name for des_set_key(). + +int des_rw_mode; /* defaults to DES_PCBC_MODE */ + This flag holds either DES_CBC_MODE or DES_PCBC_MODE (default). + This specifies the function to use in the enc_read() and enc_write() + functions. + +void des_encrypt( +unsigned long *data, +des_key_schedule ks, +int enc); + This is the DES encryption function that gets called by just about + every other DES routine in the library. You should not use this + function except to implement 'modes' of DES. I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. The characters are loaded 'little endian', + have a look at my source code for more details on how I use this + function. + Data is a pointer to 2 unsigned long's and ks is the + des_key_schedule to use. enc, is non zero specifies encryption, + zero if decryption. + +void des_encrypt2( +unsigned long *data, +des_key_schedule ks, +int enc); + This functions is the same as des_encrypt() except that the DES + initial permutation (IP) and final permutation (FP) have been left + out. As for des_encrypt(), you should not use this function. + It is used by the routines in my library that implement triple DES. + IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same + as des_encrypt() des_encrypt() des_encrypt() except faster :-). + +void des_ecb_encrypt( +des_cblock *input, +des_cblock *output, +des_key_schedule ks, +int enc); + This is the basic Electronic Code Book form of DES, the most basic + form. Input is encrypted into output using the key represented by + ks. If enc is non zero (DES_ENCRYPT), encryption occurs, otherwise + decryption occurs. Input is 8 bytes long and output is 8 bytes. + (the des_cblock structure is 8 chars). + +void des_ecb3_encrypt( +des_cblock *input, +des_cblock *output, +des_key_schedule ks1, +des_key_schedule ks2, +des_key_schedule ks3, +int enc); + This is the 3 key EDE mode of ECB DES. What this means is that + the 8 bytes of input is encrypted with ks1, decrypted with ks2 and + then encrypted again with ks3, before being put into output; + C=E(ks3,D(ks2,E(ks1,M))). There is a macro, des_ecb2_encrypt() + that only takes 2 des_key_schedules that implements, + C=E(ks1,D(ks2,E(ks1,M))) in that the final encrypt is done with ks1. + +void des_cbc_encrypt( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule ks, +des_cblock *ivec, +int enc); + This routine implements DES in Cipher Block Chaining mode. + Input, which should be a multiple of 8 bytes is encrypted + (or decrypted) to output which will also be a multiple of 8 bytes. + The number of bytes is in length (and from what I've said above, + should be a multiple of 8). If length is not a multiple of 8, I'm + not being held responsible :-). ivec is the initialisation vector. + This function does not modify this variable. To correctly implement + cbc mode, you need to do one of 2 things; copy the last 8 bytes of + cipher text for use as the next ivec in your application, + or use des_ncbc_encrypt(). + Only this routine has this problem with updating the ivec, all + other routines that are implementing cbc mode update ivec. + +void des_ncbc_encrypt( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule sk, +des_cblock *ivec, +int enc); + For historical reasons, des_cbc_encrypt() did not update the + ivec with the value requires so that subsequent calls to + des_cbc_encrypt() would 'chain'. This was needed so that the same + 'length' values would not need to be used when decrypting. + des_ncbc_encrypt() does the right thing. It is the same as + des_cbc_encrypt accept that ivec is updates with the correct value + to pass in subsequent calls to des_ncbc_encrypt(). I advise using + des_ncbc_encrypt() instead of des_cbc_encrypt(); + +void des_xcbc_encrypt( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule sk, +des_cblock *ivec, +des_cblock *inw, +des_cblock *outw, +int enc); + This is RSA's DESX mode of DES. It uses inw and outw to + 'whiten' the encryption. inw and outw are secret (unlike the iv) + and are as such, part of the key. So the key is sort of 24 bytes. + This is much better than cbc des. + +void des_3cbc_encrypt( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule sk1, +des_key_schedule sk2, +des_cblock *ivec1, +des_cblock *ivec2, +int enc); + This function is flawed, do not use it. I have left it in the + library because it is used in my des(1) program and will function + correctly when used by des(1). If I removed the function, people + could end up unable to decrypt files. + This routine implements outer triple cbc encryption using 2 ks and + 2 ivec's. Use des_ede2_cbc_encrypt() instead. + +void des_ede3_cbc_encrypt( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule ks1, +des_key_schedule ks2, +des_key_schedule ks3, +des_cblock *ivec, +int enc); + This function implements outer triple CBC DES encryption with 3 + keys. What this means is that each 'DES' operation + inside the cbc mode is really an C=E(ks3,D(ks2,E(ks1,M))). + Again, this is cbc mode so an ivec is requires. + This mode is used by SSL. + There is also a des_ede2_cbc_encrypt() that only uses 2 + des_key_schedule's, the first being reused for the final + encryption. C=E(ks1,D(ks2,E(ks1,M))). This form of triple DES + is used by the RSAref library. + +void des_pcbc_encrypt( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule ks, +des_cblock *ivec, +int enc); + This is Propagating Cipher Block Chaining mode of DES. It is used + by Kerberos v4. It's parameters are the same as des_ncbc_encrypt(). + +void des_cfb_encrypt( +unsigned char *in, +unsigned char *out, +int numbits, +long length, +des_key_schedule ks, +des_cblock *ivec, +int enc); + Cipher Feedback Back mode of DES. This implementation 'feeds back' + in numbit blocks. The input (and output) is in multiples of numbits + bits. numbits should to be a multiple of 8 bits. Length is the + number of bytes input. If numbits is not a multiple of 8 bits, + the extra bits in the bytes will be considered padding. So if + numbits is 12, for each 2 input bytes, the 4 high bits of the + second byte will be ignored. So to encode 72 bits when using + a numbits of 12 take 12 bytes. To encode 72 bits when using + numbits of 9 will take 16 bytes. To encode 80 bits when using + numbits of 16 will take 10 bytes. etc, etc. This padding will + apply to both input and output. + + +void des_cfb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +des_key_schedule ks, +des_cblock *ivec, +int *num, +int enc); + This is one of the more useful functions in this DES library, it + implements CFB mode of DES with 64bit feedback. Why is this + useful you ask? Because this routine will allow you to encrypt an + arbitrary number of bytes, no 8 byte padding. Each call to this + routine will encrypt the input bytes to output and then update ivec + and num. num contains 'how far' we are though ivec. If this does + not make much sense, read more about cfb mode of DES :-). + +void des_ede3_cfb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +des_key_schedule ks1, +des_key_schedule ks2, +des_key_schedule ks3, +des_cblock *ivec, +int *num, +int enc); + Same as des_cfb64_encrypt() accept that the DES operation is + triple DES. As usual, there is a macro for + des_ede2_cfb64_encrypt() which reuses ks1. + +void des_ofb_encrypt( +unsigned char *in, +unsigned char *out, +int numbits, +long length, +des_key_schedule ks, +des_cblock *ivec); + This is a implementation of Output Feed Back mode of DES. It is + the same as des_cfb_encrypt() in that numbits is the size of the + units dealt with during input and output (in bits). + +void des_ofb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +des_key_schedule ks, +des_cblock *ivec, +int *num); + The same as des_cfb64_encrypt() except that it is Output Feed Back + mode. + +void des_ede3_ofb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +des_key_schedule ks1, +des_key_schedule ks2, +des_key_schedule ks3, +des_cblock *ivec, +int *num); + Same as des_ofb64_encrypt() accept that the DES operation is + triple DES. As usual, there is a macro for + des_ede2_ofb64_encrypt() which reuses ks1. + +int des_read_pw_string( +char *buf, +int length, +char *prompt, +int verify); + This routine is used to get a password from the terminal with echo + turned off. Buf is where the string will end up and length is the + size of buf. Prompt is a string presented to the 'user' and if + verify is set, the key is asked for twice and unless the 2 copies + match, an error is returned. A return code of -1 indicates a + system error, 1 failure due to use interaction, and 0 is success. + +unsigned long des_cbc_cksum( +des_cblock *input, +des_cblock *output, +long length, +des_key_schedule ks, +des_cblock *ivec); + This function produces an 8 byte checksum from input that it puts in + output and returns the last 4 bytes as a long. The checksum is + generated via cbc mode of DES in which only the last 8 byes are + kept. I would recommend not using this function but instead using + the EVP_Digest routines, or at least using MD5 or SHA. This + function is used by Kerberos v4 so that is why it stays in the + library. + +char *des_fcrypt( +const char *buf, +const char *salt +char *ret); + This is my fast version of the unix crypt(3) function. This version + takes only a small amount of space relative to other fast + crypt() implementations. This is different to the normal crypt + in that the third parameter is the buffer that the return value + is written into. It needs to be at least 14 bytes long. This + function is thread safe, unlike the normal crypt. + +char *crypt( +const char *buf, +const char *salt); + This function calls des_fcrypt() with a static array passed as the + third parameter. This emulates the normal non-thread safe semantics + of crypt(3). + +void des_string_to_key( +char *str, +des_cblock *key); + This function takes str and converts it into a DES key. I would + recommend using MD5 instead and use the first 8 bytes of output. + When I wrote the first version of these routines back in 1990, MD5 + did not exist but I feel these routines are still sound. This + routines is compatible with the one in MIT's libdes. + +void des_string_to_2keys( +char *str, +des_cblock *key1, +des_cblock *key2); + This function takes str and converts it into 2 DES keys. + I would recommend using MD5 and using the 16 bytes as the 2 keys. + I have nothing against these 2 'string_to_key' routines, it's just + that if you say that your encryption key is generated by using the + 16 bytes of an MD5 hash, every-one knows how you generated your + keys. + +int des_read_password( +des_cblock *key, +char *prompt, +int verify); + This routine combines des_read_pw_string() with des_string_to_key(). + +int des_read_2passwords( +des_cblock *key1, +des_cblock *key2, +char *prompt, +int verify); + This routine combines des_read_pw_string() with des_string_to_2key(). + +void des_random_seed( +des_cblock key); + This routine sets a starting point for des_random_key(). + +void des_random_key( +des_cblock ret); + This function return a random key. Make sure to 'seed' the random + number generator (with des_random_seed()) before using this function. + I personally now use a MD5 based random number system. + +int des_enc_read( +int fd, +char *buf, +int len, +des_key_schedule ks, +des_cblock *iv); + This function will write to a file descriptor the encrypted data + from buf. This data will be preceded by a 4 byte 'byte count' and + will be padded out to 8 bytes. The encryption is either CBC of + PCBC depending on the value of des_rw_mode. If it is DES_PCBC_MODE, + pcbc is used, if DES_CBC_MODE, cbc is used. The default is to use + DES_PCBC_MODE. + +int des_enc_write( +int fd, +char *buf, +int len, +des_key_schedule ks, +des_cblock *iv); + This routines read stuff written by des_enc_read() and decrypts it. + I have used these routines quite a lot but I don't believe they are + suitable for non-blocking io. If you are after a full + authentication/encryption over networks, have a look at SSL instead. + +unsigned long des_quad_cksum( +des_cblock *input, +des_cblock *output, +long length, +int out_count, +des_cblock *seed); + This is a function from Kerberos v4 that is not anything to do with + DES but was needed. It is a cksum that is quicker to generate than + des_cbc_cksum(); I personally would use MD5 routines now. +===== +Modes of DES +Quite a bit of the following information has been taken from + AS 2805.5.2 + Australian Standard + Electronic funds transfer - Requirements for interfaces, + Part 5.2: Modes of operation for an n-bit block cipher algorithm + Appendix A + +There are several different modes in which DES can be used, they are +as follows. + +Electronic Codebook Mode (ECB) (des_ecb_encrypt()) +- 64 bits are enciphered at a time. +- The order of the blocks can be rearranged without detection. +- The same plaintext block always produces the same ciphertext block + (for the same key) making it vulnerable to a 'dictionary attack'. +- An error will only affect one ciphertext block. + +Cipher Block Chaining Mode (CBC) (des_cbc_encrypt()) +- a multiple of 64 bits are enciphered at a time. +- The CBC mode produces the same ciphertext whenever the same + plaintext is encrypted using the same key and starting variable. +- The chaining operation makes the ciphertext blocks dependent on the + current and all preceding plaintext blocks and therefore blocks can not + be rearranged. +- The use of different starting variables prevents the same plaintext + enciphering to the same ciphertext. +- An error will affect the current and the following ciphertext blocks. + +Cipher Feedback Mode (CFB) (des_cfb_encrypt()) +- a number of bits (j) <= 64 are enciphered at a time. +- The CFB mode produces the same ciphertext whenever the same + plaintext is encrypted using the same key and starting variable. +- The chaining operation makes the ciphertext variables dependent on the + current and all preceding variables and therefore j-bit variables are + chained together and can not be rearranged. +- The use of different starting variables prevents the same plaintext + enciphering to the same ciphertext. +- The strength of the CFB mode depends on the size of k (maximal if + j == k). In my implementation this is always the case. +- Selection of a small value for j will require more cycles through + the encipherment algorithm per unit of plaintext and thus cause + greater processing overheads. +- Only multiples of j bits can be enciphered. +- An error will affect the current and the following ciphertext variables. + +Output Feedback Mode (OFB) (des_ofb_encrypt()) +- a number of bits (j) <= 64 are enciphered at a time. +- The OFB mode produces the same ciphertext whenever the same + plaintext enciphered using the same key and starting variable. More + over, in the OFB mode the same key stream is produced when the same + key and start variable are used. Consequently, for security reasons + a specific start variable should be used only once for a given key. +- The absence of chaining makes the OFB more vulnerable to specific attacks. +- The use of different start variables values prevents the same + plaintext enciphering to the same ciphertext, by producing different + key streams. +- Selection of a small value for j will require more cycles through + the encipherment algorithm per unit of plaintext and thus cause + greater processing overheads. +- Only multiples of j bits can be enciphered. +- OFB mode of operation does not extend ciphertext errors in the + resultant plaintext output. Every bit error in the ciphertext causes + only one bit to be in error in the deciphered plaintext. +- OFB mode is not self-synchronising. If the two operation of + encipherment and decipherment get out of synchronism, the system needs + to be re-initialised. +- Each re-initialisation should use a value of the start variable + different from the start variable values used before with the same + key. The reason for this is that an identical bit stream would be + produced each time from the same parameters. This would be + susceptible to a ' known plaintext' attack. + +Triple ECB Mode (des_ecb3_encrypt()) +- Encrypt with key1, decrypt with key2 and encrypt with key3 again. +- As for ECB encryption but increases the key length to 168 bits. + There are theoretic attacks that can be used that make the effective + key length 112 bits, but this attack also requires 2^56 blocks of + memory, not very likely, even for the NSA. +- If both keys are the same it is equivalent to encrypting once with + just one key. +- If the first and last key are the same, the key length is 112 bits. + There are attacks that could reduce the key space to 55 bit's but it + requires 2^56 blocks of memory. +- If all 3 keys are the same, this is effectively the same as normal + ecb mode. + +Triple CBC Mode (des_ede3_cbc_encrypt()) +- Encrypt with key1, decrypt with key2 and then encrypt with key3. +- As for CBC encryption but increases the key length to 168 bits with + the same restrictions as for triple ecb mode. diff --git a/src/lib/libssl/src/doc/digest.doc b/src/lib/libssl/src/doc/digest.doc new file mode 100644 index 0000000000..d2fb987591 --- /dev/null +++ b/src/lib/libssl/src/doc/digest.doc @@ -0,0 +1,94 @@ + +The Message Digest subroutines. + +These routines require "evp.h" to be included. + +These functions are a higher level interface to the various message digest +routines found in this library. As such, they allow the same code to be +used to digest via different algorithms with only a change in an initial +parameter. They are basically just a front-end to the MD2, MD5, SHA +and SHA1 +routines. + +These routines all take a pointer to the following structure to specify +which message digest algorithm to use. +typedef struct evp_md_st + { + int type; + int pkey_type; + int md_size; + void (*init)(); + void (*update)(); + void (*final)(); + + int required_pkey_type; /*EVP_PKEY_xxx */ + int (*sign)(); + int (*verify)(); + } EVP_MD; + +If additional message digest algorithms are to be supported, a structure of +this type needs to be declared and populated and then the Digest routines +can be used with that algorithm. The type field is the object NID of the +digest type (read the section on Objects for an explanation). The pkey_type +is the Object type to use when the a message digest is generated by there +routines and then is to be signed with the pkey algorithm. Md_size is +the size of the message digest returned. Init, update +and final are the relevant functions to perform the message digest function +by parts. One reason for specifying the message digest to use via this +mechanism is that if you only use md5, only the md5 routines will +be included in you linked program. If you passed an integer +that specified which message digest to use, the routine that mapped that +integer to a set of message digest functions would cause all the message +digests functions to be link into the code. This setup also allows new +message digest functions to be added by the application. + +The six message digests defined in this library are + +EVP_MD *EVP_md2(void); /* RSA sign/verify */ +EVP_MD *EVP_md5(void); /* RSA sign/verify */ +EVP_MD *EVP_sha(void); /* RSA sign/verify */ +EVP_MD *EVP_sha1(void); /* RSA sign/verify */ +EVP_MD *EVP_dss(void); /* DSA sign/verify */ +EVP_MD *EVP_dss1(void); /* DSA sign/verify */ + +All the message digest routines take a EVP_MD_CTX pointer as an argument. +The state of the message digest is kept in this structure. + +typedef struct pem_md_ctx_st + { + EVP_MD *digest; + union { + unsigned char base[4]; /* this is used in my library as a + * 'pointer' to all union elements + * structures. */ + MD2_CTX md2; + MD5_CTX md5; + SHA_CTX sha; + } md; + } EVP_MD_CTX; + +The Digest functions are as follows. + +void EVP_DigestInit( +EVP_MD_CTX *ctx, +EVP_MD *type); + This function is used to initialise the EVP_MD_CTX. The message + digest that will associated with 'ctx' is specified by 'type'. + +void EVP_DigestUpdate( +EVP_MD_CTX *ctx, +unsigned char *data, +unsigned int cnt); + This function is used to pass more data to the message digest + function. 'cnt' bytes are digested from 'data'. + +void EVP_DigestFinal( +EVP_MD_CTX *ctx, +unsigned char *md, +unsigned int *len); + This function finishes the digestion and puts the message digest + into 'md'. The length of the message digest is put into len; + EVP_MAX_MD_SIZE is the size of the largest message digest that + can be returned from this function. Len can be NULL if the + size of the digest is not required. + diff --git a/src/lib/libssl/src/doc/encode.doc b/src/lib/libssl/src/doc/encode.doc new file mode 100644 index 0000000000..af17549289 --- /dev/null +++ b/src/lib/libssl/src/doc/encode.doc @@ -0,0 +1,15 @@ + +void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); +void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, + int *outl,unsigned char *in,int inl); +void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); +int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int n); + +void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + unsigned char *in, int inl); +int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned + char *out, int *outl); +int EVP_DecodeBlock(unsigned char *t, unsigned + char *f, int n); + diff --git a/src/lib/libssl/src/doc/envelope.doc b/src/lib/libssl/src/doc/envelope.doc new file mode 100644 index 0000000000..483e4fca6b --- /dev/null +++ b/src/lib/libssl/src/doc/envelope.doc @@ -0,0 +1,67 @@ +The following routines are use to create 'digital' envelopes. +By this I mean that they perform various 'higher' level cryptographic +functions. Have a read of 'cipher.doc' and 'digest.doc' since those +routines are used by these functions. +cipher.doc contains documentation about the cipher part of the +envelope library and digest.doc contatins the description of the +message digests supported. + +To 'sign' a document involves generating a message digest and then encrypting +the digest with an private key. + +#define EVP_SignInit(a,b) EVP_DigestInit(a,b) +#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +Due to the fact this operation is basically just an extended message +digest, the first 2 functions are macro calls to Digest generating +functions. + +int EVP_SignFinal( +EVP_MD_CTX *ctx, +unsigned char *md, +unsigned int *s, +EVP_PKEY *pkey); + This finalisation function finishes the generation of the message +digest and then encrypts the digest (with the correct message digest +object identifier) with the EVP_PKEY private key. 'ctx' is the message digest +context. 'md' will end up containing the encrypted message digest. This +array needs to be EVP_PKEY_size(pkey) bytes long. 's' will actually +contain the exact length. 'pkey' of course is the private key. It is +one of EVP_PKEY_RSA or EVP_PKEY_DSA type. +If there is an error, 0 is returned, otherwise 1. + +Verify is used to check an signed message digest. + +#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) +#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +Since the first step is to generate a message digest, the first 2 functions +are macros. + +int EVP_VerifyFinal( +EVP_MD_CTX *ctx, +unsigned char *md, +unsigned int s, +EVP_PKEY *pkey); + This function finishes the generation of the message digest and then +compares it with the supplied encrypted message digest. 'md' contains the +'s' bytes of encrypted message digest. 'pkey' is used to public key decrypt +the digest. It is then compared with the message digest just generated. +If they match, 1 is returned else 0. + +int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, + int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk); +Must have at least one public key, error is 0. I should also mention that +the buffers pointed to by 'ek' need to be EVP_PKEY_size(pubk[n]) is size. + +#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) +void EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); + + +int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, + int ekl,unsigned char *iv,EVP_PKEY *priv); +0 on failure + +#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) + +int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); +Decrypt final return code + diff --git a/src/lib/libssl/src/doc/error.doc b/src/lib/libssl/src/doc/error.doc new file mode 100644 index 0000000000..a91654999a --- /dev/null +++ b/src/lib/libssl/src/doc/error.doc @@ -0,0 +1,115 @@ +The error routines. + +The 'error' system I've implemented is intended to server 2 purpose, to +record the reason why a command failed and to record where in the libraries +the failure occurred. It is more or less setup to record a 'trace' of which +library components were being traversed when the error occurred. + +When an error is recorded, it is done so a as single unsigned long which is +composed of three parts. The top byte is the 'library' number, the middle +12 bytes is the function code, and the bottom 12 bits is the 'reason' code. + +Each 'library', or should a say, 'section' of the SSLeay library has a +different unique 'library' error number. Each function in the library has +a number that is unique for that library. Each 'library' also has a number +for each 'error reason' that is only unique for that 'library'. + +Due to the way these error routines record a 'error trace', there is an +array per thread that is used to store the error codes. +The various functions in this library are used to access +and manipulate this array. + +void ERR_put_error(int lib, int func,int reason); + This routine records an error in library 'lib', function 'func' +and reason 'reason'. As errors get 'put' into the buffer, they wrap +around and overwrite old errors if too many are written. It is assumed +that the last errors are the most important. + +unsigned long ERR_get_error(void ); + This function returns the last error added to the error buffer. +In effect it is popping the value off the buffer so repeated calls will +continue to return values until there are no more errors to return in which +case 0 is returned. + +unsigned long ERR_peek_error(void ); + This function returns the value of the last error added to the +error buffer but does not 'pop' it from the buffer. + +void ERR_clear_error(void ); + This function clears the error buffer, discarding all unread +errors. + +While the above described error system obviously produces lots of different +error number, a method for 'reporting' these errors in a human readable +form is required. To achieve this, each library has the option of +'registering' error strings. + +typedef struct ERR_string_data_st + { + unsigned long error; + char *string; + } ERR_STRING_DATA; + +The 'ERR_STRING_DATA' contains an error code and the corresponding text +string. To add new function error strings for a library, the +ERR_STRING_DATA needs to be 'registered' with the library. + +void ERR_load_strings(unsigned long lib,ERR_STRING_DATA *err); + This function 'registers' the array of ERR_STRING_DATA pointed to by +'err' as error text strings for the error library 'lib'. + +void ERR_free_strings(void); + This function free()s all the loaded error strings. + +char *ERR_error_string(unsigned long error,char *buf); + This function returns a text string that is a human readable +version of the error represented by 'error'. Buff should be at least 120 +bytes long and if it is NULL, the return value is a pointer to a static +variable that will contain the error string, otherwise 'buf' is returned. +If there is not a text string registered for a particular error, a text +string containing the error number is returned instead. + +void ERR_print_errors(BIO *bp); +void ERR_print_errors_fp(FILE *fp); + This function is a convenience routine that prints the error string +for each error until all errors have been accounted for. + +char *ERR_lib_error_string(unsigned long e); +char *ERR_func_error_string(unsigned long e); +char *ERR_reason_error_string(unsigned long e); +The above three functions return the 3 different components strings for the +error 'e'. ERR_error_string() uses these functions. + +void ERR_load_ERR_strings(void ); + This function 'registers' the error strings for the 'ERR' module. + +void ERR_load_crypto_strings(void ); + This function 'register' the error strings for just about every +library in the SSLeay package except for the SSL routines. There is no +need to ever register any error text strings and you will probably save in +program size. If on the other hand you do 'register' all errors, it is +quite easy to determine why a particular routine failed. + +As a final footnote as to why the error system is designed as it is. +1) I did not want a single 'global' error code. +2) I wanted to know which subroutine a failure occurred in. +3) For Windows NT etc, it should be simple to replace the 'key' routines + with code to pass error codes back to the application. +4) I wanted the option of meaningful error text strings. + +Late breaking news - the changes to support threads. + +Each 'thread' has an 'ERR_STATE' state associated with it. +ERR_STATE *ERR_get_state(void ) will return the 'state' for the calling +thread/process. + +ERR_remove_state(unsigned long pid); will 'free()' this state. If pid == 0 +the current 'thread/process' will have it's error state removed. +If you do not remove the error state of a thread, this could be considered a +form of memory leak, so just after 'reaping' a thread that has died, +call ERR_remove_state(pid). + +Have a read of thread.doc for more details for what is required for +multi-threading support. All the other error routines will +work correctly when using threads. + diff --git a/src/lib/libssl/src/doc/legal.doc b/src/lib/libssl/src/doc/legal.doc new file mode 100644 index 0000000000..b55ed5ce6a --- /dev/null +++ b/src/lib/libssl/src/doc/legal.doc @@ -0,0 +1,117 @@ +From eay@mincom.com Thu Jun 27 00:25:45 1996 +Received: by orb.mincom.oz.au id AA15821 + (5.65c/IDA-1.4.4 for eay); Wed, 26 Jun 1996 14:25:45 +1000 +Date: Wed, 26 Jun 1996 14:25:45 +1000 (EST) +From: Eric Young +X-Sender: eay@orb +To: Ken Toll +Cc: Eric Young , ssl-talk@netscape.com +Subject: Re: Unidentified subject! +In-Reply-To: <9606261950.ZM28943@ren.digitalage.com> +Message-Id: +Mime-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +Status: O +X-Status: + + +This is a little off topic but since SSLeay is a free implementation of +the SSLv2 protocol, I feel it is worth responding on the topic of if it +is actually legal for Americans to use free cryptographic software. + +On Wed, 26 Jun 1996, Ken Toll wrote: +> Is the U.S the only country that SSLeay cannot be used commercially +> (because of RSAref) or is that going to be an issue with every country +> that a client/server application (non-web browser/server) is deployed +> and sold? + +>From what I understand, the software patents that apply to algorithms +like RSA and DH only apply in the USA. The IDEA algorithm I believe is +patened in europe (USA?), but considing how little it is used by other SSL +implementations, it quite easily be left out of the SSLeay build +(this can be done with a compile flag). + +Actually if the RSA patent did apply outside the USA, it could be rather +interesting since RSA is not alowed to let RSA toolkits outside of the USA +[1], and since these are the only forms that they will alow the algorithm +to be used in, it would mean that non-one outside of the USA could produce +public key software which would be a very strong statment for +international patent law to make :-). This logic is a little flawed but +it still points out some of the more interesting permutations of USA +patent law and ITAR restrictions. + +Inside the USA there is also the unresolved issue of RC4/RC2 which were +made public on sci.crypt in Sep 1994 (RC4) and Feb 1996 (RC2). I have +copies of the origional postings if people are interested. RSA I believe +claim that they were 'trade-secrets' and that some-one broke an NDA in +revealing them. Other claim they reverse engineered the algorithms from +compiled binaries. If the algorithms were reverse engineered, I belive +RSA had no legal leg to stand on. If an NDA was broken, I don't know. +Regardless, RSA, I belive, is willing to go to court over the issue so +licencing is probably the best idea, or at least talk to them. +If there are people who actually know more about this, pease let me know, I +don't want to vilify or spread miss-information if I can help it. + +If you are not producing a web browser, it is easy to build SSLeay with +RC2/RC4 removed. Since RC4 is the defacto standard cipher in +all web software (and it is damn fast) it is more or less required for +www use. For non www use of SSL, especially for an application where +interoperability with other vendors is not critical just leave it out. + +Removing IDEA, RC2 and RC4 would only leave DES and Triple DES but +they should be ok. Considing that Triple DES can encrypt at rates of +410k/sec on a pentium 100, and 940k/sec on a P6/200, this is quite +reasonable performance. Single DES clocks in at 1160k/s and 2467k/s +respectivly is actually quite fast for those not so paranoid (56 bit key).[1] + +> Is it possible to get a certificate for commercial use outside of the U.S.? +yes. + +Thawte Consulting issues certificates (they are the people who sell the + Sioux httpd server and are based in South Africa) +Verisign will issue certificates for Sioux (sold from South Africa), so this + proves that they will issue certificate for OS use if they are + happy with the quality of the software. + +(The above mentioned companies just the ones that I know for sure are issuing + certificates outside the USA). + +There is always the point that if you are using SSL for an intra net, +SSLeay provides programs that can be used so you can issue your own +certificates. They need polishing but at least it is a good starting point. + +I am not doing anything outside Australian law by implementing these +algorithms (to the best of my knowedge). It is another example of how +the world legal system does not cope with the internet very well. + +I may start making shared libraries available (I have now got DLL's for +Windows). This will mean that distributions into the usa could be +shipped with a version with a reduced cipher set and the versions outside +could use the DLL/shared library with all the ciphers (and without RSAref). + +This could be completly hidden from the application, so this would not +even require a re-linking. + +This is the reverse of what people were talking about doing to get around +USA export regulations :-) + +eric + +[1]: The RSAref2.0 tookit is available on at least 3 ftp sites in Europe + and one in South Africa. + +[2]: Since I always get questions when I post benchmark numbers :-), + DES performace figures are in 1000's of bytes per second in cbc + mode using an 8192 byte buffer. The pentium 100 was running Windows NT + 3.51 DLLs and the 686/200 was running NextStep. + I quote pentium 100 benchmarks because it is basically the + 'entry level' computer that most people buy for personal use. + Windows 95 is the OS shipping on those boxes, so I'll give + NT numbers (the same Win32 runtime environment). The 686 + numbers are present as an indication of where we will be in a + few years. +-- +Eric Young | BOOL is tri-state according to Bill Gates. +AARNet: eay@mincom.oz.au | RTFM Win32 GetMessage(). + + diff --git a/src/lib/libssl/src/doc/lhash.doc b/src/lib/libssl/src/doc/lhash.doc new file mode 100644 index 0000000000..5a2aeb4b38 --- /dev/null +++ b/src/lib/libssl/src/doc/lhash.doc @@ -0,0 +1,151 @@ +The LHASH library. + +I wrote this library in 1991 and have since forgotten why I called it lhash. +It implements a hash table from an article I read at the +time from 'Communications of the ACM'. What makes this hash +table different is that as the table fills, the hash table is +increased (or decreased) in size via realloc(). +When a 'resize' is done, instead of all hashes being redistributed over +twice as many 'buckets', one bucket is split. So when an 'expand' is done, +there is only a minimal cost to redistribute some values. Subsequent +inserts will cause more single 'bucket' redistributions but there will +never be a sudden large cost due to redistributing all the 'buckets'. + +The state for a particular hash table is kept in the LHASH structure. +The LHASH structure also records statistics about most aspects of accessing +the hash table. This is mostly a legacy of my writing this library for +the reasons of implementing what looked like a nice algorithm rather than +for a particular software product. + +Internal stuff you probably don't want to know about. +The decision to increase or decrease the hash table size is made depending +on the 'load' of the hash table. The load is the number of items in the +hash table divided by the size of the hash table. The default values are +as follows. If (hash->up_load < load) => expand. +if (hash->down_load > load) => contract. The 'up_load' has a default value of +1 and 'down_load' has a default value of 2. These numbers can be modified +by the application by just playing with the 'up_load' and 'down_load' +variables. The 'load' is kept in a form which is multiplied by 256. So +hash->up_load=8*256; will cause a load of 8 to be set. + +If you are interested in performance the field to watch is +num_comp_calls. The hash library keeps track of the 'hash' value for +each item so when a lookup is done, the 'hashes' are compared, if +there is a match, then a full compare is done, and +hash->num_comp_calls is incremented. If num_comp_calls is not equal +to num_delete plus num_retrieve it means that your hash function is +generating hashes that are the same for different values. It is +probably worth changing your hash function if this is the case because +even if your hash table has 10 items in a 'bucked', it can be searched +with 10 'unsigned long' compares and 10 linked list traverses. This +will be much less expensive that 10 calls to you compare function. + +LHASH *lh_new( +unsigned long (*hash)(), +int (*cmp)()); + This function is used to create a new LHASH structure. It is passed + function pointers that are used to store and retrieve values passed + into the hash table. The 'hash' + function is a hashing function that will return a hashed value of + it's passed structure. 'cmp' is passed 2 parameters, it returns 0 + is they are equal, otherwise, non zero. + If there are any problems (usually malloc failures), NULL is + returned, otherwise a new LHASH structure is returned. The + hash value is normally truncated to a power of 2, so make sure + that your hash function returns well mixed low order bits. + +void lh_free( +LHASH *lh); + This function free()s a LHASH structure. If there is malloced + data in the hash table, it will not be freed. Consider using the + lh_doall function to deallocate any remaining entries in the hash + table. + +char *lh_insert( +LHASH *lh, +char *data); + This function inserts the data pointed to by data into the lh hash + table. If there is already and entry in the hash table entry, the + value being replaced is returned. A NULL is returned if the new + entry does not clash with an entry already in the table (the normal + case) or on a malloc() failure (perhaps I should change this....). + The 'char *data' is exactly what is passed to the hash and + comparison functions specified in lh_new(). + +char *lh_delete( +LHASH *lh, +char *data); + This routine deletes an entry from the hash table. The value being + deleted is returned. NULL is returned if there is no such value in + the hash table. + +char *lh_retrieve( +LHASH *lh, +char *data); + If 'data' is in the hash table it is returned, else NULL is + returned. The way these routines would normally be uses is that a + dummy structure would have key fields populated and then + ret=lh_retrieve(hash,&dummy);. Ret would now be a pointer to a fully + populated structure. + +void lh_doall( +LHASH *lh, +void (*func)(char *a)); + This function will, for every entry in the hash table, call function + 'func' with the data item as parameters. + This function can be quite useful when used as follows. + void cleanup(STUFF *a) + { STUFF_free(a); } + lh_doall(hash,cleanup); + lh_free(hash); + This can be used to free all the entries, lh_free() then + cleans up the 'buckets' that point to nothing. Be careful + when doing this. If you delete entries from the hash table, + in the call back function, the table may decrease in size, + moving item that you are + currently on down lower in the hash table. This could cause + some entries to be skipped. The best solution to this problem + is to set lh->down_load=0 before you start. This will stop + the hash table ever being decreased in size. + +void lh_doall_arg( +LHASH *lh; +void(*func)(char *a,char *arg)); +char *arg; + This function is the same as lh_doall except that the function + called will be passed 'arg' as the second argument. + +unsigned long lh_strhash( +char *c); + This function is a demo string hashing function. Since the LHASH + routines would normally be passed structures, this routine would + not normally be passed to lh_new(), rather it would be used in the + function passed to lh_new(). + +The next three routines print out various statistics about the state of the +passed hash table. These numbers are all kept in the lhash structure. + +void lh_stats( +LHASH *lh, +FILE *out); + This function prints out statistics on the size of the hash table, + how many entries are in it, and the number and result of calls to + the routines in this library. + +void lh_node_stats( +LHASH *lh, +FILE *out); + For each 'bucket' in the hash table, the number of entries is + printed. + +void lh_node_usage_stats( +LHASH *lh, +FILE *out); + This function prints out a short summary of the state of the hash + table. It prints what I call the 'load' and the 'actual load'. + The load is the average number of data items per 'bucket' in the + hash table. The 'actual load' is the average number of items per + 'bucket', but only for buckets which contain entries. So the + 'actual load' is the average number of searches that will need to + find an item in the hash table, while the 'load' is the average number + that will be done to record a miss. diff --git a/src/lib/libssl/src/doc/md2.doc b/src/lib/libssl/src/doc/md2.doc new file mode 100644 index 0000000000..b106bc675d --- /dev/null +++ b/src/lib/libssl/src/doc/md2.doc @@ -0,0 +1,49 @@ +The MD2 library. +MD2 is a message digest algorithm that can be used to condense an arbitrary +length message down to a 16 byte hash. The functions all need to be passed +a MD2_CTX which is used to hold the MD2 context during multiple MD2_Update() +function calls. The normal method of use for this library is as follows + +MD2_Init(...); +MD2_Update(...); +... +MD2_Update(...); +MD2_Final(...); + +This library requires the inclusion of 'md2.h'. + +The main negative about MD2 is that it is slow, especially when compared +to MD5. + +The functions are as follows: + +void MD2_Init( +MD2_CTX *c); + This function needs to be called to initiate a MD2_CTX structure for + use. + +void MD2_Update( +MD2_CTX *c; +unsigned char *data; +unsigned long len); + This updates the message digest context being generated with 'len' + bytes from the 'data' pointer. The number of bytes can be any + length. + +void MD2_Final( +unsigned char *md; +MD2_CTX *c; + This function is called when a message digest of the data digested + with MD2_Update() is wanted. The message digest is put in the 'md' + array and is MD2_DIGEST_LENGTH (16) bytes long. + +unsigned char *MD2( +unsigned long n; +unsigned char *d; +unsigned char *md; + This function performs a MD2_Init(), followed by a MD2_Update() + followed by a MD2_Final() (using a local MD2_CTX). + The resulting digest is put into 'md' if it is not NULL. + Regardless of the value of 'md', the message + digest is returned from the function. If 'md' was NULL, the message + digest returned is being stored in a static structure. diff --git a/src/lib/libssl/src/doc/md5.doc b/src/lib/libssl/src/doc/md5.doc new file mode 100644 index 0000000000..519dbdc61a --- /dev/null +++ b/src/lib/libssl/src/doc/md5.doc @@ -0,0 +1,50 @@ +The MD5 library. +MD5 is a message digest algorithm that can be used to condense an arbitrary +length message down to a 16 byte hash. The functions all need to be passed +a MD5_CTX which is used to hold the MD5 context during multiple MD5_Update() +function calls. This library also contains random number routines that are +based on MD5 + +The normal method of use for this library is as follows + +MD5_Init(...); +MD5_Update(...); +... +MD5_Update(...); +MD5_Final(...); + +This library requires the inclusion of 'md5.h'. + +The functions are as follows: + +void MD5_Init( +MD5_CTX *c); + This function needs to be called to initiate a MD5_CTX structure for + use. + +void MD5_Update( +MD5_CTX *c; +unsigned char *data; +unsigned long len); + This updates the message digest context being generated with 'len' + bytes from the 'data' pointer. The number of bytes can be any + length. + +void MD5_Final( +unsigned char *md; +MD5_CTX *c; + This function is called when a message digest of the data digested + with MD5_Update() is wanted. The message digest is put in the 'md' + array and is MD5_DIGEST_LENGTH (16) bytes long. + +unsigned char *MD5( +unsigned char *d; +unsigned long n; +unsigned char *md; + This function performs a MD5_Init(), followed by a MD5_Update() + followed by a MD5_Final() (using a local MD5_CTX). + The resulting digest is put into 'md' if it is not NULL. + Regardless of the value of 'md', the message + digest is returned from the function. If 'md' was NULL, the message + digest returned is being stored in a static structure. + diff --git a/src/lib/libssl/src/doc/memory.doc b/src/lib/libssl/src/doc/memory.doc new file mode 100644 index 0000000000..b9aa33ace0 --- /dev/null +++ b/src/lib/libssl/src/doc/memory.doc @@ -0,0 +1,27 @@ +In the interests of debugging SSLeay, there is an option to compile +using some simple memory leak checking. + +All malloc(), free() and realloc() calls in SSLeay now go via +Malloc(), Free() and Realloc() (except those in crypto/lhash). + +If CRYPTO_MDEBUG is defined, these calls are #defined to +CRYPTO_malloc(), CRYPTO_free() and CRYPTO_realloc(). +If it is not defined, they are #defined to malloc(), free() and realloc(). + +the CRYPTO_malloc() routines by default just call the underlying library +functons. + +If CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) is called, memory leak detection is +turned on. CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) turns it off. + +When turned on, each Malloc() or Realloc() call is recored along with the file +and line number from where the call was made. (This is done using the +lhash library which always uses normal system malloc(3) routines). + +void CRYPTO_mem_leaks(BIO *b); +void CRYPTO_mem_leaks_fp(FILE *fp); +These both print out the list of memory that has not been free()ed. +This will probably be rather hard to read, but if you look for the 'top level' +structure allocation, this will often give an idea as to what is not being +free()ed. I don't expect people to use this stuff normally. + diff --git a/src/lib/libssl/src/doc/ms3-ca.doc b/src/lib/libssl/src/doc/ms3-ca.doc new file mode 100644 index 0000000000..f8350aadc2 --- /dev/null +++ b/src/lib/libssl/src/doc/ms3-ca.doc @@ -0,0 +1,398 @@ +Date: Mon, 9 Jun 97 08:00:33 +0200 +From: Holger.Reif@PrakInf.TU-Ilmenau.DE (Holger Reif) +Subject: ms3-ca.doc +Organization: TU Ilmenau, Fak. IA, FG Telematik +Content-Length: 14575 +Status: RO +X-Status: + +Loading client certs into MSIE 3.01 +=================================== + +This document conatains all the information necessary to succesfully set up +some scripts to issue client certs to Microsoft Internet Explorer. It +includes the required knowledge about the model MSIE uses for client +certification and includes complete sample scripts ready to play with. The +scripts were tested against a modified ca program of SSLeay 0.6.6 and should +work with the regular ca program that comes with version 0.8.0. I haven't +tested against MSIE 4.0 + +You can use the information contained in this document in either way you +want. However if you feel it saved you a lot of time I ask you to be as fair +as to mention my name: Holger Reif . + +1.) The model used by MSIE +-------------------------- + +The Internet Explorer doesn't come with a embedded engine for installing +client certs like Netscape's Navigator. It rather uses the CryptoAPI (CAPI) +defined by Microsoft. CAPI comes with WindowsNT 4.0 or is installed together +with Internet Explorer since 3.01. The advantage of this approach is a higher +flexibility because the certificates in the (per user) system open +certificate store may be used by other applications as well. The drawback +however is that you need to do a bit more work to get a client cert issued. + +CAPI defines functions which will handle basic cryptographic work, eg. +generating keys, encrypting some data, signing text or building a certificate +request. The procedure is as follows: A CAPI function generates you a key +pair and saves it into the certificate store. After that one builds a +Distinguished Name. Together with that key pair another CAPI function forms a +PKCS#10 request which you somehow need to submit to a CA. Finally the issued +cert is given to a yet another CAPI function which saves it into the +certificate store. + +The certificate store with the user's keys and certs is in the registry. You +will find it under HKEY_CURRENT_USER/Software/Microsoft/Cryptography/ (I +leave it to you as a little exercise to figure out what all the entries mean +;-). Note that the keys are protected only with the user's usual Windows +login password. + +2.) The practical usage +----------------------- + +Unfortunatly since CAPI is a system API you can't access its functions from +HTML code directly. For this purpose Microsoft provides a wrapper called +certenr3.dll. This DLL accesses the CAPI functions and provides an interface +usable from Visual Basic Script. One needs to install that library on the +computer which wants to have client cert. The easiest way is to load it as an +ActiveX control (certenr3.dll is properly authenticode signed by MS ;-). If +you have ever enrolled e cert request at a CA you will have installed it. + +At time of writing certenr3.dll is contained in +http://www.microsoft.com/workshop/prog/security/csa/certenr3.exe. It comes +with an README file which explains the available functions. It is labeled +beta but every CA seems to use it anyway. The license.txt allows you the +usage for your own purposes (as far as I understood) and a somehow limited +distribution. + +The two functions of main interest are GenerateKeyPair and AcceptCredentials. +For complete explanation of all possible parameters see the README file. Here +are only minimal required parameters and their values. + +GenerateKeyPair(sessionID, FASLE, szName, 0, "ClientAuth", TRUE, FALSE, 1) +- sessionID is a (locally to that computer) unique string to correlate the +generated key pair with a cert installed later. +- szName is the DN of the form "C=DE; S=Thueringen; L=Ilmenau; CN=Holger +Reif; 1.2.840.113549.1.9.1=reif@prakinf.tu-ilmenau.de". Note that S is the +abreviation for StateOrProvince. The recognized abreviation include CN, O, C, +OU, G, I, L, S, T. If the abreviation is unknown (eg. for PKCS#9 email addr) +you need to use the full object identifier. The starting point for searching +them could be crypto/objects.h since all OIDs know to SSLeay are listed +there. +- note: the possible ninth parameter which should give a default name to the +certificate storage location doesn't seem to work. Changes to the constant +values in the call above doesn't seem to make sense. You can't generate +PKCS#10 extensions with that function. + +The result of GenerateKeyPair is the base64 encoded PKCS#10 request. However +it has a little strange format that SSLeay doesn't accept. (BTW I feel the +decision of rejecting that format as standard conforming.) It looks like +follows: + 1st line with 76 chars + 2nd line with 76 chars + ... + (n-2)th line with 76 chars + (n-1)th line contains a multiple of 4 chars less then 76 (possible +empty) + (n)th line has zero or 4 chars (then with 1 or 2 equal signs - the + original text's lenght wasn'T a multiple of 3) + The line separator has two chars: 0x0d 0x0a + +AcceptCredentials(sessionID, credentials, 0, FALSE) +- sessionID needs to be the same as while generating the key pair +- credentials is the base64 encoded PKCS#7 object containing the cert. + +CRL's and CA certs are not required simply just the client cert. (It seems to +me that both are not even checked somehow.) The only format of the base64 +encoded object I succesfully used was all characters in a very long string +without line feeds or carriage returns. (Hey, it doesn't matter, only a +computer reads it!) + +The result should be S_OK. For error handling see the example that comes with +certenr3.dll. + +A note about ASN.1 character encodings. certenr3.dll seems to know only about +2 of them: UniversalString and PrintableString. First it is definitely wrong +for an email address which is IA5STRING (checked by ssleay's ca). Second +unfortunately MSIE (at least until version 3.02) can't handle UniversalString +correctly - they just blow up you cert store! Therefore ssleay's ca (starting +from version 0.8.0) tries to convert the encodings automatically to IA5STRING +or TeletexString. The beef is it will work only for the latin-1 (western) +charset. Microsoft still has to do abit of homework... + +3.) An example +-------------- + +At least you need two steps: generating the key & request and then installing +the certificate. A real world CA would have some more steps involved, eg. +accepting some license. Note that both scripts shown below are just +experimental state without any warrenty! + +First how to generate a request. Note that we can't use a static page because +of the sessionID. I generate it from system time plus pid and hope it is +unique enough. Your are free to feed it through md5 to get more impressive +ID's ;-) Then the intended text is read in with sed which inserts the +sessionID. + +-----BEGIN ms-enroll.cgi----- +#!/bin/sh +SESSION_ID=`date '+%y%m%d%H%M%S'`$$ +echo Content-type: text/html +echo +sed s/template_for_sessId/$SESSION_ID/ < +Certificate Enrollment Test Page + + + + + +
+

enrollment for a personal cert

+


+

+ + + + + + + + + + + + +
Country
State
Location
Organization
Organizational Unit
Name
eMail Address
+ + +
+


+

+ + + + +EOF +-----END ms-enroll.cgi----- + +Second, how to extract the request and feed the certificate back? We need to +"normalize" the base64 encoding of the PKCS#10 format which means +regenerating the lines and wrapping with BEGIN and END line. This is done by +gawk. The request is taken by ca the normal way. Then the cert needs to be +packed into a PKCS#7 structure (note: the use of a CRL is necessary for +crl2pkcs7 as of version 0.6.6. Starting with 0.8.0 it it might probably be +ommited). Finally we need to format the PKCS#7 object and generate the HTML +text. I use two templates to have a clearer script. + +1st note: postit2 is slightly modified from a program I found at ncsa's ftp +site. Grab it from http://www.easterngraphics.com/certs/IX9704/postit2.c. You +need utils.c from there too. + +2nd note: I'm note quite sure wether the gawk script really handles all +possible inputs for the request right! Today I don't use this construction +anymore myself. + +3d note: the cert must be of version 3! This could be done with the nsComment +line in ssleay.cnf... + +------BEGIN ms-gencert.cgi----- +#!/bin/sh +FILE="/tmp/"`date '+%y%m%d%H%M%S'-`$$ +rm -f "$FILE".* + +HOME=`pwd`; export HOME # as ssleay.cnf insists on having such an env var +cd /usr/local/ssl #where demoCA (as named in ssleay.conf) is located + +postit2 -s " " -i 0x0d > "$FILE".inp # process the FORM vars + +SESSION_ID=`gawk '$1 == "SessionId" { print $2; exit }' "$FILE".inp` + +gawk \ + 'BEGIN { \ + OFS = ""; \ + print "-----BEGIN CERTIFICATE REQUEST-----"; \ + req_seen=0 \ + } \ + $1 == "Request" { \ + req_seen=1; \ + if (length($2) == 72) print($2); \ + lastline=$2; \ + next; \ + } \ + { \ + if (req_seen == 1) { \ + if (length($1) >= 72) print($1); \ + else if (length(lastline) < 72) { \ + req_seen=0; \ + print (lastline,$1); \ + } \ + lastline=$1; \ + } \ + } \ + END { \ + print "-----END CERTIFICATE REQUEST-----"; \ + }' > "$FILE".pem < "$FILE".inp + +ssleay ca -batch -in "$FILE".pem -key passwd -out "$FILE".out +ssleay crl2pkcs7 -certfile "$FILE".out -out "$FILE".pkcs7 -in demoCA/crl.pem + +sed s/template_for_sessId/$SESSION_ID/ "$FILE".cert +/usr/local/bin/gawk \ + 'BEGIN { \ + OFS = ""; \ + dq = sprintf("%c",34); \ + } \ + $0 ~ "PKCS7" { next; } \ + { \ + print dq$0dq" & _"; \ + }' <"$FILE".pkcs7 >> "$FILE".cert +cat ms-enroll2b.html >>"$FILE".cert + +echo Content-type: text/html +echo Content-length: `wc -c "$FILE".cert` +echo +cat "$FILE".cert +rm -f "$FILE".* +-----END ms-gencert.cgi----- + +----BEGIN ms-enroll2a.html---- +Certificate Acceptance Test Page + + + + +
+

Your personal certificate

+


+Press the button! +

+

+


+ + + + +----END ms-enroll2b.html---- + +4.) What do do with the cert? +----------------------------- + +The cert is visible (without restarting MSIE) under the following menu: +View->Options->Security->Personal certs. You can examine it's contents at +least partially. + +To use it for client authentication you need to use SSL3.0 (fortunately +SSLeay supports it with 0.8.0). Furthermore MSIE is told to only supports a +kind of automatic selection of certs (I personally wasn't able to test it +myself). But there is a requirement that the issuer of the server cert and +the issuer of the client cert needs to be the same (according to a developer +from MS). Which means: you need may more then one cert to talk to all +servers... + +I'm sure we will get a bit more experience after ApacheSSL is available for +SSLeay 0.8.8. + + +I hope you enjoyed reading and that in future questions on this topic will +rarely appear on ssl-users@moncom.com ;-) + +Ilmenau, 9th of June 1997 +Holger Reif +-- +read you later - Holger Reif +---------------------------------------- Signaturprojekt Deutsche Einheit +TU Ilmenau - Informatik - Telematik (Verdamp lang her) +Holger.Reif@PrakInf.TU-Ilmenau.DE Alt wie ein Baum werden, um ueber +http://Remus.PrakInf.TU-Ilmenau.DE/Reif/ alle 7 Bruecken gehen zu koennen + diff --git a/src/lib/libssl/src/doc/ns-ca.doc b/src/lib/libssl/src/doc/ns-ca.doc new file mode 100644 index 0000000000..836883e1a0 --- /dev/null +++ b/src/lib/libssl/src/doc/ns-ca.doc @@ -0,0 +1,154 @@ +The following documentation was supplied by Jeff Barber, who provided the +patch to the CA program to add this functionality. + +eric +-- +Jeff Barber Email: jeffb@issl.atl.hp.com + +Hewlett Packard Phone: (404) 648-9503 +Internet and System Security Lab Fax: (404) 648-9516 + + oo +---------------------cut /\ here for ns-ca.doc ------------------------------ + +This document briefly describes how to use SSLeay to implement a +certificate authority capable of dynamically serving up client +certificates for version 3.0 beta 5 (and presumably later) versions of +the Netscape Navigator. Before describing how this is done, it's +important to understand a little about how the browser implements its +client certificate support. This is documented in some detail in the +URLs based at . +Here's a brief overview: + +- The Navigator supports a new HTML tag "KEYGEN" which will cause + the browser to generate an RSA key pair when you submit a form + containing the tag. The public key, along with an optional + challenge (supposedly provided for use in certificate revocation + but I don't use it) is signed, DER-encoded, base-64 encoded + and sent to the web server as the value of the variable + whose NAME is provided in the KEYGEN tag. The private key is + stored by the browser in a local key database. + + This "Signed Public Key And Challenge" (SPKAC) arrives formatted + into 64 character lines (which are of course URL-encoded when + sent via HTTP -- i.e. spaces, newlines and most punctuatation are + encoded as "%HH" where HH is the hex equivalent of the ASCII code). + Note that the SPKAC does not contain the other usual attributes + of a certificate request, especially the subject name fields. + These must be otherwise encoded in the form for submission along + with the SPKAC. + +- Either immediately (in response to this form submission), or at + some later date (a real CA will probably verify your identity in + some way before issuing the certificate), a web server can send a + certificate based on the public key and other attributes back to + the browser by encoding it in DER (the binary form) and sending it + to the browser as MIME type: + "Content-type: application/x-x509-user-cert" + + The browser uses the public key encoded in the certificate to + associate the certificate with the appropriate private key in + its local key database. Now, the certificate is "installed". + +- When a server wants to require authentication based on client + certificates, it uses the right signals via the SSL protocol to + trigger the Navigator to ask you which certificate you want to + send. Whether the certificate is accepted is dependent on CA + certificates and so forth installed in the server and is beyond + the scope of this document. + + +Now, here's how the SSLeay package can be used to provide client +certficates: + +- You prepare a file for input to the SSLeay ca application. + The file contains a number of "name = value" pairs that identify + the subject. The names here are the same subject name component + identifiers used in the CA section of the lib/ssleay.conf file, + such as "emailAddress", "commonName" "organizationName" and so + forth. Both the long version and the short version (e.g. "Email", + "CN", "O") can be used. + + One more name is supported: this one is "SPKAC". Its value + is simply the value of the base-64 encoded SPKAC sent by the + browser (with all the newlines and other space charaters + removed -- and newline escapes are NOT supported). + + [ As of SSLeay 0.6.4, multiple lines are supported. + Put a \ at the end of each line and it will be joined with the + previous line with the '\n' removed - eay ] + + Here's a sample input file: + +C = US +SP = Georgia +O = Some Organization, Inc. +OU = Netscape Compatibility Group +CN = John X. Doe +Email = jxdoe@someorg.com +SPKAC = MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAwmk6FMJ4uAVIYbcvIOx5+bDGTfvL8X5gE+R67ccMk6rCSGbVQz2cetyQtnI+VIs0NwdD6wjuSuVtVFbLoHonowIDAQABFgAwDQYJKoZIhvcNAQEEBQADQQBFZDUWFl6BJdomtN1Bi53mwijy1rRgJ4YirF15yBEDM3DjAQkKXHYOIX+qpz4KXKnl6EYxTnGSFL5wWt8X2iyx + +- You execute the ca command (either from a CGI program run out of + the web server, or as a later manual task) giving it the above + file as input. For example, if the file were named /tmp/cert.req, + you'd run: + $SSLDIR/bin/ca -spkac /tmp/cert.req -out /tmp/cert + + The output is in DER format (binary) if a -out argument is + provided, as above; otherwise, it's in the PEM format (base-64 + encoded DER). Also, the "-batch" switch is implied by the + "-spkac" so you don't get asked whether to complete the signing + (probably it shouldn't work this way but I was only interested + in hacking together an online CA that could be used for issuing + test certificates). + + The "-spkac" capability doesn't support multiple files (I think). + + Any CHALLENGE provided in the SPKAC is simply ignored. + + The interactions between the identification fields you provide + and those identified in your lib/ssleay.conf are the same as if + you did an ordinary "ca -in infile -out outfile" -- that is, if + something is marked as required in the ssleay.conf file and it + isn't found in the -spkac file, the certificate won't be issued. + +- Now, you pick up the output from /tmp/cert and pass it back to + the Navigator prepending the Content-type string described earlier. + +- In order to run the ca command out of a CGI program, you must + provide a password to decrypt the CA's private key. You can + do this by using "echo MyKeyPassword | $SSLDIR/bin/ca ..." + I think there's a way to not encrypt the key file in the first + place, but I didn't see how to do that, so I made a small change + to the library that allows the password to be accepted from a pipe. + Either way is UTTERLY INSECURE and a real CA would never do that. + + [ You can use the 'ssleay rsa' command to remove the password + from the private key, or you can use the '-key' option to the + ca command to specify the decryption key on the command line + or use the -nodes option when generating the key. + ca will try to clear the command line version of the password + but for quite a few operating systems, this is not possible. + - eric ] + +So, what do you have to do to make use of this stuff to create an online +demo CA capability with SSLeay? + +1 Create an HTML form for your users. The form should contain + fields for all of the required or optional fields in ssleay.conf. + The form must contain a KEYGEN tag somewhere with at least a NAME + attribute. + +2 Create a CGI program to process the form input submitted by the + browser. The CGI program must URL-decode the variables and create + the file described above, containing subject identification info + as well as the SPKAC block. It should then run the the ca program + with the -spkac option. If it works (check the exit status), + return the new certificate with the appropriate MIME type. If not, + return the output of the ca command with MIME type "text/plain". + +3 Set up your web server to accept connections signed by your demo + CA. This probably involves obtaining the PEM-encoded CA certificate + (ordinarily in $SSLDIR/CA/cacert.pem) and installing it into a + server database. See your server manual for instructions. + diff --git a/src/lib/libssl/src/doc/obj.doc b/src/lib/libssl/src/doc/obj.doc new file mode 100644 index 0000000000..bad347c936 --- /dev/null +++ b/src/lib/libssl/src/doc/obj.doc @@ -0,0 +1,69 @@ +The Object library. + +As part of my Crypto library, I found I required a method of identifying various +objects. These objects normally had 3 different values associated with +them, a short text name, a long (or lower case) text name, and an +ASN.1 Object Identifier (which is a sequence of numbers). +This library contains a static list of objects and functions to lookup +according to one type and to return the other types. + +To use these routines, 'Object.h' needs to be included. + +For each supported object, #define entries are defined as follows +#define SN_Algorithm "Algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 38 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +SN_ stands for short name. +LN_ stands for either long name or lowercase name. +NID_ stands for Numeric ID. I each object has a unique NID and this + should be used internally to identify objects. +OBJ_ stands for ASN.1 Object Identifier or ASN1_OBJECT as defined in the + ASN1 routines. These values are used in ASN1 encoding. + +The following functions are to be used to return pointers into a static +definition of these types. What this means is "don't try to free() any +pointers returned from these functions. + +ASN1_OBJECT *OBJ_nid2obj( +int n); + Return the ASN1_OBJECT that corresponds to a NID of n. + +char *OBJ_nid2ln( +int n); + Return the long/lower case name of the object represented by the + NID of n. + +char *OBJ_nid2sn( +int n); + Return the short name for the object represented by the NID of n. + +ASN1_OBJECT *OBJ_dup( +ASN1_OBJECT *o); + Duplicate and return a new ASN1_OBJECT that is the same as the + passed parameter. + +int OBJ_obj2nid( +ASN1_OBJECT *o); + Given ASN1_OBJECT o, return the NID that corresponds. + +int OBJ_ln2nid( +char *s); + Given the long/lower case name 's', return the NID of the object. + +int OBJ_sn2nid( +char *s); + Given the short name 's', return the NID of the object. + +char *OBJ_bsearch( +char *key, +char *base, +int num, +int size, +int (*cmp)()); + Since I have come across a few platforms that do not have the + bsearch() function, OBJ_bsearch is my version of that function. + Feel free to use this function, but you may as well just use the + normal system bsearch(3) if it is present. This version also + has tolerance of being passed NULL pointers. diff --git a/src/lib/libssl/src/doc/rand.doc b/src/lib/libssl/src/doc/rand.doc new file mode 100644 index 0000000000..da02a07f64 --- /dev/null +++ b/src/lib/libssl/src/doc/rand.doc @@ -0,0 +1,141 @@ +My Random number library. + +These routines can be used to generate pseudo random numbers and can be +used to 'seed' the pseudo random number generator (RNG). The RNG make no +effort to reproduce the same random number stream with each execution. +Various other routines in the SSLeay library 'seed' the RNG when suitable +'random' input data is available. Read the section at the end for details +on the design of the RNG. + +void RAND_bytes( +unsigned char *buf, +int num); + This routine puts 'num' random bytes into 'buf'. One should make + sure RAND_seed() has been called before using this routine. + +void RAND_seed( +unsigned char *buf, +int num); + This routine adds more 'seed' data the RNG state. 'num' bytes + are added to the RNG state, they are taken from 'buf'. This + routine can be called with sensitive data such as user entered + passwords. This sensitive data is in no way recoverable from + the RAND library routines or state. Try to pass as much data + from 'random' sources as possible into the RNG via this function. + Also strongly consider using the RAND_load_file() and + RAND_write_file() routines. + +void RAND_cleanup(); + When a program has finished with the RAND library, if it so + desires, it can 'zero' all RNG state. + +The following 3 routines are convenience routines that can be used to +'save' and 'restore' data from/to the RNG and it's state. +Since the more 'random' data that is feed as seed data the better, why not +keep it around between executions of the program? Of course the +application should pass more 'random' data in via RAND_seed() and +make sure no-one can read the 'random' data file. + +char *RAND_file_name( +char *buf, +int size); + This routine returns a 'default' name for the location of a 'rand' + file. The 'rand' file should keep a sequence of random bytes used + to initialise the RNG. The filename is put in 'buf'. Buf is 'size' + bytes long. Buf is returned if things go well, if they do not, + NULL is returned. The 'rand' file name is generated in the + following way. First, if there is a 'RANDFILE' environment + variable, it is returned. Second, if there is a 'HOME' environment + variable, $HOME/.rand is returned. Third, NULL is returned. NULL + is also returned if a buf would overflow. + +int RAND_load_file( +char *file, +long number); + This function 'adds' the 'file' into the RNG state. It does this by + doing a RAND_seed() on the value returned from a stat() system call + on the file and if 'number' is non-zero, upto 'number' bytes read + from the file. The number of bytes passed to RAND_seed() is returned. + +int RAND_write_file( +char *file), + RAND_write_file() writes N random bytes to the file 'file', where + N is the size of the internal RND state (currently 1k). + This is a suitable method of saving RNG state for reloading via + RAND_load_file(). + +What follows is a description of this RNG and a description of the rational +behind it's design. + +It should be noted that this RNG is intended to be used to generate +'random' keys for various ciphers including generation of DH and RSA keys. + +It should also be noted that I have just created a system that I am happy with. +It may be overkill but that does not worry me. I have not spent that much +time on this algorithm so if there are glaring errors, please let me know. +Speed has not been a consideration in the design of these routines. + +First up I will state the things I believe I need for a good RNG. +1) A good hashing algorithm to mix things up and to convert the RNG 'state' + to random numbers. +2) An initial source of random 'state'. +3) The state should be very large. If the RNG is being used to generate + 4096 bit RSA keys, 2 2048 bit random strings are required (at a minimum). + If your RNG state only has 128 bits, you are obviously limiting the + search space to 128 bits, not 2048. I'm probably getting a little + carried away on this last point but it does indicate that it may not be + a bad idea to keep quite a lot of RNG state. It should be easier to + break a cipher than guess the RNG seed data. +4) Any RNG seed data should influence all subsequent random numbers + generated. This implies that any random seed data entered will have + an influence on all subsequent random numbers generated. +5) When using data to seed the RNG state, the data used should not be + extractable from the RNG state. I believe this should be a + requirement because one possible source of 'secret' semi random + data would be a private key or a password. This data must + not be disclosed by either subsequent random numbers or a + 'core' dump left by a program crash. +6) Given the same initial 'state', 2 systems should deviate in their RNG state + (and hence the random numbers generated) over time if at all possible. +7) Given the random number output stream, it should not be possible to determine + the RNG state or the next random number. + + +The algorithm is as follows. + +There is global state made up of a 1023 byte buffer (the 'state'), a +working message digest ('md') and a counter ('count'). + +Whenever seed data is added, it is inserted into the 'state' as +follows. + The input is chopped up into units of 16 bytes (or less for + the last block). Each of these blocks is run through the MD5 + message digest. The data passed to the MD5 digest is the + current 'md', the same number of bytes from the 'state' + (the location determined by in incremented looping index) as + the current 'block' and the new key data 'block'. The result + of this is kept in 'md' and also xored into the 'state' at the + same locations that were used as input into the MD5. + I believe this system addresses points 1 (MD5), 3 (the 'state'), + 4 (via the 'md'), 5 (by the use of MD5 and xor). + +When bytes are extracted from the RNG, the following process is used. +For each group of 8 bytes (or less), we do the following, + Input into MD5, the top 8 bytes from 'md', the byte that are + to be overwritten by the random bytes and bytes from the + 'state' (incrementing looping index). From this digest output + (which is kept in 'md'), the top (upto) 8 bytes are + returned to the caller and the bottom (upto) 8 bytes are xored + into the 'state'. + Finally, after we have finished 'generation' random bytes for the + called, 'count' (which is incremented) and 'md' are fed into MD5 and + the results are kept in 'md'. + I believe the above addressed points 1 (use of MD5), 6 (by + hashing into the 'state' the 'old' data from the caller that + is about to be overwritten) and 7 (by not using the 8 bytes + given to the caller to update the 'state', but they are used + to update 'md'). + +So of the points raised, only 2 is not addressed, but sources of +random data will always be a problem. + diff --git a/src/lib/libssl/src/doc/rc2.doc b/src/lib/libssl/src/doc/rc2.doc new file mode 100644 index 0000000000..efab015bd1 --- /dev/null +++ b/src/lib/libssl/src/doc/rc2.doc @@ -0,0 +1,165 @@ +The RC2 library. + +RC2 is a block cipher that operates on 64bit (8 byte) quantities. It +uses variable size key, but 128bit (16 byte) key would normally be considered +good. It can be used in all the modes that DES can be used. This +library implements the ecb, cbc, cfb64, ofb64 modes. + +I have implemented this library from an article posted to sci.crypt on +11-Feb-1996. I personally don't know how far to trust the RC2 cipher. +While it is capable of having a key of any size, not much reseach has +publically been done on it at this point in time (Apr-1996) +since the cipher has only been public for a few months :-) +It is of a similar speed to DES and IDEA, so unless it is required for +meeting some standard (SSLv2, perhaps S/MIME), it would probably be advisable +to stick to IDEA, or for the paranoid, Tripple DES. + +Mind you, having said all that, I should mention that I just read alot and +implement ciphers, I'm a 'babe in the woods' when it comes to evaluating +ciphers :-). + +For all calls that have an 'input' and 'output' variables, they can be the +same. + +This library requires the inclusion of 'rc2.h'. + +All of the encryption functions take what is called an RC2_KEY as an +argument. An RC2_KEY is an expanded form of the RC2 key. +For all modes of the RC2 algorithm, the RC2_KEY used for +decryption is the same one that was used for encryption. + +The define RC2_ENCRYPT is passed to specify encryption for the functions +that require an encryption/decryption flag. RC2_DECRYPT is passed to +specify decryption. + +Please note that any of the encryption modes specified in my DES library +could be used with RC2. I have only implemented ecb, cbc, cfb64 and +ofb64 for the following reasons. +- ecb is the basic RC2 encryption. +- cbc is the normal 'chaining' form for block ciphers. +- cfb64 can be used to encrypt single characters, therefore input and output + do not need to be a multiple of 8. +- ofb64 is similar to cfb64 but is more like a stream cipher, not as + secure (not cipher feedback) but it does not have an encrypt/decrypt mode. +- If you want triple RC2, thats 384 bits of key and you must be totally + obsessed with security. Still, if you want it, it is simple enough to + copy the function from the DES library and change the des_encrypt to + RC2_encrypt; an exercise left for the paranoid reader :-). + +The functions are as follows: + +void RC2_set_key( +RC2_KEY *ks; +int len; +unsigned char *key; +int bits; + RC2_set_key converts an 'len' byte key into a RC2_KEY. + A 'ks' is an expanded form of the 'key' which is used to + perform actual encryption. It can be regenerated from the RC2 key + so it only needs to be kept when encryption or decryption is about + to occur. Don't save or pass around RC2_KEY's since they + are CPU architecture dependent, 'key's are not. RC2 is an + interesting cipher in that it can be used with a variable length + key. 'len' is the length of 'key' to be used as the key. + A 'len' of 16 is recomended. The 'bits' argument is an + interesting addition which I only found out about in Aug 96. + BSAFE uses this parameter to 'limit' the number of bits used + for the key. To use the 'key' unmodified, set bits to 1024. + This is what old versions of my RC2 library did (SSLeay 0.6.3). + RSAs BSAFE library sets this parameter to be 128 if 128 bit + keys are being used. So to be compatable with BSAFE, set it + to 128, if you don't want to reduce RC2's key length, leave it + at 1024. + +void RC2_encrypt( +unsigned long *data, +RC2_KEY *key, +int encrypt); + This is the RC2 encryption function that gets called by just about + every other RC2 routine in the library. You should not use this + function except to implement 'modes' of RC2. I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. + Data is a pointer to 2 unsigned long's and key is the + RC2_KEY to use. Encryption or decryption is indicated by 'encrypt'. + which can have the values RC2_ENCRYPT or RC2_DECRYPT. + +void RC2_ecb_encrypt( +unsigned char *in, +unsigned char *out, +RC2_KEY *key, +int encrypt); + This is the basic Electronic Code Book form of RC2 (in DES this + mode is called Electronic Code Book so I'm going to use the term + for rc2 as well. + Input is encrypted into output using the key represented by + key. Depending on the encrypt, encryption or + decryption occurs. Input is 8 bytes long and output is 8 bytes. + +void RC2_cbc_encrypt( +unsigned char *in, +unsigned char *out, +long length, +RC2_KEY *ks, +unsigned char *ivec, +int encrypt); + This routine implements RC2 in Cipher Block Chaining mode. + Input, which should be a multiple of 8 bytes is encrypted + (or decrypted) to output which will also be a multiple of 8 bytes. + The number of bytes is in length (and from what I've said above, + should be a multiple of 8). If length is not a multiple of 8, bad + things will probably happen. ivec is the initialisation vector. + This function updates iv after each call so that it can be passed to + the next call to RC2_cbc_encrypt(). + +void RC2_cfb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +RC2_KEY *schedule, +unsigned char *ivec, +int *num, +int encrypt); + This is one of the more useful functions in this RC2 library, it + implements CFB mode of RC2 with 64bit feedback. + This allows you to encrypt an arbitrary number of bytes, + you do not require 8 byte padding. Each call to this + routine will encrypt the input bytes to output and then update ivec + and num. Num contains 'how far' we are though ivec. + 'Encrypt' is used to indicate encryption or decryption. + CFB64 mode operates by using the cipher to generate a stream + of bytes which is used to encrypt the plain text. + The cipher text is then encrypted to generate the next 64 bits to + be xored (incrementally) with the next 64 bits of plain + text. As can be seen from this, to encrypt or decrypt, + the same 'cipher stream' needs to be generated but the way the next + block of data is gathered for encryption is different for + encryption and decryption. + +void RC2_ofb64_encrypt( +unsigned char *in, +unsigned char *out, +long length, +RC2_KEY *schedule, +unsigned char *ivec, +int *num); + This functions implements OFB mode of RC2 with 64bit feedback. + This allows you to encrypt an arbitrary number of bytes, + you do not require 8 byte padding. Each call to this + routine will encrypt the input bytes to output and then update ivec + and num. Num contains 'how far' we are though ivec. + This is in effect a stream cipher, there is no encryption or + decryption mode. + +For reading passwords, I suggest using des_read_pw_string() from my DES library. +To generate a password from a text string, I suggest using MD5 (or MD2) to +produce a 16 byte message digest that can then be passed directly to +RC2_set_key(). + +===== +For more information about the specific RC2 modes in this library +(ecb, cbc, cfb and ofb), read the section entitled 'Modes of DES' from the +documentation on my DES library. What is said about DES is directly +applicable for RC2. + diff --git a/src/lib/libssl/src/doc/rc4.doc b/src/lib/libssl/src/doc/rc4.doc new file mode 100644 index 0000000000..4b2897eb74 --- /dev/null +++ b/src/lib/libssl/src/doc/rc4.doc @@ -0,0 +1,44 @@ +The RC4 library. +RC4 is a stream cipher that operates on a byte stream. It can be used with +any length key but I would recommend normally using 16 bytes. + +This library requires the inclusion of 'rc4.h'. + +The RC4 encryption function takes what is called an RC4_KEY as an argument. +The RC4_KEY is generated by the RC4_set_key function from the key bytes. + +RC4, being a stream cipher, does not have an encryption or decryption mode. +It produces a stream of bytes that the input stream is xor'ed against and +so decryption is just a case of 'encrypting' again with the same key. + +I have only put in one 'mode' for RC4 which is the normal one. This means +there is no initialisation vector and there is no feedback of the cipher +text into the cipher. This implies that you should not ever use the +same key twice if you can help it. If you do, you leave yourself open to +known plain text attacks; if you know the plain text and +corresponding cipher text in one message, all messages that used the same +key can have the cipher text decoded for the corresponding positions in the +cipher stream. + +The main positive feature of RC4 is that it is a very fast cipher; about 4 +times faster that DES. This makes it ideally suited to protocols where the +key is randomly chosen, like SSL. + +The functions are as follows: + +void RC4_set_key( +RC4_KEY *key; +int len; +unsigned char *data); + This function initialises the RC4_KEY structure with the key passed + in 'data', which is 'len' bytes long. The key data can be any + length but 16 bytes seems to be a good number. + +void RC4( +RC4_KEY *key; +unsigned long len; +unsigned char *in; +unsigned char *out); + Do the actual RC4 encryption/decryption. Using the 'key', 'len' + bytes are transformed from 'in' to 'out'. As mentioned above, + decryption is the operation as encryption. diff --git a/src/lib/libssl/src/doc/readme b/src/lib/libssl/src/doc/readme new file mode 100644 index 0000000000..824d4fd0e2 --- /dev/null +++ b/src/lib/libssl/src/doc/readme @@ -0,0 +1,6 @@ +This is the old 0.6.6 docuementation. Most of the cipher stuff is still +relevent but I'm working (very slowly) on new docuemtation. +The current version can be found online at + +http://www.cryptsoft.com/ssleay/doc + diff --git a/src/lib/libssl/src/doc/ref.doc b/src/lib/libssl/src/doc/ref.doc new file mode 100644 index 0000000000..211559900d --- /dev/null +++ b/src/lib/libssl/src/doc/ref.doc @@ -0,0 +1,48 @@ +I have lots more references etc, and will update this list in the future, +30 Aug 1996 - eay + + +SSL The SSL Protocol - from Netscapes. + +RC4 Newsgroups: sci.crypt + From: sterndark@netcom.com (David Sterndark) + Subject: RC4 Algorithm revealed. + Message-ID: + +RC2 Newsgroups: sci.crypt + From: pgut01@cs.auckland.ac.nz (Peter Gutmann) + Subject: Specification for Ron Rivests Cipher No.2 + Message-ID: <4fk39f$f70@net.auckland.ac.nz> + +MD2 RFC1319 The MD2 Message-Digest Algorithm +MD5 RFC1321 The MD5 Message-Digest Algorithm + +X509 Certificates + RFC1421 Privacy Enhancement for Internet Electronic Mail: Part I + RFC1422 Privacy Enhancement for Internet Electronic Mail: Part II + RFC1423 Privacy Enhancement for Internet Electronic Mail: Part III + RFC1424 Privacy Enhancement for Internet Electronic Mail: Part IV + +RSA and various standard encoding + PKCS#1 RSA Encryption Standard + PKCS#5 Password-Based Encryption Standard + PKCS#7 Cryptographic Message Syntax Standard + A Layman's Guide to a Subset of ASN.1, BER, and DER + An Overview of the PKCS Standards + Some Examples of the PKCS Standards + +IDEA Chapter 3 The Block Cipher IDEA + +RSA, prime number generation and bignum algorithms + Introduction To Algorithms, + Thomas Cormen, Charles Leiserson, Ronald Rivest, + Section 29 Arithmetic Circuits + Section 33 Number-Theoretic Algorithms + +Fast Private Key algorithm + Fast Decipherment Algorithm for RSA Public-Key Cryptosystem + J.-J. Quisquater and C. Couvreur, Electronics Letters, + 14th October 1982, Vol. 18 No. 21 + +Prime number generation and bignum algorithms. + PGP-2.3a diff --git a/src/lib/libssl/src/doc/req.1 b/src/lib/libssl/src/doc/req.1 new file mode 100644 index 0000000000..684fda580e --- /dev/null +++ b/src/lib/libssl/src/doc/req.1 @@ -0,0 +1,137 @@ +The 'req' command is used to manipulate and deal with pkcs#10 +certificate requests. + +It's default mode of operation is to load a certificate and then +write it out again. + +By default the 'req' is read from stdin in 'PEM' format. +The -inform option can be used to specify 'pem' format or 'der' +format. PEM format is the base64 encoding of the DER format. + +By default 'req' then writes the request back out. -outform can be used +to indicate the desired output format, be it 'pem' or 'der'. + +To specify an input file, use the '-in' option and the '-out' option +can be used to specify the output file. + +If you wish to perform a command and not output the certificate +request afterwards, use the '-noout' option. + +When a certificate is loaded, it can be printed in a human readable +ascii format via the '-text' option. + +To check that the signature on a certificate request is correct, use +the '-verify' option to make sure that the private key contained in the +certificate request corresponds to the signature. + +Besides the default mode, there is also the 'generate a certificate +request' mode. There are several flags that trigger this mode. + +-new will generate a new RSA key (if required) and then prompts +the user for details for the certificate request. +-newkey has an argument that is the number of bits to make the new +key. This function also triggers '-new'. + +The '-new' option can have a key to use specified instead of having to +load one, '-key' is used to specify the file containg the key. +-keyform can be used to specify the format of the key. Only +'pem' and 'der' formats are supported, later, 'netscape' format may be added. + +Finally there is the '-x509' options which makes req output a self +signed x509 certificate instead of a certificate request. + +Now as you may have noticed, there are lots of default options that +cannot be specified via the command line. They are held in a 'template' +or 'configuration file'. The -config option specifies which configuration +file to use. See conf.doc for details on the syntax of this file. + +The req command uses the 'req' section of the config file. + +--- +# The following variables are defined. For this example I will populate +# the various values +[ req ] +default_bits = 512 # default number of bits to use. +default_keyfile = testkey.pem # Where to write the generated keyfile + # if not specified. +distinguished_name= req_dn # The section that contains the + # information about which 'object' we + # want to put in the DN. +attributes = req_attr # The objects we want for the + # attributes field. +encrypt_rsa_key = no # Should we encrypt newly generated + # keys. I strongly recommend 'yes'. + +# The distinguished name section. For the following entries, the +# object names must exist in the SSLeay header file objects.h. If they +# do not, they will be silently ignored. The entries have the following +# format. +# => string to prompt with +# _default => default value for people +# _value => Automatically use this value for this field. +# _min => minimum number of characters for data (def. 0) +# _max => maximum number of characters for data (def. inf.) +# All of these entries are optional except for the first one. +[ req_dn ] +countryName = Country Name (2 letter code) +countryName_default = AU + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Queensland + +localityName = Locality Name (eg, city) + +organizationName = Organization Name (eg, company) +organizationName_default = Mincom Pty Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +organizationalUnitName_default = MTR + +commonName = Common Name (eg, YOUR name) +commonName_max = 64 + +emailAddress = Email Address +emailAddress_max = 40 + +# The next section is the attributes section. This is exactly the +# same as for the previous section except that the resulting objects are +# put in the attributes field. +[ req_attr ] +challengePassword = A challenge password +challengePassword_min = 4 +challengePassword_max = 20 + +unstructuredName = An optional company name + +---- +Also note that the order that attributes appear in this file is the +order they will be put into the distinguished name. + +Once this request has been generated, it can be sent to a CA for +certifying. + +---- +A few quick examples.... + +To generate a new request and a new key +req -new + +To generate a new request and a 1058 bit key +req -newkey 1058 + +To generate a new request using a pre-existing key +req -new -key key.pem + +To generate a self signed x509 certificate from a certificate +request using a supplied key, and we want to see the text form of the +output certificate (which we will put in the file selfSign.pem +req -x509 -in req.pem -key key.pem -text -out selfSign.pem + +Verify that the signature is correct on a certificate request. +req -verify -in req.pem + +Verify that the signature was made using a specified public key. +req -verify -in req.pem -key key.pem + +Print the contents of a certificate request +req -text -in req.pem diff --git a/src/lib/libssl/src/doc/rsa.doc b/src/lib/libssl/src/doc/rsa.doc new file mode 100644 index 0000000000..f260452bc6 --- /dev/null +++ b/src/lib/libssl/src/doc/rsa.doc @@ -0,0 +1,135 @@ +The RSA encryption and utility routines. + +The RSA routines are built on top of a big number library (the BN library). +There are support routines in the X509 library for loading and manipulating +the various objects in the RSA library. When errors are returned, read +about the ERR library for how to access the error codes. + +All RSA encryption is done according to the PKCS-1 standard which is +compatible with PEM and RSAref. This means that any values being encrypted +must be less than the size of the modulus in bytes, minus 10, bytes long. + +This library uses RAND_bytes()() for it's random data, make sure to feed +RAND_seed() with lots of interesting and varied data before using these +routines. + +The RSA library has one specific data type, the RSA structure. +It is composed of 8 BIGNUM variables (see the BN library for details) and +can hold either a private RSA key or a public RSA key. +Some RSA libraries have different structures for public and private keys, I +don't. For my libraries, a public key is determined by the fact that the +RSA->d value is NULL. These routines will operate on any size RSA keys. +While I'm sure 4096 bit keys are very very secure, they take a lot longer +to process that 1024 bit keys :-). + +The function in the RSA library are as follows. + +RSA *RSA_new(); + This function creates a new RSA object. The sub-fields of the RSA + type are also malloced so you should always use this routine to + create RSA variables. + +void RSA_free( +RSA *rsa); + This function 'frees' an RSA structure. This routine should always + be used to free the RSA structure since it will also 'free' any + sub-fields of the RSA type that need freeing. + +int RSA_size( +RSA *rsa); + This function returns the size of the RSA modulus in bytes. Why do + I need this you may ask, well the reason is that when you encrypt + with RSA, the output string will be the size of the RSA modulus. + So the output for the RSA_encrypt and the input for the RSA_decrypt + routines need to be RSA_size() bytes long, because this is how many + bytes are expected. + +For the following 4 RSA encryption routines, it should be noted that +RSA_private_decrypt() should be used on the output from +RSA_public_encrypt() and RSA_public_decrypt() should be used on +the output from RSA_private_encrypt(). + +int RSA_public_encrypt( +int from_len; +unsigned char *from +unsigned char *to +RSA *rsa); + This function implements RSA public encryption, the rsa variable + should be a public key (but can be a private key). 'from_len' + bytes taken from 'from' and encrypted and put into 'to'. 'to' needs + to be at least RSA_size(rsa) bytes long. The number of bytes + written into 'to' is returned. -1 is returned on an error. The + operation performed is + to = from^rsa->e mod rsa->n. + +int RSA_private_encrypt( +int from_len; +unsigned char *from +unsigned char *to +RSA *rsa); + This function implements RSA private encryption, the rsa variable + should be a private key. 'from_len' bytes taken from + 'from' and encrypted and put into 'to'. 'to' needs + to be at least RSA_size(rsa) bytes long. The number of bytes + written into 'to' is returned. -1 is returned on an error. The + operation performed is + to = from^rsa->d mod rsa->n. + +int RSA_public_decrypt( +int from_len; +unsigned char *from +unsigned char *to +RSA *rsa); + This function implements RSA public decryption, the rsa variable + should be a public key (but can be a private key). 'from_len' + bytes are taken from 'from' and decrypted. The decrypted data is + put into 'to'. The number of bytes encrypted is returned. -1 is + returned to indicate an error. The operation performed is + to = from^rsa->e mod rsa->n. + +int RSA_private_decrypt( +int from_len; +unsigned char *from +unsigned char *to +RSA *rsa); + This function implements RSA private decryption, the rsa variable + should be a private key. 'from_len' bytes are taken + from 'from' and decrypted. The decrypted data is + put into 'to'. The number of bytes encrypted is returned. -1 is + returned to indicate an error. The operation performed is + to = from^rsa->d mod rsa->n. + +int RSA_mod_exp( +BIGNUM *n; +BIGNUM *p; +RSA *rsa); + Normally you will never use this routine. + This is really an internal function which is called by + RSA_private_encrypt() and RSA_private_decrypt(). It performs + n=n^p mod rsa->n except that it uses the 5 extra variables in the + RSA structure to make this more efficient. + +RSA *RSA_generate_key( +int bits; +unsigned long e; +void (*callback)(); +char *cb_arg; + This routine is used to generate RSA private keys. It takes + quite a period of time to run and should only be used to + generate initial private keys that should then be stored + for later use. The passed callback function + will be called periodically so that feedback can be given + as to how this function is progressing. + 'bits' is the length desired for the modulus, so it would be 1024 + to generate a 1024 bit private key. + 'e' is the value to use for the public exponent 'e'. Traditionally + it is set to either 3 or 0x10001. + The callback function (if not NULL) is called in the following + situations. + when we have generated a suspected prime number to test, + callback(0,num1++,cb_arg). When it passes a prime number test, + callback(1,num2++,cb_arg). When it is rejected as one of + the 2 primes required due to gcd(prime,e value) != 0, + callback(2,num3++,cb_arg). When finally accepted as one + of the 2 primes, callback(3,num4++,cb_arg). + diff --git a/src/lib/libssl/src/doc/rsaref.doc b/src/lib/libssl/src/doc/rsaref.doc new file mode 100644 index 0000000000..0505b76f76 --- /dev/null +++ b/src/lib/libssl/src/doc/rsaref.doc @@ -0,0 +1,35 @@ +This package can be compiled to use the RSAref library. +This library is not allowed outside of the USA but inside the USA it is +claimed by RSA to be the only RSA public key library that can be used +besides BSAFE.. + +There are 2 files, rsaref/rsaref.c and rsaref/rsaref.h that contain the glue +code to use RSAref. These files were written by looking at the PGP +source code and seeing which routines it used to access RSAref. +I have also been sent by some-one a copy of the RSAref header file that +contains the library error codes. + +[ Jun 1996 update - I have recently gotten hold of RSAref 2.0 from + South Africa and have been doing some performace tests. ] + +They have now been tested against the recently announced RSAEURO +library. + +There are 2 ways to use SSLeay and RSAref. First, to build so that +the programs must be linked with RSAref, add '-DRSAref' to CFLAG in the top +level makefile and -lrsaref (or where ever you are keeping RSAref) to +EX_LIBS. + +To build a makefile via util/mk1mf.pl to do this, use the 'rsaref' option. + +The second method is to build as per normal and link applications with +the RSAglue library. The correct library order would be +cc -o cmd cmd.o -lssl -lRSAglue -lcrypto -lrsaref -ldes +The RSAglue library is built in the rsa directory and is NOT +automatically installed. + +Be warned that the RSAEURO library, that is claimed to be compatible +with RSAref contains a different value for the maximum number of bits +supported. This changes structure sizes and so if you are using +RSAEURO, change the value of RSAref_MAX_BITS in rsa/rsaref.h + diff --git a/src/lib/libssl/src/doc/s_mult.doc b/src/lib/libssl/src/doc/s_mult.doc new file mode 100644 index 0000000000..726085bc57 --- /dev/null +++ b/src/lib/libssl/src/doc/s_mult.doc @@ -0,0 +1,17 @@ +s_mult is a test program I hacked up on a Sunday for testing non-blocking +IO. It has a select loop at it's centre that handles multiple readers +and writers. + +Try the following command +ssleay s_mult -echo -nbio -ssl -v +echo - sends any sent text back to the sender +nbio - turns on non-blocking IO +ssl - accept SSL connections, default is normal text +v - print lots + type Q to quit + +In another window, run the following +ssleay s_client -pause new_session_cb is a function pointer to a function of type +int new_session_callback(SSL *ssl,SSL_SESSION *new); +This function, if set in the SSL_CTX structure is called whenever a new +SSL_SESSION is added to the cache. If the callback returns non-zero, it +means that the application will have to do a SSL_SESSION_free() +on the structure (this is +to do with the cache keeping the reference counts correct, without the +application needing to know about it. +The 'active' parameter is the current SSL session for which this connection +was created. + +void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,int (*cb)()); +to set the callback, +int (*cb)() SSL_CTX_sess_get_new_cb(SSL_CTX *ctx) +to get the callback. + +If the 'get session' callback is set, when a session id is looked up and +it is not in the session-id cache, this callback is called. The callback is +of the form +SSL_SESSION *get_session_callback(unsigned char *sess_id,int sess_id_len, + int *copy); + +The get_session_callback is intended to return null if no session id is found. +The reference count on the SSL_SESSION in incremented by the SSL library, +if copy is 1. Otherwise, the reference count is not modified. + +void SSL_CTX_sess_set_get_cb(ctx,cb) sets the callback and +int (*cb)()SSL_CTX_sess_get_get_cb(ctx) returns the callback. + +These callbacks are basically indended to be used by processes to +send their session-id's to other processes. I currently have not implemented +non-blocking semantics for these callbacks, it is upto the appication +to make the callbacks effiecent if they require blocking (perhaps +by 'saving' them and then 'posting them' when control returns from +the SSL_accept(). + +LHASH *SSL_CTX_sessions(SSL_CTX *ctx) +This returns the session cache. The lhash strucutre can be accessed for +statistics about the cache. + +void lh_stats(LHASH *lh, FILE *out); +void lh_node_stats(LHASH *lh, FILE *out); +void lh_node_usage_stats(LHASH *lh, FILE *out); + +can be used to print details about it's activity and current state. +You can also delve directly into the lhash structure for 14 different +counters that are kept against the structure. When I wrote the lhash library, +I was interested in gathering statistics :-). +Have a read of doc/lhash.doc in the SSLeay distribution area for more details +on the lhash library. + +Now as mentioned ealier, when a SSL is created, it needs a SSL_CTX. +SSL * SSL_new(SSL_CTX *); + +This stores a session. A session is secret information shared between 2 +SSL contexts. It will only be created if both ends of the connection have +authenticated their peer to their satisfaction. It basically contains +the information required to use a particular secret key cipher. + +To retrieve the SSL_CTX being used by a SSL, +SSL_CTX *SSL_get_SSL_CTX(SSL *s); + +Now when a SSL session is established between to programs, the 'session' +information that is cached in the SSL_CTX can me manipulated by the +following functions. +int SSL_set_session(SSL *s, SSL_SESSION *session); +This will set the SSL_SESSION to use for the next SSL_connect(). If you use +this function on an already 'open' established SSL connection, 'bad things +will happen'. This function is meaning-less when used on a ssl strucutre +that is just about to be used in a SSL_accept() call since the +SSL_accept() will either create a new session or retrieve one from the +cache. + +SSL_SESSION *SSL_get_session(SSL *s); +This will return the SSL_SESSION for the current SSL, NULL if there is +no session associated with the SSL structure. + +The SSL sessions are kept in the SSL_CTX in a hash table, to remove a +session +void SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); +and to add one +int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); +SSL_CTX_add_session() returns 1 if the session was already in the cache (so it +was not added). +Whenever a new session is created via SSL_connect()/SSL_accept(), +they are automatically added to the cache, depending on the session_cache_mode +settings. SSL_set_session() +does not add it to the cache. Just call SSL_CTX_add_session() if you do want the +session added. For a 'client' this would not normally be the case. +SSL_CTX_add_session() is not normally ever used, except for doing 'evil' things +which the next 2 funtions help you do. + +int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length); +These 2 functions are in the standard ASN1 library form and can be used to +load and save to a byte format, the SSL_SESSION structure. +With these functions, you can save and read these structures to a files or +arbitary byte string. +The PEM_write_SSL_SESSION(fp,x) and PEM_read_SSL_SESSION(fp,x,cb) will +write to a file pointer in base64 encoding. + +What you can do with this, is pass session information between separate +processes. Please note, that you will probably also need to modify the +timeout information on the SSL_SESSIONs. + +long SSL_get_time(SSL_SESSION *s) +will return the 'time' that the session +was loaded. The timeout is relative to this time. This information is +saved when the SSL_SESSION is converted to binarary but it is stored +in as a unix long, which is rather OS dependant, but easy to convert back. + +long SSL_set_time(SSL_SESSION *s,long t) will set the above mentioned time. +The time value is just the value returned from time(3), and should really +be defined by be to be time_t. + +long SSL_get_timeout(SSL_SESSION *s); +long SSL_set_timeout(SSL_SESSION *s,long t); +These 2 retrieve and set the timeout which is just a number of secconds +from the 'SSL_get_time()' value. When this time period has elapesed, +the session will no longer be in the cache (well it will actually be removed +the next time it is attempted to be retrieved, so you could 'bump' +the timeout so it remains valid). +The 'time' and 'timeout' are set on a session when it is created, not reset +each time it is reused. If you did wish to 'bump it', just after establishing +a connection, do a +SSL_set_time(ssl,time(NULL)); + +You can also use +SSL_CTX_set_timeout(SSL_CTX *ctx,unsigned long t) and +SSL_CTX_get_timeout(SSL_CTX *ctx) to manipulate the default timeouts for +all SSL connections created against a SSL_CTX. If you set a timeout in +an SSL_CTX, all new SSL's created will inherit the timeout. It can be over +written by the SSL_set_timeout(SSL *s,unsigned long t) function call. +If you 'set' the timeout back to 0, the system default will be used. + +SSL_SESSION *SSL_SESSION_new(); +void SSL_SESSION_free(SSL_SESSION *ses); +These 2 functions are used to create and dispose of SSL_SESSION functions. +You should not ever normally need to use them unless you are using +i2d_SSL_SESSION() and/or d2i_SSL_SESSION(). If you 'load' a SSL_SESSION +via d2i_SSL_SESSION(), you will need to SSL_SESSION_free() it. +Both SSL_set_session() and SSL_CTX_add_session() will 'take copies' of the +structure (via reference counts) when it is passed to them. + +SSL_CTX_flush_sessions(ctx,time); +The first function will clear all sessions from the cache, which have expired +relative to 'time' (which could just be time(NULL)). + +SSL_CTX_flush_sessions(ctx,0); +This is a special case that clears everything. + +As a final comment, a 'session' is not enough to establish a new +connection. If a session has timed out, a certificate and private key +need to have been associated with the SSL structure. +SSL_copy_session_id(SSL *to,SSL *from); will copy not only the session +strucutre but also the private key and certificate associated with +'from'. + +EXAMPLES. + +So lets play at being a wierd SSL server. + +/* setup a context */ +ctx=SSL_CTX_new(); + +/* Lets load some session from binary into the cache, why one would do + * this is not toally clear, but passing between programs does make sense + * Perhaps you are using 4096 bit keys and are happy to keep them + * valid for a week, to avoid the RSA overhead of 15 seconds, I'm not toally + * sure, perhaps this is a process called from an SSL inetd and this is being + * passed to the application. */ +session=d2i_SSL_SESSION(....) +SSL_CTX_add_session(ctx,session); + +/* Lets even add a session from a file */ +session=PEM_read_SSL_SESSION(....) +SSL_CTX_add_session(ctx,session); + +/* create a new SSL structure */ +ssl=SSL_new(ctx); + +/* At this point we want to be able to 'create' new session if + * required, so we need a certificate and RSAkey. */ +SSL_use_RSAPrivateKey_file(ssl,...) +SSL_use_certificate_file(ssl,...) + +/* Now since we are a server, it make little sence to load a session against + * the ssl strucutre since a SSL_accept() will either create a new session or + * grab an existing one from the cache. */ + +/* grab a socket descriptor */ +fd=accept(...); + +/* associated it with the ssl strucutre */ +SSL_set_fd(ssl,fd); + +SSL_accept(ssl); /* 'do' SSL using out cert and RSA key */ + +/* Lets print out the session details or lets save it to a file, + * perhaps with a secret key cipher, so that we can pass it to the FBI + * when they want to decode the session :-). While we have RSA + * this does not matter much but when I do SSLv3, this will allow a mechanism + * for the server/client to record the information needed to decode + * the traffic that went over the wire, even when using Diffie-Hellman */ +PEM_write_SSL_SESSION(SSL_get_session(ssl),stdout,....) + +Lets 'connect' back to the caller using the same session id. + +ssl2=SSL_new(ctx); +fd2=connect(them); +SSL_set_fd(ssl2,fd2); +SSL_set_session(ssl2,SSL_get_session(ssl)); +SSL_connect(ssl2); + +/* what the hell, lets accept no more connections using this session */ +SSL_CTX_remove_session(SSL_get_SSL_CTX(ssl),SSL_get_session(ssl)); + +/* we could have just as easily used ssl2 since they both are using the + * same session. + * You will note that both ssl and ssl2 are still using the session, and + * the SSL_SESSION structure will be free()ed when both ssl and ssl2 + * finish using the session. Also note that you could continue to initiate + * connections using this session by doing SSL_get_session(ssl) to get the + * existing session, but SSL_accept() will not be able to find it to + * use for incoming connections. + * Of corse, the session will timeout at the far end and it will no + * longer be accepted after a while. The time and timeout are ignored except + * by SSL_accept(). */ + +/* Since we have had our server running for 10 weeks, and memory is getting + * short, perhaps we should clear the session cache to remove those + * 100000 session entries that have expired. Some may consider this + * a memory leak :-) */ + +SSL_CTX_flush_sessions(ctx,time(NULL)); + +/* Ok, after a bit more time we wish to flush all sessions from the cache + * so that all new connections will be authenticated and incure the + * public key operation overhead */ + +SSL_CTX_flush_sessions(ctx,0); + +/* As a final note, to copy everything to do with a SSL, use */ +SSL_copy_session_id(SSL *to,SSL *from); +/* as this also copies the certificate and RSA key so new session can + * be established using the same details */ + diff --git a/src/lib/libssl/src/doc/sha.doc b/src/lib/libssl/src/doc/sha.doc new file mode 100644 index 0000000000..895fa182ed --- /dev/null +++ b/src/lib/libssl/src/doc/sha.doc @@ -0,0 +1,52 @@ +The SHA (Secure Hash Algorithm) library. +SHA is a message digest algorithm that can be used to condense an arbitrary +length message down to a 20 byte hash. The functions all need to be passed +a SHA_CTX which is used to hold the SHA context during multiple SHA_Update() +function calls. The normal method of use for this library is as follows +This library contains both SHA and SHA-1 digest algorithms. SHA-1 is +an update to SHA (which should really be called SHA-0 now) which +tweaks the algorithm slightly. The SHA-1 algorithm is used by simply +using SHA1_Init(), SHA1_Update(), SHA1_Final() and SHA1() instead of the +SHA*() calls + +SHA_Init(...); +SHA_Update(...); +... +SHA_Update(...); +SHA_Final(...); + +This library requires the inclusion of 'sha.h'. + +The functions are as follows: + +void SHA_Init( +SHA_CTX *c); + This function needs to be called to initiate a SHA_CTX structure for + use. + +void SHA_Update( +SHA_CTX *c; +unsigned char *data; +unsigned long len); + This updates the message digest context being generated with 'len' + bytes from the 'data' pointer. The number of bytes can be any + length. + +void SHA_Final( +unsigned char *md; +SHA_CTX *c; + This function is called when a message digest of the data digested + with SHA_Update() is wanted. The message digest is put in the 'md' + array and is SHA_DIGEST_LENGTH (20) bytes long. + +unsigned char *SHA( +unsigned char *d; +unsigned long n; +unsigned char *md; + This function performs a SHA_Init(), followed by a SHA_Update() + followed by a SHA_Final() (using a local SHA_CTX). + The resulting digest is put into 'md' if it is not NULL. + Regardless of the value of 'md', the message + digest is returned from the function. If 'md' was NULL, the message + digest returned is being stored in a static structure. + diff --git a/src/lib/libssl/src/doc/speed.doc b/src/lib/libssl/src/doc/speed.doc new file mode 100644 index 0000000000..11dfa85f08 --- /dev/null +++ b/src/lib/libssl/src/doc/speed.doc @@ -0,0 +1,96 @@ +To get an idea of the performance of this library, use +ssleay speed + +perl util/sp-diff.pl file1 file2 + +will print out the relative differences between the 2 files which are +expected to be the output from the speed program. + +The performace of the library is very dependant on the Compiler +quality and various flags used to build. + +--- + +These are some numbers I did comparing RSAref and SSLeay on a Pentium 100. +[ These numbers are all out of date, as of SSL - 0.6.1 the RSA +operations are about 2 times faster, so check the version number ] + +RSA performance. + +SSLeay 0.6.0 +Pentium 100, 32meg, Windows NT Workstation 3.51 +linux - gcc v 2.7.0 -O3 -fomit-frame-pointer -m486 +and +Windows NT - Windows NT 3.51 - Visual C++ 4.1 - 586 code + 32bit assember +Windows 3.1 - Windows NT 3.51 - Visual C++ 1.52c - 286 code + 32bit assember +NT Dos Shell- Windows NT 3.51 - Visual C++ 1.52c - 286 code + 16bit assember + +Times are how long it takes to do an RSA private key operation. + + 512bits 1024bits +------------------------------- +SSLeay NT dll 0.042s 0.202s see above +SSLeay linux 0.046s 0.218s Assember inner loops (normal build) +SSLeay linux 0.067s 0.380s Pure C code with BN_LLONG defined +SSLeay W3.1 dll 0.108s 0.478s see above +SSLeay linux 0.109s 0.713s C without BN_LLONG. +RSAref2.0 linux 0.149s 0.936s +SSLeay MS-DOS 0.197s 1.049s see above + +486DX66, 32meg, Windows NT Server 3.51 + 512bits 1024bits +------------------------------- +SSLeay NT dll 0.084s 0.495s <- SSLeay 0.6.3 +SSLeay NT dll 0.154s 0.882s +SSLeay W3.1 dll 0.335s 1.538s +SSLeay MS-DOS 0.490s 2.790s + +What I find cute is that I'm still faster than RSAref when using standard C, +without using the 'long long' data type :-), %35 faster for 512bit and we +scale up to 3.2 times faster for the 'default linux' build. I should mention +that people should 'try' to use either x86-lnx.s (elf), x86-lnxa.s or +x86-sol.s for any x86 based unix they are building on. The only problems +with be with syntax but the performance gain is quite large, especially for +servers. The code is very simple, you just need to modify the 'header'. + +The message is, if you are stuck using RSAref, the RSA performance will be +bad. Considering the code was compiled for a pentium, the 486DX66 number +would indicate 'Use RSAref and turn you Pentium 100 into a 486DX66' :-). +[ As of verson 0.6.1, it would be correct to say 'turn you pentium 100 + into a 486DX33' :-) ] + +I won't tell people if the DLL's are using RSAref or my stuff if no-one +asks :-). + +eric + +PS while I know I could speed things up further, I will probably not do + so due to the effort involved. I did do some timings on the + SSLeay bignum format -> RSAref number format conversion that occurs + each time RSAref is used by SSLeay, and the numbers are trivial. + 0.00012s a call for 512bit vs 0.149s for the time spent in the function. + 0.00018s for 1024bit vs 0.938s. Insignificant. + So the 'way to go', to support faster RSA libraries, if people are keen, + is to write 'glue' code in a similar way that I do for RSAref and send it + to me :-). + My base library still has the advantage of being able to operate on + any size numbers, and is not that far from the performance from the + leaders in the field. (-%30?) + [ Well as of 0.6.1 I am now the leader in the filed on x86 (we at + least very close :-) ] + + I suppose I should also mention some other numbers RSAref numbers, again + on my Pentium. + DES CBC EDE-DES MD5 + RSAref linux 830k/s 302k/s 4390k/s + SSLeay linux 855k/s 319k/s 10025k/s + SSLeay NT 1158k/s 410k/s 10470k/s + SSLeay w31 378k/s 143k/s 2383k/s (fully 16bit) + + Got to admit that Visual C++ 4.[01] is a damn fine compiler :-) +-- +Eric Young | BOOL is tri-state according to Bill Gates. +AARNet: eay@cryptsoft.com | RTFM Win32 GetMessage(). + + + diff --git a/src/lib/libssl/src/doc/ssl-ciph.doc b/src/lib/libssl/src/doc/ssl-ciph.doc new file mode 100644 index 0000000000..33a7e41f0e --- /dev/null +++ b/src/lib/libssl/src/doc/ssl-ciph.doc @@ -0,0 +1,84 @@ +This is a quick high level summery of how things work now. + +Each SSLv2 and SSLv3 cipher is composed of 4 major attributes plus a few extra +minor ones. + +They are 'The key exchange algorithm', which is RSA for SSLv2 but can also +be Diffle-Hellman for SSLv3. + +An 'Authenticion algorithm', which can be RSA, Diffle-Helman, DSS or +none. + +The cipher + +The MAC digest. + +A cipher can also be an export cipher and is either an SSLv2 or a +SSLv3 ciphers. + +To specify which ciphers to use, one can either specify all the ciphers, +one at a time, or use 'aliases' to specify the preference and order for +the ciphers. + +There are a large number of aliases, but the most importaint are +kRSA, kDHr, kDHd and kEDH for key exchange types. + +aRSA, aDSS, aNULL and aDH for authentication +DES, 3DES, RC4, RC2, IDEA and eNULL for ciphers +MD5, SHA0 and SHA1 digests + +Now where this becomes interesting is that these can be put together to +specify the order and ciphers you wish to use. + +To speed this up there are also aliases for certian groups of ciphers. +The main ones are +SSLv2 - all SSLv2 ciphers +SSLv3 - all SSLv3 ciphers +EXP - all export ciphers +LOW - all low strngth ciphers (no export ciphers, normally single DES) +MEDIUM - 128 bit encryption +HIGH - Triple DES + +These aliases can be joined in a : separated list which specifies to +add ciphers, move them to the current location and delete them. + +A simpler way to look at all of this is to use the 'ssleay ciphers -v' command. +The default library cipher spec is +!ADH:RC4+RSA:HIGH:MEDIUM:LOW:EXP:+SSLv2:+EXP +which means, first, remove from consideration any ciphers that do not +authenticate. Next up, use ciphers using RC4 and RSA. Next include the HIGH, +MEDIUM and the LOW security ciphers. Finish up by adding all the export +ciphers on the end, then 'pull' all the SSLv2 and export ciphers to +the end of the list. + +The results are +$ ssleay ciphers -v '!ADH:RC4+RSA:HIGH:MEDIUM:LOW:EXP:+SSLv2:+EXP' + +RC4-SHA SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=SHA1 +RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5 +EDH-RSA-DES-CBC3-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1 +EDH-DSS-DES-CBC3-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1 +DES-CBC3-SHA SSLv3 Kx=RSA Au=RSA Enc=3DES(168) Mac=SHA1 +IDEA-CBC-MD5 SSLv3 Kx=RSA Au=RSA Enc=IDEA(128) Mac=SHA1 +EDH-RSA-DES-CBC-SHA SSLv3 Kx=DH Au=RSA Enc=DES(56) Mac=SHA1 +EDH-DSS-DES-CBC-SHA SSLv3 Kx=DH Au=DSS Enc=DES(56) Mac=SHA1 +DES-CBC-SHA SSLv3 Kx=RSA Au=RSA Enc=DES(56) Mac=SHA1 +DES-CBC3-MD5 SSLv2 Kx=RSA Au=RSA Enc=3DES(168) Mac=MD5 +DES-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=DES(56) Mac=MD5 +IDEA-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=IDEA(128) Mac=MD5 +RC2-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC2(128) Mac=MD5 +RC4-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5 +EXP-EDH-RSA-DES-CBC SSLv3 Kx=DH(512) Au=RSA Enc=DES(40) Mac=SHA1 export +EXP-EDH-DSS-DES-CBC-SHA SSLv3 Kx=DH(512) Au=DSS Enc=DES(40) Mac=SHA1 export +EXP-DES-CBC-SHA SSLv3 Kx=RSA(512) Au=RSA Enc=DES(40) Mac=SHA1 export +EXP-RC2-CBC-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export +EXP-RC4-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export +EXP-RC2-CBC-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export +EXP-RC4-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export + +I would recoment people use the 'ssleay ciphers -v "text"' +command to check what they are going to use. + +Anyway, I'm falling asleep here so I'll do some more tomorrow. + +eric diff --git a/src/lib/libssl/src/doc/ssl.doc b/src/lib/libssl/src/doc/ssl.doc new file mode 100644 index 0000000000..1f89cd5db2 --- /dev/null +++ b/src/lib/libssl/src/doc/ssl.doc @@ -0,0 +1,172 @@ +SSL_CTX_sessions(SSL_CTX *ctx) - the session-id hash table. + +/* Session-id cache stats */ +SSL_CTX_sess_number +SSL_CTX_sess_connect +SSL_CTX_sess_connect_good +SSL_CTX_sess_accept +SSL_CTX_sess_accept_good +SSL_CTX_sess_hits +SSL_CTX_sess_cb_hits +SSL_CTX_sess_misses +SSL_CTX_sess_timeouts + +/* Session-id application notification callbacks */ +SSL_CTX_sess_set_new_cb +SSL_CTX_sess_get_new_cb +SSL_CTX_sess_set_get_cb +SSL_CTX_sess_get_get_cb + +/* Session-id cache operation mode */ +SSL_CTX_set_session_cache_mode +SSL_CTX_get_session_cache_mode + +/* Set default timeout values to use. */ +SSL_CTX_set_timeout +SSL_CTX_get_timeout + +/* Global SSL initalisation informational callback */ +SSL_CTX_set_info_callback +SSL_CTX_get_info_callback +SSL_set_info_callback +SSL_get_info_callback + +/* If the SSL_accept/SSL_connect returned with -1, these indicate when + * we should re-call *. +SSL_want +SSL_want_nothing +SSL_want_read +SSL_want_write +SSL_want_x509_lookup + +/* Where we are in SSL initalisation, used in non-blocking, perhaps + * have a look at ssl/bio_ssl.c */ +SSL_state +SSL_is_init_finished +SSL_in_init +SSL_in_connect_init +SSL_in_accept_init + +/* Used to set the 'inital' state so SSL_in_connect_init and SSL_in_accept_init + * can be used to work out which function to call. */ +SSL_set_connect_state +SSL_set_accept_state + +/* Where to look for certificates for authentication */ +SSL_set_default_verify_paths /* calles SSL_load_verify_locations */ +SSL_load_verify_locations + +/* get info from an established connection */ +SSL_get_session +SSL_get_certificate +SSL_get_SSL_CTX + +SSL_CTX_new +SSL_CTX_free +SSL_new +SSL_clear +SSL_free + +SSL_CTX_set_cipher_list +SSL_get_cipher +SSL_set_cipher_list +SSL_get_cipher_list +SSL_get_shared_ciphers + +SSL_accept +SSL_connect +SSL_read +SSL_write + +SSL_debug + +SSL_get_read_ahead +SSL_set_read_ahead +SSL_set_verify + +SSL_pending + +SSL_set_fd +SSL_set_rfd +SSL_set_wfd +SSL_set_bio +SSL_get_fd +SSL_get_rbio +SSL_get_wbio + +SSL_use_RSAPrivateKey +SSL_use_RSAPrivateKey_ASN1 +SSL_use_RSAPrivateKey_file +SSL_use_PrivateKey +SSL_use_PrivateKey_ASN1 +SSL_use_PrivateKey_file +SSL_use_certificate +SSL_use_certificate_ASN1 +SSL_use_certificate_file + +ERR_load_SSL_strings +SSL_load_error_strings + +/* human readable version of the 'state' of the SSL connection. */ +SSL_state_string +SSL_state_string_long +/* These 2 report what kind of IO operation the library was trying to + * perform last. Probably not very usefull. */ +SSL_rstate_string +SSL_rstate_string_long + +SSL_get_peer_certificate + +SSL_SESSION_new +SSL_SESSION_print_fp +SSL_SESSION_print +SSL_SESSION_free +i2d_SSL_SESSION +d2i_SSL_SESSION + +SSL_get_time +SSL_set_time +SSL_get_timeout +SSL_set_timeout +SSL_copy_session_id +SSL_set_session +SSL_CTX_add_session +SSL_CTX_remove_session +SSL_CTX_flush_sessions + +BIO_f_ssl + +/* used to hold information as to why a certificate verification failed */ +SSL_set_verify_result +SSL_get_verify_result + +/* can be used by the application to associate data with an SSL structure. + * It needs to be 'free()ed' by the application */ +SSL_set_app_data +SSL_get_app_data + +/* The following all set values that are kept in the SSL_CTX but + * are used as the default values when an SSL session is created. + * They are over writen by the relevent SSL_xxxx functions */ + +/* SSL_set_verify */ +void SSL_CTX_set_default_verify + +/* This callback, if set, totaly overrides the normal SSLeay verification + * functions and should return 1 on sucesss and 0 on failure */ +void SSL_CTX_set_cert_verify_callback + +/* The following are the same as the equivilent SSL_xxx functions. + * Only one copy of this information is kept and if a particular + * SSL structure has a local override, it is totally separate structure. + */ +int SSL_CTX_use_RSAPrivateKey +int SSL_CTX_use_RSAPrivateKey_ASN1 +int SSL_CTX_use_RSAPrivateKey_file +int SSL_CTX_use_PrivateKey +int SSL_CTX_use_PrivateKey_ASN1 +int SSL_CTX_use_PrivateKey_file +int SSL_CTX_use_certificate +int SSL_CTX_use_certificate_ASN1 +int SSL_CTX_use_certificate_file + diff --git a/src/lib/libssl/src/doc/ssl_ctx.doc b/src/lib/libssl/src/doc/ssl_ctx.doc new file mode 100644 index 0000000000..508394e75f --- /dev/null +++ b/src/lib/libssl/src/doc/ssl_ctx.doc @@ -0,0 +1,68 @@ +This is now a bit dated, quite a few of the SSL_ functions could be +SSL_CTX_ functions. I will update this in the future. 30 Aug 1996 + +From eay@orb.mincom.oz.au Mon Dec 11 21:37:08 1995 +Received: by orb.mincom.oz.au id AA00696 + (5.65c/IDA-1.4.4 for eay); Mon, 11 Dec 1995 11:37:08 +1000 +Date: Mon, 11 Dec 1995 11:37:08 +1000 (EST) +From: Eric Young +X-Sender: eay@orb +To: sameer +Cc: Eric Young +Subject: Re: PEM_readX509 oesn't seem to be working +In-Reply-To: <199512110102.RAA12521@infinity.c2.org> +Message-Id: +Mime-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +Status: RO +X-Status: + +On Sun, 10 Dec 1995, sameer wrote: +> OK, that's solved. I've found out that it is saying "no +> certificate set" in SSL_accept because s->conn == NULL +> so there is some place I need to initialize s->conn that I am +> not initializing it. + +The full order of things for a server should be. + +ctx=SSL_CTX_new(); + +/* The next line should not really be using ctx->cert but I'll leave it + * this way right now... I don't want a X509_ routine to know about an SSL + * structure, there should be an SSL_load_verify_locations... hmm, I may + * add it tonight. + */ +X509_load_verify_locations(ctx->cert,CAfile,CApath); + +/* Ok now for each new connection we do the following */ +con=SSL_new(ctx); +SSL_set_fd(con,s); +SSL_set_verify(con,verify,verify_callback); + +/* set the certificate and private key to use. */ +SSL_use_certificate_ASN1(con,X509_certificate); +SSL_use_RSAPrivateKey_ASN1(con,RSA_private_key); + +SSL_accept(con); + +SSL_read(con)/SSL_write(con); + +There is a bit more than that but that is basically the structure. + +Create a context and specify where to lookup certificates. + +foreach connection + { + create a SSL structure + set the certificate and private key + do a SSL_accept + + we should now be ok + } + +eric +-- +Eric Young | Signature removed since it was generating +AARNet: eay@mincom.oz.au | more followups than the message contents :-) + + diff --git a/src/lib/libssl/src/doc/ssleay.doc b/src/lib/libssl/src/doc/ssleay.doc new file mode 100644 index 0000000000..a0e86aef7c --- /dev/null +++ b/src/lib/libssl/src/doc/ssleay.doc @@ -0,0 +1,213 @@ +SSLeay: a cryptographic kitchen sink. + +1st December 1995 +Way back at the start of April 1995, I was looking for a mindless +programming project. A friend of mine (Tim Hudson) said "why don't you do SSL, +it has DES encryption in it and I would not mind using it in a SSL telnet". +While it was true I had written a DES library in previous years, litle +did I know what an expansive task SSL would turn into. + +First of all, the SSL protocol contains DES encryption. Well and good. My +DES library was fast and portable. It also contained the RSA's RC4 stream +cipher. Again, not a problem, some-one had just posted to sci.crypt +something that was claimed to be RC4. It also contained IDEA, I had the +specifications, not a problem to implement. MD5, an RFC, trivial, at most +I could spend a week or so trying to see if I could speed up the +implementation. All in all a nice set of ciphers. +Then the first 'expantion of the scope', RSA public key +encryption. Since I did not knowing a thing about public key encryption +or number theory, this appeared quite a daunting task. Just writing a +big number library would be problomatic in itself, let alone making it fast. +At this point the scope of 'implementing SSL' expands eponentialy. +First of all, the RSA private keys were being kept in ASN.1 format. +Thankfully the RSA PKCS series of documents explains this format. So I now +needed to be able to encode and decode arbitary ASN.1 objects. The Public +keys were embeded in X509 certificates. Hmm... these are not only +ASN.1 objects but they make up a heirachy of authentication. To +authenticate a X509 certificate one needs to retrieve it's issuers +certificate etc etc. Hmm..., so I also need to implement some kind +of certificate management software. I would also have to implement +software to authenticate certificates. At this point the support code made +the SSL part of my library look quite small. +Around this time, the first version of SSLeay was released. + +Ah, but here was the problem, I was not happy with the code so far. As may +have become obvious, I had been treating all of this as a learning +exersize, so I have completely written the library myself. As such, due +to the way it had grown like a fungus, much of the library was not +'elagent' or neat. There were global and static variables all over the +place, the SSL part did not even handle non-blocking IO. +The Great rewrite began. + +As of this point in time, the 'Great rewrite' has almost finished. So what +follows is an approximate list of what is actually SSLeay 0.5.0 + +/********* This needs to be updated for 0.6.0+ *************/ + +--- +The library contains the following routines. Please note that most of these +functions are not specfic for SSL or any other particular cipher +implementation. I have tried to make all the routines as general purpose +as possible. So you should not think of this library as an SSL +implemtation, but rather as a library of cryptographic functions +that also contains SSL. I refer to each of these function groupings as +libraries since they are often capable of functioning as independant +libraries + +First up, the general ciphers and message digests supported by the library. + +MD2 rfc???, a standard 'by parts' interface to this algorithm. +MD5 rfc???, the same type of interface as for the MD2 library except a + different algorithm. +SHA THe Secure Hash Algorithm. Again the same type of interface as + MD2/MD5 except the digest is 20 bytes. +SHA1 The 'revised' version of SHA. Just about identical to SHA except + for one tweak of an inner loop. +DES This is my libdes library that has been floating around for the last + few years. It has been enhanced for no other reason than completeness. + It now supports ecb, cbc, cfb, ofb, cfb64, ofb64 in normal mode and + triple DES modes of ecb, cbc, cfb64 and ofb64. cfb64 and ofb64 are + functional interfaces to the 64 bit modes of cfb and ofb used in + such a way thay they function as single character interfaces. +RC4 The RSA Inc. stream cipher. +RC2 The RSA Inc. block cipher. +IDEA An implmentation of the IDEA cipher, the library supports ecb, cbc, + cfb64 and ofb64 modes of operation. + +Now all the above mentioned ciphers and digests libraries support high +speed, minimal 'crap in the way' type interfaces. For fastest and +lowest level access, these routines should be used directly. + +Now there was also the matter of public key crypto systems. These are +based on large integer arithmatic. + +BN This is my large integer library. It supports all the normal + arithmentic operations. It uses malloc extensivly and as such has + no limits of the size of the numbers being manipulated. If you + wish to use 4000 bit RSA moduli, these routines will handle it. + This library also contains routines to 'generate' prime numbers and + to test for primality. The RSA and DH libraries sit on top of this + library. As of this point in time, I don't support SHA, but + when I do add it, it will just sit on top of the routines contained + in this library. +RSA This implements the RSA public key algorithm. It also contains + routines that will generate a new private/public key pair. + All the RSA functions conform to the PKCS#1 standard. +DH This is an implementation of the + Diffie-Hellman protocol. There are all the require routines for + the protocol, plus extra routines that can be used to generate a + strong prime for use with a specified generator. While this last + routine is not generally required by applications implementing DH, + It is present for completeness and because I thing it is much + better to be able to 'generate' your own 'magic' numbers as oposed + to using numbers suplied by others. I conform to the PKCS#3 + standard where required. + +You may have noticed the preceeding section mentions the 'generation' of +prime numbers. Now this requries the use of 'random numbers'. + +RAND This psuedo-random number library is based on MD5 at it's core + and a large internal state (2k bytes). Once you have entered enough + seed data into this random number algorithm I don't feel + you will ever need to worry about it generating predictable output. + Due to the way I am writing a portable library, I have left the + issue of how to get good initial random seed data upto the + application but I do have support routines for saving and loading a + persistant random number state for use between program runs. + +Now to make all these ciphers easier to use, a higher level +interface was required. In this form, the same function would be used to +encrypt 'by parts', via any one of the above mentioned ciphers. + +EVP The Digital EnVeloPe library is quite large. At it's core are + function to perform encryption and decryption by parts while using + an initial parameter to specify which of the 17 different ciphers + or 4 different message digests to use. On top of these are implmented + the digital signature functions, sign, verify, seal and open. + Base64 encoding of binary data is also done in this library. + +PEM rfc???? describe the format for Privacy Enhanced eMail. + As part of this standard, methods of encoding digital enveloped + data is an ascii format are defined. As such, I use a form of these + to encode enveloped data. While at this point in time full support + for PEM has not been built into the library, a minimal subset of + the secret key and Base64 encoding is present. These reoutines are + mostly used to Ascii encode binary data with a 'type' associated + with it and perhaps details of private key encryption used to + encrypt the data. + +PKCS7 This is another Digital Envelope encoding standard which uses ASN.1 + to encode the data. At this point in time, while there are some + routines to encode and decode this binary format, full support is + not present. + +As Mentioned, above, there are several different ways to encode +data structures. + +ASN1 This library is more a set of primatives used to encode the packing + and unpacking of data structures. It is used by the X509 + certificate standard and by the PKCS standards which are used by + this library. It also contains routines for duplicating and signing + the structures asocisated with X509. + +X509 The X509 library contains routines for packing and unpacking, + verifying and just about every thing else you would want to do with + X509 certificates. + +PKCS7 PKCS-7 is a standard for encoding digital envelope data + structures. At this point in time the routines will load and save + DER forms of these structees. They need to be re-worked to support + the BER form which is the normal way PKCS-7 is encoded. If the + previous 2 sentances don't make much sense, don't worry, this + library is not used by this version of SSLeay anyway. + +OBJ ASN.1 uses 'object identifiers' to identify objects. A set of + functions were requred to translate from ASN.1 to an intenger, to a + character string. This library provieds these translations + +Now I mentioned an X509 library. X509 specified a hieachy of certificates +which needs to be traversed to authenticate particular certificates. + +METH This library is used to push 'methods' of retrieving certificates + into the library. There are some supplied 'methods' with SSLeay + but applications can add new methods if they so desire. + This library has not been finished and is not being used in this + version. + +Now all the above are required for use in the initial point of this project. + +SSL The SSL protocol. This is a full implmentation of SSL v 2. It + support both server and client authentication. SSL v 3 support + will be added when the SSL v 3 specification is released in it's + final form. + +Now quite a few of the above mentioned libraries rely on a few 'complex' +data structures. For each of these I have a library. + +Lhash This is a hash table library which is used extensivly. + +STACK An implemetation of a Stack data structure. + +BUF A simple character array structure that also support a function to + check that the array is greater that a certain size, if it is not, + it is realloced so that is it. + +TXT_DB A simple memory based text file data base. The application can specify + unique indexes that will be enforced at update time. + +CONF Most of the programs written for this library require a configuration + file. Instead of letting programs constantly re-implment this + subsystem, the CONF library provides a consistant and flexable + interface to not only configuration files but also environment + variables. + +But what about when something goes wrong? +The one advantage (and perhaps disadvantage) of all of these +functions being in one library was the ability to implement a +single error reporting system. + +ERR This library is used to report errors. The error system records + library number, function number (in the library) and reason + number. Multiple errors can be reported so that an 'error' trace + is created. The errors can be printed in numeric or textual form. + diff --git a/src/lib/libssl/src/doc/ssluse.doc b/src/lib/libssl/src/doc/ssluse.doc new file mode 100644 index 0000000000..2e3a26cbf3 --- /dev/null +++ b/src/lib/libssl/src/doc/ssluse.doc @@ -0,0 +1,45 @@ +We have an SSL_CTX which contains global information for lots of +SSL connections. The session-id cache and the certificate verificate cache. +It also contains default values for use when certificates are used. + +SSL_CTX + default cipher list + session-id cache + certificate cache + default session-id timeout period + New session-id callback + Required session-id callback + session-id stats + Informational callback + Callback that is set, overrides the SSLeay X509 certificate + verification + The default Certificate/Private Key pair + Default read ahead mode. + Default verify mode and verify callback. These are not used + if the over ride callback mentioned above is used. + +Each SSL can have the following defined for it before a connection is made. + +Certificate +Private key +Ciphers to use +Certificate verify mode and callback +IO object to use in the comunication. +Some 'read-ahead' mode information. +A previous session-id to re-use. + +A connection is made by using SSL_connect or SSL_accept. +When non-blocking IO is being used, there are functions that can be used +to determin where and why the SSL_connect or SSL_accept did not complete. +This information can be used to recall the functions when the 'error' +condition has dissapeared. + +After the connection has been made, information can be retrived about the +SSL session and the session-id values that have been decided apon. +The 'peer' certificate can be retrieved. + +The session-id values include +'start time' +'timeout length' + + diff --git a/src/lib/libssl/src/doc/stack.doc b/src/lib/libssl/src/doc/stack.doc new file mode 100644 index 0000000000..7c20b1b664 --- /dev/null +++ b/src/lib/libssl/src/doc/stack.doc @@ -0,0 +1,96 @@ +The stack data structure is used to store an ordered list of objects. +It is basically misnamed to call it a stack but it can function that way +and that is what I originally used it for. Due to the way element +pointers are kept in a malloc()ed array, the most efficient way to use this +structure is to add and delete elements from the end via sk_pop() and +sk_push(). If you wish to do 'lookups' sk_find() is quite efficient since +it will sort the stack (if required) and then do a binary search to lookup +the requested item. This sorting occurs automatically so just sk_push() +elements on the stack and don't worry about the order. Do remember that if +you do a sk_find(), the order of the elements will change. + +You should never need to 'touch' this structure directly. +typedef struct stack_st + { + unsigned int num; + char **data; + int sorted; + + unsigned int num_alloc; + int (*comp)(); + } STACK; + +'num' holds the number of elements in the stack, 'data' is the array of +elements. 'sorted' is 1 is the list has been sorted, 0 if not. + +num_alloc is the number of 'nodes' allocated in 'data'. When num becomes +larger than num_alloc, data is realloced to a larger size. +If 'comp' is set, it is a function that is used to compare 2 of the items +in the stack. The function should return -1, 0 or 1, depending on the +ordering. + +#define sk_num(sk) ((sk)->num) +#define sk_value(sk,n) ((sk)->data[n]) + +These 2 macros should be used to access the number of elements in the +'stack' and to access a pointer to one of the values. + +STACK *sk_new(int (*c)()); + This creates a new stack. If 'c', the comparison function, is not +specified, the various functions that operate on a sorted 'stack' will not +work (sk_find()). NULL is returned on failure. + +void sk_free(STACK *); + This function free()'s a stack structure. The elements in the +stack will not be freed so one should 'pop' and free all elements from the +stack before calling this function or call sk_pop_free() instead. + +void sk_pop_free(STACK *st; void (*func)()); + This function calls 'func' for each element on the stack, passing +the element as the argument. sk_free() is then called to free the 'stack' +structure. + +int sk_insert(STACK *sk,char *data,int where); + This function inserts 'data' into stack 'sk' at location 'where'. +If 'where' is larger that the number of elements in the stack, the element +is put at the end. This function tends to be used by other 'stack' +functions. Returns 0 on failure, otherwise the number of elements in the +new stack. + +char *sk_delete(STACK *st,int loc); + Remove the item a location 'loc' from the stack and returns it. +Returns NULL if the 'loc' is out of range. + +char *sk_delete_ptr(STACK *st, char *p); + If the data item pointed to by 'p' is in the stack, it is deleted +from the stack and returned. NULL is returned if the element is not in the +stack. + +int sk_find(STACK *st,char *data); + Returns the location that contains a value that is equal to +the 'data' item. If the comparison function was not set, this function +does a linear search. This function actually qsort()s the stack if it is not +in order and then uses bsearch() to do the initial search. If the +search fails,, -1 is returned. For mutliple items with the same +value, the index of the first in the array is returned. + +int sk_push(STACK *st,char *data); + Append 'data' to the stack. 0 is returned if there is a failure +(due to a malloc failure), else 1. This is +sk_insert(st,data,sk_num(st)); + +int sk_unshift(STACK *st,char *data); + Prepend 'data' to the front (location 0) of the stack. This is +sk_insert(st,data,0); + +char *sk_shift(STACK *st); + Return and delete from the stack the first element in the stack. +This is sk_delete(st,0); + +char *sk_pop(STACK *st); + Return and delete the last element on the stack. This is +sk_delete(st,sk_num(sk)-1); + +void sk_zero(STACK *st); + Removes all items from the stack. It does not 'free' +pointers but is a quick way to clear a 'stack of references'. diff --git a/src/lib/libssl/src/doc/threads.doc b/src/lib/libssl/src/doc/threads.doc new file mode 100644 index 0000000000..251061e896 --- /dev/null +++ b/src/lib/libssl/src/doc/threads.doc @@ -0,0 +1,90 @@ +How to compile SSLeay for multi-threading. + +Well basically it is quite simple, set the compiler flags and build. +I have only really done much testing under Solaris and Windows NT. +If you library supports localtime_r() and gmtime_r() add, +-DTHREADS to the makefile parameters. You can probably survive with out +this define unless you are going to have multiple threads generating +certificates at once. It will not affect the SSL side of things. + +The approach I have taken to doing locking is to make the application provide +callbacks to perform locking and so that the SSLeay library can distinguish +between threads (for the error state). + +To have a look at an example program, 'cd mt; vi mttest.c'. +To build under solaris, sh solaris.sh, for Windows NT or Windows 95, +win32.bat + +This will build mttest which will fire up 10 threads that talk SSL +to each other 10 times. +To enable everything to work, the application needs to call + +CRYPTO_set_id_callback(id_function); +CRYPTO_set_locking_callback(locking_function); + +before any multithreading is started. +id_function does not need to be defined under Windows NT or 95, the +correct function will be called if it is not. Under unix, getpid() +is call if the id_callback is not defined, for solaris this is wrong +(since threads id's are not pid's) but under IRIX it is correct +(threads are just processes sharing the data segement). + +The locking_callback is used to perform locking by the SSLeay library. +eg. + +void solaris_locking_callback(mode,type,file,line) +int mode; +int type; +char *file; +int line; + { + if (mode & CRYPTO_LOCK) + mutex_lock(&(lock_cs[type])); + else + mutex_unlock(&(lock_cs[type])); + } + +Now in this case I have used mutexes instead of read/write locks, since they +are faster and there are not many read locks in SSLeay, you may as well +always use write locks. file and line are __FILE__ and __LINE__ from +the compile and can be usefull when debugging. + +Now as you can see, 'type' can be one of a range of values, these values are +defined in crypto/crypto.h +CRYPTO_get_lock_name(type) will return a text version of what the lock is. +There are CRYPTO_NUM_LOCKS locks required, so under solaris, the setup +for multi-threading can be + +static mutex_t lock_cs[CRYPTO_NUM_LOCKS]; + +void thread_setup() + { + int i; + + for (i=0; i +#include +#include +#include +#ifdef LINUX +#include +#endif +#ifdef WIN32 +#include +#endif +#ifdef SOLARIS +#include +#include +#endif +#ifdef IRIX +#include +#include +#endif +#include "lhash.h" +#include "crypto.h" +#include "buffer.h" +#include "../e_os.h" +#include "x509.h" +#include "ssl.h" +#include "err.h" + +#ifdef NO_FP_API +#define APPS_WIN16 +#include "../crypto/buffer/bss_file.c" +#endif + +#define TEST_SERVER_CERT "../apps/server.pem" +#define TEST_CLIENT_CERT "../apps/client.pem" + +#define MAX_THREAD_NUMBER 100 + +#ifndef NOPROTO +int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, + int error,char *arg); +void thread_setup(void); +void thread_cleanup(void); +void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); + +void irix_locking_callback(int mode,int type,char *file,int line); +void solaris_locking_callback(int mode,int type,char *file,int line); +void win32_locking_callback(int mode,int type,char *file,int line); +void pthreads_locking_callback(int mode,int type,char *file,int line); + +unsigned long irix_thread_id(void ); +unsigned long solaris_thread_id(void ); +unsigned long pthreads_thread_id(void ); + +#else +int MS_CALLBACK verify_callback(); +void thread_setup(); +void thread_cleanup(); +void do_threads(); + +void irix_locking_callback(); +void solaris_locking_callback(); +void win32_locking_callback(); +void pthreads_locking_callback(); + +unsigned long irix_thread_id(); +unsigned long solaris_thread_id(); +unsigned long pthreads_thread_id(); + +#endif + +BIO *bio_err=NULL; +BIO *bio_stdout=NULL; + +static char *cipher=NULL; +int verbose=0; +#ifdef FIONBIO +static int s_nbio=0; +#endif + +int thread_number=10; +int number_of_loops=10; +int reconnect=0; +int cache_stats=0; + +#ifndef NOPROTO +int doit(char *ctx[4]); +#else +int doit(); +#endif + +static void print_stats(fp,ctx) +FILE *fp; +SSL_CTX *ctx; +{ + fprintf(fp,"%4ld items in the session cache\n", + SSL_CTX_sess_number(ctx)); + fprintf(fp,"%4d client connects (SSL_connect())\n", + SSL_CTX_sess_connect(ctx)); + fprintf(fp,"%4d client connects that finished\n", + SSL_CTX_sess_connect_good(ctx)); + fprintf(fp,"%4d server connects (SSL_accept())\n", + SSL_CTX_sess_accept(ctx)); + fprintf(fp,"%4d server connects that finished\n", + SSL_CTX_sess_accept_good(ctx)); + fprintf(fp,"%4d session cache hits\n",SSL_CTX_sess_hits(ctx)); + fprintf(fp,"%4d session cache misses\n",SSL_CTX_sess_misses(ctx)); + fprintf(fp,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ctx)); + } + +static void sv_usage() + { + fprintf(stderr,"usage: ssltest [args ...]\n"); + fprintf(stderr,"\n"); + fprintf(stderr," -server_auth - check server certificate\n"); + fprintf(stderr," -client_auth - do client authentication\n"); + fprintf(stderr," -v - more output\n"); + fprintf(stderr," -CApath arg - PEM format directory of CA's\n"); + fprintf(stderr," -CAfile arg - PEM format file of CA's\n"); + fprintf(stderr," -threads arg - number of threads\n"); + fprintf(stderr," -loops arg - number of 'connections', per thread\n"); + fprintf(stderr," -reconnect - reuse session-id's\n"); + fprintf(stderr," -stats - server session-id cache stats\n"); + fprintf(stderr," -cert arg - server certificate/key\n"); + fprintf(stderr," -ccert arg - client certificate/key\n"); + fprintf(stderr," -ssl3 - just SSLv3n\n"); + } + +int main(argc, argv) +int argc; +char *argv[]; + { + char *CApath=NULL,*CAfile=NULL; + int badop=0; + int ret=1; + int client_auth=0; + int server_auth=0; + SSL_CTX *s_ctx=NULL; + SSL_CTX *c_ctx=NULL; + char *scert=TEST_SERVER_CERT; + char *ccert=TEST_CLIENT_CERT; + SSL_METHOD *ssl_method=SSLv23_method(); + + if (bio_err == NULL) + bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); + if (bio_stdout == NULL) + bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); + argc--; + argv++; + + while (argc >= 1) + { + if (strcmp(*argv,"-server_auth") == 0) + server_auth=1; + else if (strcmp(*argv,"-client_auth") == 0) + client_auth=1; + else if (strcmp(*argv,"-reconnect") == 0) + reconnect=1; + else if (strcmp(*argv,"-stats") == 0) + cache_stats=1; + else if (strcmp(*argv,"-ssl3") == 0) + ssl_method=SSLv3_method(); + else if (strcmp(*argv,"-ssl2") == 0) + ssl_method=SSLv2_method(); + else if (strcmp(*argv,"-CApath") == 0) + { + if (--argc < 1) goto bad; + CApath= *(++argv); + } + else if (strcmp(*argv,"-CAfile") == 0) + { + if (--argc < 1) goto bad; + CAfile= *(++argv); + } + else if (strcmp(*argv,"-cert") == 0) + { + if (--argc < 1) goto bad; + scert= *(++argv); + } + else if (strcmp(*argv,"-ccert") == 0) + { + if (--argc < 1) goto bad; + ccert= *(++argv); + } + else if (strcmp(*argv,"-threads") == 0) + { + if (--argc < 1) goto bad; + thread_number= atoi(*(++argv)); + if (thread_number == 0) thread_number=1; + if (thread_number > MAX_THREAD_NUMBER) + thread_number=MAX_THREAD_NUMBER; + } + else if (strcmp(*argv,"-loops") == 0) + { + if (--argc < 1) goto bad; + number_of_loops= atoi(*(++argv)); + if (number_of_loops == 0) number_of_loops=1; + } + else + { + fprintf(stderr,"unknown option %s\n",*argv); + badop=1; + break; + } + argc--; + argv++; + } + if (badop) + { +bad: + sv_usage(); + goto end; + } + + if (cipher == NULL) cipher=getenv("SSL_CIPHER"); + + SSL_load_error_strings(); + SSLeay_add_ssl_algorithms(); + + c_ctx=SSL_CTX_new(ssl_method); + s_ctx=SSL_CTX_new(ssl_method); + if ((c_ctx == NULL) || (s_ctx == NULL)) + { + ERR_print_errors(bio_err); + goto end; + } + + SSL_CTX_set_session_cache_mode(s_ctx, + SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER); + SSL_CTX_set_session_cache_mode(c_ctx, + SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER); + + SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM); + SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM); + + if (client_auth) + { + SSL_CTX_use_certificate_file(c_ctx,ccert, + SSL_FILETYPE_PEM); + SSL_CTX_use_RSAPrivateKey_file(c_ctx,ccert, + SSL_FILETYPE_PEM); + } + + if ( (!SSL_CTX_load_verify_locations(s_ctx,CAfile,CApath)) || + (!SSL_CTX_set_default_verify_paths(s_ctx)) || + (!SSL_CTX_load_verify_locations(c_ctx,CAfile,CApath)) || + (!SSL_CTX_set_default_verify_paths(c_ctx))) + { + fprintf(stderr,"SSL_load_verify_locations\n"); + ERR_print_errors(bio_err); + goto end; + } + + if (client_auth) + { + fprintf(stderr,"client authentication\n"); + SSL_CTX_set_verify(s_ctx, + SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + verify_callback); + } + if (server_auth) + { + fprintf(stderr,"server authentication\n"); + SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER, + verify_callback); + } + + thread_setup(); + do_threads(s_ctx,c_ctx); + thread_cleanup(); +end: + + if (c_ctx != NULL) + { + fprintf(stderr,"Client SSL_CTX stats then free it\n"); + print_stats(stderr,c_ctx); + SSL_CTX_free(c_ctx); + } + if (s_ctx != NULL) + { + fprintf(stderr,"Server SSL_CTX stats then free it\n"); + print_stats(stderr,s_ctx); + if (cache_stats) + { + fprintf(stderr,"-----\n"); + lh_stats(SSL_CTX_sessions(s_ctx),stderr); + fprintf(stderr,"-----\n"); + /* lh_node_stats(SSL_CTX_sessions(s_ctx),stderr); + fprintf(stderr,"-----\n"); */ + lh_node_usage_stats(SSL_CTX_sessions(s_ctx),stderr); + fprintf(stderr,"-----\n"); + } + SSL_CTX_free(s_ctx); + fprintf(stderr,"done free\n"); + } + exit(ret); + return(0); + } + +#define W_READ 1 +#define W_WRITE 2 +#define C_DONE 1 +#define S_DONE 2 + +int ndoit(ssl_ctx) +SSL_CTX *ssl_ctx[2]; + { + int i; + int ret; + char *ctx[4]; + + ctx[0]=(char *)ssl_ctx[0]; + ctx[1]=(char *)ssl_ctx[1]; + + if (reconnect) + { + ctx[2]=(char *)SSL_new(ssl_ctx[0]); + ctx[3]=(char *)SSL_new(ssl_ctx[1]); + } + else + { + ctx[2]=NULL; + ctx[3]=NULL; + } + + fprintf(stdout,"started thread %lu\n",CRYPTO_thread_id()); + for (i=0; iref (%3d,%3d)\n", + CRYPTO_thread_id(),i, + ssl_ctx[0]->references, + ssl_ctx[1]->references); */ + /* pthread_delay_np(&tm);*/ + + ret=doit(ctx); + if (ret != 0) + { + fprintf(stdout,"error[%d] %lu - %d\n", + i,CRYPTO_thread_id(),ret); + return(ret); + } + } + fprintf(stdout,"DONE %lu\n",CRYPTO_thread_id()); + if (reconnect) + { + SSL_free((SSL *)ctx[2]); + SSL_free((SSL *)ctx[3]); + } + return(0); + } + +int doit(ctx) +char *ctx[4]; + { + SSL_CTX *s_ctx,*c_ctx; + static char cbuf[200],sbuf[200]; + SSL *c_ssl=NULL; + SSL *s_ssl=NULL; + BIO *c_to_s=NULL; + BIO *s_to_c=NULL; + BIO *c_bio=NULL; + BIO *s_bio=NULL; + int c_r,c_w,s_r,s_w; + int c_want,s_want; + int i; + int done=0; + int c_write,s_write; + int do_server=0,do_client=0; + + s_ctx=(SSL_CTX *)ctx[0]; + c_ctx=(SSL_CTX *)ctx[1]; + + if (ctx[2] != NULL) + s_ssl=(SSL *)ctx[2]; + else + s_ssl=SSL_new(s_ctx); + + if (ctx[3] != NULL) + c_ssl=(SSL *)ctx[3]; + else + c_ssl=SSL_new(c_ctx); + + if ((s_ssl == NULL) || (c_ssl == NULL)) goto err; + + c_to_s=BIO_new(BIO_s_mem()); + s_to_c=BIO_new(BIO_s_mem()); + if ((s_to_c == NULL) || (c_to_s == NULL)) goto err; + + c_bio=BIO_new(BIO_f_ssl()); + s_bio=BIO_new(BIO_f_ssl()); + if ((c_bio == NULL) || (s_bio == NULL)) goto err; + + SSL_set_connect_state(c_ssl); + SSL_set_bio(c_ssl,s_to_c,c_to_s); + BIO_set_ssl(c_bio,c_ssl,(ctx[2] == NULL)?BIO_CLOSE:BIO_NOCLOSE); + + SSL_set_accept_state(s_ssl); + SSL_set_bio(s_ssl,c_to_s,s_to_c); + BIO_set_ssl(s_bio,s_ssl,(ctx[3] == NULL)?BIO_CLOSE:BIO_NOCLOSE); + + c_r=0; s_r=1; + c_w=1; s_w=0; + c_want=W_WRITE; + s_want=0; + c_write=1,s_write=0; + + /* We can always do writes */ + for (;;) + { + do_server=0; + do_client=0; + + i=(int)BIO_pending(s_bio); + if ((i && s_r) || s_w) do_server=1; + + i=(int)BIO_pending(c_bio); + if ((i && c_r) || c_w) do_client=1; + + if (do_server && verbose) + { + if (SSL_in_init(s_ssl)) + printf("server waiting in SSL_accept - %s\n", + SSL_state_string_long(s_ssl)); + else if (s_write) + printf("server:SSL_write()\n"); + else + printf("server:SSL_read()\n"); + } + + if (do_client && verbose) + { + if (SSL_in_init(c_ssl)) + printf("client waiting in SSL_connect - %s\n", + SSL_state_string_long(c_ssl)); + else if (c_write) + printf("client:SSL_write()\n"); + else + printf("client:SSL_read()\n"); + } + + if (!do_client && !do_server) + { + fprintf(stdout,"ERROR IN STARTUP\n"); + break; + } + if (do_client && !(done & C_DONE)) + { + if (c_write) + { + i=BIO_write(c_bio,"hello from client\n",18); + if (i < 0) + { + c_r=0; + c_w=0; + if (BIO_should_retry(c_bio)) + { + if (BIO_should_read(c_bio)) + c_r=1; + if (BIO_should_write(c_bio)) + c_w=1; + } + else + { + fprintf(stderr,"ERROR in CLIENT\n"); + return(1); + } + } + else if (i == 0) + { + fprintf(stderr,"SSL CLIENT STARTUP FAILED\n"); + return(1); + } + else + { + /* ok */ + c_write=0; + } + } + else + { + i=BIO_read(c_bio,cbuf,100); + if (i < 0) + { + c_r=0; + c_w=0; + if (BIO_should_retry(c_bio)) + { + if (BIO_should_read(c_bio)) + c_r=1; + if (BIO_should_write(c_bio)) + c_w=1; + } + else + { + fprintf(stderr,"ERROR in CLIENT\n"); + return(1); + } + } + else if (i == 0) + { + fprintf(stderr,"SSL CLIENT STARTUP FAILED\n"); + return(1); + } + else + { + done|=C_DONE; +#ifdef undef + fprintf(stdout,"CLIENT:from server:"); + fwrite(cbuf,1,i,stdout); + fflush(stdout); +#endif + } + } + } + + if (do_server && !(done & S_DONE)) + { + if (!s_write) + { + i=BIO_read(s_bio,sbuf,100); + if (i < 0) + { + s_r=0; + s_w=0; + if (BIO_should_retry(s_bio)) + { + if (BIO_should_read(s_bio)) + s_r=1; + if (BIO_should_write(s_bio)) + s_w=1; + } + else + { + fprintf(stderr,"ERROR in SERVER\n"); + ERR_print_errors_fp(stderr); + return(1); + } + } + else if (i == 0) + { + fprintf(stderr,"SSL SERVER STARTUP FAILED\n"); + return(1); + } + else + { + s_write=1; + s_w=1; +#ifdef undef + fprintf(stdout,"SERVER:from client:"); + fwrite(sbuf,1,i,stdout); + fflush(stdout); +#endif + } + } + else + { + i=BIO_write(s_bio,"hello from server\n",18); + if (i < 0) + { + s_r=0; + s_w=0; + if (BIO_should_retry(s_bio)) + { + if (BIO_should_read(s_bio)) + s_r=1; + if (BIO_should_write(s_bio)) + s_w=1; + } + else + { + fprintf(stderr,"ERROR in SERVER\n"); + ERR_print_errors_fp(stderr); + return(1); + } + } + else if (i == 0) + { + fprintf(stderr,"SSL SERVER STARTUP FAILED\n"); + return(1); + } + else + { + s_write=0; + s_r=1; + done|=S_DONE; + } + } + } + + if ((done & S_DONE) && (done & C_DONE)) break; + } + + SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); + SSL_set_shutdown(s_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); + +#ifdef undef + fprintf(stdout,"DONE\n"); +#endif +err: + /* We have to set the BIO's to NULL otherwise they will be + * free()ed twice. Once when th s_ssl is SSL_free()ed and + * again when c_ssl is SSL_free()ed. + * This is a hack required because s_ssl and c_ssl are sharing the same + * BIO structure and SSL_set_bio() and SSL_free() automatically + * BIO_free non NULL entries. + * You should not normally do this or be required to do this */ + + if (s_ssl != NULL) + { + s_ssl->rbio=NULL; + s_ssl->wbio=NULL; + } + if (c_ssl != NULL) + { + c_ssl->rbio=NULL; + c_ssl->wbio=NULL; + } + + /* The SSL's are optionally freed in the following calls */ + if (c_to_s != NULL) BIO_free(c_to_s); + if (s_to_c != NULL) BIO_free(s_to_c); + + if (c_bio != NULL) BIO_free(c_bio); + if (s_bio != NULL) BIO_free(s_bio); + return(0); + } + +int MS_CALLBACK verify_callback(ok, xs, xi, depth, error, arg) +int ok; +X509 *xs; +X509 *xi; +int depth; +int error; +char *arg; + { + char buf[256]; + + if (verbose) + { + X509_NAME_oneline(X509_get_subject_name(xs),buf,256); + if (ok) + fprintf(stderr,"depth=%d %s\n",depth,buf); + else + fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf); + } + return(ok); + } + +#define THREAD_STACK_SIZE (16*1024) + +#ifdef WIN32 + +static PRLOCK lock_cs[CRYPTO_NUM_LOCKS]; + +void thread_setup() + { + int i; + + for (i=0; i end.wDayOfWeek) end.wDayOfWeek+=7; + ret=(end.wDayOfWeek-start.wDayOfWeek)*24; + + ret=(ret+end.wHour-start.wHour)*60; + ret=(ret+end.wMinute-start.wMinute)*60; + ret=(ret+end.wSecond-start.wSecond); + ret+=(end.wMilliseconds-start.wMilliseconds)/1000.0; + + printf("win32 threads done - %.3f seconds\n",ret); + } + +#endif /* WIN32 */ + +#ifdef SOLARIS + +static mutex_t lock_cs[CRYPTO_NUM_LOCKS]; +/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */ +static long lock_count[CRYPTO_NUM_LOCKS]; + +void thread_setup() + { + int i; + + for (i=0; ireferences,c_ctx->references); + } + +unsigned long solaris_thread_id() + { + unsigned long ret; + + ret=(unsigned long)thr_self(); + return(ret); + } +#endif /* SOLARIS */ + +#ifdef IRIX + + +static usptr_t *arena; +static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; + +void thread_setup() + { + int i; + char filename[20]; + + strcpy(filename,"/tmp/mttest.XXXXXX"); + mktemp(filename); + + usconfig(CONF_STHREADIOOFF); + usconfig(CONF_STHREADMALLOCOFF); + usconfig(CONF_INITUSERS,100); + usconfig(CONF_LOCKTYPE,US_DEBUGPLUS); + arena=usinit(filename); + unlink(filename); + + for (i=0; ireferences,c_ctx->references); + } + +unsigned long irix_thread_id() + { + unsigned long ret; + + ret=(unsigned long)getpid(); + return(ret); + } +#endif /* IRIX */ + +#ifdef PTHREADS + +static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; +static long lock_count[CRYPTO_NUM_LOCKS]; + +void thread_setup() + { + int i; + + for (i=0; ireferences,c_ctx->references); + } + +unsigned long pthreads_thread_id() + { + unsigned long ret; + + ret=(unsigned long)pthread_self(); + return(ret); + } + +#endif /* PTHREADS */ + + + diff --git a/src/lib/libssl/src/mt/profile.sh b/src/lib/libssl/src/mt/profile.sh new file mode 100644 index 0000000000..de5eb06708 --- /dev/null +++ b/src/lib/libssl/src/mt/profile.sh @@ -0,0 +1,4 @@ +#!/bin/sh +/bin/rm -f mttest +cc -p -DSOLARIS -I../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L.. -lthread -lssl -lcrypto -lnsl -lsocket + diff --git a/src/lib/libssl/src/mt/ptest.bat b/src/lib/libssl/src/mt/ptest.bat new file mode 100644 index 0000000000..ccaccae09d --- /dev/null +++ b/src/lib/libssl/src/mt/ptest.bat @@ -0,0 +1,4 @@ +del mttest.exe + +purify cl /O2 -DWIN32 /MD -I..\out mttest.c /Femttest ..\out\ssl32.lib ..\out\crypt32.lib + diff --git a/src/lib/libssl/src/mt/pthread.sh b/src/lib/libssl/src/mt/pthread.sh new file mode 100644 index 0000000000..7d0b6e55f5 --- /dev/null +++ b/src/lib/libssl/src/mt/pthread.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +# build using pthreads +# +# http://www.mit.edu:8001/people/proven/pthreads.html +# +/bin/rm -f mttest +pgcc -DPTHREADS -I../include -g mttest.c -o mttest -L.. -lssl -lcrypto + diff --git a/src/lib/libssl/src/mt/purify.sh b/src/lib/libssl/src/mt/purify.sh new file mode 100644 index 0000000000..57c4017073 --- /dev/null +++ b/src/lib/libssl/src/mt/purify.sh @@ -0,0 +1,4 @@ +#!/bin/sh +/bin/rm -f mttest +purify cc -DSOLARIS -I../include -g mttest.c -o mttest -L.. -lthread -lssl -lcrypto -lnsl -lsocket + diff --git a/src/lib/libssl/src/mt/solaris.sh b/src/lib/libssl/src/mt/solaris.sh new file mode 100644 index 0000000000..f6a90b17ee --- /dev/null +++ b/src/lib/libssl/src/mt/solaris.sh @@ -0,0 +1,4 @@ +#!/bin/sh +/bin/rm -f mttest +cc -DSOLARIS -I../include -g mttest.c -o mttest -L.. -lthread -lssl -lcrypto -lnsl -lsocket + diff --git a/src/lib/libssl/src/mt/win32.bat b/src/lib/libssl/src/mt/win32.bat new file mode 100644 index 0000000000..56089f69be --- /dev/null +++ b/src/lib/libssl/src/mt/win32.bat @@ -0,0 +1,4 @@ +del mttest.exe + +cl /O2 -DWIN32 /MD -I..\out mttest.c /Femttest ..\out\ssleay32.lib ..\out\libeay32.lib + diff --git a/src/lib/libssl/src/perl/MANIFEST b/src/lib/libssl/src/perl/MANIFEST new file mode 100644 index 0000000000..992db5ed4c --- /dev/null +++ b/src/lib/libssl/src/perl/MANIFEST @@ -0,0 +1,17 @@ +MANIFEST +Makefile.PL +SSLeay.pm +bio.xs +bn.xs +cipher.xs +digest.xs +err.xs +ssl.xs +x509.xs +test.pl +test2.pl +test3.pl +test9.pl +testbn.pl +testmd.pl +typemap diff --git a/src/lib/libssl/src/perl/Makefile.PL b/src/lib/libssl/src/perl/Makefile.PL new file mode 100644 index 0000000000..f9998e0a61 --- /dev/null +++ b/src/lib/libssl/src/perl/Makefile.PL @@ -0,0 +1,25 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'OPTIMIZE' => '-g', + 'DISTNAME' => 'SSLeay-perl5-0.8.5', + 'NAME' => 'SSLeay', + 'VERSION_FROM' => 'SSLeay.pm', + 'LIBS' => ['-L.. -lssl -lcrypto'], + 'DEFINE' => '', + 'INC' => '-I../include', + 'C' => ['callback.c'], + 'H' => ['p5SSLeay.h'], + 'OBJECT' => " SSLeay.o bio.o bn.o cipher.o digest.o err.o + ssl.o x509.o", + 'XS' => { 'SSLeay.xs' => 'SSLeay.c', + 'bio.xs' => 'bio.c', + 'bn.xs' => 'bn.c', + 'cipher.xs' => 'cipher.c', + 'digest.xs' => 'digest.c', + 'err.xs' => 'err.c', + 'ssl.xs' => 'ssl.c', + 'x509.xs' => 'x509.c', + } + ); diff --git a/src/lib/libssl/src/perl/SSLeay.pm b/src/lib/libssl/src/perl/SSLeay.pm new file mode 100644 index 0000000000..f7710039d2 --- /dev/null +++ b/src/lib/libssl/src/perl/SSLeay.pm @@ -0,0 +1,78 @@ +package SSLeay; + +use Exporter; +use DynaLoader; + +@ISA = qw(Exporter DynaLoader); +@EXPORT = qw(); + +$VERSION='0.82'; +$VERSION='0.82'; +bootstrap SSLeay; + +@SSLeay::BN::ISA= qw(SSLeay::ERR); +@SSLeay::MD::ISA= qw(SSLeay::ERR); +@SSLeay::Cipher::ISA= qw(SSLeay::ERR); +@SSLeay::SSL::CTX::ISA= qw(SSLeay::ERR); +@SSLeay::BIO::ISA= qw(SSLeay::ERR); +@SSLeay::SSL::ISA= qw(SSLeay::ERR); + +@BN::ISA= qw(SSLeay::BN); +@MD::ISA= qw(SSLeay::MD); +@Cipher::ISA= qw(SSLeay::Cipher); +@SSL::ISA= qw(SSLeay::SSL); +@SSL::CTX::ISA= qw(SSLeay::SSL::CTX); +@BIO::ISA= qw(SSLeay::BIO); + + +@SSLeay::MD::names=qw(md2 md5 sha sha1 ripemd160 mdc2); + +@SSLeay::Cipher::names=qw( + des-ecb des-cfb des-ofb des-cbc + des-ede des-ede-cfb des-ede-ofb des-ede-cbc + des-ede3 des-ede3-cfb des-ede3-ofb des-ede3-cbc + desx-cbc rc4 rc4-40 + idea-ecb idea-cfb idea-ofb idea-cbc + rc2-ecb rc2-cbc rc2-40-cbc rc2-cfb rc2-ofb + bf-ecb bf-cfb bf-ofb bf-cbc + cast5-ecb cast5-cfb cast5-ofb cast5-cbc + rc5-ecb rc5-cfb rc5-ofb rc5-cbc + ); + +sub SSLeay::SSL::CTX::new_ssl { SSLeay::SSL::new($_[0]); } + +sub SSLeay::ERR::error + { + my($o)=@_; + my($s,$ret); + + while (($s=$o->get_error()) != 0) + { + $ret.=$s."\n"; + } + return($ret); + } + +@SSLeay::Cipher::aliases=qw(des desx des3 idea rc2 bf cast); + +package SSLeay::BN; + +sub bnfix { (ref($_[0]) ne "SSLeay::BN")?SSLeay::BN::dec2bn($_[0]):$_[0]; } +use overload +"=" => sub { dup($_[0]); }, +"+" => sub { add($_[0],$_[1]); }, +"-" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; + SSLeay::BN::sub($_[0],$_[1]); }, +"*" => sub { mul($_[0],$_[1]); }, +"/" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; (div($_[0],$_[1]))[0]; }, +"%" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; mod($_[0],$_[1]); }, +"**" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; exp($_[0],$_[1]); }, +"<<" => sub { lshift($_[0],$_[1]); }, +">>" => sub { rshift($_[0],$_[1]); }, +"<=>" => sub { SSLeay::BN::cmp($_[0],$_[1]); }, +'""' => sub { bn2dec($_[0]); }, +'0+' => sub { dec2bn($_[0]); }, +"bool" => sub { ref($_[0]) eq "SSLeay::BN"; }; + +sub SSLeay::BIO::do_accept { SSLeay::BIO::do_handshake(@_); } +1; diff --git a/src/lib/libssl/src/perl/SSLeay.xs b/src/lib/libssl/src/perl/SSLeay.xs new file mode 100644 index 0000000000..582b5705aa --- /dev/null +++ b/src/lib/libssl/src/perl/SSLeay.xs @@ -0,0 +1,63 @@ +#include "p5SSLeay.h" + +SV *new_ref(type,obj,mort) +char *type; +char *obj; + { + SV *ret; + + if (mort) + ret=sv_newmortal(); + else + ret=newSViv(0); + sv_setref_pv(ret,type,(void *)obj); + return(ret); + } + +int ex_new(obj,data,ad,idx,argl,argp) +char *obj; +SV *data; +CRYPTO_EX_DATA *ad; +int idx; +long argl; +char *argp; + { + SV *sv; + +fprintf(stderr,"ex_new %08X %s\n",obj,argp); + sv=sv_newmortal(); + sv_setref_pv(sv,argp,(void *)obj); + CRYPTO_set_ex_data(ad,idx,(char *)sv); + return(1); + } + +void ex_cleanup(obj,data,ad,idx,argl,argp) +char *obj; +SV *data; +CRYPTO_EX_DATA *ad; +int idx; +long argl; +char *argp; + { + pr_name("ex_cleanup"); +fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp); + if (data != NULL) + SvREFCNT_dec((SV *)data); + } + +MODULE = SSLeay PACKAGE = SSLeay + +BOOT: + boot_bio(); + boot_cipher(); + boot_digest(); + boot_err(); + boot_ssl(); + boot_SSLeay__BN(); + boot_SSLeay__BIO(); + boot_SSLeay__Cipher(); + boot_SSLeay__MD(); + boot_SSLeay__ERR(); + boot_SSLeay__SSL(); + boot_SSLeay__X509(); + diff --git a/src/lib/libssl/src/perl/b.pl b/src/lib/libssl/src/perl/b.pl new file mode 100644 index 0000000000..e8b3fd0dd9 --- /dev/null +++ b/src/lib/libssl/src/perl/b.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$cmd=<<"EOF"; + +EOF + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; +print "X\n"; +$bio=BIO->new("connect"); +print "XX\n"; +$bio->set_callback(sub {print STDERR $_[0]->number_read."\n"; $_[$#_] }); +print "XXX\n"; +$bio->hostname($conn) || die $ssl->error(); +print "XXXX\n"; + +#$ssl=BIO->new("ssl"); diff --git a/src/lib/libssl/src/perl/bio.pl b/src/lib/libssl/src/perl/bio.pl new file mode 100644 index 0000000000..653322c2cc --- /dev/null +++ b/src/lib/libssl/src/perl/bio.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$cmd=<<"EOF"; + +EOF + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; +$bio=SSLeay::BIO::new("connect"); +$bio->set_callback(sub {print STDERR $_[0]->number_read."\n"; $_[$#_] }); +$bio->hostname($conn) || die $ssl->error(); + + +(($ret=$bio->do_handshake()) > 0) || die $bio->error(); + +(($ret=$bio->syswrite($cmd)) > 0) || die $bio->error(); + +while (1) + { + $ret=$bio->sysread($buf,10240); + last if ($ret <= 0); + print $buf; + } + diff --git a/src/lib/libssl/src/perl/bio.txt b/src/lib/libssl/src/perl/bio.txt new file mode 100644 index 0000000000..5b46c9f5ee --- /dev/null +++ b/src/lib/libssl/src/perl/bio.txt @@ -0,0 +1,36 @@ +BIO::new(type) + "connect" + "accept" + "ssl" + "buffer" + +"connect" + BIO::hostname(name) host:port to connect to + +"accept" + BIO::set_accept_port(port) port to connect too. + +"connect", "accept", "ssl" + BIO::do_andshake do protocol + +"ssl" + BIO::set_ssl(ssl) + BIO::get_ssl() + +BIO::push(bio) +BIO::pop; return BIO +BIO::number_read() +BIO::number_written() +BIO::references() + +BIO::sysread(buf,len[,offset]) +BIO::syswrite(in[,len][,offset]) +BIO::getline() +BIO::puts(in) +BIO::flush() +BIO::type() +BIO::next_bio(); +BIO::set_callback(callback[, args]) + +BIO::new_buffer_ssl_connect(SSL_CTX) +BIO::new_ssl_connect(SSL_CTX) diff --git a/src/lib/libssl/src/perl/bio.xs b/src/lib/libssl/src/perl/bio.xs new file mode 100644 index 0000000000..3782d42062 --- /dev/null +++ b/src/lib/libssl/src/perl/bio.xs @@ -0,0 +1,448 @@ +#include "p5SSLeay.h" + +static int p5_bio_ex_bio_ptr=0; +static int p5_bio_ex_bio_callback=0; +static int p5_bio_ex_bio_callback_data=0; + +static long p5_bio_callback(bio,state,parg,cmd,larg,ret) +BIO *bio; +int state; +char *parg; +int cmd; +long larg; +int ret; + { + int i; + SV *me,*cb; + + me=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); + cb=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_callback); + if (cb != NULL) + { + dSP; + + ENTER ; + SAVETMPS; + + PUSHMARK(sp); + XPUSHs(me); + XPUSHs(sv_2mortal(newSViv(state))); + XPUSHs(sv_2mortal(newSViv(cmd))); + if ((state == BIO_CB_READ) || (state == BIO_CB_WRITE)) + { + XPUSHs(sv_2mortal(newSVpv(parg,larg))); + } + else + XPUSHs(&sv_undef); + /* ptr one */ + XPUSHs(sv_2mortal(newSViv(larg))); + XPUSHs(sv_2mortal(newSViv(ret))); + PUTBACK; + + i=perl_call_sv(cb,G_SCALAR); + + SPAGAIN; + if (i == 1) + ret=POPi; + else + ret=1; + PUTBACK; + FREETMPS; + LEAVE; + } + else + { + croak("Internal error in SSL p5_ssl_info_callback"); + } + return(ret); + } + +int boot_bio() + { + p5_bio_ex_bio_ptr= + BIO_get_ex_new_index(0,"SSLeay::BIO",ex_new,NULL,ex_cleanup); + p5_bio_ex_bio_callback= + BIO_get_ex_new_index(0,"bio_callback",NULL,NULL, + ex_cleanup); + p5_bio_ex_bio_callback_data= + BIO_get_ex_new_index(0,"bio_callback_data",NULL,NULL, + ex_cleanup); + return(1); + } + +MODULE = SSLeay::BIO PACKAGE = SSLeay::BIO PREFIX = p5_BIO_ + +VERSIONCHECK: DISABLE + +void +p5_BIO_new_buffer_ssl_connect(...) + PREINIT: + SSL_CTX *ctx; + BIO *bio; + SV *arg; + PPCODE: + if (items == 1) + arg=ST(0); + else if (items == 2) + arg=ST(1); + else + arg=NULL; + + if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX"))) + croak("Usage: SSLeay::BIO::new_buffer_ssl_connect(SSL_CTX)"); + else + { + IV tmp=SvIV((SV *)SvRV(arg)); + ctx=(SSL_CTX *)tmp; + } + EXTEND(sp,1); + bio=BIO_new_buffer_ssl_connect(ctx); + arg=new_ref("SSLeay::BIO",(char *)bio,0); + PUSHs(arg); + BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); + +void +p5_BIO_new_ssl_connect(...) + PREINIT: + SSL_CTX *ctx; + BIO *bio; + SV *arg; + PPCODE: + if (items == 1) + arg=ST(0); + else if (items == 2) + arg=ST(1); + else + arg=NULL; + + if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX"))) + croak("Usage: SSLeay::BIO::new_ssl_connect(SSL_CTX)"); + else + { + IV tmp=SvIV((SV *)SvRV(arg)); + ctx=(SSL_CTX *)tmp; + } + EXTEND(sp,1); + bio=BIO_new_ssl_connect(ctx); + arg=new_ref("SSLeay::BIO",(char *)bio,0); + PUSHs(arg); + BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); + +void +p5_BIO_new(...) + PREINIT: + BIO *bio; + char *type; + SV *arg; + PPCODE: + pr_name("p5_BIO_new"); + if ((items == 1) && SvPOK(ST(0))) + type=SvPV(ST(0),na); + else if ((items == 2) && SvPOK(ST(1))) + type=SvPV(ST(1),na); + else + croak("Usage: SSLeay::BIO::new(type)"); + + EXTEND(sp,1); + if (strcmp(type,"connect") == 0) + bio=BIO_new(BIO_s_connect()); + else if (strcmp(type,"accept") == 0) + bio=BIO_new(BIO_s_accept()); + else if (strcmp(type,"ssl") == 0) + bio=BIO_new(BIO_f_ssl()); + else if (strcmp(type,"buffer") == 0) + bio=BIO_new(BIO_f_buffer()); + else + croak("unknown BIO type"); + arg=new_ref("SSLeay::BIO",(char *)bio,0); + PUSHs(arg); + BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); + +int +p5_BIO_hostname(bio,name) + BIO *bio; + char *name; + CODE: + RETVAL=BIO_set_hostname(bio,name); + OUTPUT: + RETVAL + +int +p5_BIO_set_accept_port(bio,str) + BIO *bio; + char *str; + CODE: + RETVAL=BIO_set_accept_port(bio,str); + OUTPUT: + RETVAL + +int +p5_BIO_do_handshake(bio) + BIO *bio; + CODE: + RETVAL=BIO_do_handshake(bio); + OUTPUT: + RETVAL + +BIO * +p5_BIO_push(b,bio) + BIO *b; + BIO *bio; + CODE: + /* This reference will be reduced when the reference is + * let go, and then when the BIO_free_all() is called + * inside the SSLeay library by the BIO with this + * pushed into */ + bio->references++; + RETVAL=BIO_push(b,bio); + OUTPUT: + RETVAL + +void +p5_BIO_pop(b) + BIO *b + PREINIT: + BIO *bio; + char *type; + SV *arg; + PPCODE: + bio=BIO_pop(b); + if (bio != NULL) + { + /* This BIO will either be one created in the + * perl library, in which case it will have a perl + * SV, otherwise it will have been created internally, + * inside SSLeay. For the 'pushed in', it needs + * the reference count decememted. */ + arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); + if (arg == NULL) + { + arg=new_ref("SSLeay::BIO",(char *)bio,0); + PUSHs(arg); + BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); + } + else + { + /* it was pushed in */ + SvREFCNT_inc(arg); + PUSHs(arg); + if (bio->references < 1) + abort(); + /* decrement the reference count */ + BIO_free(bio); + } + } + +int +p5_BIO_sysread(bio,in,num, ...) + BIO *bio; + SV *in; + int num; + PREINIT: + int i,n,olen; + int offset; + char *p; + CODE: + offset=0; + if (!SvPOK(in)) + sv_setpvn(in,"",0); + SvPV(in,olen); + if (items > 3) + { + offset=SvIV(ST(3)); + if (offset < 0) + { + if (-offset > olen) + croad("Offset outside string"); + offset+=olen; + } + } + if ((num+offset) > olen) + { + SvGROW(in,num+offset+1); + p=SvPV(in,i); + memset(&(p[olen]),0,(num+offset)-olen+1); + } + p=SvPV(in,n); + + i=BIO_read(bio,p+offset,num); + RETVAL=i; + if (i <= 0) i=0; + SvCUR_set(in,offset+i); + OUTPUT: + RETVAL + +int +p5_BIO_syswrite(bio,in, ...) + BIO *bio; + SV *in; + PREINIT: + char *ptr; + int len,in_len; + int offset=0; + int n; + CODE: + ptr=SvPV(in,in_len); + if (items > 2) + { + len=SvOK(ST(2))?SvIV(ST(2)):in_len; + if (items > 3) + { + offset=SvIV(ST(3)); + if (offset < 0) + { + if (-offset > in_len) + croak("Offset outside string"); + offset+=in_len; + } + else if ((offset >= in_len) && (in_len > 0)) + croak("Offset outside string"); + } + if (len >= (in_len-offset)) + len=in_len-offset; + } + else + len=in_len; + + RETVAL=BIO_write(bio,ptr+offset,len); + OUTPUT: + RETVAL + +void +p5_BIO_getline(bio) + BIO *bio; + PREINIT: + int i; + char *p; + PPCODE: + pr_name("p5_BIO_gets"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + sv_setpvn(ST(0),"",0); + SvGROW(ST(0),1024); + p=SvPV(ST(0),na); + i=BIO_gets(bio,p,1024); + if (i < 0) i=0; + SvCUR_set(ST(0),i); + +int +p5_BIO_flush(bio) + BIO *bio; + CODE: + RETVAL=BIO_flush(bio); + OUTPUT: + RETVAL + +char * +p5_BIO_type(bio) + BIO *bio; + CODE: + RETVAL=bio->method->name; + OUTPUT: + RETVAL + +void +p5_BIO_next_bio(b) + BIO *b + PREINIT: + BIO *bio; + char *type; + SV *arg; + PPCODE: + bio=b->next_bio; + if (bio != NULL) + { + arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr); + if (arg == NULL) + { + arg=new_ref("SSLeay::BIO",(char *)bio,0); + PUSHs(arg); + BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg); + } + else + { + SvREFCNT_inc(arg); + PUSHs(arg); + } + } + +int +p5_BIO_puts(bio,in) + BIO *bio; + SV *in; + PREINIT: + char *ptr; + CODE: + ptr=SvPV(in,na); + RETVAL=BIO_puts(bio,ptr); + OUTPUT: + RETVAL + +void +p5_BIO_set_callback(bio,cb,...) + BIO *bio; + SV *cb; + PREINIT: + SV *arg=NULL; + SV *arg2=NULL; + CODE: + if (items > 3) + croak("Usage: SSLeay::BIO::set_callback(bio,callback[,arg]"); + if (items == 3) + { + arg2=sv_mortalcopy(ST(2)); + SvREFCNT_inc(arg2); + BIO_set_ex_data(bio,p5_bio_ex_bio_callback_data, + (char *)arg2); + } + arg=sv_mortalcopy(ST(1)); + SvREFCNT_inc(arg); + BIO_set_ex_data(bio,p5_bio_ex_bio_callback,(char *)arg); + BIO_set_callback(bio,p5_bio_callback); + +void +p5_BIO_DESTROY(bio) + BIO *bio + PREINIT: + SV *sv; + PPCODE: + pr_name_d("p5_BIO_DESTROY",bio->references); + printf("p5_BIO_DESTROY <%s> %d\n",bio->method->name,bio->references); + BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,NULL); + BIO_free_all(bio); + +int +p5_BIO_set_ssl(bio,ssl) + BIO *bio; + SSL *ssl; + CODE: + pr_name("p5_BIO_set_ssl"); + ssl->references++; + RETVAL=BIO_set_ssl(bio,ssl,BIO_CLOSE); + OUTPUT: + RETVAL + +int +p5_BIO_number_read(bio) + BIO *bio; + CODE: + RETVAL=BIO_number_read(bio); + OUTPUT: + RETVAL + +int +p5_BIO_number_written(bio) + BIO *bio; + CODE: + RETVAL=BIO_number_written(bio); + OUTPUT: + RETVAL + +int +p5_BIO_references(bio) + BIO *bio; + CODE: + RETVAL=bio->references; + OUTPUT: + RETVAL + diff --git a/src/lib/libssl/src/perl/bn.pl b/src/lib/libssl/src/perl/bn.pl new file mode 100644 index 0000000000..5314ca46e1 --- /dev/null +++ b/src/lib/libssl/src/perl/bn.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl +use ExtUtils::testlib; +use SSLeay; + +$message=SSLeay::BN::new(); +$e=SSLeay::BN::new(); +$mod=SSLeay::BN::new(); + +$mod=SSLeay::BN::dec2bn("114381625757888867669235779976146612010218296721242362562561842935706935245733897830597123563958705058989075147599290026879543541"); +$e=5; +$d=SSLeay::BN::dec2bn("45752650303155547067694311990458644804087318688496945025024737159778909096647814932594914301288138204957467016445183857236173773"); + +$message=SSLeay::BN::bin2bn("The magic words are squeamish ossifrage"); + + + $cipher_text= $message->mod_exp($e,$mod); +print $mod."\n"; +print $mod->num_bits()."\n"; +for (1 .. 1000) + { + $clear= $cipher_text->mod_exp($d,$mod); + } +print $clear->bn2bin()."\n"; diff --git a/src/lib/libssl/src/perl/bn.txt b/src/lib/libssl/src/perl/bn.txt new file mode 100644 index 0000000000..784e761558 --- /dev/null +++ b/src/lib/libssl/src/perl/bn.txt @@ -0,0 +1,38 @@ +BN->new() +BN->dup(a) +BN->rand(bits[,top][,bottom]) + +BN->hex2bn(a) +BN->bn2hex(a) +BN->dec2bn(a) +BN->bn2dec(a) +BN->bin2bn(a) +BN->bn2bin(a) +BN->mpi2bn(a) +BN->bn2mpi(a) + +BN->add(a,b) +BN->sub(a,b) +BN->mul(a,b) +(div,mod)=BN->div(a,b) +BN->mod(a,b) +BN->exp(a,p) +BN->mod_mul(a,b,c) +BN->mod_exp(a,b,c) + +BN->is_prime(p,num) +BN->generate_prime(bits,strong,callback) + +BN->num_bits(a) +BN->cmp(a,b) +BN->ucmp(a,b) +BN->is_bit_set(a,pos) +BN->set_bit(a,pos) +BN->clear_bit(a,pos) +BN->lshift(a,num) +BN->rshift(a,num) +BN->mask_bits(a,pos) +BN->clear(a) +BN->gcd(a,b) +BN->mod_inverse(a,mod) + diff --git a/src/lib/libssl/src/perl/bn.xs b/src/lib/libssl/src/perl/bn.xs new file mode 100644 index 0000000000..c15be3729a --- /dev/null +++ b/src/lib/libssl/src/perl/bn.xs @@ -0,0 +1,589 @@ +#include "p5SSLeay.h" + +int sv_to_BIGNUM(var,arg,name) +BIGNUM **var; +SV *arg; +char *name; + { + int ret=1; + + if (sv_derived_from(arg,"SSLeay::BN")) + { + IV tmp = SvIV((SV*)SvRV(arg)); + *var = (BIGNUM *) tmp; + } + else if (SvIOK(arg)) { + SV *tmp=sv_newmortal(); + *var=BN_new(); + BN_set_word(*var,SvIV(arg)); + sv_setref_pv(tmp,"SSLeay::BN",(void*)*var); + } + else if (SvPOK(arg)) { + char *ptr; + STRLEN len; + SV *tmp=sv_newmortal(); + *var=BN_new(); + sv_setref_pv(tmp,"SSLeay::BN", (void*)*var); + ptr=SvPV(arg,len); + SvGROW(arg,len+1); + ptr[len]='\0'; + BN_dec2bn(var,ptr); + } + else + { + croak(name); + ret=0; + } + return(ret); + } + +typedef struct gpc_args_st { + SV *cb; + SV *arg; + } GPC_ARGS; + +static void generate_prime_callback(pos,num,arg) +int pos; +int num; +char *arg; + { + dSP ; + int i; + GPC_ARGS *a=(GPC_ARGS *)arg; + + ENTER ; + SAVETMPS ; + + PUSHMARK(sp); + XPUSHs(sv_2mortal(newSViv(pos))); + XPUSHs(sv_2mortal(newSViv(num))); + XPUSHs(sv_2mortal(newSVsv(a->arg))); + PUTBACK; + + i=perl_call_sv(a->cb,G_DISCARD); + + SPAGAIN; + + PUTBACK; + FREETMPS; + LEAVE; + } + +MODULE = SSLeay::BN PACKAGE = SSLeay::BN PREFIX = p5_BN_ + +VERSIONCHECK: DISABLE + +void +p5_BN_new(...) + PREINIT: + BIGNUM *bn; + SV *arg; + PPCODE: + pr_name("p5_BN_new"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + bn=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn); + +void +p5_BN_dup(a) + BIGNUM *a; + PREINIT: + BIGNUM *bn; + PPCODE: + pr_name("p5_BN_dup"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + bn=BN_dup(a); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn); + +void +p5_BN_rand(bits,...) + int bits; + PREINIT: + int top=1; + int bottom=0; + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_rand"); + if ((items < 1) || (items > 3)) + croak("Usage: SSLeay::BN::rand(bits[,top_bit][,bottombit]"); + if (items >= 2) top=(int)SvIV(ST(0)); + if (items >= 3) bottom=(int)SvIV(ST(1)); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + BN_rand(ret,bits,top,bottom); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + +void +p5_BN_bin2bn(a) + datum a; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_bin2bn"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_bin2bn(a.dptr,a.dsize,NULL); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + +void +p5_BN_bn2bin(a) + BIGNUM *a; + PREINIT: + int i; + PPCODE: + pr_name("p5_BN_bn2bin"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + i=BN_num_bytes(a)+2; + sv_setpvn(ST(0),"",1); + SvGROW(ST(0),i+1); + SvCUR_set(ST(0),BN_bn2bin(a,SvPV(ST(0),na))); + +void +p5_BN_mpi2bn(a) + datum a; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_mpi2bn"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_mpi2bn(a.dptr,a.dsize,NULL); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + +void +p5_BN_bn2mpi(a) + BIGNUM *a; + PREINIT: + int i; + PPCODE: + pr_name("p5_BN_bn2mpi"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + i=BN_bn2mpi(a,NULL); + sv_setpvn(ST(0),"",1); + SvGROW(ST(0),i+1); + SvCUR_set(ST(0),BN_bn2mpi(a,SvPV(ST(0),na))); + +void +p5_BN_hex2bn(a) + datum a; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_hex2bn"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_hex2bn(&ret,a.dptr); + +void +p5_BN_dec2bn(a) + datum a; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_dec2bn"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_dec2bn(&ret,a.dptr); + +SV * +p5_BN_bn2hex(a) + BIGNUM *a; + PREINIT: + char *ptr; + int i; + CODE: + pr_name("p5_BN_bn2hex"); + ptr=BN_bn2hex(a); + RETVAL=newSVpv("",0); + i=strlen(ptr); + SvGROW(RETVAL,i+1); + memcpy(SvPV(RETVAL,na),ptr,i+1); + SvCUR_set(RETVAL,i); + Free(ptr); + OUTPUT: + RETVAL + +SV * +p5_BN_bn2dec(a) + BIGNUM *a; + PREINIT: + char *ptr; + int i; + CODE: + pr_name("p5_BN_bn2dec"); + ptr=BN_bn2dec(a); + RETVAL=newSVpv("",0); + i=strlen(ptr); + SvGROW(RETVAL,i+1); + memcpy(SvPV(RETVAL,na),ptr,i+1); + SvCUR_set(RETVAL,i); + Free(ptr); + OUTPUT: + RETVAL + +void +p5_BN_add(a,b) + BIGNUM *a; + BIGNUM *b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_add"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_add(ret,a,b); + +void +p5_BN_sub(a,b) + BIGNUM *a; + BIGNUM *b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_sub"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_sub(ret,a,b); + +void +p5_BN_mul(a,b) + BIGNUM *a; + BIGNUM *b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_mul"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_mul(ret,a,b); + +void +p5_BN_div(a,b) + BIGNUM *a; + BIGNUM *b; + PREINIT: + static BN_CTX *ctx=NULL; + BIGNUM *div,*mod; + PPCODE: + pr_name("p5_BN_div"); + if (ctx == NULL) ctx=BN_CTX_new(); + EXTEND(sp,2); + PUSHs(sv_newmortal()); + PUSHs(sv_newmortal()); + div=BN_new(); + mod=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)div); + sv_setref_pv(ST(1), "SSLeay::BN", (void*)mod); + BN_div(div,mod,a,b,ctx); + +void +p5_BN_mod(a,b) + BIGNUM *a; + BIGNUM *b; + PREINIT: + static BN_CTX *ctx=NULL; + BIGNUM *rem; + PPCODE: + pr_name("p5_BN_mod"); + if (ctx == NULL) ctx=BN_CTX_new(); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + rem=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)rem); + BN_mod(rem,a,b,ctx); + +void +p5_BN_exp(a,p) + BIGNUM *a; + BIGNUM *p; + PREINIT: + BIGNUM *ret; + static BN_CTX *ctx=NULL; + PPCODE: + pr_name("p5_BN_exp"); + if (ctx == NULL) ctx=BN_CTX_new(); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_exp(ret,a,p,ctx); + +void +p5_BN_mod_mul(a,b,c) + BIGNUM *a; + BIGNUM *b; + BIGNUM *c; + PREINIT: + static BN_CTX *ctx=NULL; + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_mod_mul"); + if (ctx == NULL) ctx=BN_CTX_new(); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_mod_mul(ret,a,b,c,ctx); + +void +p5_BN_mod_exp(a,b,c) + BIGNUM *a; + BIGNUM *b; + BIGNUM *c; + PREINIT: + static BN_CTX *ctx=NULL; + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_mod_exp"); + if (ctx == NULL) ctx=BN_CTX_new(); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_mod_exp(ret,a,b,c,ctx); + +void +p5_BN_generate_prime(...) + PREINIT: + int bits=512; + int strong=0; + BIGNUM *ret=NULL; + SV *callback=NULL; + SV *cb_arg=NULL; + GPC_ARGS arg; + dSP; + + PPCODE: + pr_name("p5_BN_generate_prime"); + if ((items < 0) || (items > 4)) + croak("Usage: SSLeay::BN::generate_prime(a[,strong][,callback][,cb_arg]"); + if (items >= 1) bits=(int)SvIV(ST(0)); + if (items >= 2) strong=(int)SvIV(ST(1)); + if (items >= 3) callback=ST(2); + if (items == 4) cb_arg=ST(3); + + if (callback == NULL) + ret=BN_generate_prime(bits,strong,NULL,NULL,NULL,NULL); + else + { + arg.cb=callback; + arg.arg=cb_arg; + + ret=BN_generate_prime(bits,strong,NULL,NULL, + generate_prime_callback,(char *)&arg); + } + + SPAGAIN; + sp-=items; /* a bit evil that I do this */ + + EXTEND(sp,1); + PUSHs(sv_newmortal()); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + +void +p5_BN_is_prime(p,...) + BIGNUM *p; + PREINIT: + int nchecks=5,ret; + SV *callback=NULL; + SV *cb_arg=NULL; + GPC_ARGS arg; + dSP; + static BN_CTX *ctx=NULL; + PPCODE: + pr_name("p5_BN_is_prime"); + if ((items < 1) || (items > 4)) + croak("Usage: SSLeay::BN::is_prime(a[,ncheck][,callback][,callback_arg]"); + if (ctx == NULL) ctx=BN_CTX_new(); + if (items >= 2) nchecks=(int)SvIV(ST(1)); + if (items >= 3) callback=ST(2); + if (items >= 4) cb_arg=ST(3); + arg.arg=cb_arg; + if (callback == NULL) + ret=BN_is_prime(p,nchecks,NULL,ctx,NULL); + else + { + arg.cb=callback; + arg.arg=cb_arg; + ret=BN_is_prime(p,nchecks,generate_prime_callback, + ctx,(char *)&arg); + } + SPAGAIN; + sp-=items; /* a bit evil */ + PUSHs(sv_2mortal(newSViv(ret))); + +int +p5_BN_num_bits(a) + BIGNUM *a; + CODE: + pr_name("p5_BN_num_bits"); + RETVAL=BN_num_bits(a); + OUTPUT: + RETVAL + +int +p5_BN_cmp(a,b) + BIGNUM *a; + BIGNUM *b; + CODE: + pr_name("p5_BN_cmp"); + RETVAL=BN_cmp(a,b); + OUTPUT: + RETVAL + +int +p5_BN_ucmp(a,b) + BIGNUM *a; + BIGNUM *b; + CODE: + pr_name("p5_BN_ucmp"); + RETVAL=BN_ucmp(a,b); + OUTPUT: + RETVAL + +int +p5_BN_is_bit_set(a,b) + BIGNUM *a; + int b; + CODE: + pr_name("p5_BN_is_bit_set"); + RETVAL=BN_is_bit_set(a,b); + OUTPUT: + RETVAL + +void +p5_BN_set_bit(a,b) + BIGNUM *a; + int b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_set_bit"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_dup(a); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_set_bit(ret,b); + +void +p5_BN_clear_bit(a,b) + BIGNUM *a; + int b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_clear_bit"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_dup(a); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_clear_bit(ret,b); + +void +p5_BN_lshift(a,b) + BIGNUM *a; + int b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_lshift"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + if (b == 1) + BN_lshift1(ret,a); + else + BN_lshift(ret,a,b); + +void +p5_BN_rshift(a,b) + BIGNUM *a; + int b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_rshift"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + if (b == 1) + BN_rshift1(ret,a); + else + BN_rshift(ret,a,b); + +void +p5_BN_mask_bits(a,b) + BIGNUM *a; + int b; + PREINIT: + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_mask_bits"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_dup(a); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_mask_bits(ret,b); + +void +p5_BN_clear(a) + BIGNUM *a; + PPCODE: + pr_name("p5_BN_clear"); + BN_clear(a); + +void +p5_BN_gcd(a,b) + BIGNUM *a; + BIGNUM *b; + PREINIT: + static BN_CTX *ctx=NULL; + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_gcd"); + if (ctx == NULL) ctx=BN_CTX_new(); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ret=BN_new(); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + BN_gcd(ret,a,b,ctx); + +void +p5_BN_mod_inverse(a,mod) + BIGNUM *a; + BIGNUM *mod; + PREINIT: + static BN_CTX *ctx=NULL; + BIGNUM *ret; + PPCODE: + pr_name("p5_BN_mod_inverse"); + if (ctx == NULL) ctx=BN_CTX_new(); + ret=BN_mod_inverse(a,mod,ctx); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret); + +void +p5_BN_DESTROY(bn) + BIGNUM *bn + CODE: + pr_name("p5_BN_DESTROY"); + BN_free(bn); + diff --git a/src/lib/libssl/src/perl/callback.c b/src/lib/libssl/src/perl/callback.c new file mode 100644 index 0000000000..01840abc85 --- /dev/null +++ b/src/lib/libssl/src/perl/callback.c @@ -0,0 +1,103 @@ +/* perl/callback.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +SV *new_ref(type,obj,mort) +char *type; +char *obj; + { + SV *ret; + + if (mort) + ret=sv_newmortal(); + else + ret=newSViv(0); + sv_setref_pv(ret,type,(void *)obj); + return(ret); + } + +int ex_new(obj,data,ad,idx,argl,argp) +char *obj; +SV *data; +CRYPTO_EX_DATA *ad; +int idx; +long argl; +char *argp; + { + SV *sv; + +fprintf(stderr,"ex_new %08X %s\n",obj,argp); + sv=sv_newmortal(); + sv_setref_pv(sv,argp,(void *)obj); + CRYPTO_set_ex_data(ad,idx,(char *)sv); + return(1); + } + +void ex_cleanup(obj,data,ad,idx,argl,argp) +char *obj; +SV *data; +CRYPTO_EX_DATA *ad; +int idx; +long argl; +char *argp; + { + pr_name("ex_cleanup"); +fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp); + if (data != NULL) + SvREFCNT_dec((SV *)data); + } + diff --git a/src/lib/libssl/src/perl/cipher.pl b/src/lib/libssl/src/perl/cipher.pl new file mode 100644 index 0000000000..e774bceed2 --- /dev/null +++ b/src/lib/libssl/src/perl/cipher.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$md=SSLeay::MD::new("md5"); + +foreach (@SSLeay::Cipher::names) + { + ($c=SSLeay::Cipher::new($_)) || + die "'$_' is an unknown cipher algorithm\n"; + + + $data="012345678abcdefghijklmnopqrstuvwxyz"; + $c->init("01234567abcdefghABCDEFGH","zyxwvut",1); + + $in =$c->update(substr($data, 0, 5)); + $in.=$c->update(substr($data, 5,10)); + $in.=$c->update(substr($data,15,1)); + $in.=$c->update(substr($data,16)); + + $in.=$c->final(); + + $c->init("01234567abcdefghABCDEFGH","zyxwvut",0); + $out=$c->update($in); + $out.=$c->final(); + + ($out eq $data) || die "decrypt for $_ failed:$!\n"; + + $md->init(); + $md->update($in); + $digest=$md->final(); + + print unpack("H*",$digest); + printf " %2d %2d %2d %s\n", $c->key_length(), $c->iv_length(), + $c->block_size(), $c->name(); + } + diff --git a/src/lib/libssl/src/perl/cipher.txt b/src/lib/libssl/src/perl/cipher.txt new file mode 100644 index 0000000000..c47952b5c9 --- /dev/null +++ b/src/lib/libssl/src/perl/cipher.txt @@ -0,0 +1,10 @@ +Cipher::new(name) "des-cbc" etc +Cipher::name() +Cipher::key_length() +Cipher::iv_length() +Cipher::block_size() + +Cipher::init(key,iv,enc) +Cipher::update(in) +Cipher::final() +Cipher::cipher(in) diff --git a/src/lib/libssl/src/perl/cipher.xs b/src/lib/libssl/src/perl/cipher.xs new file mode 100644 index 0000000000..1044d7a4ef --- /dev/null +++ b/src/lib/libssl/src/perl/cipher.xs @@ -0,0 +1,152 @@ +#include "p5SSLeay.h" + +int boot_cipher() + { + SSLeay_add_all_ciphers(); + return(1); + } + +MODULE = SSLeay::Cipher PACKAGE = SSLeay::Cipher PREFIX = p5_EVP_C_ + +VERSIONCHECK: DISABLE + +void +p5_EVP_C_new(...) + PREINIT: + EVP_CIPHER_CTX *ctx; + EVP_CIPHER *c; + char *name; + PPCODE: + if ((items == 1) && SvPOK(ST(0))) + name=SvPV(ST(0),na); + else if ((items == 2) && SvPOK(ST(1))) + name=SvPV(ST(1),na); + else + croak("Usage: SSLeay::Cipher::new(type)"); + PUSHs(sv_newmortal()); + c=EVP_get_cipherbyname(name); + if (c != NULL) + { + ctx=malloc(sizeof(EVP_CIPHER_CTX)); + EVP_EncryptInit(ctx,c,NULL,NULL); + sv_setref_pv(ST(0), "SSLeay::Cipher", (void*)ctx); + } + +datum +p5_EVP_C_name(ctx) + EVP_CIPHER_CTX *ctx + CODE: + RETVAL.dptr=OBJ_nid2ln(EVP_CIPHER_CTX_nid(ctx)); + RETVAL.dsize=strlen(RETVAL.dptr); + OUTPUT: + RETVAL + +int +p5_EVP_C_key_length(ctx) + EVP_CIPHER_CTX *ctx + CODE: + RETVAL=EVP_CIPHER_CTX_key_length(ctx); + OUTPUT: + RETVAL + +int +p5_EVP_C_iv_length(ctx) + EVP_CIPHER_CTX *ctx + CODE: + RETVAL=EVP_CIPHER_CTX_iv_length(ctx); + OUTPUT: + RETVAL + +int +p5_EVP_C_block_size(ctx) + EVP_CIPHER_CTX *ctx + CODE: + RETVAL=EVP_CIPHER_CTX_block_size(ctx); + OUTPUT: + RETVAL + +void +p5_EVP_C_init(ctx,key,iv,enc) + EVP_CIPHER_CTX *ctx + datum key + datum iv + int enc + PREINIT: + char loc_iv[EVP_MAX_IV_LENGTH]; + char loc_key[EVP_MAX_KEY_LENGTH]; + char *ip=loc_iv,*kp=loc_key; + int i; + memset(loc_iv,0,EVP_MAX_IV_LENGTH); + memset(loc_key,0,EVP_MAX_KEY_LENGTH); + CODE: + i=key.dsize; + if (key.dsize > EVP_CIPHER_CTX_key_length(ctx)) + i=EVP_CIPHER_CTX_key_length(ctx); + if (i > 0) + { + memset(kp,0,EVP_MAX_KEY_LENGTH); + memcpy(kp,key.dptr,i); + } + else + kp=NULL; + i=iv.dsize; + if (iv.dsize > EVP_CIPHER_CTX_iv_length(ctx)) + i=EVP_CIPHER_CTX_iv_length(ctx); + if (i > 0) + { + memcpy(ip,iv.dptr,i); + memset(ip,0,EVP_MAX_IV_LENGTH); + } + else + ip=NULL; + EVP_CipherInit(ctx,EVP_CIPHER_CTX_cipher(ctx),kp,ip,enc); + memset(loc_key,0,sizeof(loc_key)); + memset(loc_iv,0,sizeof(loc_iv)); + +SV * +p5_EVP_C_cipher(ctx,in) + EVP_CIPHER_CTX *ctx; + datum in; + CODE: + RETVAL=newSVpv("",0); + SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1); + EVP_Cipher(ctx,SvPV(RETVAL,na),in.dptr,in.dsize); + SvCUR_set(RETVAL,in.dsize); + OUTPUT: + RETVAL + +SV * +p5_EVP_C_update(ctx, in) + EVP_CIPHER_CTX *ctx + datum in + PREINIT: + int i; + CODE: + RETVAL=newSVpv("",0); + SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1); + EVP_CipherUpdate(ctx,SvPV(RETVAL,na),&i,in.dptr,in.dsize); + SvCUR_set(RETVAL,i); + OUTPUT: + RETVAL + +SV * +p5_EVP_C_final(ctx) + EVP_CIPHER_CTX *ctx + PREINIT: + int i; + CODE: + RETVAL=newSVpv("",0); + SvGROW(RETVAL,EVP_CIPHER_CTX_block_size(ctx)+1); + if (!EVP_CipherFinal(ctx,SvPV(RETVAL,na),&i)) + sv_setpv(RETVAL,"BAD DECODE"); + else + SvCUR_set(RETVAL,i); + OUTPUT: + RETVAL + +void +p5_EVP_C_DESTROY(ctx) + EVP_CIPHER_CTX *ctx + CODE: + free((char *)ctx); + diff --git a/src/lib/libssl/src/perl/dh.pl b/src/lib/libssl/src/perl/dh.pl new file mode 100644 index 0000000000..73decc241a --- /dev/null +++ b/src/lib/libssl/src/perl/dh.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$g=SSLeay::BN::hex2bn("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"); +$p=SSLeay::BN::hex2bn("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"); +$pub=SSLeay::BN::hex2bn("521b5b72d0a23f5f908eff62741b9c43ac65c47ad264a4f8d62d73dfab4938a6e019f81c28d64efd9b47c1b8188566c6184b6064cc42fac2778bd732678148c6cc7601bfe0ed18da76dd7bb976cd2ff0afc7b20f3f81171e2ea6534de061f929"); +$priv=SSLeay::BN::hex2bn("6e15c752af3f4cf6d7425164c451eeba760ec0651d12dc3b0ee5002a95af6191268ca47c0fbb3d836136eee795ae4af3a1adad5e04d0dbb04378cae0406ece23ca3b86839c0fd60064c1019c7d18be4dc0ec4be6c1e9ff6b0f5bd76373585503"); +$his=SSLeay::BN::hex2bn("d0fb51cd44a8578f55eb0822ede90f07504f4720d7367ff4bf76c27fedbce79d9204421ff7e86bd1dd02031bce4ceccd1d3e7c62679b6eb5fda8238fd4fe07bff573d552795f0d46f25753c688300fb9ed396792b59a49fdf89c8429124b668e"); +$sh=SSLeay::BN::hex2bn("66ec34b09bddf86147f6c6efd5ee4e6691e690eb0e90aceda16a742cad0abe531cb61d057aff362001ca19013215140ca2a1dd8966c78105bacbf2161f9cfbd58d351ff87923de77f9c56851037223d48272565416ee769e65a621cefb90b403"); + +$g2=SSLeay::BN::hex2bn("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"); +$p2=SSLeay::BN::hex2bn("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"); +$pub2=SSLeay::BN::hex2bn("d0fb51cd44a8578f55eb0822ede90f07504f4720d7367ff4bf76c27fedbce79d9204421ff7e86bd1dd02031bce4ceccd1d3e7c62679b6eb5fda8238fd4fe07bff573d552795f0d46f25753c688300fb9ed396792b59a49fdf89c8429124b668e"); +$priv2=SSLeay::BN::hex2bn("b81d54f52b687669fc8bd8087ac319accc2f94a2feafe09779f4a81e8e01f77290f5bbe84a08003afc4448145be427fad0b9d047889cf361c9dd378b15c1ebd5bda33e051fbd9eba8bf063e2bd836467cddb61f1db5c4b06bea5c9a77fb87b24"); +$his2=SSLeay::BN::hex2bn("521b5b72d0a23f5f908eff62741b9c43ac65c47ad264a4f8d62d73dfab4938a6e019f81c28d64efd9b47c1b8188566c6184b6064cc42fac2778bd732678148c6cc7601bfe0ed18da76dd7bb976cd2ff0afc7b20f3f81171e2ea6534de061f929"); +$sh2=SSLeay::BN::hex2bn("791faba7a6b592cb68a963945229483dc30f80f5cb295b2b5a59ef618a262d22de0845948a34db83d8bde260b940967ff85593a609e53ee6510aea09b776b4704d5e916917f384458d4790b6e0befcb1cb2f112b850e9ed410a091db80e1db2e"); + +print "g=".$g->bn2hex."\n"; +print "p=".$p->bn2hex."\n"; +print "pub=".$pub->bn2hex."\n"; +print "priv=".$priv->bn2hex."\n"; +print "sh=".$sh->bn2hex."\n"; + +print "new p - p2 = ".($p-$p2)."\n"; + +$tmp=$g->mod_exp($priv,$p); +print "XXXXXXXXXXXXXXXX\n"; +print "new pub - pub = ".($tmp-$pub)."\n"; +$tmp2=$g2->mod_exp($priv2,$p2); +print "XXXXXXXXXXXXXXXX\n"; + +print $p." pub\n"; +print $tmp2." calc pub\n"; +print $pub2." txt pub\n"; + + + diff --git a/src/lib/libssl/src/perl/digest.txt b/src/lib/libssl/src/perl/digest.txt new file mode 100644 index 0000000000..6cb3ffedb0 --- /dev/null +++ b/src/lib/libssl/src/perl/digest.txt @@ -0,0 +1,7 @@ +MD::new(name) "md2", "md5" etc +MD::name() +MD::init() +MD::update(in) +MD::final() + + diff --git a/src/lib/libssl/src/perl/digest.xs b/src/lib/libssl/src/perl/digest.xs new file mode 100644 index 0000000000..5738b09e48 --- /dev/null +++ b/src/lib/libssl/src/perl/digest.xs @@ -0,0 +1,83 @@ +#include "p5SSLeay.h" + +int boot_digest() + { + SSLeay_add_all_digests(); + return(1); + } + +MODULE = SSLeay::MD PACKAGE = SSLeay::MD PREFIX = p5_EVP_MD_ + +PROTOTYPES: ENABLE +VERSIONCHECK: DISABLE + +# SSLeay::MD::new(name) name= md2, md5, sha, sha1, or mdc2 +# md->name() - returns the name +# md->init() - reinitalises the digest +# md->update(data) - adds more data to digest +# digest=md->final() - returns digest +# + +void +p5_EVP_MD_new(...) + PREINIT: + EVP_MD_CTX *ctx; + EVP_MD *md; + char *name; + PPCODE: + if ((items == 1) && SvPOK(ST(0))) + name=SvPV(ST(0),na); + else if ((items == 2) && SvPOK(ST(1))) + name=SvPV(ST(1),na); + else + croak("Usage: SSLeay::MD::new(type)"); + PUSHs(sv_newmortal()); + md=EVP_get_digestbyname(name); + if (md != NULL) + { + ctx=malloc(sizeof(EVP_MD_CTX)); + EVP_DigestInit(ctx,md); + sv_setref_pv(ST(0), "SSLeay::MD", (void*)ctx); + } + +datum +p5_EVP_MD_name(ctx) + EVP_MD_CTX *ctx + CODE: + RETVAL.dptr=OBJ_nid2ln(EVP_MD_type(EVP_MD_CTX_type(ctx))); + RETVAL.dsize=strlen(RETVAL.dptr); + OUTPUT: + RETVAL + +void +p5_EVP_MD_init(ctx) + EVP_MD_CTX *ctx + CODE: + EVP_DigestInit(ctx,EVP_MD_CTX_type(ctx)); + +void +p5_EVP_MD_update(ctx, in) + EVP_MD_CTX *ctx + datum in + CODE: + EVP_DigestUpdate(ctx,in.dptr,in.dsize); + +datum +p5_EVP_MD_final(ctx) + EVP_MD_CTX *ctx + PREINIT: + char md[EVP_MAX_MD_SIZE]; + int len; + CODE: + EVP_DigestFinal(ctx,md,&len); + RETVAL.dptr=md; + RETVAL.dsize=len; + OUTPUT: + RETVAL + +void +p5_EVP_MD_DESTROY(ctx) + EVP_MD_CTX *ctx + CODE: + free((char *)ctx); + diff --git a/src/lib/libssl/src/perl/err.txt b/src/lib/libssl/src/perl/err.txt new file mode 100644 index 0000000000..5e6cdaecdc --- /dev/null +++ b/src/lib/libssl/src/perl/err.txt @@ -0,0 +1,2 @@ +ERR::get_error() +ERR::peek_error() diff --git a/src/lib/libssl/src/perl/err.xs b/src/lib/libssl/src/perl/err.xs new file mode 100644 index 0000000000..6d1aec3ea1 --- /dev/null +++ b/src/lib/libssl/src/perl/err.xs @@ -0,0 +1,46 @@ +#include "p5SSLeay.h" + +int boot_err() + { + SSL_load_error_strings(); + return(1); + } + +MODULE = SSLeay::ERR PACKAGE = SSLeay::ERR PREFIX = p5_ERR_ + +PROTOTYPES: ENABLE +VERSIONCHECK: DISABLE + +# md->error() - returns the last error in text or numeric context + +void +p5_ERR_get_error(...) + PPCODE: + char buf[512]; + unsigned long l; + + pr_name("p5_ERR_get_code"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + l=ERR_get_error(); + ERR_error_string(l,buf); + sv_setiv(ST(0),l); + sv_setpv(ST(0),buf); + SvIOK_on(ST(0)); + +void +p5_ERR_peek_error(...) + PPCODE: + char buf[512]; + unsigned long l; + + pr_name("p5_ERR_get_code"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + l=ERR_peek_error(); + ERR_error_string(l,buf); + sv_setiv(ST(0),l); + sv_setpv(ST(0),buf); + SvIOK_on(ST(0)); + + diff --git a/src/lib/libssl/src/perl/f.pl b/src/lib/libssl/src/perl/f.pl new file mode 100644 index 0000000000..a255931864 --- /dev/null +++ b/src/lib/libssl/src/perl/f.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$data=<>; + +#$b=SSLeay::BN::hex2bn($a); +#$data=$b->bn2bin; + +#substr($data,0,8)=""; +#print $data; + +$md=SSLeay::MD::new("md5"); +$md->init(); +$md->update("test"); +$key=$md->final(); + +$rc4=SSLeay::Cipher::new("rc4"); +$rc4->init($key,"",1); +$out=$rc4->cipher($data); + +print $out; + diff --git a/src/lib/libssl/src/perl/g.pl b/src/lib/libssl/src/perl/g.pl new file mode 100644 index 0000000000..ffbe694b05 --- /dev/null +++ b/src/lib/libssl/src/perl/g.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +use ExtUtils::testlib; +use SSLeay; + +$num=SSLeay::BN::new(); +$shift=SSLeay::BN::new(); + +print "0\n"; +$num=SSLeay::BN::hex2bn("1234329378209857309429670349760347603497603496398"); +print "1\n"; +$s=SSLeay::BN::hex2bn("59"); +print "a\n"; +$r=$num->lshift(59); +print "b"; + +print $num->bn2hex."\n"; +print $s->bn2hex."\n"; +print $r->bn2hex."\n"; diff --git a/src/lib/libssl/src/perl/gen_rsa.pl b/src/lib/libssl/src/perl/gen_rsa.pl new file mode 100644 index 0000000000..ed8c71aa9e --- /dev/null +++ b/src/lib/libssl/src/perl/gen_rsa.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$bits=512; +$bits=$ARGV[0] if $#ARGV >= 0; + +$p=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."}); +print "\n"; +$q=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."}); +print "\n"; + +$e=SSLeay::BN::hex2bn("10001"); + +$t1=$p-1; +$t2=$q-1; + +($t1->gcd($e) == 1) || die "p failed the gcd test\n"; +($t2->gcd($e) == 1) || die "q failed the gcd test\n"; + +($q,$p)=($p,$q) if ($p < $q); +$n=$p*$q; +$t=($p-1)*($q-1); +($t->gcd($e) == 1) || die "t failed the gcd test\n"; + +$d=$e->mod_inverse($t); + +$dmp1=$d%($p-1); +$dmq1=$d%($q-1); +$iqmp=$q->mod_inverse($p); + +print "n =$n\n"; +print "e =$e\n"; +print "d =$d\n"; +print "dmp1=$dmp1\n"; +print "dmq1=$dmq1\n"; +print "iqmp=$iqmp\n"; + +$a=SSLeay::BN::bin2bn("This is an RSA test"); +print "Test with\n'".$a->bn2bin."' or\n$a\n"; + +$t1=$a->mod_exp($e,$n); +print "$t1\n"; +$t2=$t1->mod_exp($d,$n); +print "'".$t2->bn2bin."'\n"; + + diff --git a/src/lib/libssl/src/perl/mul.pl b/src/lib/libssl/src/perl/mul.pl new file mode 100644 index 0000000000..611a760625 --- /dev/null +++ b/src/lib/libssl/src/perl/mul.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + + +sub mul + { + my($ab,$cd,$num)=@_; + + if ($num <= 4096) + { + return($ab*$cd); + } + else + { + my($a,$b,$c,$d,$n,$ac,$bd,$m,$t1,$t2); + + $n=$num/2; + + $a=$ab->mask_bits($n); + $b=$ab->rshift($n); + $c=$cd->mask_bits($n); + $d=$cd->rshift($n); + + $t1=($b-$a); + $t2=($c-$d); + $m= &mul($t1,$t2,$n); + $ac=&mul($a,$c,$n); + $bd=&mul($b,$d,$n); + $m=$m+$ac+$bd; + $m=$m->lshift($n); + $bd=$bd->lshift($num); + + $r=$ac+$m+$bd; + return($r); + } + } + +$num=4096*32; +$a=SSLeay::BN::rand($num); +$b=SSLeay::BN::rand($num); + +#for (1 .. 10) + { + $r=&mul($a,$b,$num); + } + +#for (1 .. 10) + { + $rr=$a*$b; + } + +$res=$rr-$r; +print $res->bn2hex()."\n"; diff --git a/src/lib/libssl/src/perl/p5SSLeay.h b/src/lib/libssl/src/perl/p5SSLeay.h new file mode 100644 index 0000000000..bcccda7d5f --- /dev/null +++ b/src/lib/libssl/src/perl/p5SSLeay.h @@ -0,0 +1,96 @@ +/* perl/p5SSLeay.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#ifdef __cplusplus +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" +#ifdef __cplusplus +} +#endif + +typedef struct datum_st + { + char *dptr; + int dsize; + } datum; + +#include "crypto.h" +#include "buffer.h" +#include "bio.h" +#include "evp.h" +#include "err.h" +#include "x509.h" +#include "ssl.h" + +#if 0 +#define pr_name(name) printf("%s\n",name) +#define pr_name_d(name,p2) printf("%s %d\n",name,p2) +#define pr_name_dd(name,p2,p3) printf("%s %d %d\n",name,p2,p3) +#else +#define pr_name(name) +#define pr_name_d(name,p2) +#define pr_name_dd(name,p2,p3) +#endif + +SV *new_ref(char *type, char *obj, int mort); +int ex_new(char *obj,SV *data,CRYPTO_EX_DATA *ad,int idx,long argl,char *argp); +void ex_cleanup(char *obj,SV *data,CRYPTO_EX_DATA *ad,int idx, + long argl,char *argp); + diff --git a/src/lib/libssl/src/perl/r.pl b/src/lib/libssl/src/perl/r.pl new file mode 100644 index 0000000000..abcc331c78 --- /dev/null +++ b/src/lib/libssl/src/perl/r.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$bits=512; +$bits=$ARGV[0] if $#ARGV >= 0; + +$q=SSLeay::BN::dec2bn("334533373942443239443435463034324139443635374634423531423146313742443038394230324138363038393539303745363034393946353346323345374537463935433635374238353245344341444241344138413244373443323338334431414134363244443532423243423133433537"); + +$p=SSLeay::BN::dec2bn("3338413942343132463534373734353742343636444439363131313131353843334536434330363934313646414132453044434138413630434631334134443046313735313632344131433437443642434436423642453234383046393732383538444139393131314339303743393939363744443235443332393332394543384630304634323646333735"); +$pp=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."}); + +printf $pp->is_prime."\n"; +printf $p->is_prime."\n"; +printf $q->is_prime."\n"; +printf "p->length=%d\n",$p->num_bits; +printf "q->length=%d\n",$q->num_bits; +$bits=$p->num_bits+$q->num_bits; +$e=SSLeay::BN::hex2bn("10001"); + +$t1=$p-1; +$t2=$q-1; + +($t1->gcd($e) == 1) || die "p failed the gcd test\n"; +($t2->gcd($e) == 1) || die "q failed the gcd test\n"; + +($q,$p)=($p,$q) if ($p < $q); +$n=$p*$q; +$t=($p-1)*($q-1); +($t->gcd($e) == 1) || die "t failed the gcd test\n"; + +$d=$e->mod_inverse($t); + +$dmp1=$d%($p-1); +$dmq1=$d%($q-1); +$iqmp=$q->mod_inverse($p); + +print "n =$n\n"; +print "e =$e\n"; +print "d =$d\n"; +print "dmp1=$dmp1\n"; +print "dmq1=$dmq1\n"; +print "iqmp=$iqmp\n"; + +$a=SSLeay::BN::bin2bn("This is an RSA test"); +print "Test with\n'".$a->bn2bin."' or\n$a\n"; + +print "<$a>\n"; +$t1=$a->mod_exp($e,$n); +print ">$t1>\n"; +$t2=$t1->mod_exp($d,$n); +print "<$t2>\n"; + + diff --git a/src/lib/libssl/src/perl/s.pl b/src/lib/libssl/src/perl/s.pl new file mode 100644 index 0000000000..1d438a6765 --- /dev/null +++ b/src/lib/libssl/src/perl/s.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$ssl_ctx=SSL::CTX->new("SSLv3_client"); + +$ssl_ctx->set_options("-info_callback" => + sub { + print STDERR $_[0]->state()."\n"; + } + ); + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; +$cbio=BIO->new("connect"); +$cbio->hostname($conn) || die $ssl->error(); + +$bbio=BIO->new("buffer"); + +$sbio=BIO->new("ssl"); +$ssl=$ssl_ctx->new_ssl; +$ssl->set_options(-connect_state); +$sbio->set_ssl($ssl); + +$sbio->push($cbio); +$bbio->push($sbio); +$bio=$bbio; + +#$bio->set_callback( +# sub { +# my($bio,$state,$cmd,$buf,$lart,$ret)=@_; +# print STDERR "$state:$cmd\n"; +# return($ret); +# } +# ); + +$b=$bio; +do { + print STDERR $b->type."\n"; + } while ($b=$b->next_bio); + +(($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bio->error(); +$bio->flush; + +$data=""; +while (1) + { + $ret=$bio->getline; + $ret =~ s/[\r\n]//g; + print STDERR "$ret\n"; + last if $ret eq ""; + $server=$1 if $ret=~ /^Server: (.*)/; + } + + +print "server is $server\n"; +$x509=$ssl->get_peer_certificate(); +print "version :".$x509->get_version()."\n"; +print "serialNumber:".$x509->get_serialNumber()->bn2hex."\n"; +print "subject :".$x509->get_subject_name()."\n"; +print "issuer :". $x509->get_issuer_name()."\n"; + +$c=$ssl->get_current_cipher; +($i,$a)=$c->get_bits; +$v=$c->get_version; +$n=$c->get_name; + +print "protocol=".$ssl->get_version."\n"; +print "bits=$i($a) cipher type=$v cipher=$n\n"; + diff --git a/src/lib/libssl/src/perl/s2.pl b/src/lib/libssl/src/perl/s2.pl new file mode 100644 index 0000000000..d39b4b8e25 --- /dev/null +++ b/src/lib/libssl/src/perl/s2.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$ssl_ctx=SSL::CTX->new("SSLv3"); + +$ssl_ctx->set_options("-info_callback" => + sub { + print STDERR $_[0]->state()."\n"; + } + ); + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; +$cbio=BIO->new("connect"); +$cbio->hostname($conn) || die $ssl->error(); + +$ssl=$ssl_ctx->new_ssl; +$sbio=BIO->new("ssl"); +$sbio->set_ssl($ssl); +$ssl->set_options("-connect_state"); + +$bio=BIO->new("buffer"); + +$sbio->push($cbio); +$bio->push($sbio); + +($bio->do_handshake() > 0) || die $bio->error(); + +(($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error(); +$bio->flush() || die $bio->error(); + +$data=""; +while ($_=$bio->getline()) + { + if (/^Server:/) + { + print; + last; + } + } + +if ($bio->peek_error()) + { + print "There was an error:".$ssl->error(); + } +print "exit\n"; diff --git a/src/lib/libssl/src/perl/server.pem b/src/lib/libssl/src/perl/server.pem new file mode 100644 index 0000000000..eabb927036 --- /dev/null +++ b/src/lib/libssl/src/perl/server.pem @@ -0,0 +1,369 @@ +issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit) +subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Server test cert (512 bit) +-----BEGIN CERTIFICATE----- +MIIB6TCCAVICAQAwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV +BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD +VQQDExJUZXN0IENBICgxMDI0IGJpdCkwHhcNOTcwNjA5MTM1NzQ2WhcNOTgwNjA5 +MTM1NzQ2WjBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEaMBgG +A1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGlNlcnZlciB0ZXN0IGNl +cnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ+zw4Qnlf8SMVIP +Fe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVDTGiXav6ooKXfX3j/7tdkuD8Ey2// +Kv7+ue0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQB4TMR2CvacKE9wAsu9jyCX8YiW +mgCM+YoP6kt4Zkj2z5IRfm7WrycKsnpnOR+tGeqAjkCeZ6/36o9l91RvPnN1VJ/i +xQv2df0KFeMr00IkDdTNAdIWqFkSsZTAY2QAdgenb7MB1joejquYzO2DQIO7+wpH +irObpESxAZLySCmPPg== +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +MIIBPAIBAAJBAJ+zw4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVD +TGiXav6ooKXfX3j/7tdkuD8Ey2//Kv7+ue0CAwEAAQJAN6W31vDEP2DjdqhzCDDu +OA4NACqoiFqyblo7yc2tM4h4xMbC3Yx5UKMN9ZkCtX0gzrz6DyF47bdKcWBzNWCj +gQIhANEoojVt7hq+SQ6MCN6FTAysGgQf56Q3TYoJMoWvdiXVAiEAw3e3rc+VJpOz +rHuDo6bgpjUAAXM+v3fcpsfZSNO6V7kCIQCtbVjanpUwvZkMI9by02oUk9taki3b +PzPfAfNPYAbCJQIhAJXNQDWyqwn/lGmR11cqY2y9nZ1+5w3yHGatLrcDnQHxAiEA +vnlEGo8K85u+KwIOimM48ZG8oTk7iFdkqLJR1utT3aU= +-----END RSA PRIVATE KEY----- +subject=/C=US/O=AT&T Bell Laboratories/OU=Prototype Research CA +issuer= /C=US/O=AT&T Bell Laboratories/OU=Prototype Research CA +notBefore=950413210656Z +notAfter =970412210656Z +-----BEGIN X509 CERTIFICATE----- + +MIICCDCCAXECAQAwDQYJKoZIhvcNAQEEBQAwTjELMAkGA1UEBhMCVVMxHzAdBgNV +BAoUFkFUJlQgQmVsbCBMYWJvcmF0b3JpZXMxHjAcBgNVBAsUFVByb3RvdHlwZSBS +ZXNlYXJjaCBDQTAeFw05NTA0MTMyMTA2NTZaFw05NzA0MTIyMTA2NTZaME4xCzAJ +BgNVBAYTAlVTMR8wHQYDVQQKFBZBVCZUIEJlbGwgTGFib3JhdG9yaWVzMR4wHAYD +VQQLFBVQcm90b3R5cGUgUmVzZWFyY2ggQ0EwgZwwDQYJKoZIhvcNAQEBBQADgYoA +MIGGAoGAebOmgtSCl+wCYZc86UGYeTLY8cjmW2P0FN8ToT/u2pECCoFdrlycX0OR +3wt0ZhpFXLVNeDnHwEE9veNUih7pCL2ZBFqoIoQkB1lZmXRiVtjGonz8BLm/qrFM +YHb0lme/Ol+s118mwKVxnn6bSAeI/OXKhLaVdYZWk+aEaxEDkVkCAQ8wDQYJKoZI +hvcNAQEEBQADgYEAAZMG14lZmZ8bahkaHaTV9dQf4p2FZiQTFwHP9ZyGsXPC+LT5 +dG5iTaRmyjNIJdPWohZDl97kAci79aBndvuEvRKOjLHs3WRGBIwERnAcnY9Mz8u/ +zIHK23PjYVxGGaZd669OJwD0CYyqH22HH9nFUGaoJdsv39ChW0NRdLE9+y8= +-----END X509 CERTIFICATE----- +issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit) +subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit) +-----BEGIN CERTIFICATE----- +MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV +BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD +VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw +OTEzNTc0M1owWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY +BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgxMDI0 +IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgybTsZ +DCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/dFXSv +1F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUecQU2 +mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAM7achv3v +hLQJcv/65eGEpBXM40ZDVoFQFFJWaY5p883HTqLB1x4FdzsXHH0QKBTcKpWwqyu4 +YDm3fb8oDugw72bCzfyZK/zVZPR/hVlqI/fvU109Qoc+7oPvIXWky71HfcK6ZBCA +q30KIqGM/uoM60INq97qjDmCJapagcNBGQs= +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425 +gxSK4jqhhT62UPpqDBEwvQ+fYkVv3RV0r9ReuZGv12NoS4fXsQgqO17lHA7Od0Kd +2yNwJjKh44MxPKDt2o8iQMyZE0zlHnEFNpsP4COLTDNC6ljEEu5bk8uPsQIDAQAB +AoGAVZmpFZsDZfr0l2S9tLLwpjRWNOlKATQkno6q2WesT0eGLQufTciY+c8ypfU6 +hyio8r5iUl/VhhdjhAtKx1mRpiotftHo/eYf8rtsrnprOnWG0bWjLjtIoMbcxGn2 +J3bN6LJmbJMjDs0eJ3KnTu646F3nDUw2oGAwmpzKXA1KAP0CQQDRvQhxk2D3Pehs +HvG665u2pB5ipYQngEFlZO7RHJZzJOZEWSLuuMqaF/7pTfA5jiBvWqCgJeCRRInL +21ru4dlPAkEAx9jj7BgKn5TYnMoBSSe0afjsV9oApVpN1Nacb1YDtCwy+scp3++s +nFxlv98wxIlSdpwMUn+AUWfjiWR7Tu/G/wJBAJ/KjwZIrFVxewP0x2ILYsTRYLzz +MS4PDsO7FB+I0i7DbBOifXS2oNSpd3I0CNMwrxFnUHzynpbOStVfN3ZL5w0CQQCa +pwFahxBRhkJKsxhjoFJBX9yl75JoY4Wvm5Tbo9ih6UJaRx3kqfkN14L2BKYcsZgb +KY9vmDOYy6iNfjDeWTfJAkBkfPUb8oTJ/nSP5zN6sqGxSY4krc4xLxpRmxoJ8HL2 +XfhqXkTzbU13RX9JJ/NZ8vQN9Vm2NhxRGJocQkmcdVtJ +-----END RSA PRIVATE KEY----- +-----BEGIN X509 CERTIFICATE----- +MIICYDCCAiACAgEoMAkGBSsOAwINBQAwfDELMAkGA1UEBhMCVVMxNjA0BgNVBAoT +LU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFuZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEZ +MBcGA1UECxMQVGVzdCBFbnZpcm9ubWVudDEaMBgGA1UECxMRRFNTLU5BU0EtUGls +b3QtQ0EwHhcNOTYwMjI2MTYzMjQ1WhcNOTcwMjI1MTYzMjQ1WjB8MQswCQYDVQQG +EwJVUzE2MDQGA1UEChMtTmF0aW9uYWwgQWVyb25hdXRpY3MgYW5kIFNwYWNlIEFk +bWluaXN0cmF0aW9uMRkwFwYDVQQLExBUZXN0IEVudmlyb25tZW50MRowGAYDVQQL +ExFEU1MtTkFTQS1QaWxvdC1DQTCB8jAJBgUrDgMCDAUAA4HkADCB4AJBAMA/ssKb +hPNUG7ZlASfVwEJU21O5OyF/iyBzgHI1O8eOhJGUYO8cc8wDMjR508Mr9cp6Uhl/ +ZB7FV5GkLNEnRHYCQQDUEaSg45P2qrDwixTRhFhmWz5Nvc4lRFQ/42XPcchiJBLb +bn3QK74T2IxY1yY+kCNq8XrIqf5fJJzIH0J/xUP3AhUAsg2wsQHfDGYk/BOSulX3 +fVd0geUCQQCzCFUQAh+ZkEmp5804cs6ZWBhrUAfnra8lJItYo9xPcXgdIfLfibcX +R71UsyO77MRD7B0+Ag2tq794IleCVcEEMAkGBSsOAwINBQADLwAwLAIUUayDfreR +Yh2WeU86/pHNdkUC1IgCFEfxe1f0oMpxJyrJ5XIxTi7vGdoK +-----END X509 CERTIFICATE----- +-----BEGIN X509 CERTIFICATE----- + +MIICGTCCAdgCAwCqTDAJBgUrDgMCDQUAMHwxCzAJBgNVBAYTAlVTMTYwNAYDVQQK +Ey1OYXRpb25hbCBBZXJvbmF1dGljcyBhbmQgU3BhY2UgQWRtaW5pc3RyYXRpb24x +GTAXBgNVBAsTEFRlc3QgRW52aXJvbm1lbnQxGjAYBgNVBAsTEURTUy1OQVNBLVBp +bG90LUNBMB4XDTk2MDUxNDE3MDE0MVoXDTk3MDUxNDE3MDE0MVowMzELMAkGA1UE +BhMCQVUxDzANBgNVBAoTBk1pbmNvbTETMBEGA1UEAxMKRXJpYyBZb3VuZzCB8jAJ +BgUrDgMCDAUAA4HkADCB4AJBAKbfHz6vE6pXXMTpswtGUec2tvnfLJUsoxE9qs4+ +ObZX7LmLvragNPUeiTJx7UOWZ5DfBj6bXLc8eYne0lP1g3ACQQDUEaSg45P2qrDw +ixTRhFhmWz5Nvc4lRFQ/42XPcchiJBLbbn3QK74T2IxY1yY+kCNq8XrIqf5fJJzI +H0J/xUP3AhUAsg2wsQHfDGYk/BOSulX3fVd0geUCQQCzCFUQAh+ZkEmp5804cs6Z +WBhrUAfnra8lJItYo9xPcXgdIfLfibcXR71UsyO77MRD7B0+Ag2tq794IleCVcEE +MAkGBSsOAwINBQADMAAwLQIUWsuuJRE3VT4ueWkWMAJMJaZjj1ECFQCYY0zX4bzM +LC7obsrHD8XAHG+ZRG== +-----END X509 CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICTTCCAbagAwIBAgIBADANBgkqhkiG9w0BAQQFADBMMQswCQYDVQQGEwJHQjEM +MAoGA1UEChMDVUNMMRgwFgYDVQQLEw9JQ0UtVEVMIFByb2plY3QxFTATBgNVBAMT +DFRydXN0RmFjdG9yeTAeFw05NzA0MjIxNDM5MTRaFw05ODA0MjIxNDM5MTRaMEwx +CzAJBgNVBAYTAkdCMQwwCgYDVQQKEwNVQ0wxGDAWBgNVBAsTD0lDRS1URUwgUHJv +amVjdDEVMBMGA1UEAxMMVHJ1c3RGYWN0b3J5MIGcMAoGBFUIAQECAgQAA4GNADCB +iQKBgQCEieR8NcXkUW1f0G6aC6u0i8q/98JqS6RxK5YmHIGKCkuTWAUjzLfUa4dt +U9igGCjTuxaDqlzEim+t/02pmiBZT9HaX++35MjQPUWmsChcYU5WyzGErXi+rQaw +zlwS73zM8qiPj/97lXYycWhgL0VaiDSPxRXEUdWoaGruom4mNQIDAQABo0IwQDAd +BgNVHQ4EFgQUHal1LZr7oVg5z6lYzrhTgZRCmcUwDgYDVR0PAQH/BAQDAgH2MA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAfaggfl6FZoioecjv0dq8 +/DXo/u11iMZvXn08gjX/zl2b4wtPbShOSY5FhkSm8GeySasz+/Nwb/uzfnIhokWi +lfPZHtlCWtXbIy/TN51eJyq04ceDCQDWvLC2enVg9KB+GJ34b5c5VaPRzq8MBxsA +S7ELuYGtmYgYm9NZOIr7yU0= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIB6jCCAZQCAgEtMA0GCSqGSIb3DQEBBAUAMIGAMQswCQYDVQQGEwJVUzE2MDQG +A1UEChMtTmF0aW9uYWwgQWVyb25hdXRpY3MgYW5kIFNwYWNlIEFkbWluaXN0cmF0 +aW9uMRkwFwYDVQQLExBUZXN0IEVudmlyb25tZW50MR4wHAYDVQQLExVNRDUtUlNB +LU5BU0EtUGlsb3QtQ0EwHhcNOTYwNDMwMjIwNTAwWhcNOTcwNDMwMjIwNTAwWjCB +gDELMAkGA1UEBhMCVVMxNjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFu +ZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEZMBcGA1UECxMQVGVzdCBFbnZpcm9ubWVu +dDEeMBwGA1UECxMVTUQ1LVJTQS1OQVNBLVBpbG90LUNBMFkwCgYEVQgBAQICAgAD +SwAwSAJBALmmX5+GqAvcrWK13rfDrNX9UfeA7f+ijyBgeFQjYUoDpFqapw4nzQBL +bAXug8pKkRwa2Zh8YODhXsRWu2F/UckCAwEAATANBgkqhkiG9w0BAQQFAANBAH9a +OBA+QCsjxXgnSqHx04gcU8S49DVUb1f2XVoLnHlIb8RnX0k5O6mpHT5eti9bLkiW +GJNMJ4L0AJ/ac+SmHZc= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICajCCAdMCBDGA0QUwDQYJKoZIhvcNAQEEBQAwfTELMAkGA1UEBhMCQ2ExDzAN +BgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmlsaXR5IEFjY2VwdGVkMR8w +HQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRwwGgYDVQQDExNFbnRydXN0 +IERlbW8gV2ViIENBMB4XDTk2MDQyNjEzMzUwMVoXDTA2MDQyNjEzMzUwMVowfTEL +MAkGA1UEBhMCQ2ExDzANBgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmls +aXR5IEFjY2VwdGVkMR8wHQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRww +GgYDVQQDExNFbnRydXN0IERlbW8gV2ViIENBMIGdMA0GCSqGSIb3DQEBAQUAA4GL +ADCBhwKBgQCaroS7O1DA0hm4IefNYU1cx/nqOmzEnk291d1XqznDeF4wEgakbkCc +zTKxK791yNpXG5RmngqH7cygDRTHZJ6mfCRn0wGC+AI00F2vYTGqPGRQL1N3lZT0 +YDKFC0SQeMMjFIZ1aeQigroFQnHo0VB3zWIMpNkka8PY9lxHZAmWwQIBAzANBgkq +hkiG9w0BAQQFAAOBgQBAx0UMVA1s54lMQyXjMX5kj99FJN5itb8bK1Rk+cegPQPF +cWO9SEWyEjjBjIkjjzAwBkaEszFsNGxemxtXvwjIm1xEUMTVlPEWTs2qnDvAUA9W +YqhWbhH0toGT36236QAsqCZ76rbTRVSSX2BHyJwJMG2tCRv7kRJ//NIgxj3H4w== +-----END CERTIFICATE----- + +issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit) +subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit) +-----BEGIN CERTIFICATE----- +MIICJzCCAZACAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV +BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD +VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTczN1oXDTAxMDYw +OTEzNTczN1owXDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY +BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYDVQQDExNUZXN0IFBDQSAoMTAy +NCBiaXQpMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCdoWk/3+WcMlfjIrkg +40ketmnQaEogQe1LLcuOJV6rKfUSAsPgwgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp +22Jp85PmemiDzyUIStwk72qhp1imbANZvlmlCFKiQrjUyuDfu4TABmn+kkt3vR1Y +BEOGt+IFye1UBVSATVdRJ2UVhwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABNA1u/S +Cg/LJZWb7GliiKJsvuhxlE4E5JxQF2zMub/CSNbF97//tYSyj96sxeFQxZXbcjm9 +xt6mr/xNLA4szNQMJ4P+L7b5e/jC5DSqlwS+CUYJgaFs/SP+qJoCSu1bR3IM9XWO +cRBpDmcBbYLkSyB92WURvsZ1LtjEcn+cdQVI +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCdoWk/3+WcMlfjIrkg40ketmnQaEogQe1LLcuOJV6rKfUSAsPg +wgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp22Jp85PmemiDzyUIStwk72qhp1imbANZ +vlmlCFKiQrjUyuDfu4TABmn+kkt3vR1YBEOGt+IFye1UBVSATVdRJ2UVhwIDAQAB +AoGAba4fTtuap5l7/8ZsbE7Z1O32KJY4ZcOZukLOLUUhXxXduT+FTgGWujc0/rgc +z9qYCLlNZHOouMYTgtSfYvuMuLZ11VIt0GYH+nRioLShE59Yy+zCRyC+gPigS1kz +xvo14AsOIPYV14Tk/SsHyq6E0eTk7VzaIE197giiINUERPECQQDSKmtPTh/lRKw7 +HSZSM0I1mFWn/1zqrAbontRQY5w98QWIOe5qmzYyFbPXYT3d9BzlsMyhgiRNoBbD +yvohSHXJAkEAwAHx6ezAZeWWzD5yXD36nyjpkVCw7Tk7TSmOceLJMWt1QcrCfqlS +xA5jjpQ6Z8suU5DdtWAryM2sAir1WisYzwJAd6Zcx56jvAQ3xcPXsE6scBTVFzrj +7FqZ6E+cclPzfLQ+QQsyOBE7bpI6e/FJppY26XGZXo3YGzV8IGXrt40oOQJALETG +h86EFXo3qGOFbmsDy4pdP5nBERCu8X1xUCSfintiD4c2DInxgS5oGclnJeMcjTvL +QjQoJCX3UJCi/OUO1QJBAKgcDHWjMvt+l1pjJBsSEZ0HX9AAIIVx0RQmbFGS+F2Q +hhu5l77WnnZOQ9vvhV5u7NPCUF9nhU3jh60qWWO8mkc= +-----END RSA PRIVATE KEY----- +subject=/C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority +issuer= /C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority +notBefore=941104185834Z +notAfter =991103185834Z +-----BEGIN X509 CERTIFICATE----- + +MIICIzCCAZACBQJBAAAWMA0GCSqGSIb3DQEBAgUAMFwxCzAJBgNVBAYTAlVTMSAw +HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVy +Y2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDQxODU4MzRaFw05 +OTExMDMxODU4MzRaMFwxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0YSBT +ZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVyY2lhbCBDZXJ0aWZpY2F0aW9u +IEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCk+4Fie84QJ93o +975sbsZwmdu41QUDaSiCnHJ/lj+O7Kwpkj+KFPhCdr69XQO5kNTQvAayUTNfxMK/ +touPmbZiImDd298ggrTKoi8tUO2UMt7gVY3UaOLgTNLNBRYulWZcYVI4HlGogqHE +7yXpCuaLK44xZtn42f29O2nZ6wIDAQABMA0GCSqGSIb3DQEBAgUAA34AdrW2EP4j +9/dZYkuwX5zBaLxJu7NJbyFHXSudVMQAKD+YufKKg5tgf+tQx6sFEC097TgCwaVI +0v5loMC86qYjFmZsGySp8+x5NRhPJsjjr1BKx6cxa9B8GJ1Qv6km+iYrRpwUqbtb +MJhCKLVLU7tDCZJAuqiqWqTGtotXTcU= +-----END X509 CERTIFICATE----- +subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority +issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority +notBefore=941109235417Z +notAfter =991231235417Z +-----BEGIN X509 CERTIFICATE----- + +MIICKTCCAZYCBQJBAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw +HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl +IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDkyMzU0MTda +Fw05OTEyMzEyMzU0MTdaMF8xCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0 +YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJlIFNlcnZlciBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCSznrB +roM+WqqJg1esJQF2DK2ujiw3zus1eGRUA+WEQFHJv48I4oqCCNIWhjdV6bEhAq12 +aIGaBaJLyUslZiJWbIgHj/eBWW2EB2VwE3F2Ppt3TONQiVaYSLkdpykaEy5KEVmc +HhXVSVQsczppgrGXOZxtcGdI5d0t1sgeewIDAQABMA0GCSqGSIb3DQEBAgUAA34A +iNHReSHO4ovo+MF9NFM/YYPZtgs4F7boviGNjwC4i1N+RGceIr2XJ+CchcxK9oU7 +suK+ktPlDemvXA4MRpX/oRxePug2WHpzpgr4IhFrwwk4fia7c+8AvQKk8xQNMD9h +cHsg/jKjn7P0Z1LctO6EjJY2IN6BCINxIYoPnqk= +-----END X509 CERTIFICATE----- +subject=/C=ZA/SP=Western Cape/L=Cape Town/O=Thawte Consulting cc + /OU=Certification Services Division/CN=Thawte Server CA + /Email=server-certs@thawte.com +issuer= /C=ZA/SP=Western Cape/L=Cape Town/O=Thawte Consulting cc + /OU=Certification Services Division/CN=Thawte Server CA + /Email=server-certs@thawte.com +-----BEGIN CERTIFICATE----- +MIIC+TCCAmICAQAwDQYJKoZIhvcNAQEEBQAwgcQxCzAJBgNVBAYTAlpBMRUwEwYD +VQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU +VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2Vy +dmljZXMgRGl2aXNpb24xGTAXBgNVBAMTEFRoYXd0ZSBTZXJ2ZXIgQ0ExJjAkBgkq +hkiG9w0BCQEWF3NlcnZlci1jZXJ0c0B0aGF3dGUuY29tMB4XDTk2MDcyNzE4MDc1 +N1oXDTk4MDcyNzE4MDc1N1owgcQxCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMUVGhhd3RlIENv +bnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2 +aXNpb24xGTAXBgNVBAMTEFRoYXd0ZSBTZXJ2ZXIgQ0ExJjAkBgkqhkiG9w0BCQEW +F3NlcnZlci1jZXJ0c0B0aGF3dGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB +iQKBgQDTpFBuyP9Wa+bPXbbqDGh1R6KqwtqEJfyo9EdR2oW1IHSUhh4PdcnpCGH1 +Bm0wbhUZAulSwGLbTZme4moMRDjN/r7jZAlwxf6xaym2L0nIO9QnBCUQly/nkG3A +KEKZ10xD3sP1IW1Un13DWOHA5NlbsLjctHvfNjrCtWYiEtaHDQIDAQABMA0GCSqG +SIb3DQEBBAUAA4GBAIsvn7ifX3RUIrvYXtpI4DOfARkTogwm6o7OwVdl93yFhDcX +7h5t0XZ11MUAMziKdde3rmTvzUYIUCYoY5b032IwGMTvdiclK+STN6NP2m5nvFAM +qJT5gC5O+j/jBuZRQ4i0AMYQr5F4lT8oBJnhgafw6PL8aDY2vMHGSPl9+7uf +-----END CERTIFICATE----- + +-----BEGIN CERTIFICATE----- +MIIDDTCCAnYCAQAwDQYJKoZIhvcNAQEEBQAwgc4xCzAJBgNVBAYTAlpBMRUwEwYD +VQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU +VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2Vy +dmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNlcnZlciBD +QTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNvbTAeFw05 +NjA3MjcxODA3MTRaFw05ODA3MjcxODA3MTRaMIHOMQswCQYDVQQGEwJaQTEVMBMG +A1UECBMMV2VzdGVybiBDYXBlMRIwEAYDVQQHEwlDYXBlIFRvd24xHTAbBgNVBAoT +FFRoYXd0ZSBDb25zdWx0aW5nIGNjMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNl +cnZpY2VzIERpdmlzaW9uMSEwHwYDVQQDExhUaGF3dGUgUHJlbWl1bSBTZXJ2ZXIg +Q0ExKDAmBgkqhkiG9w0BCQEWGXByZW1pdW0tc2VydmVyQHRoYXd0ZS5jb20wgZ8w +DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANI2NmqL18JbntqBQWKPOO5JBFXW0O8c +G5UWR+8YSDU6UvQragaPOy/qVuOvho2eF/eetGV1Ak3vywmiIVHYm9Bn0LoNkgYU +c9STy5cqAJxcTgy8+hVS/PJEbtoRSm4Iny8t4/mqOoZztkZTWMiJBb2DEbhzP6oH +jfRCTedAnRw3AgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAutFIgTRZVYerIZfL9lvR +w9Eifvvo5KTZ3h+Bj+VzNnyw4Qc/IyXkPOu6SIiH9LQ3sCmWBdxpe+qr4l77rLj2 +GYuMtESFfn1XVALzkYgC7JcPuTOjMfIiMByt+uFf8AV8x0IW/Qkuv+hEQcyM9vxK +3VZdLbCVIhNoEsysrxCpxcI= +-----END CERTIFICATE----- +Tims test GCI CA + +-----BEGIN CERTIFICATE----- +MIIB8DCCAZoCAQAwDQYJKoZIhvcNAQEEBQAwgYIxCzAJBgNVBAYTAkFVMRMwEQYD +VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5 +cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBD +cnlwdFNvZnQgRGV2IENBMB4XDTk3MDMyMjEzMzQwNFoXDTk4MDMyMjEzMzQwNFow +gYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhC +cmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2Rl +dmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQgRGV2IENBMFwwDQYJKoZIhvcN +AQEBBQADSwAwSAJBAOAOAqogG5QwAmLhzyO4CoRnx/wVy4NZP4dxJy83O1EnL0rw +OdsamJKvPOLHgSXo3gDu9uVyvCf/QJmZAmC5ml8CAwEAATANBgkqhkiG9w0BAQQF +AANBADRRS/GVdd7rAqRW6SdmgLJduOU2yq3avBu99kRqbp9A/dLu6r6jU+eP4oOA +TfdbFZtAAD2Hx9jUtY3tfdrJOb8= +-----END CERTIFICATE----- + +-----BEGIN CERTIFICATE----- +MIICVjCCAgACAQAwDQYJKoZIhvcNAQEEBQAwgbUxCzAJBgNVBAYTAkFVMRMwEQYD +VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5 +cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsTI1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9O +IEFVVEhPUklUSUVTMTQwMgYDVQQDEytaRVJPIFZBTFVFIENBIC0gREVNT05TVFJB +VElPTiBQVVJQT1NFUyBPTkxZMB4XDTk3MDQwMzEzMjI1NFoXDTk4MDQwMzEzMjI1 +NFowgbUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH +EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsT +I1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9OIEFVVEhPUklUSUVTMTQwMgYDVQQDEyta +RVJPIFZBTFVFIENBIC0gREVNT05TVFJBVElPTiBQVVJQT1NFUyBPTkxZMFwwDQYJ +KoZIhvcNAQEBBQADSwAwSAJBAOZ7T7yqP/tyspcko3yPY1y0Cm2EmwNvzW4QgVXR +Fjs3HmJ4xtSpXdo6mwcGezL3Abt/aQXaxv9PU8xt+Jr0OFUCAwEAATANBgkqhkiG +9w0BAQQFAANBAOQpYmGgyCqCy1OljgJhCqQOu627oVlHzK1L+t9vBaMfn40AVUR4 +WzQVWO31KTgi5vTK1U+3h46fgUWqQ0h+6rU= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIAwgKADAgECAgEAMA0GCSqGSIb3DQEBBAUAMGIxETAPBgNVBAcTCEludGVybmV0 +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xh +c3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjAeFw05NjA0MDgxMDIwMjda +Fw05NzA0MDgxMDIwMjdaMGIxETAPBgNVBAcTCEludGVybmV0MRcwFQYDVQQKEw5W +ZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xhc3MgMSBDQSAtIElu +ZGl2aWR1YWwgU3Vic2NyaWJlcjCAMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2 +FKbPTdAFDdjKI9BvqrQpkmOOLPhvltcunXZLEbE2jVfJw/0cxrr+Hgi6M8qV6r7j +W80GqLd5HUQq7XPysVKDaBBwZJHXPmv5912dFEObbpdFmIFH0S3L3bty10w/cari +QPJUObwW7s987LrbP2wqsxaxhhKdrpM01bjV0Pc+qQIDAQABAAAAADANBgkqhkiG +9w0BAQQFAAOBgQA+1nJryNt8VBRjRr07ArDAV/3jAH7GjDc9jsrxZS68ost9v06C +TvTNKGL+LISNmFLXl+JXhgGB0JZ9fvyYzNgHQ46HBUng1H6voalfJgS2KdEo50wW +8EFZYMDkT1k4uynwJqkVN2QJK/2q4/A/VCov5h6SlM8Affg2W+1TLqvqkwAA +-----END CERTIFICATE----- + + subject=/L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber + issuer= /L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber + +-----BEGIN CERTIFICATE----- +MIIEkzCCA/ygAwIBAgIRANDTUpSRL3nTFeMrMayFSPAwDQYJKoZIhvcNAQECBQAw +YjERMA8GA1UEBxMISW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQw +MgYDVQQLEytWZXJpU2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3Jp +YmVyMB4XDTk2MDYwNDAwMDAwMFoXDTk4MDYwNDIzNTk1OVowYjERMA8GA1UEBxMI +SW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJp +U2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyMIGfMA0GCSqG +SIb3DQEBAQUAA4GNADCBiQKBgQC6A+2czKGRcYMfm8gdnk+0de99TDDzsqo0v5nb +RsbUmMcdRQ7nsMbRWe0SAb/9QoLTZ/cJ0iOBqdrkz7UpqqKarVoTSdlSMVM92tWp +3bJncZHQD1t4xd6lQVdI1/T6R+5J0T1ukOdsI9Jmf+F28S6g3R3L1SFwiHKeZKZv +z+793wIDAQABo4ICRzCCAkMwggIpBgNVHQMBAf8EggIdMIICGTCCAhUwggIRBgtg +hkgBhvhFAQcBATCCAgAWggGrVGhpcyBjZXJ0aWZpY2F0ZSBpbmNvcnBvcmF0ZXMg +YnkgcmVmZXJlbmNlLCBhbmQgaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRv +LCB0aGUgVmVyaVNpZ24gQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1lbnQg +KENQUyksIGF2YWlsYWJsZSBhdDogaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL0NQ +Uy0xLjA7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBv +ciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1v +dW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMw +IENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBS +ZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJ +TElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMC8w +LRYraHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTLTEuMDAU +BglghkgBhvhCAQEBAf8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEApRJRkNBqLLgs +53IR/d18ODdLOWMTZ+QOOxBrq460iBEdUwgF8vmPRX1ku7UiDeNzaLlurE6eFqHq +2zPyK5j60zfTLVJMWKcQWwTJLjHtXrW8pxhNtFc6Fdvy5ZkHnC/9NIl7/t4U6WqB +p4y+p7SdMIkEwIZfds0VbnQyX5MRUJY= +-----END CERTIFICATE----- + + subject=/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority + issuer= /C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority +-----BEGIN CERTIFICATE----- +MIICMTCCAZoCBQKhAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgMyBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa +Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln +biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyVxZ +nvIbigEUtBDfBEDb41evakVAj4QMC9Ez2dkRz+4CWB8l9yqoRAWq7AMfeH+ek7ma +AKojfdashaJjRcdyJ8z0TMZ1cdI5709C8HXfCpDGjiBvmA/4rCNfcCk2pMmG57Ga +IMtTpYXnPb59mv4kRTPcdhXtD6JxZExlLoFoRacCAwEAATANBgkqhkiG9w0BAQIF +AAOBgQB1Zmw+0c2B27X4LzZRtvdCvM1Cr9wO+hVs+GeTVzrrtpLotgHKjLeOQ7RJ +Zfk+7r11Ri7J/CVdqMcvi5uPaM+0nJcYwE3vH9mvgrPmZLiEXIqaB1JDYft0nls6 +NvxMsvwaPxUupVs8G5DsiCnkWRb5zget7Ond2tIxik/W2O8XjQ== +-----END CERTIFICATE----- + subject=/C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority + issuer= /C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority +-----BEGIN CERTIFICATE----- +MIICMTCCAZoCBQKmAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa +Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln +biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0LJ1 +9njQrlpQ9OlQqZ+M1++RlHDo0iSQdomF1t+s5gEXMoDwnZNHvJplnR+Xrr/phnVj +IIm9gFidBAydqMEk6QvlMXi9/C0MN2qeeIDpRnX57aP7E3vIwUzSo+/1PLBij0pd +O92VZ48TucE81qcmm+zDO3rZTbxtm+gVAePwR6kCAwEAATANBgkqhkiG9w0BAQIF +AAOBgQBT3dPwnCR+QKri/AAa19oM/DJhuBUNlvP6Vxt/M3yv6ZiaYch6s7f/sdyZ +g9ysEvxwyR84Qu1E9oAuW2szaayc01znX1oYx7EteQSWQZGZQbE8DbqEOcY7l/Am +yY7uvcxClf8exwI/VAx49byqYHwCaejcrOICdmHEPgPq0ook0Q== +-----END CERTIFICATE----- diff --git a/src/lib/libssl/src/perl/ss.pl b/src/lib/libssl/src/perl/ss.pl new file mode 100644 index 0000000000..f243a3af50 --- /dev/null +++ b/src/lib/libssl/src/perl/ss.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$ssl_ctx=SSL::CTX->new("SSLv3_client"); + +#$ssl_ctx->set_options("-info_callback" => +# sub { +# print STDERR $_[0]->state()."\n"; +# } +# ); + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; + +print $ssl_ctx."\n"; +$bio=BIO->new_buffer_ssl_connect($ssl_ctx); +$bio->hostname($conn) || die $bio->error(); + +#$bio->set_callback( +# sub { +# my($bio,$state,$cmd,$buf,$lart,$ret)=@_; +# print STDERR "$state:$cmd\n"; +# return($ret); +# } +# ); + +#$b=$bio; +#do { +# print STDERR $b->type."\n"; +# } while ($b=$b->next_bio); + +(($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bio->error(); +$bio->flush; + +$data=""; +while (1) + { + $ret=$bio->getline; + $ret =~ s/[\r\n]//g; + print STDERR "$ret\n"; + last if $ret eq ""; + $server=$1 if $ret=~ /^Server: (.*)/; + } + + +print "server is $server\n"; +$x509=$ssl->get_peer_certificate(); +print "version :".$x509->get_version()."\n"; +print "serialNumber:".$x509->get_serialNumber()->bn2hex."\n"; +print "subject :".$x509->get_subject_name()."\n"; +print "issuer :". $x509->get_issuer_name()."\n"; + +$c=$ssl->get_current_cipher; +($i,$a)=$c->get_bits; +$v=$c->get_version; +$n=$c->get_name; + +$ssl=$bio->get_ssl(); +print "protocol=".$ssl->get_version."\n"; +print "bits=$i($a) cipher type=$v cipher=$n\n"; + diff --git a/src/lib/libssl/src/perl/ssl.pl b/src/lib/libssl/src/perl/ssl.pl new file mode 100644 index 0000000000..f9e983ed87 --- /dev/null +++ b/src/lib/libssl/src/perl/ssl.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$ssl_ctx=SSL::CTX->new("SSLv3"); + +$ssl_ctx->set_options("-info_callback" => + sub { + print STDERR $_[0]->state()."\n"; + } + ); + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; +$bio=BIO->new("connect"); +$bio->hostname($conn) || die $ssl->error(); + +#$bbio=BIO->new("buffer"); +#$bbio->push($cbio); +#$bio=$bbio; + +#$bio->set_callback( +# sub { +# my($bio,$state,$cmd,$buf,$lart,$ret)=@_; +# print STDERR "$state:$cmd\n"; +# return($ret); +# } +# ); + +print STDERR "-1 ABCD\n"; +$ssl=$ssl_ctx->new_ssl; +print STDERR "000 ABCD\n"; +$ssl->set_bio($bio); + +print STDERR "00 ABCD\n"; +(($ret=$ssl->connect()) > 0) || die $ssl->error(); + +print STDERR "0 ABCD\n"; + +(($ret=$ssl->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error(); + +print STDERR "1 ABCD\n"; +$data=""; +while (1) + { +print STDERR "2 ABCD\n"; + $ret=$ssl->sysread($buf,1024); +print STDERR "3 ABCD\n"; + last if $ret <= 0; + $data.=$buf; + } + +print STDERR "4 ABCD\n"; +@a=split(/[\r]\n/,$data); +($server)=grep(/^Server:/,@a); + +print "$server\n"; +$x509=$ssl->get_peer_certificate(); +print "subject:".$x509->get_subject_name()."\n"; +print "issuer:". $x509->get_issuer_name()."\n"; + +$c=$ssl->get_current_cipher; +($i,$a)=$c->get_bits; +$v=$c->get_version; +$n=$c->get_name; + +print "protocol=".$ssl->get_version."\n"; +print "bits=$i($a) cipher type=$v cipher=$n\n"; + diff --git a/src/lib/libssl/src/perl/ssl.txt b/src/lib/libssl/src/perl/ssl.txt new file mode 100644 index 0000000000..63c52a0e1d --- /dev/null +++ b/src/lib/libssl/src/perl/ssl.txt @@ -0,0 +1,43 @@ +SSL_CTX::new(method) + SSLv3 + SSLv3_client + SSLv3_server + SSLv23 + SSLv23_client + SSLv23_server + SSLv2 + SSLv2_client + SSLv2_server + +SSL_CTX::use_PrivateKey_file(file[,type]) + type eq "der" or "pem". Default == 'pem'. + +SSL_CTX::set_options(...) + -info_callback function + +SSL::new(SSL_CTX) + +SSL::connect(); returns 0, -1 or 1 +SSL::accept(); return 0, -1 or 1 +SSL::sysread(); as per sysread +SSL::syswrite(); as per syswrite +SSL::set_bio(bio); + +SSL::set_options(...) + -info_callback function + -connect_state + -accept_state + +SSL::state(); the state in numeric and text form. +SSL::references(); debug stuff +SSL::get_peer_certificate() +SSL::do_handshake() +SSL::renegotiate() +SSL::shutdown() +SSL::get_version() + +SSL::get_current_cipher(); + +(key,alg)=SSL_CIPHER::get_bits(); +SSL_CIPHER::get_version(); +SSL_CIPHER::get_name(); diff --git a/src/lib/libssl/src/perl/ssl.xs b/src/lib/libssl/src/perl/ssl.xs new file mode 100644 index 0000000000..6777cf7ada --- /dev/null +++ b/src/lib/libssl/src/perl/ssl.xs @@ -0,0 +1,474 @@ +#include "p5SSLeay.h" + +static int p5_ssl_ex_ssl_ptr=0; +static int p5_ssl_ex_ssl_info_callback=0; +static int p5_ssl_ex_ssl_ctx_ptr=0; +static int p5_ssl_ctx_ex_ssl_info_callback=0; + +typedef struct ssl_ic_args_st { + SV *cb; + SV *arg; + } SSL_IC_ARGS; + +static void p5_ssl_info_callback(ssl,mode,ret) +SSL *ssl; +int mode; +int ret; + { + int i; + SV *me,*cb; + + me=(SV *)SSL_get_ex_data(ssl,p5_ssl_ex_ssl_ptr); + cb=(SV *)SSL_get_ex_data(ssl,p5_ssl_ex_ssl_info_callback); + if (cb == NULL) + cb=(SV *)SSL_CTX_get_ex_data( + SSL_get_SSL_CTX(ssl),p5_ssl_ctx_ex_ssl_info_callback); + if (cb != NULL) + { + dSP; + + PUSHMARK(sp); + XPUSHs(me); + XPUSHs(sv_2mortal(newSViv(mode))); + XPUSHs(sv_2mortal(newSViv(ret))); + PUTBACK; + + i=perl_call_sv(cb,G_DISCARD); + } + else + { + croak("Internal error in SSL p5_ssl_info_callback"); + } + } + +int boot_ssl() + { + p5_ssl_ex_ssl_ptr= + SSL_get_ex_new_index(0,"SSLeay::SSL",ex_new,NULL,ex_cleanup); + p5_ssl_ex_ssl_info_callback= + SSL_get_ex_new_index(0,"ssl_info_callback",NULL,NULL, + ex_cleanup); + p5_ssl_ex_ssl_ctx_ptr= + SSL_get_ex_new_index(0,"ssl_ctx_ptr",NULL,NULL, + ex_cleanup); + p5_ssl_ctx_ex_ssl_info_callback= + SSL_CTX_get_ex_new_index(0,"ssl_ctx_info_callback",NULL,NULL, + ex_cleanup); + return(1); + } + +MODULE = SSLeay::SSL PACKAGE = SSLeay::SSL::CTX PREFIX = p5_SSL_CTX_ + +VERSIONCHECK: DISABLE + +void +p5_SSL_CTX_new(...) + PREINIT: + SSL_METHOD *meth; + SSL_CTX *ctx; + char *method; + PPCODE: + pr_name("p5_SSL_CTX_new"); + if ((items == 1) && SvPOK(ST(0))) + method=SvPV(ST(0),na); + else if ((items == 2) && SvPOK(ST(1))) + method=SvPV(ST(1),na); + else + croak("Usage: SSLeay::SSL_CTX::new(type)"); + + if (strcmp(method,"SSLv3") == 0) + meth=SSLv3_method(); + else if (strcmp(method,"SSLv3_client") == 0) + meth=SSLv3_client_method(); + else if (strcmp(method,"SSLv3_server") == 0) + meth=SSLv3_server_method(); + else if (strcmp(method,"SSLv23") == 0) + meth=SSLv23_method(); + else if (strcmp(method,"SSLv23_client") == 0) + meth=SSLv23_client_method(); + else if (strcmp(method,"SSLv23_server") == 0) + meth=SSLv23_server_method(); + else if (strcmp(method,"SSLv2") == 0) + meth=SSLv2_method(); + else if (strcmp(method,"SSLv2_client") == 0) + meth=SSLv2_client_method(); + else if (strcmp(method,"SSLv2_server") == 0) + meth=SSLv2_server_method(); + else + { + croak("Not passed a valid SSL method name, should be 'SSLv[23] [client|server]'"); + } + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ctx=SSL_CTX_new(meth); + sv_setref_pv(ST(0), "SSLeay::SSL::CTX", (void*)ctx); + +int +p5_SSL_CTX_use_PrivateKey_file(ctx,file,...) + SSL_CTX *ctx; + char *file; + PREINIT: + int i=SSL_FILETYPE_PEM; + char *ptr; + CODE: + pr_name("p5_SSL_CTX_use_PrivateKey_file"); + if (items > 3) + croak("SSLeay::SSL::CTX::use_PrivateKey_file(ssl_ctx,file[,type])"); + if (items == 3) + { + ptr=SvPV(ST(2),na); + if (strcmp(ptr,"der") == 0) + i=SSL_FILETYPE_ASN1; + else + i=SSL_FILETYPE_PEM; + } + RETVAL=SSL_CTX_use_RSAPrivateKey_file(ctx,file,i); + OUTPUT: + RETVAL + +int +p5_SSL_CTX_set_options(ctx,...) + SSL_CTX *ctx; + PREINIT: + int i; + char *ptr; + SV *sv; + CODE: + pr_name("p5_SSL_CTX_set_options"); + + for (i=1; ireferences); + SSL_CTX_free(ctx); + +MODULE = SSLeay::SSL PACKAGE = SSLeay::SSL PREFIX = p5_SSL_ + +void +p5_SSL_new(...) + PREINIT: + SV *sv_ctx; + SSL_CTX *ctx; + SSL *ssl; + int i; + SV *arg; + PPCODE: + pr_name("p5_SSL_new"); + if ((items != 1) && (items != 2)) + croak("Usage: SSLeay::SSL::new(ssl_ctx)"); + if (sv_derived_from(ST(items-1),"SSLeay::SSL::CTX")) + { + IV tmp = SvIV((SV*)SvRV(ST(items-1))); + ctx=(SSL_CTX *)tmp; + sv_ctx=ST(items-1); + } + else + croak("ssl_ctx is not of type SSLeay::SSL::CTX"); + + EXTEND(sp,1); + PUSHs(sv_newmortal()); + ssl=SSL_new(ctx); + sv_setref_pv(ST(0), "SSLeay::SSL", (void*)ssl); + + /* Now this is being a little hairy, we keep a pointer to + * our perl reference. We need to do a different one + * to the one we return because it will have it's reference + * count droped to 0 apon return and if we up its reference + * count, it will never be DESTROYED */ + arg=newSVsv(ST(0)); + SSL_set_ex_data(ssl,p5_ssl_ex_ssl_ptr,(char *)arg); + SvREFCNT_inc(sv_ctx); + SSL_set_ex_data(ssl,p5_ssl_ex_ssl_ctx_ptr,(char *)sv_ctx); + +int +p5_SSL_connect(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_connect(ssl); + OUTPUT: + RETVAL + +int +p5_SSL_accept(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_connect(ssl); + OUTPUT: + RETVAL + +int +p5_SSL_sysread(ssl,in,num, ...) + SSL *ssl; + SV *in; + int num; + PREINIT: + int i,n,olen; + int offset; + char *p; + CODE: + offset=0; + if (!SvPOK(in)) + sv_setpvn(in,"",0); + SvPV(in,olen); + if (items > 3) + { + offset=SvIV(ST(3)); + if (offset < 0) + { + if (-offset > olen) + croad("Offset outside string"); + offset+=olen; + } + } + if ((num+offset) > olen) + { + SvGROW(in,num+offset+1); + p=SvPV(in,i); + memset(&(p[olen]),0,(num+offset)-olen+1); + } + p=SvPV(in,n); + + i=SSL_read(ssl,p+offset,num); + RETVAL=i; + if (i <= 0) i=0; + SvCUR_set(in,offset+i); + OUTPUT: + RETVAL + +int +p5_SSL_syswrite(ssl,in, ...) + SSL *ssl; + SV *in; + PREINIT: + char *ptr; + int len,in_len; + int offset=0; + int n; + CODE: + ptr=SvPV(in,in_len); + if (items > 2) + { + len=SvOK(ST(2))?SvIV(ST(2)):in_len; + if (items > 3) + { + offset=SvIV(ST(3)); + if (offset < 0) + { + if (-offset > in_len) + croak("Offset outside string"); + offset+=in_len; + } + else if ((offset >= in_len) && (in_len > 0)) + croak("Offset outside string"); + } + if (len >= (in_len-offset)) + len=in_len-offset; + } + else + len=in_len; + + RETVAL=SSL_write(ssl,ptr+offset,len); + OUTPUT: + RETVAL + +void +p5_SSL_set_bio(ssl,bio) + SSL *ssl; + BIO *bio; + CODE: + bio->references++; + SSL_set_bio(ssl,bio,bio); + +int +p5_SSL_set_options(ssl,...) + SSL *ssl; + PREINIT: + int i; + char *ptr; + SV *sv; + CODE: + pr_name("p5_SSL_set_options"); + + for (i=1; ireferences,ssl->ctx->references); + fprintf(stderr,"SSL_DESTROY %d\n",ssl->references); + SSL_free(ssl); + +int +p5_SSL_references(ssl) + SSL *ssl; + CODE: + RETVAL=ssl->references; + OUTPUT: + RETVAL + +int +p5_SSL_do_handshake(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_do_handshake(ssl); + OUTPUT: + RETVAL + +int +p5_SSL_renegotiate(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_renegotiate(ssl); + OUTPUT: + RETVAL + +int +p5_SSL_shutdown(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_shutdown(ssl); + OUTPUT: + RETVAL + +char * +p5_SSL_get_version(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_get_version(ssl); + OUTPUT: + RETVAL + +SSL_CIPHER * +p5_SSL_get_current_cipher(ssl) + SSL *ssl; + CODE: + RETVAL=SSL_get_current_cipher(ssl); + OUTPUT: + RETVAL + +X509 * +p5_SSL_get_peer_certificate(ssl) + SSL *ssl + CODE: + RETVAL=SSL_get_peer_certificate(ssl); + OUTPUT: + RETVAL + +MODULE = SSLeay::SSL PACKAGE = SSLeay::SSL::CIPHER PREFIX = p5_SSL_CIPHER_ + +int +p5_SSL_CIPHER_get_bits(sc) + SSL_CIPHER *sc + PREINIT: + int i,ret; + PPCODE: + EXTEND(sp,2); + PUSHs(sv_newmortal()); + PUSHs(sv_newmortal()); + ret=SSL_CIPHER_get_bits(sc,&i); + sv_setiv(ST(0),(IV)ret); + sv_setiv(ST(1),(IV)i); + +char * +p5_SSL_CIPHER_get_version(sc) + SSL_CIPHER *sc + CODE: + RETVAL=SSL_CIPHER_get_version(sc); + OUTPUT: + RETVAL + +char * +p5_SSL_CIPHER_get_name(sc) + SSL_CIPHER *sc + CODE: + RETVAL=SSL_CIPHER_get_name(sc); + OUTPUT: + RETVAL + +MODULE = SSLeay::SSL PACKAGE = SSLeay::BIO PREFIX = p5_BIO_ + +void +p5_BIO_get_ssl(bio) + BIO *bio; + PREINIT: + SSL *ssl; + SV *ret; + int i; + PPCODE: + if ((i=BIO_get_ssl(bio,&ssl)) > 0) + { + ret=(SV *)SSL_get_ex_data(ssl,p5_ssl_ex_ssl_ptr); + ret=sv_mortalcopy(ret); + } + else + ret= &sv_undef; + EXTEND(sp,1); + PUSHs(ret); + diff --git a/src/lib/libssl/src/perl/ssl_srvr.pl b/src/lib/libssl/src/perl/ssl_srvr.pl new file mode 100644 index 0000000000..653a2e7f03 --- /dev/null +++ b/src/lib/libssl/src/perl/ssl_srvr.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$ssl_ctx=SSL::CTX->new("SSLv3"); + +$ssl_ctx->set_options("-info_callback" => + sub { + print STDERR $_[0]->state()."\n"; + } + ); + +$ssl_ctx->use_PrivateKey_file("server.pem"); + +$conn="localhost:4433"; +$conn=$ARGV[0] if $#ARGV >= 0; +$bio=BIO->new("connect"); +$bio->hostname($conn) || die $ssl->error(); + +$ssl=$ssl_ctx->new_ssl; +$ssl->set_bio($bio); + +(($ret=$ssl->connect()) > 0) || die $ssl->error(); + +(($ret=$ssl->write("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error(); + +while (1) + { + $ret=$ssl->read($buf,10240); + last if ($ret <= 0); + print $buf; + } + diff --git a/src/lib/libssl/src/perl/sslbio.pl b/src/lib/libssl/src/perl/sslbio.pl new file mode 100644 index 0000000000..ca9daa36a1 --- /dev/null +++ b/src/lib/libssl/src/perl/sslbio.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$ssl_ctx=SSL::CTX->new("SSLv3"); + +#$ssl_ctx->set_options("-info_callback" => +# sub { +# print STDOUT $_[0]->state()."\n"; +# } +# ); + +# create a ssl bio +$bssl=BIO->new("ssl"); +$bssl->set_ssl($ssl_ctx->new_ssl()) || die $bssl->error(); +$bssl->get_ssl->set_options("-connect_state") || die $ssl->error(); + +$bssl->set_callback(sub { printf "XXXXXXXXXXXXXXXXXXXXXX %d %s\n",$_[1],$_[0]->type; }); + +# create connect bio +$host="localhost:4433"; +$host=$ARGV[0] if $#ARGV >= 0; +$bio=BIO->new("connect"); +$bio->hostname($host) || die $bio->error(); + +# push it in +$bssl->push($bio); + +(($ret=$bssl->write("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bssl->error(); + +while (1) + { + $ret=$bssl->read($buf,10240); + last if ($ret <= 0); + print $buf; + } + + diff --git a/src/lib/libssl/src/perl/t.pl b/src/lib/libssl/src/perl/t.pl new file mode 100644 index 0000000000..fbd9fb8490 --- /dev/null +++ b/src/lib/libssl/src/perl/t.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$a=SSLeay::BN::dec2bn("1231353465324563455"); +print "a=$a\n".$a->bn2dec."\n"; +$b=SSLeay::BN::dec2bn("98790816238765235"); +print "a=$a\nb=$b\n"; +print $a->gcd($b)."\n"; + diff --git a/src/lib/libssl/src/perl/test b/src/lib/libssl/src/perl/test new file mode 100644 index 0000000000..3977c48865 --- /dev/null +++ b/src/lib/libssl/src/perl/test @@ -0,0 +1,32 @@ +30373b8dbfc38d360bda81fad2fb462e 8 0 8 des-ecb +a5f61a73a0894979d46c2481e9f27151 8 8 1 des-cfb +a64a08dc69e79becccde95bed6239fca 8 8 1 des-ofb +553d168193e54100524541f2c473b705 8 8 8 des-cbc +bb75383e4aad6d83418dde16c6cea6f5 16 0 8 des-ede +3ea71cd9a2e50d82d66b433e9471eeb2 16 8 1 des-ede-cfb +3d56b76d43dc8d51647773bc9719a355 16 8 1 des-ede-ofb +eafa89aae63167b9798639c0e31223b4 16 8 8 des-ede-cbc +a952f8c409fb0df75a7df1aa54ba30b8 24 0 8 des-ede3 +0badccc43a14d8503d33f32a2345bbd2 24 8 1 des-ede3-cfb +bae638c0e33850d02c792ed0e3d6b600 24 8 1 des-ede3-ofb +ec4522bbefabf0198126683e661325e2 24 8 8 des-ede3-cbc +4431f05d198d8afc003aeec85bea01b9 24 8 8 desx-cbc +606af8d6f30c1fd9c647df5eb716ae0f 16 0 1 rc4 +4aaaf7e4bc3fd2caa6318a4852f636f4 5 0 1 rc4-40 +77e0851e8c96c4a1e26140d1ec822036 16 0 8 idea-ecb +a28e51e283519fde0e128bcb697bc23e 16 8 1 idea-cfb +17d0e70f07de6c08e9673d52987599ab 16 8 1 idea-ofb +0687cf6ca11ee45f8bf9c29525405a4d 16 8 8 idea-cbc +e2268681a63198fe38282b0a1bb6ed36 16 0 8 rc2-ecb +f48748e6386790e639bbee4fccaa5067 16 8 8 rc2-cbc +f250cfe829ef797d6866e32526ec4fe4 5 8 8 rc2-40-cbc +a372f970b6c346341a2899bb872a7349 16 8 1 rc2-cfb +d2da66102dea6b833f0fbf71e2cb4988 16 8 1 rc2-ofb +237b0ef0e4f7fb28a5708d59773caecf 16 0 8 bf-ecb +c58cf5da90472caf0f0b7fafb0590977 16 8 1 bf-cfb +1f3e49e2e27f9ad177a6a64b09d361ed 16 8 1 bf-ofb +66acaf2cb5f301580c59fa17d005b716 16 8 8 bf-cbc +3548c9fe9fcd13f647ae177a15915af9 16 0 8 cast5-ecb +e8d074ad8cc0d3d828da80ab18452f91 16 8 1 cast5-cfb +5331eb4351c2048c27c8a8901fd29e20 16 8 1 cast5-ofb +8033607fdb68598cc62c379af218eeeb 16 8 8 cast5-cbc diff --git a/src/lib/libssl/src/perl/test.pl b/src/lib/libssl/src/perl/test.pl new file mode 100644 index 0000000000..52423ef620 --- /dev/null +++ b/src/lib/libssl/src/perl/test.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +($a=SSLeay::BN::new()) || die "unable to make bignum\n"; +($b=SSLeay::BN::new()) || die "unable to make bignum\n"; + +$a=SSLeay::BN::hex2bn("123456789ABCDEF"); +$b=SSLeay::BN::hex2bn("123456789ABCDEF"); +$mod=SSLeay::BN::hex2bn("fedcba9876543201"); +$c=SSLeay::BN::hex2bn("1234"); + +print "a=".$a->bn2hex()."\n"; +print "b=".$b->bn2hex()."\n"; +print "c=".$c->bn2hex()."\n"; + +print $a->mul($b)->bn2hex."\n"; +($d,$r)=$b->div($c); +print "($d)($r)\n"; +printf "%s x %s + %s\n",$c->bn2hex,$d->bn2hex,$r->bn2hex; + +$g=$d; + +for (;;) + { + $a=$a->mod_mul($a,$mod); + print $a->bn2hex."\n"; + } diff --git a/src/lib/libssl/src/perl/test.txt b/src/lib/libssl/src/perl/test.txt new file mode 100644 index 0000000000..ff37ffd09b --- /dev/null +++ b/src/lib/libssl/src/perl/test.txt @@ -0,0 +1,36 @@ +30373b8dbfc38d360bda81fad2fb462e 8 0 8 des-ecb +a5f61a73a0894979d46c2481e9f27151 8 8 1 des-cfb +a64a08dc69e79becccde95bed6239fca 8 8 1 des-ofb +553d168193e54100524541f2c473b705 8 8 8 des-cbc +bb75383e4aad6d83418dde16c6cea6f5 16 0 8 des-ede +3ea71cd9a2e50d82d66b433e9471eeb2 16 8 1 des-ede-cfb +3d56b76d43dc8d51647773bc9719a355 16 8 1 des-ede-ofb +eafa89aae63167b9798639c0e31223b4 16 8 8 des-ede-cbc +a952f8c409fb0df75a7df1aa54ba30b8 24 0 8 des-ede3 +0badccc43a14d8503d33f32a2345bbd2 24 8 1 des-ede3-cfb +bae638c0e33850d02c792ed0e3d6b600 24 8 1 des-ede3-ofb +ec4522bbefabf0198126683e661325e2 24 8 8 des-ede3-cbc +4431f05d198d8afc003aeec85bea01b9 24 8 8 desx-cbc +606af8d6f30c1fd9c647df5eb716ae0f 16 0 1 rc4 +4aaaf7e4bc3fd2caa6318a4852f636f4 5 0 1 rc4-40 +77e0851e8c96c4a1e26140d1ec822036 16 0 8 idea-ecb +a28e51e283519fde0e128bcb697bc23e 16 8 1 idea-cfb +17d0e70f07de6c08e9673d52987599ab 16 8 1 idea-ofb +0687cf6ca11ee45f8bf9c29525405a4d 16 8 8 idea-cbc +e2268681a63198fe38282b0a1bb6ed36 16 0 8 rc2-ecb +f48748e6386790e639bbee4fccaa5067 16 8 8 rc2-cbc +f250cfe829ef797d6866e32526ec4fe4 5 8 8 rc2-40-cbc +a372f970b6c346341a2899bb872a7349 16 8 1 rc2-cfb +d2da66102dea6b833f0fbf71e2cb4988 16 8 1 rc2-ofb +237b0ef0e4f7fb28a5708d59773caecf 16 0 8 bf-ecb +c58cf5da90472caf0f0b7fafb0590977 16 8 1 bf-cfb +1f3e49e2e27f9ad177a6a64b09d361ed 16 8 1 bf-ofb +66acaf2cb5f301580c59fa17d005b716 16 8 8 bf-cbc +3548c9fe9fcd13f647ae177a15915af9 16 0 8 cast5-ecb +e8d074ad8cc0d3d828da80ab18452f91 16 8 1 cast5-cfb +5331eb4351c2048c27c8a8901fd29e20 16 8 1 cast5-ofb +8033607fdb68598cc62c379af218eeeb 16 8 8 cast5-cbc +e3a6760eb5e79bf4063cf0791e99842d 16 0 8 rc5-ecb +2f5eab0d0992dcce8615a5a60966391a 16 8 1 rc5-cfb +c5893e49e73342db2957b83b70f23e27 16 8 1 rc5-ofb +683ce60c8b7bf028ec0d3dc0f018a1a4 16 8 8 rc5-cbc diff --git a/src/lib/libssl/src/perl/test2.pl b/src/lib/libssl/src/perl/test2.pl new file mode 100644 index 0000000000..2e1196c072 --- /dev/null +++ b/src/lib/libssl/src/perl/test2.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +@md=(); +($c=SSLeay::Cipher::new("idea")) || + die "'des' is an unknown cipher algorithm\n"; + +printf "name =%s\n" ,$c->name(); +printf "key length=%2d\n",$c->key_length(); +printf "iv length =%2d\n",$c->iv_length(); +printf "block size=%2d\n",$c->block_size(); + +$data="1234"; +$c->init("01234567","abcdefgh",1); +$in=$c->update($data); +$in.=$c->final(); + +$c->init("01234567","abcdefgh",0); +$out=$c->update($in); +$out.=$c->final(); +print $data; +print " -> "; +print $out; +print "\n"; + diff --git a/src/lib/libssl/src/perl/test3.pl b/src/lib/libssl/src/perl/test3.pl new file mode 100644 index 0000000000..4102ab9297 --- /dev/null +++ b/src/lib/libssl/src/perl/test3.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +@md=(); +($c=SSLeay::Cipher::new("idea")) || + die "'des' is an unknown cipher algorithm\n"; + +$key=" "; +$iv=" "; +$c->init($key,$iv,0); +while (<>) + { + print $c->update($_); + } +print $c->final(); + diff --git a/src/lib/libssl/src/perl/test8.pl b/src/lib/libssl/src/perl/test8.pl new file mode 100644 index 0000000000..c144f7f136 --- /dev/null +++ b/src/lib/libssl/src/perl/test8.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +# 2687145 * 3003 * 10^5072 - 1. + +$a=SSLeay::BN::set_word(99); +$b=SSLeay::BN::set_word(100); + +$aa=$a->dup; +$bb=$b->dup; + +$c=$a*$b; +$bb+=$a; + +print "$a*$b=$c\n"; +print "$bb\n"; diff --git a/src/lib/libssl/src/perl/test9.pl b/src/lib/libssl/src/perl/test9.pl new file mode 100644 index 0000000000..cc710c310e --- /dev/null +++ b/src/lib/libssl/src/perl/test9.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +# 2687145 * 3003 * 10^5072 - 1. + +$a=SSLeay::BN::set_word(2687145); +$b=SSLeay::BN::set_word(3003); +$c=SSLeay::BN::set_word(10); +$d=SSLeay::BN::set_word(5072); +$e=SSLeay::BN::set_word(1); + +print $a->bn2hex()."\n"; +print $b->bn2hex()."\n"; +print $c->bn2hex()."\n"; +print $d->bn2hex()."\n"; +print $e->bn2hex()."\n"; + +$f=(($a->mul($b)->mul($c->exp($d)))->sub($e)); +#print "$a $b\n"; + +$c=$a->mul($b); +print "1->".$c->bn2hex()." \n"; + +$c=$a*$b; +print "2->".$c->bn2hex()." \n"; +$a*=$b; +print "3->$a\n"; + +print $f->bn2hex()." $a\n"; +print $a."\n"; + +print "$a=(($b*$c)/$d);\n"; +$a=(($b*$c)/$d); +print "$a\n"; + diff --git a/src/lib/libssl/src/perl/testbn.pl b/src/lib/libssl/src/perl/testbn.pl new file mode 100644 index 0000000000..3062439563 --- /dev/null +++ b/src/lib/libssl/src/perl/testbn.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$num ="a43f6a8885a308d313198a2e03707344a4093822"; +$num.="299f31d0082efa98ec4e6c89452821e638d01377"; +$num.="be5466cf34e90c6cc0ac29b7c97c50dd3f84d5b5"; +$num.="b54709179216d5d98979fb1bd1310ba698dfb5ac"; +$num.="2ffd72dbd01adfb7b8e1afed6a267e96ba7c9045"; +$num.="f12c7f9924a19947b3916cf70801f2e2858efc16"; +$num.="636920d871574e69a458fea3f4933d7e0d95748f"; +$num.="728eb658718bcd5882154aee7b54a41dc25a59b5"; +$num.="9c30d5392af26013c5d1b023286085f0ca417918"; +$num.="b8db38ef8e79dcb0603a180e6c9e0e8bb01e8a3e"; +$num.="d71577c1bd314b2778af2fda55605c60e65525f3"; +$num.="aa55ab945748986263e8144055ca396a2aab10b6"; +$num.="b4cc5c341141e8cea15486af7c8f14a7"; + +$a=SSLeay::BN::hex2bn($num); +print "num bits =".$a->num_bits."\n"; +print $a->is_prime(50,sub {print STDERR $_[0]?"+":"."})."\n"; diff --git a/src/lib/libssl/src/perl/testdec.pl b/src/lib/libssl/src/perl/testdec.pl new file mode 100644 index 0000000000..0dce3f8e79 --- /dev/null +++ b/src/lib/libssl/src/perl/testdec.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$a=SSLeay::BN::dec2bn("1234"); + +foreach (1..4) + { + $a*=$a; + print $a."\n",$a->bn2dec()."\n"; + } + diff --git a/src/lib/libssl/src/perl/testmd.pl b/src/lib/libssl/src/perl/testmd.pl new file mode 100644 index 0000000000..6549166c8a --- /dev/null +++ b/src/lib/libssl/src/perl/testmd.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +@md=(); +foreach ("md2", "md5", "sha", "sha1", "mdc2", "ripemd160") + { + ($f=MD->new($_)) || + die "$_ is an unknown message digest algorithm\n"; + push(@md,$f); + } + +while (<>) + { + foreach $md (@md) + { $md->update($_); } + } + +foreach (@md) + { + $digest=$_->final(); + printf "%-4s=%s\n",$_->name(),unpack("H*",$digest); + } + diff --git a/src/lib/libssl/src/perl/tt.pl b/src/lib/libssl/src/perl/tt.pl new file mode 100644 index 0000000000..80ec88b2a8 --- /dev/null +++ b/src/lib/libssl/src/perl/tt.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +for ($i=1; $i<1000; $i++) + { + $a.=$i%10; + $y=SSLeay::BN::dec2bn($a); + $z=SSLeay::BN::bn2dec($y); + + print "$a\n$y\n$z\n"; + } + diff --git a/src/lib/libssl/src/perl/typemap b/src/lib/libssl/src/perl/typemap new file mode 100644 index 0000000000..5226fbc369 --- /dev/null +++ b/src/lib/libssl/src/perl/typemap @@ -0,0 +1,96 @@ + +datum T_DATUM +EVP_MD_CTX * T_MD_CTX +EVP_CIPHER_CTX * T_CIPHER_CTX +BIGNUM * T_BIGNUM +SSL_METHOD * T_SSL_METHOD +SSL_CTX * T_SSL_CTX +SSL_CIPHER * T_SSL_CIPHER +SSL * T_SSL +BIO * T_BIO +X509 * T_X509 + +INPUT +T_DATUM + $var.dptr=SvPV($arg,$var.dsize); +T_MD_CTX + if (sv_derived_from($arg, \"SSLeay::MD\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (EVP_MD_CTX *) tmp; + } + else + croak(\"$var is not of type SSLeay::MD\") +T_CIPHER_CTX + if (sv_derived_from($arg, \"SSLeay::Cipher\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (EVP_CIPHER_CTX *) tmp; + } + else + croak(\"$var is not of type SSLeay::Cipher\") +T_BIGNUM + sv_to_BIGNUM(&($var),$arg,\"$var is not of type SSLeay::MD, int or string\") +T_SSL_METHOD + if (sv_derived_from($arg, \"SSLeay::SSL::METHOD\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (SSL_METHOD *) tmp; + } + else + croak(\"$var is not of type SSLeay::SSL::METHOD\") +T_SSL_CTX + if (sv_derived_from($arg, \"SSLeay::SSL::CTX\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (SSL_CTX *) tmp; + } + else + croak(\"$var is not of type SSLeay::SSL::CTX\") +T_SSL_CIPHER + if (sv_derived_from($arg, \"SSLeay::SSL::CIPHER\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (SSL_CIPHER *) tmp; + } + else + croak(\"$var is not of type SSLeay::SSL::CIPHER\") +T_SSL + if (sv_derived_from($arg, \"SSLeay::SSL\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (SSL *) tmp; + } + else + croak(\"$var is not of type SSLeay::SSL\") +T_BIO + if (sv_derived_from($arg, \"SSLeay::BIO\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (BIO *) tmp; + } + else + croak(\"$var is not of type SSLeay::BIO\") +T_X509 + if (sv_derived_from($arg, \"SSLeay::X509\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = (X509 *) tmp; + } + else + croak(\"$var is not of type SSLeay::X509\") +OUTPUT +T_DATUM + sv_setpvn($arg,$var.dptr,$var.dsize); +T_MD_CTX + sv_setref_pv($arg, \"SSLeay::MD\", (void*)$var); +T_CIPHER_CTX + sv_setref_pv($arg, \"SSLeay::Cipher\", (void*)$var); +T_BIGNUM + sv_setref_pv($arg, \"SSLeay::BN\", (void*)$var); +T_SSL_METHOD + sv_setref_pv($arg, \"SSLeay::SSL::METHOD\", (void*)$var); +T_SSL_CTX + sv_setref_pv($arg, \"SSLeay::SSL::CTX\", (void*)$var); +T_SSL_CIPHER + sv_setref_pv($arg, \"SSLeay::SSL::CIPHER\", (void*)$var); +T_SSL + sv_setref_pv($arg, \"SSLeay::SSL\", (void*)$var); +T_BIO + sv_setref_pv($arg, \"SSLeay::BIO\", (void*)$var); +T_X509 + sv_setref_pv($arg, \"SSLeay::X509\", (void*)$var); + + diff --git a/src/lib/libssl/src/perl/x509.txt b/src/lib/libssl/src/perl/x509.txt new file mode 100644 index 0000000000..8468eff512 --- /dev/null +++ b/src/lib/libssl/src/perl/x509.txt @@ -0,0 +1,6 @@ +X509::new() + +X509::get_verson() +X509::get_serial_number() +X509::get_subject_name() +X509::get_issuer_name() diff --git a/src/lib/libssl/src/perl/x509.xs b/src/lib/libssl/src/perl/x509.xs new file mode 100644 index 0000000000..67633ad225 --- /dev/null +++ b/src/lib/libssl/src/perl/x509.xs @@ -0,0 +1,74 @@ +#include "p5SSLeay.h" + +MODULE = SSLeay::X509 PACKAGE = SSLeay::X509 PREFIX = p5_X509_ + +PROTOTYPES: ENABLE +VERSIONCHECK: DISABLE + +void +p5_X509_new(void ) + PREINIT: + X509 *x509; + SV *arg; + PPCODE: + pr_name("p5_X509_new"); + EXTEND(sp,1); + PUSHs(sv_newmortal()); + x509=X509_new(); + sv_setref_pv(ST(0),"SSLeay::X509",(void *)x509); + +char * +p5_X509_get_subject_name(x509) + X509 *x509; + PREINIT: + char *p; + X509_NAME *name; + char buf[1024]; + int i; + CODE: + name=X509_get_subject_name(x509); + X509_NAME_oneline(name,buf,sizeof(buf)); + p= &(buf[0]); + RETVAL=p; + OUTPUT: + RETVAL + +char * +p5_X509_get_issuer_name(x509) + X509 *x509; + PREINIT: + char *p; + X509_NAME *name; + char buf[1024]; + int i; + CODE: + name=X509_get_issuer_name(x509); + X509_NAME_oneline(name,buf,sizeof(buf)); + p= &(buf[0]); + RETVAL=p; + OUTPUT: + RETVAL + +int +p5_X509_get_version(x509) + X509 *x509; + CODE: + RETVAL=X509_get_version(x509); + OUTPUT: + RETVAL + +BIGNUM * +p5_X509_get_serialNumber(x509) + X509 *x509; + CODE: + RETVAL=ASN1_INTEGER_to_BN(X509_get_serialNumber(x509),NULL); + OUTPUT: + RETVAL + +void +p5_X509_DESTROY(x509) + X509 *x509; + CODE: + pr_name("p5_X509_DESTROY"); + X509_free(x509); + diff --git a/src/lib/libssl/src/perl/xstmp.c b/src/lib/libssl/src/perl/xstmp.c new file mode 100644 index 0000000000..aa18959017 --- /dev/null +++ b/src/lib/libssl/src/perl/xstmp.c @@ -0,0 +1,102 @@ +/* perl/xstmp.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* + * This file was generated automatically by xsubpp version 1.9402 from the + * contents of SSLeay.xs. Do not edit this file, edit SSLeay.xs instead. + * + * ANY CHANGES MADE HERE WILL BE LOST! + * + */ + +#line 1 "SSLeay.xs" +#ifdef __cplusplus +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" +#ifdef __cplusplus +} +#endif + +typedef struct datum_st + { + char *dptr; + int dsize; + } datum; + +#include "crypto.h" +#include "buffer.h" +#include "bio.h" +#include "evp.h" +#include "err.h" +#include "x509.h" +#include "ssl.h" + +#if 0 +#define pr_name(name) printf("%s\n",name) +#define pr_name_d(name,p2) printf("%s %d\n",name,p2) +#define pr_name_dd(name,p2,p3) printf("%s %d %d\n",name,p2,p3) +#else +#define pr_name(name) +#define pr_name_d(name,p2) +#define pr_name_dd(name,p2,p3) +#endif + +#include "callback.c" + diff --git a/src/lib/libssl/src/perl/y.pl b/src/lib/libssl/src/perl/y.pl new file mode 100644 index 0000000000..fe608a6724 --- /dev/null +++ b/src/lib/libssl/src/perl/y.pl @@ -0,0 +1,7 @@ +#!/usr/bin/perl +use ExtUtils::testlib; +use SSLeay; + +$message=SSLeay::BN::dec2bn("936345681743241125150760694794510965960940252288797108931456691368672287489405603308617928680920874760917824938589009714909675985261365549781893129784821682998948722"); + +print $message->bn2hex."\n"; diff --git a/src/lib/libssl/src/perl/yy.pl b/src/lib/libssl/src/perl/yy.pl new file mode 100644 index 0000000000..2e00edb3e9 --- /dev/null +++ b/src/lib/libssl/src/perl/yy.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + +$a=SSLeay::BN::new(); + +$a+="1234567"; + +print $a->bn2hex()."\n"; + + +for (1 .. 20) + { + $a*=$a; + $b=$a->bn2hex(); + print " ".$b."\n".length($b)."\n"; + } diff --git a/src/lib/libssl/src/perl/z.pl b/src/lib/libssl/src/perl/z.pl new file mode 100644 index 0000000000..7e2d5285cc --- /dev/null +++ b/src/lib/libssl/src/perl/z.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; +use Benchmark; + +$buf=('x' x (1024*1024)); +$buf=('x' x (1024*1024)); + +@md=(); +foreach $name ("md2", "mdc2", "sha", "ripemd160", "sha1", "md5") + { + if (($name eq "md2") || ($name eq "mdc2")) + { $num=5; } + else { $num=100; } + + $t=timeit($num,'&hash($name)'); + printf "%6d000 bytes/sec:$name\n",int(($num*1024*1024)/$t->[1]/1000); + } + +sub hash + { + my($name)=@_; + my($f,$digest); + + ($f=MD->new($name)) || + die "$_ is an unknown message digest algorithm\n"; + $f->update($buf); + $digest=$f->final(); + } + diff --git a/src/lib/libssl/src/perl/zz.pl b/src/lib/libssl/src/perl/zz.pl new file mode 100644 index 0000000000..38866c9227 --- /dev/null +++ b/src/lib/libssl/src/perl/zz.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +use ExtUtils::testlib; +use SSLeay; + +$a=SSLeay::BN::dec2bn("12345678901234567890"); +$b=SSLeay::BN::dec2bn("98765432109876543210"); +print "a=$a\n"; +print "b=$b\n"; + +$n=$a*$b; +$m=$n+"1223123235345634764534567889"; +$l=$m*88888888; + +$r=$l/$b; + +print "a=$a\n"; +print "b=$b\n"; +print "n=$n\n"; +print "m=$m\n"; +print "l=$l\n"; +print "r=$r\n"; + diff --git a/src/lib/libssl/src/shlib/linux.sh b/src/lib/libssl/src/shlib/linux.sh new file mode 100644 index 0000000000..f80292d90c --- /dev/null +++ b/src/lib/libssl/src/shlib/linux.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +echo "#define DATE \"`date`\"" >crypto/date.h + +major="0" +minor="8.2" +slib=libssl +clib=libcrypto +CC=gcc +CPP='gcc -E' +AS=as +FLAGS='-DX86_ASM -DTERMIO -O3 -DL_ENDIAN -fomit-frame-pointer -m486 -Wall' +#FLAGS='-DTERMIO -g2 -ggdb -DL_ENDIAN -m486 -Wall -DREF_CHECK -DCRYPTO_MDEBUG' +INCLUDE='-Iinclude -Icrypto -Issl' +SHFLAGS='-DPIC -fpic' + +CFLAGS="$FLAGS $INCLUDE $SHFLAGS" +ASM_OBJ=""; + +echo compiling bignum assember +$CPP -DELF crypto/bn/asm/bn86unix.cpp | $AS -o bn_asm.o +CFLAGS="$CFLAGS -DBN_ASM -DX86_ASM" +ASM_OBJ="$ASM_OBJ bn_asm.o" + +echo compiling des assember +$CPP -DELF crypto/des/asm/dx86unix.cpp | $AS -o des_enc.o +$CPP -DELF crypto/des/asm/yx86unix.cpp | $AS -o fcrypt-b.o +CFLAGS="$CFLAGS -DDES_ASM" +ASM_OBJ="$ASM_OBJ des_enc.o fcrypt-b.o" + +echo compiling blowfish assember +$CPP -DELF crypto/bf/asm/bx86unix.cpp | $AS -o bf_enc.o +CFLAGS="$CFLAGS -DBF_ASM" +ASM_OBJ="$ASM_OBJ bf_enc.o" + +echo compiling cast assember +$CPP -DELF crypto/cast/asm/cx86unix.cpp | $AS -o cast_enc.o +CFLAGS="$CFLAGS -DCAST_ASM" +ASM_OBJ="$ASM_OBJ cast_enc.o" + +echo compiling rc4 assember +$CPP -DELF crypto/rc4/asm/rx86unix.cpp | $AS -o rc4_enc.o +CFLAGS="$CFLAGS -DRC4_ASM" +ASM_OBJ="$ASM_OBJ rc4_enc.o" + +echo compiling md5 assember +$CPP -DELF crypto/md5/asm/mx86unix.cpp | $AS -o md5_enc.o +CFLAGS="$CFLAGS -DMD5_ASM" +ASM_OBJ="$ASM_OBJ md5_enc.o" + +echo compiling sha1 assember +$CPP -DELF crypto/sha/asm/sx86unix.cpp | $AS -o sha1_enc.o +CFLAGS="$CFLAGS -DSHA1_ASM" +ASM_OBJ="$ASM_OBJ sha1_enc.o" + +echo compiling $clib +$CC -c $CFLAGS -DCFLAGS="\"$FLAGS\"" -o crypto.o crypto/crypto.c + +echo linking $clib.so +gcc $CFLAGS -shared -Wl,-soname,$clib.so.$major -o $clib.so.$major.$minor crypto.o $ASM_OBJ +/bin/rm -f $clib.so $clib.so.$major +ln -s $clib.so.$major.$minor $clib.so +ln -s $clib.so.$major.$minor $clib.so.$major + +echo compiling $slib.so +$CC -c $CFLAGS -o ssl.o ssl/ssl.c + +echo building $slib.so +gcc $CFLAGS -shared -Wl,-soname,$slib.so.$major -o $slib.so.$major.$minor ssl.o +/bin/rm -f $slib.so $slib.so.$major +ln -s $slib.so.$major.$minor $slib.so +ln -s $slib.so.$major.$minor $slib.so.$major + +echo building ssleay executable +gcc $CFLAGS -o ssleay apps/eay.c -L. -lssl -lcrypto + diff --git a/src/lib/libssl/src/ssl/Makefile.ssl b/src/lib/libssl/src/ssl/Makefile.ssl new file mode 100644 index 0000000000..f4b13bf83b --- /dev/null +++ b/src/lib/libssl/src/ssl/Makefile.ssl @@ -0,0 +1,100 @@ +# +# SSLeay/ssl/Makefile +# + +DIR= ssl +TOP= .. +CC= cc +INCLUDES= -I../crypto -I../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +ERR=ssl +ERRC=ssl_err +GENERAL=Makefile README +TEST=ssltest.c +APPS= + +LIB=$(TOP)/libssl.a +LIBSRC= \ + s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \ + s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \ + s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \ + t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \ + ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \ + ssl_ciph.c ssl_stat.c ssl_rsa.c \ + ssl_asn1.c ssl_txt.c ssl_algs.c \ + bio_ssl.c $(ERRC).c +LIBOBJ= \ + s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \ + s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \ + s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \ + t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o \ + ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \ + ssl_ciph.o ssl_stat.o ssl_rsa.o \ + ssl_asn1.o ssl_txt.o ssl_algs.o \ + bio_ssl.o $(ERRC).o + +SRC= $(LIBSRC) + +EXHEADER= ssl.h ssl2.h ssl3.h ssl23.h tls1.h +HEADER= $(EXHEADER) ssl_locl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ..; $(MAKE) DIRS=$(DIR) all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + sh $(TOP)/util/ranlib.sh $(LIB) + @touch lib + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + $(TOP)/util/mklink.sh ../include $(EXHEADER) + $(TOP)/util/mklink.sh ../test $(TEST) + $(TOP)/util/mklink.sh ../apps $(APPS) + +install: + @for i in $(EXHEADER) ; \ + do \ + (cp $$i $(INSTALLTOP)/include/$$i; \ + chmod 644 $(INSTALLTOP)/include/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h + perl ../crypto/err/err_genc.pl -s $(ERR).h $(ERRC).c + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/ssl/readme b/src/lib/libssl/src/ssl/readme new file mode 100644 index 0000000000..ca174848a1 --- /dev/null +++ b/src/lib/libssl/src/ssl/readme @@ -0,0 +1,277 @@ +22 Jun 1996 +This file belongs in ../apps, but I'll leave it here because it deals +with SSL :-) It is rather dated but it gives you an idea of how +things work. +=== + +17 Jul 1995 +I have been changing things quite a bit and have not fully updated +this file, so take what you read with a grain of salt +eric +=== +The s_client and s_server programs can be used to test SSL capable +IP/port addresses and the verification of the X509 certificates in use +by these services. I strongly advise having a look at the code to get +an idea of how to use the authentication under SSLeay. Any feedback +on changes and improvements would be greatly accepted. + +This file will probably be gibberish unless you have read +rfc1421, rfc1422, rfc1423 and rfc1424 which describe PEM +authentication. + +A Brief outline (and examples) how to use them to do so. + +NOTE: +The environment variable SSL_CIPER is used to specify the prefered +cipher to use, play around with setting it's value to combinations of +RC4-MD5, EXP-RC4-MD5, CBC-DES-MD5, CBC3-DES-MD5, CFB-DES-NULL +in a : separated list. + +This directory contains 3 X509 certificates which can be used by these programs. +client.pem: a file containing a certificate and private key to be used + by s_client. +server.pem :a file containing a certificate and private key to be used + by s_server. +eay1024.pem:the certificate used to sign client.pem and server.pem. + This would be your CA's certificate. There is also a link + from the file a8556381.0 to eay1024.PEM. The value a8556381 + is returned by 'x509 -hash -noout to exit. Flags are as follows. +-host arg : Arg is the host or IP address to connect to. +-port arg : Arg is the port to connect to (https is 443). +-verify arg : Turn on authentication of the server certificate. + : Arg specifies the 'depth', this will covered below. +-cert arg : The optional certificate to use. This certificate + : will be returned to the server if the server + : requests it for client authentication. +-key arg : The private key that matches the certificate + : specified by the -cert option. If this is not + : specified (but -cert is), the -cert file will be + : searched for the Private key. Both files are + : assumed to be in PEM format. +-CApath arg : When to look for certificates when 'verifying' the + : certificate from the server. +-CAfile arg : A file containing certificates to be used for + : 'verifying' the server certificate. +-reconnect : Once a connection has been made, drop it and + : reconnect with same session-id. This is for testing :-). + +The '-verify n' parameter specifies not only to verify the servers +certificate but to also only take notice of 'n' levels. The best way +to explain is to show via examples. +Given +s_server -cert server.PEM is running. + +s_client + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify error:num=1:unable to get issuer certificate + verify return:1 + CIPHER is CBC-DES-MD5 +What has happened is that the 'SSLeay demo server' certificate's +issuer ('CA') could not be found but because verify is not on, we +don't care and the connection has been made anyway. It is now 'up' +using CBC-DES-MD5 mode. This is an unauthenticate secure channel. +You may not be talking to the right person but the data going to them +is encrypted. + +s_client -verify 0 + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify error:num=1:unable to get issuer certificate + verify return:1 + CIPHER is CBC-DES-MD5 +We are 'verifying' but only to depth 0, so since the 'SSLeay demo server' +certificate passed the date and checksum, we are happy to proceed. + +s_client -verify 1 + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify error:num=1:unable to get issuer certificate + verify return:0 + ERROR + verify error:unable to get issuer certificate +In this case we failed to make the connection because we could not +authenticate the certificate because we could not find the +'CA' certificate. + +s_client -verify 1 -CAfile eay1024.PEM + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + CIPHER is CBC-DES-MD5 +We loaded the certificates from the file eay1024.PEM. Everything +checked out and so we made the connection. + +s_client -verify 1 -CApath . + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + CIPHER is CBC-DES-MD5 +We looked in out local directory for issuer certificates and 'found' +a8556381.0 and so everything is ok. + +It is worth noting that 'CA' is a self certified certificate. If you +are passed one of these, it will fail to 'verify' at depth 0 because +we need to lookup the certifier of a certificate from some information +that we trust and keep locally. + +SSL_CIPHER=CBC3-DES-MD5:RC4-MD5 +export SSL_CIPHER +s_client -verify 10 -CApath . -reconnect + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + drop the connection and reconnect with the same session id + CIPHER is CBC3-DES-MD5 +This has done a full connection and then re-estabished it with the +same session id but a new socket. No RSA stuff occures on the second +connection. Note that we said we would prefer to use CBC3-DES-MD5 +encryption and so, since the server supports it, we are. + +===== +s_server +This program accepts SSL connections on a specified port +Once connected, it will estabish an SSL connection and optionaly +attempt to authenticate the client. A 2 directional channel will be +open. Any text typed will be sent to the other end. Type Q to exit. +Flags are as follows. +-port arg : Arg is the port to listen on. +-verify arg : Turn on authentication of the client if they have a + : certificate. Arg specifies the 'depth'. +-Verify arg : Turn on authentication of the client. If they don't + : have a valid certificate, drop the connection. +-cert arg : The certificate to use. This certificate + : will be passed to the client. If it is not + : specified, it will default to server.PEM +-key arg : The private key that matches the certificate + : specified by the -cert option. If this is not + : specified (but -cert is), the -cert file will be + : searched for the Private key. Both files are + : assumed to be in PEM format. Default is server.PEM +-CApath arg : When to look for certificates when 'verifying' the + : certificate from the client. +-CAfile arg : A file containing certificates to be used for + : 'verifying' the client certificate. + +For the following 'demo' I will specify the s_server command and +the s_client command and then list the output from the s_server. +s_server +s_client + CONNECTED + CIPHER is CBC-DES-MD5 +Everything up and running + +s_server -verify 0 +s_client + CONNECTED + CIPHER is CBC-DES-MD5 +Ok since no certificate was returned and we don't care. + +s_server -verify 0 +./s_client -cert client.PEM + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client + issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify error:num=1:unable to get issuer certificate + verify return:1 + CIPHER is CBC-DES-MD5 +Ok since we were only verifying to level 0 + +s_server -verify 4 +s_client -cert client.PEM + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client + issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify error:num=1:unable to get issuer certificate + verify return:0 + ERROR + verify error:unable to get issuer certificate +Bad because we could not authenticate the returned certificate. + +s_server -verify 4 -CApath . +s_client -cert client.PEM + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + CIPHER is CBC-DES-MD5 +Ok because we could authenticate the returned certificate :-). + +s_server -Verify 0 -CApath . +s_client + CONNECTED + ERROR + SSL error:function is:REQUEST_CERTIFICATE + :error is :client end did not return a certificate +Error because no certificate returned. + +s_server -Verify 4 -CApath . +s_client -cert client.PEM + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + CIPHER is CBC-DES-MD5 +Full authentication of the client. + +So in summary to do full authentication of both ends +s_server -Verify 9 -CApath . +s_client -cert client.PEM -CApath . -verify 9 +From the server side + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + CIPHER is CBC-DES-MD5 +From the client side + CONNECTED + depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server + verify return:1 + depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA + verify return:1 + CIPHER is CBC-DES-MD5 + +For general probing of the 'internet https' servers for the +distribution area, run +s_client -host www.netscape.com -port 443 -verify 4 -CApath ../rsa/hash +Then enter +GET / +and you should be talking to the https server on that host. + +www.rsa.com was refusing to respond to connections on 443 when I was +testing. + +have fun :-). + +eric diff --git a/src/lib/libssl/src/ssl/ssl.c b/src/lib/libssl/src/ssl/ssl.c new file mode 100644 index 0000000000..7f506ce48f --- /dev/null +++ b/src/lib/libssl/src/ssl/ssl.c @@ -0,0 +1,172 @@ +/* ssl/ssl.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include + +#define USE_SOCKETS +#include "../e_os.h" + +#include "buffer.h" +#include "stack.h" +#include "lhash.h" + +#include "bio.h" +#include "err.h" + +#include "bn.h" + +#include "rand.h" +#include "conf.h" +#include "txt_db.h" + +#include "err.h" +#include "evp.h" + +#include "x509.h" +#include "pkcs7.h" +#include "pem.h" +#include "asn1.h" +#include "objects.h" + +#include "ssl_locl.h" + +#if !(BUILD_SSLV23) && !defined(BUILD_SSLV2) && !defined(BUILD_SSLV3) && !defined(BUILD_SSL_COMMON) && !defined(BUILD_SSL_BIO) && !defined(BUILD_SSL_OPTIONAL) +#define BUILD_SSLV23 +#define BUILD_SSLV2 +#define BUILD_SSLV3 +#define BUILD_TLS1 +#define BUILD_SSL_COMMON +#define BUILD_SSL_BIO +#define BUILD_SSL_OPTIONAL +#endif + +#ifdef NO_RSA +#undef BUILD_SSLV2 +#undef BUILD_SSLV23 +#endif + +#ifdef NO_SSL2 +#undef BUILD_SSLV2 +#undef BUILD_SSLV23 +#endif + +#ifdef NO_SSL3 +#undef BUILD_SSL3 +#undef BUILD_SSLV23 +#endif + +#ifdef BUILD_SSLV23 +#include "s23_clnt.c" +#include "s23_srvr.c" +#include "s23_pkt.c" +#include "s23_lib.c" +#include "s23_meth.c" +#endif + +#ifdef BUILD_SSLV2 +#include "s2_clnt.c" +#include "s2_srvr.c" +#include "s2_pkt.c" +#include "s2_enc.c" +#include "s2_lib.c" +#include "s2_meth.c" +#endif + +#ifdef BUILD_SSLV3 +#include "s3_clnt.c" +#include "s3_both.c" +#include "s3_srvr.c" +#include "s3_pkt.c" +#include "s3_enc.c" +#include "s3_lib.c" +#include "s3_meth.c" +#endif + +#ifdef BUILD_TLS1 +#include "t1_clnt.c" +#include "t1_enc.c" +#include "t1_lib.c" +#include "t1_meth.c" +#include "t1_srvr.c" +#endif + + +#ifdef BUILD_SSL_COMMON +#include "ssl_lib.c" +#include "ssl_algs.c" +#include "ssl_cert.c" +#include "ssl_ciph.c" +#include "ssl_sess.c" +#include "ssl_rsa.c" +#endif + +/* Extra things */ +#ifdef BUILD_SSL_BIO +#include "bio_ssl.c" +#endif + +#ifdef BUILD_SSL_OPTIONAL +#include "ssl_asn1.c" +#include "ssl_txt.c" +#include "ssl_stat.c" +#include "ssl_err.c" +#include "ssl_err2.c" +#endif + diff --git a/src/lib/libssl/src/ssl/ssl.err b/src/lib/libssl/src/ssl/ssl.err new file mode 100644 index 0000000000..c54326c624 --- /dev/null +++ b/src/lib/libssl/src/ssl/ssl.err @@ -0,0 +1,290 @@ +/* Error codes for the SSL functions. */ + +/* Function codes. */ +#define SSL_F_CLIENT_CERTIFICATE 100 +#define SSL_F_CLIENT_HELLO 101 +#define SSL_F_CLIENT_MASTER_KEY 102 +#define SSL_F_D2I_SSL_SESSION 103 +#define SSL_F_DO_SSL3_WRITE 104 +#define SSL_F_GET_CLIENT_FINISHED 105 +#define SSL_F_GET_CLIENT_HELLO 106 +#define SSL_F_GET_CLIENT_MASTER_KEY 107 +#define SSL_F_GET_SERVER_FINISHED 108 +#define SSL_F_GET_SERVER_HELLO 109 +#define SSL_F_GET_SERVER_VERIFY 110 +#define SSL_F_I2D_SSL_SESSION 111 +#define SSL_F_READ_N 112 +#define SSL_F_REQUEST_CERTIFICATE 113 +#define SSL_F_SERVER_HELLO 114 +#define SSL_F_SSL23_ACCEPT 115 +#define SSL_F_SSL23_CLIENT_HELLO 116 +#define SSL_F_SSL23_CONNECT 117 +#define SSL_F_SSL23_GET_CLIENT_HELLO 118 +#define SSL_F_SSL23_GET_SERVER_HELLO 119 +#define SSL_F_SSL23_READ 120 +#define SSL_F_SSL23_WRITE 121 +#define SSL_F_SSL2_ACCEPT 122 +#define SSL_F_SSL2_CONNECT 123 +#define SSL_F_SSL2_ENC_INIT 124 +#define SSL_F_SSL2_READ 125 +#define SSL_F_SSL2_SET_CERTIFICATE 126 +#define SSL_F_SSL2_WRITE 127 +#define SSL_F_SSL3_ACCEPT 128 +#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 +#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CLIENT_HELLO 131 +#define SSL_F_SSL3_CONNECT 132 +#define SSL_F_SSL3_CTX_CTRL 133 +#define SSL_F_SSL3_ENC 134 +#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 +#define SSL_F_SSL3_GET_CERT_VERIFY 136 +#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 +#define SSL_F_SSL3_GET_CLIENT_HELLO 138 +#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139 +#define SSL_F_SSL3_GET_FINISHED 140 +#define SSL_F_SSL3_GET_KEY_EXCHANGE 141 +#define SSL_F_SSL3_GET_MESSAGE 142 +#define SSL_F_SSL3_GET_RECORD 143 +#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144 +#define SSL_F_SSL3_GET_SERVER_DONE 145 +#define SSL_F_SSL3_GET_SERVER_HELLO 146 +#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 +#define SSL_F_SSL3_READ_BYTES 148 +#define SSL_F_SSL3_READ_N 149 +#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 +#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151 +#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152 +#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153 +#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154 +#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155 +#define SSL_F_SSL3_SETUP_BUFFERS 156 +#define SSL_F_SSL3_SETUP_KEY_BLOCK 157 +#define SSL_F_SSL3_WRITE_BYTES 158 +#define SSL_F_SSL3_WRITE_PENDING 159 +#define SSL_F_SSL_BAD_METHOD 160 +#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 +#define SSL_F_SSL_CERT_NEW 162 +#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 +#define SSL_F_SSL_CREATE_CIPHER_LIST 164 +#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 165 +#define SSL_F_SSL_CTX_NEW 166 +#define SSL_F_SSL_CTX_SET_SSL_VERSION 167 +#define SSL_F_SSL_CTX_USE_CERTIFICATE 168 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 169 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 170 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY 171 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 172 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 173 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 174 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 175 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 176 +#define SSL_F_SSL_DO_HANDSHAKE 177 +#define SSL_F_SSL_GET_NEW_SESSION 178 +#define SSL_F_SSL_GET_SERVER_SEND_CERT 179 +#define SSL_F_SSL_GET_SIGN_PKEY 180 +#define SSL_F_SSL_INIT_WBIO_BUFFER 181 +#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 182 +#define SSL_F_SSL_NEW 183 +#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 184 +#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 185 +#define SSL_F_SSL_SESSION_NEW 186 +#define SSL_F_SSL_SESSION_PRINT_FP 187 +#define SSL_F_SSL_SET_CERT 188 +#define SSL_F_SSL_SET_FD 189 +#define SSL_F_SSL_SET_PKEY 190 +#define SSL_F_SSL_SET_RFD 191 +#define SSL_F_SSL_SET_SESSION 192 +#define SSL_F_SSL_SET_WFD 193 +#define SSL_F_SSL_UNDEFINED_FUNCTION 194 +#define SSL_F_SSL_USE_CERTIFICATE 195 +#define SSL_F_SSL_USE_CERTIFICATE_ASN1 196 +#define SSL_F_SSL_USE_CERTIFICATE_FILE 197 +#define SSL_F_SSL_USE_PRIVATEKEY 198 +#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 199 +#define SSL_F_SSL_USE_PRIVATEKEY_FILE 200 +#define SSL_F_SSL_USE_RSAPRIVATEKEY 201 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 202 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 203 +#define SSL_F_SSL_WRITE 204 +#define SSL_F_TLS1_CHANGE_CIPHER_STATE 205 +#define SSL_F_TLS1_ENC 206 +#define SSL_F_TLS1_SETUP_KEY_BLOCK 207 +#define SSL_F_WRITE_PENDING 208 + +/* Reason codes. */ +#define SSL_R_APP_DATA_IN_HANDSHAKE 100 +#define SSL_R_BAD_ALERT_RECORD 101 +#define SSL_R_BAD_AUTHENTICATION_TYPE 102 +#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 +#define SSL_R_BAD_CHECKSUM 104 +#define SSL_R_BAD_CLIENT_REQUEST 105 +#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 +#define SSL_R_BAD_DECOMPRESSION 107 +#define SSL_R_BAD_DH_G_LENGTH 108 +#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 +#define SSL_R_BAD_DH_P_LENGTH 110 +#define SSL_R_BAD_DIGEST_LENGTH 111 +#define SSL_R_BAD_DSA_SIGNATURE 112 +#define SSL_R_BAD_MAC_DECODE 113 +#define SSL_R_BAD_MESSAGE_TYPE 114 +#define SSL_R_BAD_PACKET_LENGTH 115 +#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 +#define SSL_R_BAD_RESPONSE_ARGUMENT 117 +#define SSL_R_BAD_RSA_DECRYPT 118 +#define SSL_R_BAD_RSA_ENCRYPT 119 +#define SSL_R_BAD_RSA_E_LENGTH 120 +#define SSL_R_BAD_RSA_MODULUS_LENGTH 121 +#define SSL_R_BAD_RSA_SIGNATURE 122 +#define SSL_R_BAD_SIGNATURE 123 +#define SSL_R_BAD_SSL_FILETYPE 124 +#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125 +#define SSL_R_BAD_STATE 126 +#define SSL_R_BAD_WRITE_RETRY 127 +#define SSL_R_BIO_NOT_SET 128 +#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 +#define SSL_R_BN_LIB 130 +#define SSL_R_CA_DN_LENGTH_MISMATCH 131 +#define SSL_R_CA_DN_TOO_LONG 132 +#define SSL_R_CCS_RECEIVED_EARLY 133 +#define SSL_R_CERTIFICATE_VERIFY_FAILED 134 +#define SSL_R_CERT_LENGTH_MISMATCH 135 +#define SSL_R_CHALLENGE_IS_DIFFERENT 136 +#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 +#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 +#define SSL_R_CIPHER_TABLE_SRC_ERROR 139 +#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 +#define SSL_R_COMPRESSION_FAILURE 141 +#define SSL_R_CONNECTION_ID_IS_DIFFERENT 142 +#define SSL_R_CONNECTION_TYPE_NOT_SET 143 +#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 144 +#define SSL_R_DATA_LENGTH_TOO_LONG 145 +#define SSL_R_DECRYPTION_FAILED 146 +#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 147 +#define SSL_R_DIGEST_CHECK_FAILED 148 +#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 149 +#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 150 +#define SSL_R_EXCESSIVE_MESSAGE_SIZE 151 +#define SSL_R_EXTRA_DATA_IN_MESSAGE 152 +#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 153 +#define SSL_R_HTTPS_PROXY_REQUEST 154 +#define SSL_R_HTTP_REQUEST 155 +#define SSL_R_INTERNAL_ERROR 156 +#define SSL_R_INVALID_CHALLENGE_LENGTH 157 +#define SSL_R_LENGTH_MISMATCH 158 +#define SSL_R_LENGTH_TOO_SHORT 159 +#define SSL_R_LIBRARY_HAS_NO_CIPHERS 160 +#define SSL_R_MISSING_DH_DSA_CERT 161 +#define SSL_R_MISSING_DH_KEY 162 +#define SSL_R_MISSING_DH_RSA_CERT 163 +#define SSL_R_MISSING_DSA_SIGNING_CERT 164 +#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 165 +#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 166 +#define SSL_R_MISSING_RSA_CERTIFICATE 167 +#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 168 +#define SSL_R_MISSING_RSA_SIGNING_CERT 169 +#define SSL_R_MISSING_TMP_DH_KEY 170 +#define SSL_R_MISSING_TMP_RSA_KEY 171 +#define SSL_R_MISSING_TMP_RSA_PKEY 172 +#define SSL_R_MISSING_VERIFY_MESSAGE 173 +#define SSL_R_NON_SSLV2_INITIAL_PACKET 174 +#define SSL_R_NO_CERTIFICATES_RETURNED 175 +#define SSL_R_NO_CERTIFICATE_ASSIGNED 176 +#define SSL_R_NO_CERTIFICATE_RETURNED 177 +#define SSL_R_NO_CERTIFICATE_SET 178 +#define SSL_R_NO_CERTIFICATE_SPECIFIED 179 +#define SSL_R_NO_CIPHERS_AVAILABLE 180 +#define SSL_R_NO_CIPHERS_PASSED 181 +#define SSL_R_NO_CIPHERS_SPECIFIED 182 +#define SSL_R_NO_CIPHER_LIST 183 +#define SSL_R_NO_CIPHER_MATCH 184 +#define SSL_R_NO_CLIENT_CERT_RECEIVED 185 +#define SSL_R_NO_COMPRESSION_SPECIFIED 186 +#define SSL_R_NO_PRIVATEKEY 187 +#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 188 +#define SSL_R_NO_PROTOCOLS_AVAILABLE 189 +#define SSL_R_NO_PUBLICKEY 190 +#define SSL_R_NO_SHARED_CIPHER 191 +#define SSL_R_NULL_SSL_CTX 192 +#define SSL_R_NULL_SSL_METHOD_PASSED 193 +#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 194 +#define SSL_R_PACKET_LENGTH_TOO_LONG 195 +#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 196 +#define SSL_R_PEER_ERROR 197 +#define SSL_R_PEER_ERROR_CERTIFICATE 198 +#define SSL_R_PEER_ERROR_NO_CERTIFICATE 199 +#define SSL_R_PEER_ERROR_NO_CIPHER 200 +#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 201 +#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 202 +#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 203 +#define SSL_R_PROTOCOL_IS_SHUTDOWN 204 +#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 205 +#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 206 +#define SSL_R_PUBLIC_KEY_NOT_RSA 207 +#define SSL_R_READ_BIO_NOT_SET 208 +#define SSL_R_READ_WRONG_PACKET_TYPE 209 +#define SSL_R_RECORD_LENGTH_MISMATCH 210 +#define SSL_R_RECORD_TOO_LARGE 211 +#define SSL_R_REQUIRED_CIPHER_MISSING 212 +#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 213 +#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 214 +#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 215 +#define SSL_R_SHORT_READ 216 +#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 217 +#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 218 +#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 +#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +#define SSL_R_SSLV3_ALERT_PEER_ERROR_CERTIFICATE 219 +#define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CERTIFICATE 220 +#define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CIPHER 221 +#define SSL_R_SSLV3_ALERT_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 222 +#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +#define SSL_R_SSLV3_ALERT_UNKNOWN_REMOTE_ERROR_TYPE 223 +#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 224 +#define SSL_R_SSL_HANDSHAKE_FAILURE 225 +#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 226 +#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 227 +#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 228 +#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 229 +#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 230 +#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 231 +#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 232 +#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 233 +#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 234 +#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 235 +#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 236 +#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 237 +#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 238 +#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 239 +#define SSL_R_UNEXPECTED_MESSAGE 240 +#define SSL_R_UNEXPECTED_RECORD 241 +#define SSL_R_UNKNOWN_ALERT_TYPE 242 +#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 243 +#define SSL_R_UNKNOWN_CIPHER_RETURNED 244 +#define SSL_R_UNKNOWN_CIPHER_TYPE 245 +#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 246 +#define SSL_R_UNKNOWN_PKEY_TYPE 247 +#define SSL_R_UNKNOWN_PROTOCOL 248 +#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 249 +#define SSL_R_UNKNOWN_SSL_VERSION 250 +#define SSL_R_UNKNOWN_STATE 251 +#define SSL_R_UNSUPPORTED_CIPHER 252 +#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 253 +#define SSL_R_UNSUPPORTED_PROTOCOL 254 +#define SSL_R_UNSUPPORTED_SSL_VERSION 255 +#define SSL_R_WRITE_BIO_NOT_SET 256 +#define SSL_R_WRONG_CIPHER_RETURNED 257 +#define SSL_R_WRONG_MESSAGE_TYPE 258 +#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 259 +#define SSL_R_WRONG_SIGNATURE_LENGTH 260 +#define SSL_R_WRONG_SIGNATURE_SIZE 261 +#define SSL_R_WRONG_SSL_VERSION 262 +#define SSL_R_WRONG_VERSION_NUMBER 263 +#define SSL_R_X509_LIB 264 diff --git a/src/lib/libssl/src/test/.rnd b/src/lib/libssl/src/test/.rnd new file mode 100644 index 0000000000..234970e241 Binary files /dev/null and b/src/lib/libssl/src/test/.rnd differ diff --git a/src/lib/libssl/src/test/Makefile.ssl b/src/lib/libssl/src/test/Makefile.ssl new file mode 100644 index 0000000000..b3de76751e --- /dev/null +++ b/src/lib/libssl/src/test/Makefile.ssl @@ -0,0 +1,294 @@ +# +# test/Makefile.ssl +# + +DIR= test +TOP= .. +CC= cc +INCLUDES= -I../include +CFLAG= -g +INSTALLTOP= /usr/local/ssl +MAKEFILE= Makefile.ssl +MAKE= make -f $(MAKEFILE) +MAKEDEPEND= makedepend -f$(MAKEFILE) + +PEX_LIBS= +EX_LIBS= #-lnsl -lsocket + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile.ssl + +DLIBCRYPTO= ../libcrypto.a +DLIBSSL= ../libssl.a +LIBCRYPTO= -L.. -lcrypto +LIBSSL= -L.. -lssl + +BNTEST= bntest +EXPTEST= exptest +IDEATEST= ideatest +SHATEST= shatest +SHA1TEST= sha1test +MDC2TEST= mdc2test +RMDTEST= rmdtest +MD2TEST= md2test +MD5TEST= md5test +HMACTEST= hmactest +RC2TEST= rc2test +RC4TEST= rc4test +RC5TEST= rc5test +BFTEST= bftest +CASTTEST= casttest +DESTEST= destest +RANDTEST= randtest +DHTEST= dhtest +DSATEST= dsatest +METHTEST= methtest +SSLTEST= ssltest + +EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \ + $(RC2TEST) $(RC4TEST) $(RC5TEST) \ + $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \ + $(RANDTEST) $(DHTEST) \ + $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) + +# $(METHTEST) + +OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \ + $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \ + $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \ + $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \ + $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o +SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \ + $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \ + $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \ + $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \ + $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ..; $(MAKE) DIRS=$(DIR) all) + +all: exe + +exe: $(EXE) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + +errors: + +install: + +tags: + ctags $(SRC) + +tests: exe apps \ + test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \ + test_rc2 test_rc4 test_rc5 test_bf test_cast \ + test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \ + test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \ + test_ss test_ssl test_ca + +apps: + @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all) + +test_des: + #./$(DESTEST) + +test_idea: + ./$(IDEATEST) + +test_sha: + ./$(SHATEST) + ./$(SHA1TEST) + +test_mdc2: + ./$(MDC2TEST) + +test_md5: + ./$(MD5TEST) + +test_hmac: + ./$(HMACTEST) + +test_md2: + ./$(MD2TEST) + +test_rmd: + ./$(RMDTEST) + +test_bf: + ./$(BFTEST) + +test_cast: + ./$(CASTTEST) + +test_rc2: + ./$(RC2TEST) + +test_rc4: + ./$(RC4TEST) + +test_rc5: + ./$(RC5TEST) + +test_rand: + ./$(RANDTEST) + +test_enc: + @sh ./testenc + +test_x509: + echo test normal x509v1 certificate + sh ./tx509 2>/dev/null + echo test first x509v3 certificate + sh ./tx509 v3-cert1.pem 2>/dev/null + echo test second x509v3 certificate + sh ./tx509 v3-cert2.pem 2>/dev/null + +test_rsa: + @sh ./trsa 2>/dev/null + +test_crl: + @sh ./tcrl 2>/dev/null + +test_sid: + @sh ./tsid 2>/dev/null + +test_req: + @sh ./treq 2>/dev/null + @sh ./treq testreq2.pem 2>/dev/null + +test_pkcs7: + @sh ./tpkcs7 2>/dev/null + @sh ./tpkcs7d 2>/dev/null + +test_bn: + @echo 'test a^b%c implementations' + ./$(EXPTEST) + @echo starting big number library test, could take a while... + @(./$(BNTEST)|bc) | awk '{ \ +if ($$0 != "0") {print "error"; exit(1); } \ +if (((NR+1)%64) == 0) print NR+1," tests done"; }' + +test_verify: + @echo "The following command should have some OK's and some failures" + @echo "There are definitly a few expired certificates" + ../apps/ssleay verify -CApath ../certs ../certs/*.pem + +test_dh: + @echo "Generate as set of DH parameters" + ./$(DHTEST) + +test_dsa: + @echo "Generate as set of DSA parameters" + ./$(DSATEST) + +test_reqgen: + @echo "Generate and verify a certificate request" + @sh ./testgen + +test_ss: + @echo "Generate and certify a test certificate" + @sh ./testss + +test_ssl: + @echo "test SSL protocol" + @sh ./testssl + +test_ca: + @echo "Generate and certify a test certificate via the 'ca' program" + @sh ./testca + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log + +$(DLIBSSL): + (cd ../ssl; $(MAKE)) + +$(DLIBCRYPTO): + (cd ../crypto; $(MAKE)) + +$(BNTEST): $(BNTEST).o $(DLIBCRYPTO) + $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO) + $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO) + $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHATEST): $(SHATEST).o $(DLIBCRYPTO) + $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO) + $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO) + $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(BFTEST): $(BFTEST).o $(DLIBCRYPTO) + $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO) + $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DESTEST): $(DESTEST).o $(DLIBCRYPTO) + $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DHTEST): $(DHTEST).o $(DLIBCRYPTO) + $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DSATEST): $(DSATEST).o $(DLIBCRYPTO) + $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(METHTEST): $(METHTEST).o $(DLIBCRYPTO) + $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) + $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/test/certCA.srl b/src/lib/libssl/src/test/certCA.srl new file mode 100644 index 0000000000..39f5b69311 --- /dev/null +++ b/src/lib/libssl/src/test/certCA.srl @@ -0,0 +1 @@ +71 diff --git a/src/lib/libssl/src/test/demoCA/index.txt b/src/lib/libssl/src/test/demoCA/index.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/lib/libssl/src/test/demoCA/private/cakey.pem b/src/lib/libssl/src/test/demoCA/private/cakey.pem new file mode 100644 index 0000000000..edd5a5773f --- /dev/null +++ b/src/lib/libssl/src/test/demoCA/private/cakey.pem @@ -0,0 +1,2 @@ +-----BEGIN RSA PRIVATE KEY----- +-----END RSA PRIVATE KEY----- diff --git a/src/lib/libssl/src/test/demoCA/serial b/src/lib/libssl/src/test/demoCA/serial new file mode 100644 index 0000000000..8a0f05e166 --- /dev/null +++ b/src/lib/libssl/src/test/demoCA/serial @@ -0,0 +1 @@ +01 diff --git a/src/lib/libssl/src/test/dsa-ca.pem b/src/lib/libssl/src/test/dsa-ca.pem new file mode 100644 index 0000000000..9eb08f3ddd --- /dev/null +++ b/src/lib/libssl/src/test/dsa-ca.pem @@ -0,0 +1,43 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0 + +svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0 +Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl +Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/ +par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr +zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO +uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5 +rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx +1QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4 +HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827 +MVqOsYxGCb+kez0FoDSTgw== +-----END DSA PRIVATE KEY----- +-----BEGIN CERTIFICATE REQUEST----- +MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx +ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew +ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW +sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m +rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk +cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo +bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR +CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB +F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH +vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq +AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u +3enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v +AhQfeF5BoMMDbX/kidUVpQ6gadPlZA== +-----END CERTIFICATE REQUEST----- +-----BEGIN CERTIFICATE----- +MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK +U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww +CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw +CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu +ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE +AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi +ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh +MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD +MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa +C1Q= +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/test/dsa-pca.pem b/src/lib/libssl/src/test/dsa-pca.pem new file mode 100644 index 0000000000..e3641ad47e --- /dev/null +++ b/src/lib/libssl/src/test/dsa-pca.pem @@ -0,0 +1,49 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4 + +GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS +mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt +of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr +FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX +RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd +qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1 +diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn +V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h +hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf +dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7 +-----END DSA PRIVATE KEY----- +-----BEGIN CERTIFICATE REQUEST----- +MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx +ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB +MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G +lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O +Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR +5HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl +aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6 +kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als +QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe +6NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ +yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0 +z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB +nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w== +-----END CERTIFICATE REQUEST----- +-----BEGIN CERTIFICATE----- +MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK +U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww +CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw +CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu +ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww +ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ +R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5 +JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps +BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze +mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO +VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C +uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk +umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A +29nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D +AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n +5rKUjNBhSg== +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/src/test/p b/src/lib/libssl/src/test/p new file mode 100644 index 0000000000..b3de76751e --- /dev/null +++ b/src/lib/libssl/src/test/p @@ -0,0 +1,294 @@ +# +# test/Makefile.ssl +# + +DIR= test +TOP= .. +CC= cc +INCLUDES= -I../include +CFLAG= -g +INSTALLTOP= /usr/local/ssl +MAKEFILE= Makefile.ssl +MAKE= make -f $(MAKEFILE) +MAKEDEPEND= makedepend -f$(MAKEFILE) + +PEX_LIBS= +EX_LIBS= #-lnsl -lsocket + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile.ssl + +DLIBCRYPTO= ../libcrypto.a +DLIBSSL= ../libssl.a +LIBCRYPTO= -L.. -lcrypto +LIBSSL= -L.. -lssl + +BNTEST= bntest +EXPTEST= exptest +IDEATEST= ideatest +SHATEST= shatest +SHA1TEST= sha1test +MDC2TEST= mdc2test +RMDTEST= rmdtest +MD2TEST= md2test +MD5TEST= md5test +HMACTEST= hmactest +RC2TEST= rc2test +RC4TEST= rc4test +RC5TEST= rc5test +BFTEST= bftest +CASTTEST= casttest +DESTEST= destest +RANDTEST= randtest +DHTEST= dhtest +DSATEST= dsatest +METHTEST= methtest +SSLTEST= ssltest + +EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \ + $(RC2TEST) $(RC4TEST) $(RC5TEST) \ + $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \ + $(RANDTEST) $(DHTEST) \ + $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) + +# $(METHTEST) + +OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \ + $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \ + $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \ + $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \ + $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o +SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \ + $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \ + $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \ + $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \ + $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ..; $(MAKE) DIRS=$(DIR) all) + +all: exe + +exe: $(EXE) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + +errors: + +install: + +tags: + ctags $(SRC) + +tests: exe apps \ + test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \ + test_rc2 test_rc4 test_rc5 test_bf test_cast \ + test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \ + test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \ + test_ss test_ssl test_ca + +apps: + @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all) + +test_des: + #./$(DESTEST) + +test_idea: + ./$(IDEATEST) + +test_sha: + ./$(SHATEST) + ./$(SHA1TEST) + +test_mdc2: + ./$(MDC2TEST) + +test_md5: + ./$(MD5TEST) + +test_hmac: + ./$(HMACTEST) + +test_md2: + ./$(MD2TEST) + +test_rmd: + ./$(RMDTEST) + +test_bf: + ./$(BFTEST) + +test_cast: + ./$(CASTTEST) + +test_rc2: + ./$(RC2TEST) + +test_rc4: + ./$(RC4TEST) + +test_rc5: + ./$(RC5TEST) + +test_rand: + ./$(RANDTEST) + +test_enc: + @sh ./testenc + +test_x509: + echo test normal x509v1 certificate + sh ./tx509 2>/dev/null + echo test first x509v3 certificate + sh ./tx509 v3-cert1.pem 2>/dev/null + echo test second x509v3 certificate + sh ./tx509 v3-cert2.pem 2>/dev/null + +test_rsa: + @sh ./trsa 2>/dev/null + +test_crl: + @sh ./tcrl 2>/dev/null + +test_sid: + @sh ./tsid 2>/dev/null + +test_req: + @sh ./treq 2>/dev/null + @sh ./treq testreq2.pem 2>/dev/null + +test_pkcs7: + @sh ./tpkcs7 2>/dev/null + @sh ./tpkcs7d 2>/dev/null + +test_bn: + @echo 'test a^b%c implementations' + ./$(EXPTEST) + @echo starting big number library test, could take a while... + @(./$(BNTEST)|bc) | awk '{ \ +if ($$0 != "0") {print "error"; exit(1); } \ +if (((NR+1)%64) == 0) print NR+1," tests done"; }' + +test_verify: + @echo "The following command should have some OK's and some failures" + @echo "There are definitly a few expired certificates" + ../apps/ssleay verify -CApath ../certs ../certs/*.pem + +test_dh: + @echo "Generate as set of DH parameters" + ./$(DHTEST) + +test_dsa: + @echo "Generate as set of DSA parameters" + ./$(DSATEST) + +test_reqgen: + @echo "Generate and verify a certificate request" + @sh ./testgen + +test_ss: + @echo "Generate and certify a test certificate" + @sh ./testss + +test_ssl: + @echo "test SSL protocol" + @sh ./testssl + +test_ca: + @echo "Generate and certify a test certificate via the 'ca' program" + @sh ./testca + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log + +$(DLIBSSL): + (cd ../ssl; $(MAKE)) + +$(DLIBCRYPTO): + (cd ../crypto; $(MAKE)) + +$(BNTEST): $(BNTEST).o $(DLIBCRYPTO) + $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO) + $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO) + $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHATEST): $(SHATEST).o $(DLIBCRYPTO) + $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO) + $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO) + $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(BFTEST): $(BFTEST).o $(DLIBCRYPTO) + $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO) + $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DESTEST): $(DESTEST).o $(DLIBCRYPTO) + $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DHTEST): $(DHTEST).o $(DLIBCRYPTO) + $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DSATEST): $(DSATEST).o $(DLIBCRYPTO) + $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(METHTEST): $(METHTEST).o $(DLIBCRYPTO) + $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) + $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/test/riptest b/src/lib/libssl/src/test/riptest new file mode 100644 index 0000000000..8685d0ce53 Binary files /dev/null and b/src/lib/libssl/src/test/riptest differ diff --git a/src/lib/libssl/src/test/test.txt b/src/lib/libssl/src/test/test.txt new file mode 100644 index 0000000000..c6d8d50ba9 --- /dev/null +++ b/src/lib/libssl/src/test/test.txt @@ -0,0 +1,31 @@ +#!/bin/sh + +test=./test.txt + +cat $0 >$test; + +for i in rc4 des-cfb des-ofb des-ecb des-cbc des-ede des-ede3 \ + des-cbc-ede des-cbc-ede3 idea-ecb idea-cfb idea-ofb idea-cbc +do + echo $i + ../apps/ssleay $i -e -k test < $test > $test.$i.cipher + ../apps/ssleay $i -d -k test < $test.$i.cipher >$test.$i.clear + cmp $test $test.$i.clear + if [ $? != 0 ] + then + exit 1 + else + /bin/rm $test.$i.cipher $test.$i.clear + fi + + echo $i base64 + ../apps/ssleay $i -a -e -k test < $test > $test.$i.cipher + ../apps/ssleay $i -a -d -k test < $test.$i.cipher >$test.$i.clear + cmp $test $test.$i.clear + if [ $? != 0 ] + then + exit 1 + else + /bin/rm $test.$i.cipher $test.$i.clear + fi +done diff --git a/src/lib/libssl/src/test/testkey.pem b/src/lib/libssl/src/test/testkey.pem new file mode 100644 index 0000000000..edd5a5773f --- /dev/null +++ b/src/lib/libssl/src/test/testkey.pem @@ -0,0 +1,2 @@ +-----BEGIN RSA PRIVATE KEY----- +-----END RSA PRIVATE KEY----- diff --git a/src/lib/libssl/src/test/testreq.pem b/src/lib/libssl/src/test/testreq.pem new file mode 100644 index 0000000000..1311fa7785 --- /dev/null +++ b/src/lib/libssl/src/test/testreq.pem @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBQjCB7QIBADCBhzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx +ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDET +MBEGA1UEAxMKRXJpYyBZb3VuZzEfMB0GCSqGSIb3DQEJARYQZWF5QG1pbmNvbS5v +ei5hdTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDVKdT5QB2ZojtNQGjA/9J7s2o4 +RNkuSq8l377uWLAyMljtdkcoRsvUy5lZ997UDHFTbVFA038ZBrmw7l5EyHeXAgMB +AAGgADANBgkqhkiG9w0BAQQFAANBAKnaFr4u7PTdfmpjiX/H8Ho4UWGVRWUlvD2R +/D9yoTj7TN3uODx2BD0drErVBe/Zjv81vhH6Yo3cJO/hRS3A7jw= +-----END CERTIFICATE REQUEST----- diff --git a/src/lib/libssl/src/tools/Makefile.ssl b/src/lib/libssl/src/tools/Makefile.ssl new file mode 100644 index 0000000000..537e97d268 --- /dev/null +++ b/src/lib/libssl/src/tools/Makefile.ssl @@ -0,0 +1,54 @@ +# +# SSLeay/tools/Makefile +# + +DIR= tools +TOP= .. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= makedepend -f Makefile.ssl +MAKEFILE= Makefile.ssl + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile.ssl +TEST= +APPS= c_hash c_info c_issuer c_name c_rehash + +all: + +install: + @for i in $(APPS) ; \ + do \ + (cp $$i $(INSTALLTOP)/bin/$$i; \ + chmod 755 $(INSTALLTOP)/bin/$$i ); \ + done; + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + +lint: + +tags: + +errors: + +depend: + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +errors: + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/src/util/mklink.sh b/src/lib/libssl/src/util/mklink.sh new file mode 100644 index 0000000000..1e052ed6ee --- /dev/null +++ b/src/lib/libssl/src/util/mklink.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# A bit of an ugly shell script used to actually 'link' files. +# Used by 'make links' +# + +PATH=$PATH:.:util:../util:../../util +export PATH + +from=$1 +shift + +here=`pwd` +tmp=`dirname $from` +while [ "$tmp"x != "x" -a "$tmp"x != ".x" ] +do + t=`basename $here` + here=`dirname $here` + to="/$t$to" + tmp=`dirname $tmp` +done +to=..$to + +#echo from=$from +#echo to =$to +#exit 1 + +if [ "$*"x != "x" ]; then + for i in $* + do + /bin/rm -f $from/$i + point.sh $to/$i $from/$i + done +fi +exit 0; diff --git a/src/lib/libssl/src/util/ranlib.sh b/src/lib/libssl/src/util/ranlib.sh new file mode 100644 index 0000000000..543f712c6b --- /dev/null +++ b/src/lib/libssl/src/util/ranlib.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cwd=`pwd` +cd /tmp + +if [ -s /bin/ranlib ] ; then + RL=/bin/ranlib +else if [ -s /usr/bin/ranlib ] ; then + RL=/usr/bin/ranlib +fi +fi + +if [ "x$RL" != "x" ] +then + case "$1" in + /*) + $RL "$1" + ;; + *) + $RL "$cwd/$1" + ;; + esac +fi diff --git a/src/lib/libssl/src/util/sep_lib.sh b/src/lib/libssl/src/util/sep_lib.sh new file mode 100644 index 0000000000..2348db874e --- /dev/null +++ b/src/lib/libssl/src/util/sep_lib.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +cwd=`pwd` +/bin/rm -fr tmp/* + +cd crypto/des +make -f Makefile.uni tar +make -f Makefile.uni tar_lit +/bin/mv libdes.tgz $cwd/tmp +/bin/mv libdes-l.tgz $cwd/tmp +cd $cwd + +for name in md5 sha cast bf idea rc4 rc2 +do + echo doing $name + (cd crypto; tar cfh - $name)|(cd tmp; tar xf -) + cd tmp/$name + /bin/rm -f Makefile + /bin/rm -f Makefile.ssl + /bin/rm -f Makefile.ssl.orig + /bin/rm -f *.old + /bin/mv Makefile.uni Makefile + + cp $cwd/util/ranlib.sh . + chmod +x ranlib.sh + + if [ -d asm ]; then + mkdir asm/perlasm + cp $cwd/crypto/perlasm/*.pl asm/perlasm + fi + cd .. + tar cf - $name|gzip >$name.tgz +# /bin/rm -fr $name + cd $cwd +done + + diff --git a/src/lib/libssl/src/util/ssldir.pl b/src/lib/libssl/src/util/ssldir.pl new file mode 100644 index 0000000000..10584686da --- /dev/null +++ b/src/lib/libssl/src/util/ssldir.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +$#ARGV == 0 || die "usage: ssldir.pl /new/path\n"; +@files=('crypto/cryptlib.h', + 'Makefile.ssl', + 'tools/c_rehash', + 'util/mk1mf.pl', + ); + +%cryptlib=( + '\sX509_CERT_AREA\s',"#define X509_CERT_AREA\t\t".'"%s"', + '\sX509_CERT_DIR\s', "#define X509_CERT_DIR\t\t".'"%s/certs"', + '\sX509_CERT_FILE\s', "#define X509_CERT_FILE\t\t".'"%s/cert.pem"', + '\sX509_PRIVATE_DIR\s',"#define X509_PRIVATE_DIR\t".'"%s/private"', + ); + +%Makefile_ssl=( + '^INSTALLTOP=','INSTALLTOP=%s', + ); + +%c_rehash=( + '^DIR=', 'DIR=%s', + ); + +%mk1mf=( + '^$INSTALLTOP=','$INSTALLTOP="%s";', + ); + +&dofile("crypto/cryptlib.h",$ARGV[0],%cryptlib); +&dofile("Makefile.ssl",$ARGV[0],%Makefile_ssl); +&dofile("tools/c_rehash",$ARGV[0],%c_rehash); +&dofile("util/mk1mf.pl",$ARGV[0],%mk1mf); + +sub dofile + { + ($f,$p,%m)=@_; + + open(IN,"<$f") || die "unable to open $f:$!\n"; + @a=; + close(IN); + foreach $k (keys %m) + { + grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a); + } + ($ff=$f) =~ s/\..*$//; + open(OUT,">$ff.new") || die "unable to open $f:$!\n"; + print OUT @a; + close(OUT); + rename($f,"$ff.old") || die "unable to rename $f\n"; + rename("$ff.new",$f) || die "unable to rename $ff.new\n"; + } + diff --git a/src/lib/libssl/src/util/up_ver.pl b/src/lib/libssl/src/util/up_ver.pl new file mode 100644 index 0000000000..32c086b2aa --- /dev/null +++ b/src/lib/libssl/src/util/up_ver.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl +# +# Up the version numbers in the files. +# + +@files=( + "crypto/crypto.h", + "crypto/des/ecb_enc.c", + "crypto/idea/i_ecb.c", + "crypto/lhash/lhash.c", + "crypto/conf/conf.c", + "crypto/md2/md2_dgst.c", + "crypto/md5/md5_dgst.c", + "crypto/ripemd/rmd_dgst.c", + "crypto/pem/pem_lib.c", + "crypto/bn/bn_lib.c", + "crypto/dh/dh_lib.c", + "crypto/rc2/rc2_ecb.c", + "crypto/rc4/rc4_skey.c", + "crypto/rc5/rc5_ecb.c", + "crypto/bf/bf_ecb.c", + "crypto/cast/c_ecb.c", + "crypto/rsa/rsa_lib.c", + "crypto/dsa/dsa_lib.c", + "crypto/sha/sha1dgst.c", + "crypto/sha/sha_dgst.c", + "crypto/asn1/asn1_lib.c", + "crypto/x509/x509_vfy.c", + "crypto/evp/evp_enc.c", + "crypto/rand/md_rand.c", + "crypto/stack/stack.c", + "crypto/txt_db/txt_db.c", + "crypto/cversion.c", + "ssl/ssl_lib.c", + "ssl/s2_lib.c", + "ssl/s3_lib.c", + "ssl/t1_lib.c", + "README", + ); + +@month=('Jan','Feb','Mar','Apr','May','Jun', + 'Jul','Aug','Sep','Oct','Nov','Dec'); +@a=localtime(time()); +$time=sprintf("%02d-%s-%04d",$a[3],$month[$a[4]],$a[5]+1900); + +$ver=$ARGV[0]; +($ver ne "") || die "no version number specified\n"; +($a,$b,$c,$d)=unpack('axaxac',$ver); +$d=defined($d)?$d-96:0; +$xver=sprintf("%x%x%x%x",$a,$b,$c,$d); + +foreach $file (@files) + { + open(IN,"<$file") || die "unable to open $file:$!\n"; + open(OUT,">$file.new") || die "unable to open $file.new:$!\n"; + $found=0; + + print STDERR "$file:"; + + while () + { + if ((s/SSLeay \d\.\d.\d[^"]*(\"|\s)/SSLeay $ver $time\1/) || + s/^(\#define\s+SSLEAY_VERSION_NUMBER\s+0x)[0-9a-zA-Z]+(.*)$/$1$xver$2/) + { + print STDERR " Done"; + $found++; + print OUT; + while () { print OUT; } + last; + } + print OUT; + } + print STDERR "\n"; + close(IN); + close(OUT); + (!$found) && die "unable to update the version number in $file\n"; + rename($file,"$file.old") || die "unable to rename $file:$!\n"; + rename("$file.new",$file) || die "unable to rename $file.new:$!\n"; + } diff --git a/src/lib/libssl/ssl-patent/Makefile b/src/lib/libssl/ssl-patent/Makefile new file mode 100644 index 0000000000..4831fcfe42 --- /dev/null +++ b/src/lib/libssl/ssl-patent/Makefile @@ -0,0 +1,45 @@ + +LIB= ssl + +SSLEAYDIST= src-patent + +LSSL_SRC= ${.CURDIR}/../${SSLEAYDIST}/ssl +SSLEAY_INC= ${.CURDIR}/../${SSLEAYDIST}/include +LCRYPTO_INC= ${.CURDIR}/../${SSLEAYDIST}/crypto + +.if ${MACHINE_ARCH} == "i386" +CFLAGS+= -DL_ENDIAN -DBN_ASM +.else +.if ${MACHINE_ARCH} == "alpha" +# no ENDIAN stuff defined for alpha +.else +CFLAGS+= -DB_ENDIAN +.endif +.endif +CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE +CFLAGS+= -I${LSSL_SRC} -I${SSLEAY_INC} -I${LCRYPTO_INC} + +SRCS= s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \ + s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \ + s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \ + t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \ + ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \ + ssl_ciph.c ssl_stat.c ssl_rsa.c \ + ssl_asn1.c ssl_txt.c ssl_algs.c \ + bio_ssl.c ssl_err.c + +HDRS= ssl.h ssl2.h ssl3.h ssl23.h tls1.h + +.PATH: ${LSSL_SRC} + +includes: + @cd ${LSSL_SRC}; for i in $(HDRS); do \ + j="cmp -s $$i ${DESTDIR}/usr/include/ssl/`basename $$i` || \ + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \ + $$i ${DESTDIR}/usr/include/ssl"; \ + echo $$j; \ + eval "$$j"; \ + done + + +.include diff --git a/src/lib/libssl/ssl-patent/shlib_version b/src/lib/libssl/ssl-patent/shlib_version new file mode 100644 index 0000000000..893819d18f --- /dev/null +++ b/src/lib/libssl/ssl-patent/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=1 diff --git a/src/lib/libssl/ssl/Makefile b/src/lib/libssl/ssl/Makefile new file mode 100644 index 0000000000..a2fce87b5c --- /dev/null +++ b/src/lib/libssl/ssl/Makefile @@ -0,0 +1,45 @@ + +LIB= ssl + +SSLEAYDIST= src + +LSSL_SRC= ${.CURDIR}/../${SSLEAYDIST}/ssl +SSLEAY_INC= ${.CURDIR}/../${SSLEAYDIST}/include +LCRYPTO_INC= ${.CURDIR}/../${SSLEAYDIST}/crypto + +.if ${MACHINE_ARCH} == "i386" +CFLAGS+= -DL_ENDIAN -DBN_ASM +.else +.if ${MACHINE_ARCH} == "alpha" +# no ENDIAN stuff defined for alpha +.else +CFLAGS+= -DB_ENDIAN +.endif +.endif +CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE +CFLAGS+= -I${LSSL_SRC} -I${SSLEAY_INC} -I${LCRYPTO_INC} + +SRCS= s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \ + s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \ + s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \ + t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \ + ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \ + ssl_ciph.c ssl_stat.c ssl_rsa.c \ + ssl_asn1.c ssl_txt.c ssl_algs.c \ + bio_ssl.c ssl_err.c + +HDRS= ssl.h ssl2.h ssl3.h ssl23.h tls1.h + +.PATH: ${LSSL_SRC} + +includes: + @cd ${LSSL_SRC}; for i in $(HDRS); do \ + j="cmp -s $$i ${DESTDIR}/usr/include/ssl/`basename $$i` || \ + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \ + $$i ${DESTDIR}/usr/include/ssl"; \ + echo $$j; \ + eval "$$j"; \ + done + + +.include diff --git a/src/lib/libssl/ssl/shlib_version b/src/lib/libssl/ssl/shlib_version new file mode 100644 index 0000000000..1edea46de9 --- /dev/null +++ b/src/lib/libssl/ssl/shlib_version @@ -0,0 +1,2 @@ +major=1 +minor=0 diff --git a/src/lib/libssl/ssleay/Makefile b/src/lib/libssl/ssleay/Makefile new file mode 100644 index 0000000000..5eea72267b --- /dev/null +++ b/src/lib/libssl/ssleay/Makefile @@ -0,0 +1,38 @@ + +PROG= ssleay + +BINOWN= root +BINGRP= bin +BINMODE= 555 +BINDIR= /usr/sbin +LDADD= -lssl -lcrypto +NOMAN= not yet kiddies + +SSLEAYDIST= src + +SSLEAY_SRC= ${.CURDIR}/../${SSLEAYDIST}/apps + +.if ${MACHINE_ARCH} == "i386" +CFLAGS+= -DL_ENDIAN -DBN_ASM +.else +.if ${MACHINE_ARCH} == "alpha" +# no ENDIAN stuff defined for alpha +.else +CFLAGS+= -DB_ENDIAN +.endif +.endif + +CFLAGS+= -DMONOLITH -DNO_IDEA -DTERMIOS -DANSI_SOURCE +CFLAGS+= -I/usr/include/ssl + +SRCS= verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c \ + pkcs7.c crl2p7.c crl.c \ + rsa.c dsa.c dsaparam.c \ + x509.c genrsa.c s_server.c s_client.c speed.c \ + s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c \ + ciphers.c ssleay.c + +.PATH: ${SSLEAY_SRC} + +.include + diff --git a/src/lib/libssl/test/.rnd b/src/lib/libssl/test/.rnd new file mode 100644 index 0000000000..234970e241 Binary files /dev/null and b/src/lib/libssl/test/.rnd differ diff --git a/src/lib/libssl/test/Makefile.ssl b/src/lib/libssl/test/Makefile.ssl new file mode 100644 index 0000000000..b3de76751e --- /dev/null +++ b/src/lib/libssl/test/Makefile.ssl @@ -0,0 +1,294 @@ +# +# test/Makefile.ssl +# + +DIR= test +TOP= .. +CC= cc +INCLUDES= -I../include +CFLAG= -g +INSTALLTOP= /usr/local/ssl +MAKEFILE= Makefile.ssl +MAKE= make -f $(MAKEFILE) +MAKEDEPEND= makedepend -f$(MAKEFILE) + +PEX_LIBS= +EX_LIBS= #-lnsl -lsocket + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile.ssl + +DLIBCRYPTO= ../libcrypto.a +DLIBSSL= ../libssl.a +LIBCRYPTO= -L.. -lcrypto +LIBSSL= -L.. -lssl + +BNTEST= bntest +EXPTEST= exptest +IDEATEST= ideatest +SHATEST= shatest +SHA1TEST= sha1test +MDC2TEST= mdc2test +RMDTEST= rmdtest +MD2TEST= md2test +MD5TEST= md5test +HMACTEST= hmactest +RC2TEST= rc2test +RC4TEST= rc4test +RC5TEST= rc5test +BFTEST= bftest +CASTTEST= casttest +DESTEST= destest +RANDTEST= randtest +DHTEST= dhtest +DSATEST= dsatest +METHTEST= methtest +SSLTEST= ssltest + +EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \ + $(RC2TEST) $(RC4TEST) $(RC5TEST) \ + $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \ + $(RANDTEST) $(DHTEST) \ + $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) + +# $(METHTEST) + +OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \ + $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \ + $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \ + $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \ + $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o +SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \ + $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \ + $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \ + $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \ + $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ..; $(MAKE) DIRS=$(DIR) all) + +all: exe + +exe: $(EXE) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + +errors: + +install: + +tags: + ctags $(SRC) + +tests: exe apps \ + test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \ + test_rc2 test_rc4 test_rc5 test_bf test_cast \ + test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \ + test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \ + test_ss test_ssl test_ca + +apps: + @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all) + +test_des: + #./$(DESTEST) + +test_idea: + ./$(IDEATEST) + +test_sha: + ./$(SHATEST) + ./$(SHA1TEST) + +test_mdc2: + ./$(MDC2TEST) + +test_md5: + ./$(MD5TEST) + +test_hmac: + ./$(HMACTEST) + +test_md2: + ./$(MD2TEST) + +test_rmd: + ./$(RMDTEST) + +test_bf: + ./$(BFTEST) + +test_cast: + ./$(CASTTEST) + +test_rc2: + ./$(RC2TEST) + +test_rc4: + ./$(RC4TEST) + +test_rc5: + ./$(RC5TEST) + +test_rand: + ./$(RANDTEST) + +test_enc: + @sh ./testenc + +test_x509: + echo test normal x509v1 certificate + sh ./tx509 2>/dev/null + echo test first x509v3 certificate + sh ./tx509 v3-cert1.pem 2>/dev/null + echo test second x509v3 certificate + sh ./tx509 v3-cert2.pem 2>/dev/null + +test_rsa: + @sh ./trsa 2>/dev/null + +test_crl: + @sh ./tcrl 2>/dev/null + +test_sid: + @sh ./tsid 2>/dev/null + +test_req: + @sh ./treq 2>/dev/null + @sh ./treq testreq2.pem 2>/dev/null + +test_pkcs7: + @sh ./tpkcs7 2>/dev/null + @sh ./tpkcs7d 2>/dev/null + +test_bn: + @echo 'test a^b%c implementations' + ./$(EXPTEST) + @echo starting big number library test, could take a while... + @(./$(BNTEST)|bc) | awk '{ \ +if ($$0 != "0") {print "error"; exit(1); } \ +if (((NR+1)%64) == 0) print NR+1," tests done"; }' + +test_verify: + @echo "The following command should have some OK's and some failures" + @echo "There are definitly a few expired certificates" + ../apps/ssleay verify -CApath ../certs ../certs/*.pem + +test_dh: + @echo "Generate as set of DH parameters" + ./$(DHTEST) + +test_dsa: + @echo "Generate as set of DSA parameters" + ./$(DSATEST) + +test_reqgen: + @echo "Generate and verify a certificate request" + @sh ./testgen + +test_ss: + @echo "Generate and certify a test certificate" + @sh ./testss + +test_ssl: + @echo "test SSL protocol" + @sh ./testssl + +test_ca: + @echo "Generate and certify a test certificate via the 'ca' program" + @sh ./testca + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log + +$(DLIBSSL): + (cd ../ssl; $(MAKE)) + +$(DLIBCRYPTO): + (cd ../crypto; $(MAKE)) + +$(BNTEST): $(BNTEST).o $(DLIBCRYPTO) + $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO) + $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO) + $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHATEST): $(SHATEST).o $(DLIBCRYPTO) + $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO) + $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO) + $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(BFTEST): $(BFTEST).o $(DLIBCRYPTO) + $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO) + $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DESTEST): $(DESTEST).o $(DLIBCRYPTO) + $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DHTEST): $(DHTEST).o $(DLIBCRYPTO) + $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DSATEST): $(DSATEST).o $(DLIBCRYPTO) + $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(METHTEST): $(METHTEST).o $(DLIBCRYPTO) + $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) + $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/test/certCA.srl b/src/lib/libssl/test/certCA.srl new file mode 100644 index 0000000000..39f5b69311 --- /dev/null +++ b/src/lib/libssl/test/certCA.srl @@ -0,0 +1 @@ +71 diff --git a/src/lib/libssl/test/demoCA/index.txt b/src/lib/libssl/test/demoCA/index.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/lib/libssl/test/demoCA/private/cakey.pem b/src/lib/libssl/test/demoCA/private/cakey.pem new file mode 100644 index 0000000000..edd5a5773f --- /dev/null +++ b/src/lib/libssl/test/demoCA/private/cakey.pem @@ -0,0 +1,2 @@ +-----BEGIN RSA PRIVATE KEY----- +-----END RSA PRIVATE KEY----- diff --git a/src/lib/libssl/test/demoCA/serial b/src/lib/libssl/test/demoCA/serial new file mode 100644 index 0000000000..8a0f05e166 --- /dev/null +++ b/src/lib/libssl/test/demoCA/serial @@ -0,0 +1 @@ +01 diff --git a/src/lib/libssl/test/dsa-ca.pem b/src/lib/libssl/test/dsa-ca.pem new file mode 100644 index 0000000000..9eb08f3ddd --- /dev/null +++ b/src/lib/libssl/test/dsa-ca.pem @@ -0,0 +1,43 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0 + +svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0 +Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl +Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/ +par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr +zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO +uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5 +rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx +1QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4 +HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827 +MVqOsYxGCb+kez0FoDSTgw== +-----END DSA PRIVATE KEY----- +-----BEGIN CERTIFICATE REQUEST----- +MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx +ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew +ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW +sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m +rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk +cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo +bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR +CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB +F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH +vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq +AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u +3enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v +AhQfeF5BoMMDbX/kidUVpQ6gadPlZA== +-----END CERTIFICATE REQUEST----- +-----BEGIN CERTIFICATE----- +MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK +U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww +CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw +CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu +ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE +AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi +ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh +MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD +MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa +C1Q= +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/test/dsa-pca.pem b/src/lib/libssl/test/dsa-pca.pem new file mode 100644 index 0000000000..e3641ad47e --- /dev/null +++ b/src/lib/libssl/test/dsa-pca.pem @@ -0,0 +1,49 @@ +-----BEGIN DSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4 + +GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS +mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt +of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr +FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX +RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd +qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1 +diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn +V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h +hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf +dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7 +-----END DSA PRIVATE KEY----- +-----BEGIN CERTIFICATE REQUEST----- +MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx +ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB +MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G +lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O +Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR +5HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl +aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6 +kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als +QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe +6NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ +yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0 +z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB +nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w== +-----END CERTIFICATE REQUEST----- +-----BEGIN CERTIFICATE----- +MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK +U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww +CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw +CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu +ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww +ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ +R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5 +JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps +BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze +mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO +VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C +uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk +umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A +29nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D +AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n +5rKUjNBhSg== +-----END CERTIFICATE----- + diff --git a/src/lib/libssl/test/p b/src/lib/libssl/test/p new file mode 100644 index 0000000000..b3de76751e --- /dev/null +++ b/src/lib/libssl/test/p @@ -0,0 +1,294 @@ +# +# test/Makefile.ssl +# + +DIR= test +TOP= .. +CC= cc +INCLUDES= -I../include +CFLAG= -g +INSTALLTOP= /usr/local/ssl +MAKEFILE= Makefile.ssl +MAKE= make -f $(MAKEFILE) +MAKEDEPEND= makedepend -f$(MAKEFILE) + +PEX_LIBS= +EX_LIBS= #-lnsl -lsocket + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile.ssl + +DLIBCRYPTO= ../libcrypto.a +DLIBSSL= ../libssl.a +LIBCRYPTO= -L.. -lcrypto +LIBSSL= -L.. -lssl + +BNTEST= bntest +EXPTEST= exptest +IDEATEST= ideatest +SHATEST= shatest +SHA1TEST= sha1test +MDC2TEST= mdc2test +RMDTEST= rmdtest +MD2TEST= md2test +MD5TEST= md5test +HMACTEST= hmactest +RC2TEST= rc2test +RC4TEST= rc4test +RC5TEST= rc5test +BFTEST= bftest +CASTTEST= casttest +DESTEST= destest +RANDTEST= randtest +DHTEST= dhtest +DSATEST= dsatest +METHTEST= methtest +SSLTEST= ssltest + +EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \ + $(RC2TEST) $(RC4TEST) $(RC5TEST) \ + $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \ + $(RANDTEST) $(DHTEST) \ + $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) + +# $(METHTEST) + +OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \ + $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \ + $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \ + $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \ + $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o +SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \ + $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \ + $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \ + $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \ + $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c + +EXHEADER= +HEADER= $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ..; $(MAKE) DIRS=$(DIR) all) + +all: exe + +exe: $(EXE) + +files: + perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + /bin/rm -f Makefile + $(TOP)/util/point.sh Makefile.ssl Makefile ; + +errors: + +install: + +tags: + ctags $(SRC) + +tests: exe apps \ + test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \ + test_rc2 test_rc4 test_rc5 test_bf test_cast \ + test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \ + test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \ + test_ss test_ssl test_ca + +apps: + @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all) + +test_des: + #./$(DESTEST) + +test_idea: + ./$(IDEATEST) + +test_sha: + ./$(SHATEST) + ./$(SHA1TEST) + +test_mdc2: + ./$(MDC2TEST) + +test_md5: + ./$(MD5TEST) + +test_hmac: + ./$(HMACTEST) + +test_md2: + ./$(MD2TEST) + +test_rmd: + ./$(RMDTEST) + +test_bf: + ./$(BFTEST) + +test_cast: + ./$(CASTTEST) + +test_rc2: + ./$(RC2TEST) + +test_rc4: + ./$(RC4TEST) + +test_rc5: + ./$(RC5TEST) + +test_rand: + ./$(RANDTEST) + +test_enc: + @sh ./testenc + +test_x509: + echo test normal x509v1 certificate + sh ./tx509 2>/dev/null + echo test first x509v3 certificate + sh ./tx509 v3-cert1.pem 2>/dev/null + echo test second x509v3 certificate + sh ./tx509 v3-cert2.pem 2>/dev/null + +test_rsa: + @sh ./trsa 2>/dev/null + +test_crl: + @sh ./tcrl 2>/dev/null + +test_sid: + @sh ./tsid 2>/dev/null + +test_req: + @sh ./treq 2>/dev/null + @sh ./treq testreq2.pem 2>/dev/null + +test_pkcs7: + @sh ./tpkcs7 2>/dev/null + @sh ./tpkcs7d 2>/dev/null + +test_bn: + @echo 'test a^b%c implementations' + ./$(EXPTEST) + @echo starting big number library test, could take a while... + @(./$(BNTEST)|bc) | awk '{ \ +if ($$0 != "0") {print "error"; exit(1); } \ +if (((NR+1)%64) == 0) print NR+1," tests done"; }' + +test_verify: + @echo "The following command should have some OK's and some failures" + @echo "There are definitly a few expired certificates" + ../apps/ssleay verify -CApath ../certs ../certs/*.pem + +test_dh: + @echo "Generate as set of DH parameters" + ./$(DHTEST) + +test_dsa: + @echo "Generate as set of DSA parameters" + ./$(DSATEST) + +test_reqgen: + @echo "Generate and verify a certificate request" + @sh ./testgen + +test_ss: + @echo "Generate and certify a test certificate" + @sh ./testss + +test_ssl: + @echo "test SSL protocol" + @sh ./testssl + +test_ca: + @echo "Generate and certify a test certificate via the 'ca' program" + @sh ./testca + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC) + +dclean: + perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log + +$(DLIBSSL): + (cd ../ssl; $(MAKE)) + +$(DLIBCRYPTO): + (cd ../crypto; $(MAKE)) + +$(BNTEST): $(BNTEST).o $(DLIBCRYPTO) + $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO) + $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO) + $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHATEST): $(SHATEST).o $(DLIBCRYPTO) + $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO) + $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO) + $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO) + $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(BFTEST): $(BFTEST).o $(DLIBCRYPTO) + $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO) + $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO) + $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DESTEST): $(DESTEST).o $(DLIBCRYPTO) + $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO) + $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DHTEST): $(DHTEST).o $(DLIBCRYPTO) + $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(DSATEST): $(DSATEST).o $(DLIBCRYPTO) + $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(METHTEST): $(METHTEST).o $(DLIBCRYPTO) + $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) + +$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) + $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/lib/libssl/test/riptest b/src/lib/libssl/test/riptest new file mode 100644 index 0000000000..8685d0ce53 Binary files /dev/null and b/src/lib/libssl/test/riptest differ diff --git a/src/lib/libssl/test/test.txt b/src/lib/libssl/test/test.txt new file mode 100644 index 0000000000..c6d8d50ba9 --- /dev/null +++ b/src/lib/libssl/test/test.txt @@ -0,0 +1,31 @@ +#!/bin/sh + +test=./test.txt + +cat $0 >$test; + +for i in rc4 des-cfb des-ofb des-ecb des-cbc des-ede des-ede3 \ + des-cbc-ede des-cbc-ede3 idea-ecb idea-cfb idea-ofb idea-cbc +do + echo $i + ../apps/ssleay $i -e -k test < $test > $test.$i.cipher + ../apps/ssleay $i -d -k test < $test.$i.cipher >$test.$i.clear + cmp $test $test.$i.clear + if [ $? != 0 ] + then + exit 1 + else + /bin/rm $test.$i.cipher $test.$i.clear + fi + + echo $i base64 + ../apps/ssleay $i -a -e -k test < $test > $test.$i.cipher + ../apps/ssleay $i -a -d -k test < $test.$i.cipher >$test.$i.clear + cmp $test $test.$i.clear + if [ $? != 0 ] + then + exit 1 + else + /bin/rm $test.$i.cipher $test.$i.clear + fi +done diff --git a/src/lib/libssl/test/testkey.pem b/src/lib/libssl/test/testkey.pem new file mode 100644 index 0000000000..edd5a5773f --- /dev/null +++ b/src/lib/libssl/test/testkey.pem @@ -0,0 +1,2 @@ +-----BEGIN RSA PRIVATE KEY----- +-----END RSA PRIVATE KEY----- diff --git a/src/lib/libssl/test/testreq.pem b/src/lib/libssl/test/testreq.pem new file mode 100644 index 0000000000..1311fa7785 --- /dev/null +++ b/src/lib/libssl/test/testreq.pem @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBQjCB7QIBADCBhzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx +ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDET +MBEGA1UEAxMKRXJpYyBZb3VuZzEfMB0GCSqGSIb3DQEJARYQZWF5QG1pbmNvbS5v +ei5hdTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDVKdT5QB2ZojtNQGjA/9J7s2o4 +RNkuSq8l377uWLAyMljtdkcoRsvUy5lZ997UDHFTbVFA038ZBrmw7l5EyHeXAgMB +AAGgADANBgkqhkiG9w0BAQQFAANBAKnaFr4u7PTdfmpjiX/H8Ho4UWGVRWUlvD2R +/D9yoTj7TN3uODx2BD0drErVBe/Zjv81vhH6Yo3cJO/hRS3A7jw= +-----END CERTIFICATE REQUEST----- -- cgit v1.2.3-55-g6feb