diff options
| author | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
| commit | 5170039cf1df2194faa85741f0733977525cd5c0 (patch) | |
| tree | c667406046ddb1efca5ed4316b02e43494241660 /src/lib/libcrypto/evp | |
| parent | 536c76cbb863bab152f19842ab88772c01e922c7 (diff) | |
| download | openbsd-OPENBSD_2_4_BASE.tar.gz openbsd-OPENBSD_2_4_BASE.tar.bz2 openbsd-OPENBSD_2_4_BASE.zip | |
This commit was manufactured by cvs2git to create tag 'OPENBSD_2_4_BASE'.OPENBSD_2_4_BASE
Diffstat (limited to 'src/lib/libcrypto/evp')
31 files changed, 3808 insertions, 0 deletions
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 @@ | |||
| 1 | # | ||
| 2 | # SSLeay/crypto/evp/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= evp | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALLTOP=/usr/local/ssl | ||
| 11 | MAKE= make -f Makefile.ssl | ||
| 12 | MAKEDEPEND= makedepend -f Makefile.ssl | ||
| 13 | MAKEFILE= Makefile.ssl | ||
| 14 | AR= ar r | ||
| 15 | |||
| 16 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 17 | |||
| 18 | ERR=evp | ||
| 19 | ERRC=evp_err | ||
| 20 | GENERAL=Makefile | ||
| 21 | TEST= | ||
| 22 | APPS= | ||
| 23 | |||
| 24 | LIB=$(TOP)/libcrypto.a | ||
| 25 | LIBSRC= encode.c digest.c evp_enc.c evp_key.c \ | ||
| 26 | e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c \ | ||
| 27 | e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c \ | ||
| 28 | e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c \ | ||
| 29 | e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c \ | ||
| 30 | e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c \ | ||
| 31 | e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c \ | ||
| 32 | e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c \ | ||
| 33 | e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c \ | ||
| 34 | m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c \ | ||
| 35 | m_ripemd.c \ | ||
| 36 | p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ | ||
| 37 | bio_md.c bio_b64.c bio_enc.c $(ERRC).c e_null.c \ | ||
| 38 | c_all.c evp_lib.c | ||
| 39 | |||
| 40 | LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \ | ||
| 41 | e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \ | ||
| 42 | e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o \ | ||
| 43 | e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o \ | ||
| 44 | e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o \ | ||
| 45 | e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o \ | ||
| 46 | e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o \ | ||
| 47 | e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o \ | ||
| 48 | e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o \ | ||
| 49 | m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o \ | ||
| 50 | m_ripemd.o \ | ||
| 51 | p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ | ||
| 52 | bio_md.o bio_b64.o bio_enc.o $(ERRC).o e_null.o \ | ||
| 53 | c_all.o evp_lib.o | ||
| 54 | |||
| 55 | SRC= $(LIBSRC) | ||
| 56 | |||
| 57 | EXHEADER= evp.h | ||
| 58 | HEADER= $(EXHEADER) | ||
| 59 | |||
| 60 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 61 | |||
| 62 | top: | ||
| 63 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 64 | |||
| 65 | all: lib | ||
| 66 | |||
| 67 | lib: $(LIBOBJ) | ||
| 68 | $(AR) $(LIB) $(LIBOBJ) | ||
| 69 | sh $(TOP)/util/ranlib.sh $(LIB) | ||
| 70 | @touch lib | ||
| 71 | |||
| 72 | files: | ||
| 73 | perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 74 | |||
| 75 | links: | ||
| 76 | /bin/rm -f Makefile | ||
| 77 | $(TOP)/util/point.sh Makefile.ssl Makefile ; | ||
| 78 | $(TOP)/util/mklink.sh ../../include $(EXHEADER) | ||
| 79 | $(TOP)/util/mklink.sh ../../test $(TEST) | ||
| 80 | $(TOP)/util/mklink.sh ../../apps $(APPS) | ||
| 81 | |||
| 82 | install: | ||
| 83 | @for i in $(EXHEADER) ; \ | ||
| 84 | do \ | ||
| 85 | (cp $$i $(INSTALLTOP)/include/$$i; \ | ||
| 86 | chmod 644 $(INSTALLTOP)/include/$$i ); \ | ||
| 87 | done; | ||
| 88 | |||
| 89 | tags: | ||
| 90 | ctags $(SRC) | ||
| 91 | |||
| 92 | tests: | ||
| 93 | |||
| 94 | lint: | ||
| 95 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 96 | |||
| 97 | depend: | ||
| 98 | $(MAKEDEPEND) $(INCLUDES) $(LIBSRC) | ||
| 99 | |||
| 100 | dclean: | ||
| 101 | perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 102 | mv -f Makefile.new $(MAKEFILE) | ||
| 103 | |||
| 104 | clean: | ||
| 105 | /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 106 | |||
| 107 | errors: | ||
| 108 | perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h | ||
| 109 | perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c | ||
| 110 | |||
| 111 | # 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 @@ | |||
| 1 | /* crypto/evp/e_cbc_3d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void des_cbc_ede_init_key(); | ||
| 73 | static void des_cbc_ede3_init_key(); | ||
| 74 | static void des_cbc_ede_cipher(); | ||
| 75 | #endif | ||
| 76 | |||
| 77 | static EVP_CIPHER d_cbc_ede_cipher2= | ||
| 78 | { | ||
| 79 | NID_des_ede_cbc, | ||
| 80 | 8,16,8, | ||
| 81 | des_cbc_ede_init_key, | ||
| 82 | des_cbc_ede_cipher, | ||
| 83 | NULL, | ||
| 84 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 85 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | EVP_CIPHER_set_asn1_iv, | ||
| 88 | }; | ||
| 89 | |||
| 90 | static EVP_CIPHER d_cbc_ede_cipher3= | ||
| 91 | { | ||
| 92 | NID_des_ede3_cbc, | ||
| 93 | 8,24,8, | ||
| 94 | des_cbc_ede3_init_key, | ||
| 95 | des_cbc_ede_cipher, | ||
| 96 | NULL, | ||
| 97 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 98 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 99 | EVP_CIPHER_set_asn1_iv, | ||
| 100 | EVP_CIPHER_get_asn1_iv, | ||
| 101 | }; | ||
| 102 | |||
| 103 | EVP_CIPHER *EVP_des_ede_cbc() | ||
| 104 | { | ||
| 105 | return(&d_cbc_ede_cipher2); | ||
| 106 | } | ||
| 107 | |||
| 108 | EVP_CIPHER *EVP_des_ede3_cbc() | ||
| 109 | { | ||
| 110 | return(&d_cbc_ede_cipher3); | ||
| 111 | } | ||
| 112 | |||
| 113 | static void des_cbc_ede_init_key(ctx,key,iv,enc) | ||
| 114 | EVP_CIPHER_CTX *ctx; | ||
| 115 | unsigned char *key; | ||
| 116 | unsigned char *iv; | ||
| 117 | int enc; | ||
| 118 | { | ||
| 119 | if (iv != NULL) | ||
| 120 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 121 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 122 | |||
| 123 | if (key != NULL) | ||
| 124 | { | ||
| 125 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 126 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 127 | memcpy( (char *)ctx->c.des_ede.ks3, | ||
| 128 | (char *)ctx->c.des_ede.ks1, | ||
| 129 | sizeof(ctx->c.des_ede.ks1)); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | static void des_cbc_ede3_init_key(ctx,key,iv,enc) | ||
| 134 | EVP_CIPHER_CTX *ctx; | ||
| 135 | unsigned char *key; | ||
| 136 | unsigned char *iv; | ||
| 137 | int enc; | ||
| 138 | { | ||
| 139 | if (iv != NULL) | ||
| 140 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 141 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 142 | |||
| 143 | if (key != NULL) | ||
| 144 | { | ||
| 145 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 146 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 147 | des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | static void des_cbc_ede_cipher(ctx,out,in,inl) | ||
| 152 | EVP_CIPHER_CTX *ctx; | ||
| 153 | unsigned char *out; | ||
| 154 | unsigned char *in; | ||
| 155 | unsigned int inl; | ||
| 156 | { | ||
| 157 | des_ede3_cbc_encrypt( | ||
| 158 | (des_cblock *)in,(des_cblock *)out, | ||
| 159 | (long)inl, ctx->c.des_ede.ks1, | ||
| 160 | ctx->c.des_ede.ks2,ctx->c.des_ede.ks3, | ||
| 161 | (des_cblock *)&(ctx->iv[0]), | ||
| 162 | ctx->encrypt); | ||
| 163 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_cbc_bf.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_BLOWFISH | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void bf_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void bf_cbc_init_key(); | ||
| 73 | static void bf_cbc_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER bfish_cbc_cipher= | ||
| 77 | { | ||
| 78 | NID_bf_cbc, | ||
| 79 | 8,EVP_BLOWFISH_KEY_SIZE,8, | ||
| 80 | bf_cbc_init_key, | ||
| 81 | bf_cbc_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), | ||
| 85 | EVP_CIPHER_get_asn1_iv, | ||
| 86 | EVP_CIPHER_set_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_bf_cbc() | ||
| 90 | { | ||
| 91 | return(&bfish_cbc_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void bf_cbc_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (iv != NULL) | ||
| 101 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 102 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 103 | if (key != NULL) | ||
| 104 | BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); | ||
| 105 | } | ||
| 106 | |||
| 107 | static void bf_cbc_cipher(ctx,out,in,inl) | ||
| 108 | EVP_CIPHER_CTX *ctx; | ||
| 109 | unsigned char *out; | ||
| 110 | unsigned char *in; | ||
| 111 | unsigned int inl; | ||
| 112 | { | ||
| 113 | BF_cbc_encrypt( | ||
| 114 | in,out,(long)inl, | ||
| 115 | &(ctx->c.bf_ks),&(ctx->iv[0]), | ||
| 116 | ctx->encrypt); | ||
| 117 | } | ||
| 118 | |||
| 119 | #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 @@ | |||
| 1 | /* crypto/evp/e_cbc_c.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_CAST | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void cast_cbc_init_key(); | ||
| 73 | static void cast_cbc_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER cast5_cbc_cipher= | ||
| 77 | { | ||
| 78 | NID_cast5_cbc, | ||
| 79 | 8,EVP_CAST5_KEY_SIZE,8, | ||
| 80 | cast_cbc_init_key, | ||
| 81 | cast_cbc_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), | ||
| 85 | EVP_CIPHER_get_asn1_iv, | ||
| 86 | EVP_CIPHER_set_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_cast5_cbc() | ||
| 90 | { | ||
| 91 | return(&cast5_cbc_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void cast_cbc_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (iv != NULL) | ||
| 101 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 102 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 103 | if (key != NULL) | ||
| 104 | CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); | ||
| 105 | } | ||
| 106 | |||
| 107 | static void cast_cbc_cipher(ctx,out,in,inl) | ||
| 108 | EVP_CIPHER_CTX *ctx; | ||
| 109 | unsigned char *out; | ||
| 110 | unsigned char *in; | ||
| 111 | unsigned int inl; | ||
| 112 | { | ||
| 113 | CAST_cbc_encrypt( | ||
| 114 | in,out,(long)inl, | ||
| 115 | &(ctx->c.cast_ks),&(ctx->iv[0]), | ||
| 116 | ctx->encrypt); | ||
| 117 | } | ||
| 118 | |||
| 119 | #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 @@ | |||
| 1 | /* crypto/evp/e_cbc_d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 68 | unsigned char *in, unsigned int inl); | ||
| 69 | #else | ||
| 70 | static void des_cbc_init_key(); | ||
| 71 | static void des_cbc_cipher(); | ||
| 72 | #endif | ||
| 73 | |||
| 74 | static EVP_CIPHER d_cbc_cipher= | ||
| 75 | { | ||
| 76 | NID_des_cbc, | ||
| 77 | 8,8,8, | ||
| 78 | des_cbc_init_key, | ||
| 79 | des_cbc_cipher, | ||
| 80 | NULL, | ||
| 81 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 82 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), | ||
| 83 | EVP_CIPHER_get_asn1_iv, | ||
| 84 | EVP_CIPHER_set_asn1_iv, | ||
| 85 | }; | ||
| 86 | |||
| 87 | EVP_CIPHER *EVP_des_cbc() | ||
| 88 | { | ||
| 89 | return(&d_cbc_cipher); | ||
| 90 | } | ||
| 91 | |||
| 92 | static void des_cbc_init_key(ctx,key,iv,enc) | ||
| 93 | EVP_CIPHER_CTX *ctx; | ||
| 94 | unsigned char *key; | ||
| 95 | unsigned char *iv; | ||
| 96 | int enc; | ||
| 97 | { | ||
| 98 | if (iv != NULL) | ||
| 99 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 100 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 101 | if (key != NULL) | ||
| 102 | des_set_key((des_cblock *)key,ctx->c.des_ks); | ||
| 103 | } | ||
| 104 | |||
| 105 | static void des_cbc_cipher(ctx,out,in,inl) | ||
| 106 | EVP_CIPHER_CTX *ctx; | ||
| 107 | unsigned char *out; | ||
| 108 | unsigned char *in; | ||
| 109 | unsigned int inl; | ||
| 110 | { | ||
| 111 | des_ncbc_encrypt( | ||
| 112 | (des_cblock *)in,(des_cblock *)out, | ||
| 113 | (long)inl, ctx->c.des_ks, | ||
| 114 | (des_cblock *)&(ctx->iv[0]), | ||
| 115 | ctx->encrypt); | ||
| 116 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_cbc_i.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_IDEA | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void idea_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void idea_cbc_init_key(); | ||
| 73 | static void idea_cbc_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER i_cbc_cipher= | ||
| 77 | { | ||
| 78 | NID_idea_cbc, | ||
| 79 | 8,16,8, | ||
| 80 | idea_cbc_init_key, | ||
| 81 | idea_cbc_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), | ||
| 85 | EVP_CIPHER_get_asn1_iv, | ||
| 86 | EVP_CIPHER_set_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_idea_cbc() | ||
| 90 | { | ||
| 91 | return(&i_cbc_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void idea_cbc_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (iv != NULL) | ||
| 101 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 102 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 103 | if (key != NULL) | ||
| 104 | { | ||
| 105 | if (enc) | ||
| 106 | idea_set_encrypt_key(key,&(ctx->c.idea_ks)); | ||
| 107 | else | ||
| 108 | { | ||
| 109 | IDEA_KEY_SCHEDULE tmp; | ||
| 110 | |||
| 111 | idea_set_encrypt_key(key,&tmp); | ||
| 112 | idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks)); | ||
| 113 | memset((unsigned char *)&tmp,0, | ||
| 114 | sizeof(IDEA_KEY_SCHEDULE)); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | static void idea_cbc_cipher(ctx,out,in,inl) | ||
| 120 | EVP_CIPHER_CTX *ctx; | ||
| 121 | unsigned char *out; | ||
| 122 | unsigned char *in; | ||
| 123 | unsigned int inl; | ||
| 124 | { | ||
| 125 | idea_cbc_encrypt( | ||
| 126 | in,out,(long)inl, | ||
| 127 | &(ctx->c.idea_ks),&(ctx->iv[0]), | ||
| 128 | ctx->encrypt); | ||
| 129 | } | ||
| 130 | |||
| 131 | #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 @@ | |||
| 1 | /* crypto/evp/e_cbc_r2.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC2 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc2_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc2_cbc_init_key(); | ||
| 73 | static void rc2_cbc_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER r2_cbc_cipher= | ||
| 77 | { | ||
| 78 | NID_rc2_cbc, | ||
| 79 | 8,EVP_RC2_KEY_SIZE,8, | ||
| 80 | rc2_cbc_init_key, | ||
| 81 | rc2_cbc_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), | ||
| 85 | EVP_CIPHER_get_asn1_iv, | ||
| 86 | EVP_CIPHER_set_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | static EVP_CIPHER r2_40_cbc_cipher= | ||
| 90 | { | ||
| 91 | NID_rc2_40_cbc, | ||
| 92 | 8,5 /* 40 bit */,8, | ||
| 93 | rc2_cbc_init_key, | ||
| 94 | rc2_cbc_cipher, | ||
| 95 | NULL, | ||
| 96 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 97 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), | ||
| 98 | }; | ||
| 99 | |||
| 100 | EVP_CIPHER *EVP_rc2_cbc() | ||
| 101 | { | ||
| 102 | return(&r2_cbc_cipher); | ||
| 103 | } | ||
| 104 | |||
| 105 | EVP_CIPHER *EVP_rc2_40_cbc() | ||
| 106 | { | ||
| 107 | return(&r2_40_cbc_cipher); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void rc2_cbc_init_key(ctx,key,iv,enc) | ||
| 111 | EVP_CIPHER_CTX *ctx; | ||
| 112 | unsigned char *key; | ||
| 113 | unsigned char *iv; | ||
| 114 | int enc; | ||
| 115 | { | ||
| 116 | if (iv != NULL) | ||
| 117 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 118 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 119 | if (key != NULL) | ||
| 120 | RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx), | ||
| 121 | key,EVP_CIPHER_CTX_key_length(ctx)*8); | ||
| 122 | } | ||
| 123 | |||
| 124 | static void rc2_cbc_cipher(ctx,out,in,inl) | ||
| 125 | EVP_CIPHER_CTX *ctx; | ||
| 126 | unsigned char *out; | ||
| 127 | unsigned char *in; | ||
| 128 | unsigned int inl; | ||
| 129 | { | ||
| 130 | RC2_cbc_encrypt( | ||
| 131 | in,out,(long)inl, | ||
| 132 | &(ctx->c.rc2_ks),&(ctx->iv[0]), | ||
| 133 | ctx->encrypt); | ||
| 134 | } | ||
| 135 | |||
| 136 | #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 @@ | |||
| 1 | /* crypto/evp/e_cbc_r5.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC5 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void r_32_12_16_cbc_init_key(); | ||
| 73 | static void r_32_12_16_cbc_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER rc5_32_12_16_cbc_cipher= | ||
| 77 | { | ||
| 78 | NID_rc5_cbc, | ||
| 79 | 8,EVP_RC5_32_12_16_KEY_SIZE,8, | ||
| 80 | r_32_12_16_cbc_init_key, | ||
| 81 | r_32_12_16_cbc_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), | ||
| 85 | NULL, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc5_32_12_16_cbc() | ||
| 90 | { | ||
| 91 | return(&rc5_32_12_16_cbc_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void r_32_12_16_cbc_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (iv != NULL) | ||
| 101 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 102 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 103 | if (key != NULL) | ||
| 104 | RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE, | ||
| 105 | key,RC5_12_ROUNDS); | ||
| 106 | } | ||
| 107 | |||
| 108 | static void r_32_12_16_cbc_cipher(ctx,out,in,inl) | ||
| 109 | EVP_CIPHER_CTX *ctx; | ||
| 110 | unsigned char *out; | ||
| 111 | unsigned char *in; | ||
| 112 | unsigned int inl; | ||
| 113 | { | ||
| 114 | RC5_32_cbc_encrypt( | ||
| 115 | in,out,(long)inl, | ||
| 116 | &(ctx->c.rc5_ks),&(ctx->iv[0]), | ||
| 117 | ctx->encrypt); | ||
| 118 | } | ||
| 119 | |||
| 120 | #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 @@ | |||
| 1 | /* crypto/evp/e_cfb_3d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void des_ede_cfb_init_key(); | ||
| 73 | static void des_ede3_cfb_init_key(); | ||
| 74 | static void des_ede_cfb_cipher(); | ||
| 75 | #endif | ||
| 76 | |||
| 77 | static EVP_CIPHER d_ede_cfb_cipher2= | ||
| 78 | { | ||
| 79 | NID_des_ede_cfb64, | ||
| 80 | 1,16,8, | ||
| 81 | des_ede_cfb_init_key, | ||
| 82 | des_ede_cfb_cipher, | ||
| 83 | NULL, | ||
| 84 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 85 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 86 | EVP_CIPHER_set_asn1_iv, | ||
| 87 | EVP_CIPHER_get_asn1_iv, | ||
| 88 | }; | ||
| 89 | |||
| 90 | static EVP_CIPHER d_ede3_cfb_cipher3= | ||
| 91 | { | ||
| 92 | NID_des_ede3_cfb64, | ||
| 93 | 1,24,8, | ||
| 94 | des_ede3_cfb_init_key, | ||
| 95 | des_ede_cfb_cipher, | ||
| 96 | NULL, | ||
| 97 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 98 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 99 | EVP_CIPHER_set_asn1_iv, | ||
| 100 | EVP_CIPHER_get_asn1_iv, | ||
| 101 | }; | ||
| 102 | |||
| 103 | EVP_CIPHER *EVP_des_ede_cfb() | ||
| 104 | { | ||
| 105 | return(&d_ede_cfb_cipher2); | ||
| 106 | } | ||
| 107 | |||
| 108 | EVP_CIPHER *EVP_des_ede3_cfb() | ||
| 109 | { | ||
| 110 | return(&d_ede3_cfb_cipher3); | ||
| 111 | } | ||
| 112 | |||
| 113 | static void des_ede_cfb_init_key(ctx,key,iv,enc) | ||
| 114 | EVP_CIPHER_CTX *ctx; | ||
| 115 | unsigned char *key; | ||
| 116 | unsigned char *iv; | ||
| 117 | int enc; | ||
| 118 | { | ||
| 119 | ctx->num=0; | ||
| 120 | |||
| 121 | if (iv != NULL) | ||
| 122 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 123 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 124 | if (key != NULL) | ||
| 125 | { | ||
| 126 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 127 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 128 | memcpy( (char *)ctx->c.des_ede.ks3, | ||
| 129 | (char *)ctx->c.des_ede.ks1, | ||
| 130 | sizeof(ctx->c.des_ede.ks1)); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | static void des_ede3_cfb_init_key(ctx,key,iv,enc) | ||
| 135 | EVP_CIPHER_CTX *ctx; | ||
| 136 | unsigned char *key; | ||
| 137 | unsigned char *iv; | ||
| 138 | int enc; | ||
| 139 | { | ||
| 140 | ctx->num=0; | ||
| 141 | |||
| 142 | if (iv != NULL) | ||
| 143 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 144 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 145 | if (key != NULL) | ||
| 146 | { | ||
| 147 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 148 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 149 | des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | static void des_ede_cfb_cipher(ctx,out,in,inl) | ||
| 154 | EVP_CIPHER_CTX *ctx; | ||
| 155 | unsigned char *out; | ||
| 156 | unsigned char *in; | ||
| 157 | unsigned int inl; | ||
| 158 | { | ||
| 159 | des_ede3_cfb64_encrypt( | ||
| 160 | in,out,(long)inl, | ||
| 161 | ctx->c.des_ede.ks1, | ||
| 162 | ctx->c.des_ede.ks2, | ||
| 163 | ctx->c.des_ede.ks3, | ||
| 164 | (des_cblock *)&(ctx->iv[0]), | ||
| 165 | &ctx->num,ctx->encrypt); | ||
| 166 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_cfb_bf.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_BLOWFISH | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void bf_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void bf_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void bf_cfb_init_key(); | ||
| 73 | static void bf_cfb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER bfish_cfb_cipher= | ||
| 77 | { | ||
| 78 | NID_bf_cfb64, | ||
| 79 | 1,EVP_BLOWFISH_KEY_SIZE,8, | ||
| 80 | bf_cfb_init_key, | ||
| 81 | bf_cfb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_bf_cfb() | ||
| 90 | { | ||
| 91 | return(&bfish_cfb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void bf_cfb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void bf_cfb_cipher(ctx,out,in,inl) | ||
| 110 | EVP_CIPHER_CTX *ctx; | ||
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | ||
| 115 | BF_cfb64_encrypt( | ||
| 116 | in,out, | ||
| 117 | (long)inl, &(ctx->c.bf_ks), | ||
| 118 | &(ctx->iv[0]), | ||
| 119 | &ctx->num,ctx->encrypt); | ||
| 120 | } | ||
| 121 | #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 @@ | |||
| 1 | /* crypto/evp/e_cfb_c.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_CAST | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void cast_cfb_init_key(); | ||
| 73 | static void cast_cfb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER cast5_cfb_cipher= | ||
| 77 | { | ||
| 78 | NID_cast5_cfb64, | ||
| 79 | 1,EVP_CAST5_KEY_SIZE,8, | ||
| 80 | cast_cfb_init_key, | ||
| 81 | cast_cfb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_cast5_cfb() | ||
| 90 | { | ||
| 91 | return(&cast5_cfb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void cast_cfb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void cast_cfb_cipher(ctx,out,in,inl) | ||
| 110 | EVP_CIPHER_CTX *ctx; | ||
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | ||
| 115 | CAST_cfb64_encrypt( | ||
| 116 | in,out, | ||
| 117 | (long)inl, &(ctx->c.cast_ks), | ||
| 118 | &(ctx->iv[0]), | ||
| 119 | &ctx->num,ctx->encrypt); | ||
| 120 | } | ||
| 121 | #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 @@ | |||
| 1 | /* crypto/evp/e_cfb_d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 68 | unsigned char *in, unsigned int inl); | ||
| 69 | #else | ||
| 70 | static void des_cfb_init_key(); | ||
| 71 | static void des_cfb_cipher(); | ||
| 72 | #endif | ||
| 73 | |||
| 74 | static EVP_CIPHER d_cfb_cipher= | ||
| 75 | { | ||
| 76 | NID_des_cfb64, | ||
| 77 | 1,8,8, | ||
| 78 | des_cfb_init_key, | ||
| 79 | des_cfb_cipher, | ||
| 80 | NULL, | ||
| 81 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 82 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), | ||
| 83 | EVP_CIPHER_set_asn1_iv, | ||
| 84 | EVP_CIPHER_get_asn1_iv, | ||
| 85 | }; | ||
| 86 | |||
| 87 | EVP_CIPHER *EVP_des_cfb() | ||
| 88 | { | ||
| 89 | return(&d_cfb_cipher); | ||
| 90 | } | ||
| 91 | |||
| 92 | static void des_cfb_init_key(ctx,key,iv,enc) | ||
| 93 | EVP_CIPHER_CTX *ctx; | ||
| 94 | unsigned char *key; | ||
| 95 | unsigned char *iv; | ||
| 96 | int enc; | ||
| 97 | { | ||
| 98 | ctx->num=0; | ||
| 99 | |||
| 100 | if (iv != NULL) | ||
| 101 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 102 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 103 | if (key != NULL) | ||
| 104 | des_set_key((des_cblock *)key,ctx->c.des_ks); | ||
| 105 | } | ||
| 106 | |||
| 107 | static void des_cfb_cipher(ctx,out,in,inl) | ||
| 108 | EVP_CIPHER_CTX *ctx; | ||
| 109 | unsigned char *out; | ||
| 110 | unsigned char *in; | ||
| 111 | unsigned int inl; | ||
| 112 | { | ||
| 113 | des_cfb64_encrypt( | ||
| 114 | in,out, | ||
| 115 | (long)inl, ctx->c.des_ks, | ||
| 116 | (des_cblock *)&(ctx->iv[0]), | ||
| 117 | &ctx->num,ctx->encrypt); | ||
| 118 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_cfb_i.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_IDEA | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void idea_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void idea_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void idea_cfb_init_key(); | ||
| 73 | static void idea_cfb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER i_cfb_cipher= | ||
| 77 | { | ||
| 78 | NID_idea_cfb64, | ||
| 79 | 1,IDEA_KEY_LENGTH,IDEA_BLOCK, | ||
| 80 | idea_cfb_init_key, | ||
| 81 | idea_cfb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_idea_cfb() | ||
| 90 | { | ||
| 91 | return(&i_cfb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void idea_cfb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | idea_set_encrypt_key(key,&(ctx->c.idea_ks)); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void idea_cfb_cipher(ctx,out,in,inl) | ||
| 110 | EVP_CIPHER_CTX *ctx; | ||
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | ||
| 115 | idea_cfb64_encrypt( | ||
| 116 | in,out,(long)inl, | ||
| 117 | &(ctx->c.idea_ks),&(ctx->iv[0]), | ||
| 118 | &ctx->num,ctx->encrypt); | ||
| 119 | } | ||
| 120 | |||
| 121 | #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 @@ | |||
| 1 | /* crypto/evp/e_cfb_r2.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC2 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc2_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc2_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc2_cfb_init_key(); | ||
| 73 | static void rc2_cfb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER r2_cfb_cipher= | ||
| 77 | { | ||
| 78 | NID_rc2_cfb64, | ||
| 79 | 1,EVP_RC2_KEY_SIZE,8, | ||
| 80 | rc2_cfb_init_key, | ||
| 81 | rc2_cfb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc2_cfb() | ||
| 90 | { | ||
| 91 | return(&r2_cfb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc2_cfb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, | ||
| 107 | EVP_RC2_KEY_SIZE*8); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void rc2_cfb_cipher(ctx,out,in,inl) | ||
| 111 | EVP_CIPHER_CTX *ctx; | ||
| 112 | unsigned char *out; | ||
| 113 | unsigned char *in; | ||
| 114 | unsigned int inl; | ||
| 115 | { | ||
| 116 | RC2_cfb64_encrypt( | ||
| 117 | in,out, | ||
| 118 | (long)inl, &(ctx->c.rc2_ks), | ||
| 119 | &(ctx->iv[0]), | ||
| 120 | &ctx->num,ctx->encrypt); | ||
| 121 | } | ||
| 122 | #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 @@ | |||
| 1 | /* crypto/evp/e_cfb_r5.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC5 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc5_32_12_16_cfb_init_key(); | ||
| 73 | static void rc5_32_12_16_cfb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER rc5_cfb_cipher= | ||
| 77 | { | ||
| 78 | NID_rc5_cfb64, | ||
| 79 | 1,EVP_RC5_32_12_16_KEY_SIZE,8, | ||
| 80 | rc5_32_12_16_cfb_init_key, | ||
| 81 | rc5_32_12_16_cfb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc5_32_12_16_cfb() | ||
| 90 | { | ||
| 91 | return(&rc5_cfb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, | ||
| 107 | RC5_12_ROUNDS); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl) | ||
| 111 | EVP_CIPHER_CTX *ctx; | ||
| 112 | unsigned char *out; | ||
| 113 | unsigned char *in; | ||
| 114 | unsigned int inl; | ||
| 115 | { | ||
| 116 | RC5_32_cfb64_encrypt( | ||
| 117 | in,out, | ||
| 118 | (long)inl, &(ctx->c.rc5_ks), | ||
| 119 | &(ctx->iv[0]), | ||
| 120 | &ctx->num,ctx->encrypt); | ||
| 121 | } | ||
| 122 | #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 @@ | |||
| 1 | /* crypto/evp/e_ecb_3d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void des_ede_init_key(); | ||
| 73 | static void des_ede3_init_key(); | ||
| 74 | static void des_ede_cipher(); | ||
| 75 | #endif | ||
| 76 | |||
| 77 | static EVP_CIPHER d_ede_cipher2= | ||
| 78 | { | ||
| 79 | NID_des_ede, | ||
| 80 | 8,16,0, | ||
| 81 | des_ede_init_key, | ||
| 82 | des_ede_cipher, | ||
| 83 | NULL, | ||
| 84 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 85 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 86 | NULL, | ||
| 87 | NULL, | ||
| 88 | }; | ||
| 89 | |||
| 90 | static EVP_CIPHER d_ede3_cipher3= | ||
| 91 | { | ||
| 92 | NID_des_ede3, | ||
| 93 | 8,24,0, | ||
| 94 | des_ede3_init_key, | ||
| 95 | des_ede_cipher, | ||
| 96 | NULL, | ||
| 97 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 98 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 99 | NULL, | ||
| 100 | }; | ||
| 101 | |||
| 102 | EVP_CIPHER *EVP_des_ede() | ||
| 103 | { | ||
| 104 | return(&d_ede_cipher2); | ||
| 105 | } | ||
| 106 | |||
| 107 | EVP_CIPHER *EVP_des_ede3() | ||
| 108 | { | ||
| 109 | return(&d_ede3_cipher3); | ||
| 110 | } | ||
| 111 | |||
| 112 | static void des_ede_init_key(ctx,key,iv,enc) | ||
| 113 | EVP_CIPHER_CTX *ctx; | ||
| 114 | unsigned char *key; | ||
| 115 | unsigned char *iv; | ||
| 116 | int enc; | ||
| 117 | { | ||
| 118 | if (key != NULL) | ||
| 119 | { | ||
| 120 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 121 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 122 | memcpy( (char *)ctx->c.des_ede.ks3, | ||
| 123 | (char *)ctx->c.des_ede.ks1, | ||
| 124 | sizeof(ctx->c.des_ede.ks1)); | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | static void des_ede3_init_key(ctx,key,iv,enc) | ||
| 129 | EVP_CIPHER_CTX *ctx; | ||
| 130 | unsigned char *key; | ||
| 131 | unsigned char *iv; | ||
| 132 | int enc; | ||
| 133 | { | ||
| 134 | if (key != NULL) | ||
| 135 | { | ||
| 136 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 137 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 138 | des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | static void des_ede_cipher(ctx,out,in,inl) | ||
| 143 | EVP_CIPHER_CTX *ctx; | ||
| 144 | unsigned char *out; | ||
| 145 | unsigned char *in; | ||
| 146 | unsigned int inl; | ||
| 147 | { | ||
| 148 | unsigned int i; | ||
| 149 | |||
| 150 | if (inl < 8) return; | ||
| 151 | inl-=8; | ||
| 152 | for (i=0; i<=inl; i+=8) | ||
| 153 | { | ||
| 154 | des_ecb3_encrypt( | ||
| 155 | (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), | ||
| 156 | ctx->c.des_ede.ks1, | ||
| 157 | ctx->c.des_ede.ks2, | ||
| 158 | ctx->c.des_ede.ks3, | ||
| 159 | ctx->encrypt); | ||
| 160 | } | ||
| 161 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_ecb_bf.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_BLOWFISH | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void bf_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void bf_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void bf_ecb_init_key(); | ||
| 73 | static void bf_ecb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER bfish_ecb_cipher= | ||
| 77 | { | ||
| 78 | NID_bf_ecb, | ||
| 79 | 8,EVP_BLOWFISH_KEY_SIZE,0, | ||
| 80 | bf_ecb_init_key, | ||
| 81 | bf_ecb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), | ||
| 85 | NULL, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_bf_ecb() | ||
| 90 | { | ||
| 91 | return(&bfish_ecb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void bf_ecb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (key != NULL) | ||
| 101 | BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); | ||
| 102 | } | ||
| 103 | |||
| 104 | static void bf_ecb_cipher(ctx,out,in,inl) | ||
| 105 | EVP_CIPHER_CTX *ctx; | ||
| 106 | unsigned char *out; | ||
| 107 | unsigned char *in; | ||
| 108 | unsigned int inl; | ||
| 109 | { | ||
| 110 | unsigned int i; | ||
| 111 | |||
| 112 | if (inl < 8) return; | ||
| 113 | inl-=8; | ||
| 114 | for (i=0; i<=inl; i+=8) | ||
| 115 | { | ||
| 116 | BF_ecb_encrypt( | ||
| 117 | &(in[i]),&(out[i]), | ||
| 118 | &(ctx->c.bf_ks),ctx->encrypt); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | #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 @@ | |||
| 1 | /* crypto/evp/e_ecb_c.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_CAST | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void cast_ecb_init_key(); | ||
| 73 | static void cast_ecb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER cast5_ecb_cipher= | ||
| 77 | { | ||
| 78 | NID_cast5_ecb, | ||
| 79 | 8,EVP_CAST5_KEY_SIZE,0, | ||
| 80 | cast_ecb_init_key, | ||
| 81 | cast_ecb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), | ||
| 85 | NULL, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_cast5_ecb() | ||
| 90 | { | ||
| 91 | return(&cast5_ecb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void cast_ecb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (key != NULL) | ||
| 101 | CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); | ||
| 102 | } | ||
| 103 | |||
| 104 | static void cast_ecb_cipher(ctx,out,in,inl) | ||
| 105 | EVP_CIPHER_CTX *ctx; | ||
| 106 | unsigned char *out; | ||
| 107 | unsigned char *in; | ||
| 108 | unsigned int inl; | ||
| 109 | { | ||
| 110 | unsigned int i; | ||
| 111 | |||
| 112 | if (inl < 8) return; | ||
| 113 | inl-=8; | ||
| 114 | for (i=0; i<=inl; i+=8) | ||
| 115 | { | ||
| 116 | CAST_ecb_encrypt( | ||
| 117 | &(in[i]),&(out[i]), | ||
| 118 | &(ctx->c.cast_ks),ctx->encrypt); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | #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 @@ | |||
| 1 | /* crypto/evp/e_ecb_d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 68 | unsigned char *in, unsigned int inl); | ||
| 69 | #else | ||
| 70 | static void des_ecb_init_key(); | ||
| 71 | static void des_ecb_cipher(); | ||
| 72 | #endif | ||
| 73 | |||
| 74 | static EVP_CIPHER d_ecb_cipher= | ||
| 75 | { | ||
| 76 | NID_des_ecb, | ||
| 77 | 8,8,0, | ||
| 78 | des_ecb_init_key, | ||
| 79 | des_ecb_cipher, | ||
| 80 | NULL, | ||
| 81 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 82 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), | ||
| 83 | NULL, | ||
| 84 | NULL, | ||
| 85 | }; | ||
| 86 | |||
| 87 | EVP_CIPHER *EVP_des_ecb() | ||
| 88 | { | ||
| 89 | return(&d_ecb_cipher); | ||
| 90 | } | ||
| 91 | |||
| 92 | static void des_ecb_init_key(ctx,key,iv,enc) | ||
| 93 | EVP_CIPHER_CTX *ctx; | ||
| 94 | unsigned char *key; | ||
| 95 | unsigned char *iv; | ||
| 96 | int enc; | ||
| 97 | { | ||
| 98 | if (key != NULL) | ||
| 99 | des_set_key((des_cblock *)key,ctx->c.des_ks); | ||
| 100 | } | ||
| 101 | |||
| 102 | static void des_ecb_cipher(ctx,out,in,inl) | ||
| 103 | EVP_CIPHER_CTX *ctx; | ||
| 104 | unsigned char *out; | ||
| 105 | unsigned char *in; | ||
| 106 | unsigned int inl; | ||
| 107 | { | ||
| 108 | unsigned int i; | ||
| 109 | |||
| 110 | if (inl < 8) return; | ||
| 111 | inl-=8; | ||
| 112 | for (i=0; i<=inl; i+=8) | ||
| 113 | { | ||
| 114 | des_ecb_encrypt( | ||
| 115 | (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), | ||
| 116 | ctx->c.des_ks,ctx->encrypt); | ||
| 117 | } | ||
| 118 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_ecb_i.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_IDEA | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void idea_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void idea_ecb_init_key(); | ||
| 73 | static void idea_ecb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER i_ecb_cipher= | ||
| 77 | { | ||
| 78 | NID_idea_ecb, | ||
| 79 | 8,16,0, | ||
| 80 | idea_ecb_init_key, | ||
| 81 | idea_ecb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), | ||
| 85 | NULL, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_idea_ecb() | ||
| 90 | { | ||
| 91 | return(&i_ecb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void idea_ecb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (key != NULL) | ||
| 101 | { | ||
| 102 | if (enc) | ||
| 103 | idea_set_encrypt_key(key,&(ctx->c.idea_ks)); | ||
| 104 | else | ||
| 105 | { | ||
| 106 | IDEA_KEY_SCHEDULE tmp; | ||
| 107 | |||
| 108 | idea_set_encrypt_key(key,&tmp); | ||
| 109 | idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks)); | ||
| 110 | memset((unsigned char *)&tmp,0, | ||
| 111 | sizeof(IDEA_KEY_SCHEDULE)); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | static void idea_ecb_cipher(ctx,out,in,inl) | ||
| 117 | EVP_CIPHER_CTX *ctx; | ||
| 118 | unsigned char *out; | ||
| 119 | unsigned char *in; | ||
| 120 | unsigned int inl; | ||
| 121 | { | ||
| 122 | unsigned int i; | ||
| 123 | |||
| 124 | if (inl < 8) return; | ||
| 125 | inl-=8; | ||
| 126 | for (i=0; i<=inl; i+=8) | ||
| 127 | { | ||
| 128 | idea_ecb_encrypt( | ||
| 129 | &(in[i]),&(out[i]),&(ctx->c.idea_ks)); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | #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 @@ | |||
| 1 | /* crypto/evp/e_ecb_r2.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC2 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc2_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc2_ecb_init_key(); | ||
| 73 | static void rc2_ecb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER r2_ecb_cipher= | ||
| 77 | { | ||
| 78 | NID_rc2_ecb, | ||
| 79 | 8,EVP_RC2_KEY_SIZE,0, | ||
| 80 | rc2_ecb_init_key, | ||
| 81 | rc2_ecb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), | ||
| 85 | NULL, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc2_ecb() | ||
| 90 | { | ||
| 91 | return(&r2_ecb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc2_ecb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (key != NULL) | ||
| 101 | RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, | ||
| 102 | EVP_RC2_KEY_SIZE*8); | ||
| 103 | } | ||
| 104 | |||
| 105 | static void rc2_ecb_cipher(ctx,out,in,inl) | ||
| 106 | EVP_CIPHER_CTX *ctx; | ||
| 107 | unsigned char *out; | ||
| 108 | unsigned char *in; | ||
| 109 | unsigned int inl; | ||
| 110 | { | ||
| 111 | unsigned int i; | ||
| 112 | |||
| 113 | if (inl < 8) return; | ||
| 114 | inl-=8; | ||
| 115 | for (i=0; i<=inl; i+=8) | ||
| 116 | { | ||
| 117 | RC2_ecb_encrypt( | ||
| 118 | &(in[i]),&(out[i]), | ||
| 119 | &(ctx->c.rc2_ks),ctx->encrypt); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | #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 @@ | |||
| 1 | /* crypto/evp/e_ecb_r5.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC5 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc5_32_12_16_ecb_init_key(); | ||
| 73 | static void rc5_32_12_16_ecb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER rc5_ecb_cipher= | ||
| 77 | { | ||
| 78 | NID_rc5_ecb, | ||
| 79 | 8,EVP_RC5_32_12_16_KEY_SIZE,0, | ||
| 80 | rc5_32_12_16_ecb_init_key, | ||
| 81 | rc5_32_12_16_ecb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), | ||
| 85 | NULL, | ||
| 86 | NULL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc5_32_12_16_ecb() | ||
| 90 | { | ||
| 91 | return(&rc5_ecb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | if (key != NULL) | ||
| 101 | RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, | ||
| 102 | RC5_12_ROUNDS); | ||
| 103 | } | ||
| 104 | |||
| 105 | static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl) | ||
| 106 | EVP_CIPHER_CTX *ctx; | ||
| 107 | unsigned char *out; | ||
| 108 | unsigned char *in; | ||
| 109 | unsigned int inl; | ||
| 110 | { | ||
| 111 | unsigned int i; | ||
| 112 | |||
| 113 | if (inl < 8) return; | ||
| 114 | inl-=8; | ||
| 115 | for (i=0; i<=inl; i+=8) | ||
| 116 | { | ||
| 117 | RC5_32_ecb_encrypt( | ||
| 118 | &(in[i]),&(out[i]), | ||
| 119 | &(ctx->c.rc5_ks),ctx->encrypt); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | #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 @@ | |||
| 1 | /* crypto/evp/e_ofb_3d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void des_ede_ofb_init_key(); | ||
| 73 | static void des_ede3_ofb_init_key(); | ||
| 74 | static void des_ede_ofb_cipher(); | ||
| 75 | #endif | ||
| 76 | |||
| 77 | static EVP_CIPHER d_ede_ofb_cipher2= | ||
| 78 | { | ||
| 79 | NID_des_ede_ofb64, | ||
| 80 | 1,16,8, | ||
| 81 | des_ede_ofb_init_key, | ||
| 82 | des_ede_ofb_cipher, | ||
| 83 | NULL, | ||
| 84 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 85 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 86 | EVP_CIPHER_set_asn1_iv, | ||
| 87 | EVP_CIPHER_get_asn1_iv, | ||
| 88 | }; | ||
| 89 | |||
| 90 | static EVP_CIPHER d_ede3_ofb_cipher3= | ||
| 91 | { | ||
| 92 | NID_des_ede3_ofb64, | ||
| 93 | 1,24,8, | ||
| 94 | des_ede3_ofb_init_key, | ||
| 95 | des_ede_ofb_cipher, | ||
| 96 | NULL, | ||
| 97 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 98 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)), | ||
| 99 | EVP_CIPHER_set_asn1_iv, | ||
| 100 | EVP_CIPHER_get_asn1_iv, | ||
| 101 | }; | ||
| 102 | |||
| 103 | EVP_CIPHER *EVP_des_ede_ofb() | ||
| 104 | { | ||
| 105 | return(&d_ede_ofb_cipher2); | ||
| 106 | } | ||
| 107 | |||
| 108 | EVP_CIPHER *EVP_des_ede3_ofb() | ||
| 109 | { | ||
| 110 | return(&d_ede3_ofb_cipher3); | ||
| 111 | } | ||
| 112 | |||
| 113 | static void des_ede_ofb_init_key(ctx,key,iv,enc) | ||
| 114 | EVP_CIPHER_CTX *ctx; | ||
| 115 | unsigned char *key; | ||
| 116 | unsigned char *iv; | ||
| 117 | int enc; | ||
| 118 | { | ||
| 119 | ctx->num=0; | ||
| 120 | |||
| 121 | if (iv != NULL) | ||
| 122 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 123 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 124 | if (key != NULL) | ||
| 125 | { | ||
| 126 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 127 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 128 | memcpy( (char *)ctx->c.des_ede.ks3, | ||
| 129 | (char *)ctx->c.des_ede.ks1, | ||
| 130 | sizeof(ctx->c.des_ede.ks1)); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | static void des_ede3_ofb_init_key(ctx,key,iv,enc) | ||
| 135 | EVP_CIPHER_CTX *ctx; | ||
| 136 | unsigned char *key; | ||
| 137 | unsigned char *iv; | ||
| 138 | int enc; | ||
| 139 | { | ||
| 140 | ctx->num=0; | ||
| 141 | |||
| 142 | if (iv != NULL) | ||
| 143 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 144 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 145 | if (key != NULL) | ||
| 146 | { | ||
| 147 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | ||
| 148 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | ||
| 149 | des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | static void des_ede_ofb_cipher(ctx,out,in,inl) | ||
| 154 | EVP_CIPHER_CTX *ctx; | ||
| 155 | unsigned char *out; | ||
| 156 | unsigned char *in; | ||
| 157 | unsigned int inl; | ||
| 158 | { | ||
| 159 | des_ede3_ofb64_encrypt( | ||
| 160 | in,out, | ||
| 161 | (long)inl, | ||
| 162 | ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, | ||
| 163 | (des_cblock *)&(ctx->iv[0]), | ||
| 164 | &ctx->num); | ||
| 165 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_ofb_bf.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_BLOWFISH | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void bf_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void bf_ofb_init_key(); | ||
| 73 | static void bf_ofb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER bfish_ofb_cipher= | ||
| 77 | { | ||
| 78 | NID_bf_ofb64, | ||
| 79 | 1,EVP_BLOWFISH_KEY_SIZE,8, | ||
| 80 | bf_ofb_init_key, | ||
| 81 | bf_ofb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_bf_ofb() | ||
| 90 | { | ||
| 91 | return(&bfish_ofb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void bf_ofb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void bf_ofb_cipher(ctx,out,in,inl) | ||
| 110 | EVP_CIPHER_CTX *ctx; | ||
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | ||
| 115 | BF_ofb64_encrypt( | ||
| 116 | in,out, | ||
| 117 | (long)inl, &(ctx->c.bf_ks), | ||
| 118 | &(ctx->iv[0]), | ||
| 119 | &ctx->num); | ||
| 120 | } | ||
| 121 | |||
| 122 | #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 @@ | |||
| 1 | /* crypto/evp/e_ofb_c.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_CAST | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void cast_ofb_init_key(); | ||
| 73 | static void cast_ofb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER cast5_ofb_cipher= | ||
| 77 | { | ||
| 78 | NID_cast5_ofb64, | ||
| 79 | 1,EVP_CAST5_KEY_SIZE,8, | ||
| 80 | cast_ofb_init_key, | ||
| 81 | cast_ofb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_cast5_ofb() | ||
| 90 | { | ||
| 91 | return(&cast5_ofb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void cast_ofb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void cast_ofb_cipher(ctx,out,in,inl) | ||
| 110 | EVP_CIPHER_CTX *ctx; | ||
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | ||
| 115 | CAST_ofb64_encrypt( | ||
| 116 | in,out, | ||
| 117 | (long)inl, &(ctx->c.cast_ks), | ||
| 118 | &(ctx->iv[0]), | ||
| 119 | &ctx->num); | ||
| 120 | } | ||
| 121 | |||
| 122 | #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 @@ | |||
| 1 | /* crypto/evp/e_ofb_d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | #ifndef NOPROTO | ||
| 65 | static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 68 | unsigned char *in, unsigned int inl); | ||
| 69 | #else | ||
| 70 | static void des_ofb_init_key(); | ||
| 71 | static void des_ofb_cipher(); | ||
| 72 | #endif | ||
| 73 | |||
| 74 | static EVP_CIPHER d_ofb_cipher= | ||
| 75 | { | ||
| 76 | NID_des_ofb64, | ||
| 77 | 1,8,8, | ||
| 78 | des_ofb_init_key, | ||
| 79 | des_ofb_cipher, | ||
| 80 | NULL, | ||
| 81 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 82 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)), | ||
| 83 | EVP_CIPHER_set_asn1_iv, | ||
| 84 | EVP_CIPHER_get_asn1_iv, | ||
| 85 | }; | ||
| 86 | |||
| 87 | EVP_CIPHER *EVP_des_ofb() | ||
| 88 | { | ||
| 89 | return(&d_ofb_cipher); | ||
| 90 | } | ||
| 91 | |||
| 92 | static void des_ofb_init_key(ctx,key,iv,enc) | ||
| 93 | EVP_CIPHER_CTX *ctx; | ||
| 94 | unsigned char *key; | ||
| 95 | unsigned char *iv; | ||
| 96 | int enc; | ||
| 97 | { | ||
| 98 | ctx->num=0; | ||
| 99 | |||
| 100 | if (iv != NULL) | ||
| 101 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 102 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 103 | if (key != NULL) | ||
| 104 | des_set_key((des_cblock *)key,ctx->c.des_ks); | ||
| 105 | } | ||
| 106 | |||
| 107 | static void des_ofb_cipher(ctx,out,in,inl) | ||
| 108 | EVP_CIPHER_CTX *ctx; | ||
| 109 | unsigned char *out; | ||
| 110 | unsigned char *in; | ||
| 111 | unsigned int inl; | ||
| 112 | { | ||
| 113 | des_ofb64_encrypt( | ||
| 114 | in,out, | ||
| 115 | (long)inl, ctx->c.des_ks, | ||
| 116 | (des_cblock *)&(ctx->iv[0]), | ||
| 117 | &ctx->num); | ||
| 118 | } | ||
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 @@ | |||
| 1 | /* crypto/evp/e_ofb_i.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_IDEA | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void idea_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void idea_ofb_init_key(); | ||
| 73 | static void idea_ofb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER i_ofb_cipher= | ||
| 77 | { | ||
| 78 | NID_idea_ofb64, | ||
| 79 | 1,IDEA_KEY_LENGTH,IDEA_BLOCK, | ||
| 80 | idea_ofb_init_key, | ||
| 81 | idea_ofb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_idea_ofb() | ||
| 90 | { | ||
| 91 | return(&i_ofb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void idea_ofb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | idea_set_encrypt_key(key,&(ctx->c.idea_ks)); | ||
| 107 | } | ||
| 108 | |||
| 109 | static void idea_ofb_cipher(ctx,out,in,inl) | ||
| 110 | EVP_CIPHER_CTX *ctx; | ||
| 111 | unsigned char *out; | ||
| 112 | unsigned char *in; | ||
| 113 | unsigned int inl; | ||
| 114 | { | ||
| 115 | idea_ofb64_encrypt( | ||
| 116 | in,out,(long)inl, | ||
| 117 | &(ctx->c.idea_ks),&(ctx->iv[0]), | ||
| 118 | &ctx->num); | ||
| 119 | } | ||
| 120 | |||
| 121 | #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 @@ | |||
| 1 | /* crypto/evp/e_ofb_r2.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC2 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc2_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc2_ofb_init_key(); | ||
| 73 | static void rc2_ofb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER r2_ofb_cipher= | ||
| 77 | { | ||
| 78 | NID_rc2_ofb64, | ||
| 79 | 1,EVP_RC2_KEY_SIZE,8, | ||
| 80 | rc2_ofb_init_key, | ||
| 81 | rc2_ofb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc2_ofb() | ||
| 90 | { | ||
| 91 | return(&r2_ofb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc2_ofb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key, | ||
| 107 | EVP_RC2_KEY_SIZE*8); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void rc2_ofb_cipher(ctx,out,in,inl) | ||
| 111 | EVP_CIPHER_CTX *ctx; | ||
| 112 | unsigned char *out; | ||
| 113 | unsigned char *in; | ||
| 114 | unsigned int inl; | ||
| 115 | { | ||
| 116 | RC2_ofb64_encrypt( | ||
| 117 | in,out, | ||
| 118 | (long)inl, &(ctx->c.rc2_ks), | ||
| 119 | &(ctx->iv[0]), | ||
| 120 | &ctx->num); | ||
| 121 | } | ||
| 122 | |||
| 123 | #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 @@ | |||
| 1 | /* crypto/evp/e_ofb_r5.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC5 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include "evp.h" | ||
| 64 | #include "objects.h" | ||
| 65 | |||
| 66 | #ifndef NOPROTO | ||
| 67 | static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 68 | unsigned char *iv,int enc); | ||
| 69 | static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 70 | unsigned char *in, unsigned int inl); | ||
| 71 | #else | ||
| 72 | static void rc5_32_12_16_ofb_init_key(); | ||
| 73 | static void rc5_32_12_16_ofb_cipher(); | ||
| 74 | #endif | ||
| 75 | |||
| 76 | static EVP_CIPHER rc5_ofb_cipher= | ||
| 77 | { | ||
| 78 | NID_rc5_ofb64, | ||
| 79 | 1,EVP_RC5_32_12_16_KEY_SIZE,8, | ||
| 80 | rc5_32_12_16_ofb_init_key, | ||
| 81 | rc5_32_12_16_ofb_cipher, | ||
| 82 | NULL, | ||
| 83 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 84 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)), | ||
| 85 | EVP_CIPHER_set_asn1_iv, | ||
| 86 | EVP_CIPHER_get_asn1_iv, | ||
| 87 | }; | ||
| 88 | |||
| 89 | EVP_CIPHER *EVP_rc5_32_12_16_ofb() | ||
| 90 | { | ||
| 91 | return(&rc5_ofb_cipher); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *key; | ||
| 97 | unsigned char *iv; | ||
| 98 | int enc; | ||
| 99 | { | ||
| 100 | ctx->num=0; | ||
| 101 | |||
| 102 | if (iv != NULL) | ||
| 103 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 104 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 105 | if (key != NULL) | ||
| 106 | RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key, | ||
| 107 | RC5_12_ROUNDS); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl) | ||
| 111 | EVP_CIPHER_CTX *ctx; | ||
| 112 | unsigned char *out; | ||
| 113 | unsigned char *in; | ||
| 114 | unsigned int inl; | ||
| 115 | { | ||
| 116 | RC5_32_ofb64_encrypt( | ||
| 117 | in,out, | ||
| 118 | (long)inl, &(ctx->c.rc5_ks), | ||
| 119 | &(ctx->iv[0]), | ||
| 120 | &ctx->num); | ||
| 121 | } | ||
| 122 | |||
| 123 | #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 @@ | |||
| 1 | /* Error codes for the EVP functions. */ | ||
| 2 | |||
| 3 | /* Function codes. */ | ||
| 4 | #define EVP_F_D2I_PKEY 100 | ||
| 5 | #define EVP_F_EVP_DECRYPTFINAL 101 | ||
| 6 | #define EVP_F_EVP_OPENINIT 102 | ||
| 7 | #define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 | ||
| 8 | #define EVP_F_EVP_PKEY_DECRYPT 104 | ||
| 9 | #define EVP_F_EVP_PKEY_ENCRYPT 105 | ||
| 10 | #define EVP_F_EVP_PKEY_NEW 106 | ||
| 11 | #define EVP_F_EVP_SIGNFINAL 107 | ||
| 12 | #define EVP_F_EVP_VERIFYFINAL 108 | ||
| 13 | |||
| 14 | /* Reason codes. */ | ||
| 15 | #define EVP_R_BAD_DECRYPT 100 | ||
| 16 | #define EVP_R_DIFFERENT_KEY_TYPES 101 | ||
| 17 | #define EVP_R_IV_TOO_LARGE 102 | ||
| 18 | #define EVP_R_MISSING_PARMATERS 103 | ||
| 19 | #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 | ||
| 20 | #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 | ||
| 21 | #define EVP_R_PUBLIC_KEY_NOT_RSA 106 | ||
| 22 | #define EVP_R_UNSUPPORTED_CIPHER 107 | ||
| 23 | #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108 | ||
| 24 | #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 @@ | |||
| 1 | /* crypto/evp/pk_lib.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include "evp.h" | ||
| 62 | #include "objects.h" | ||
| 63 | |||
| 64 | static LHASH *pk_md=NULL; | ||
| 65 | |||
| 66 | static LHASH *pk_md=NULL; | ||
| 67 | |||
| 68 | int EVP_add_pkey_md(oid,pkm,md) | ||
| 69 | int oid; | ||
| 70 | EVP_PKEY_METHOD *pkm; | ||
| 71 | EVP_MD *md; | ||
| 72 | { | ||
| 73 | } | ||
| 74 | |||
| 75 | EVP_add_pkey(pkm) | ||
| 76 | EVP_PKEY_METHOD *pkm; | ||
| 77 | { | ||
| 78 | } | ||
| 79 | |||
| 80 | EVP_PKEY_METHOD:q | ||
| 81 | |||
| 82 | |||
