This commit was manufactured by cvs2svn to create branch 'BRANCH_engine'.
This commit is contained in:
commit
20ca3d49e7
80
crypto/evp/e_bf.c
Normal file
80
crypto/evp/e_bf.c
Normal file
@ -0,0 +1,80 @@
|
||||
/* crypto/evp/e_bf.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_BF
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include "evp_locl.h"
|
||||
#include <openssl/objects.h>
|
||||
|
||||
static int bf_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
IMPLEMENT_BLOCK_CIPHER(bf, bf_ks, BF, bf_ks, NID_bf, 8, 16, 8,
|
||||
0, bf_init_key, NULL,
|
||||
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
|
||||
|
||||
static int bf_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
BF_set_key(&(ctx->c.bf_ks),EVP_CIPHER_CTX_key_length(ctx),key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
82
crypto/evp/e_cast.c
Normal file
82
crypto/evp/e_cast.c
Normal file
@ -0,0 +1,82 @@
|
||||
/* crypto/evp/e_cast.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_CAST
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
static int cast_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
IMPLEMENT_BLOCK_CIPHER(cast5, cast_ks, CAST, cast_ks,
|
||||
NID_cast5, 8, EVP_CAST5_KEY_SIZE, 8,
|
||||
EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL,
|
||||
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
|
||||
|
||||
static int cast_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
CAST_set_key(&(ctx->c.cast_ks),EVP_CIPHER_CTX_key_length(ctx),key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
112
crypto/evp/e_des.c
Normal file
112
crypto/evp/e_des.c
Normal file
@ -0,0 +1,112 @@
|
||||
/* crypto/evp/e_des.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_DES
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
static int des_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
/* Because of various casts and different names can't use IMPLEMENT_BLOCK_CIPHER */
|
||||
|
||||
static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
BLOCK_CIPHER_ecb_loop()
|
||||
des_ecb_encrypt((des_cblock *)(in + i), (des_cblock *)(out + i), ctx->c.des_ks, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
des_ofb64_encrypt(in, out, (long)inl, ctx->c.des_ks, (des_cblock *)ctx->iv, &ctx->num);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
des_ncbc_encrypt(in, out, (long)inl, ctx->c.des_ks, (des_cblock *)ctx->iv, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
des_cfb64_encrypt(in, out, (long)inl, ctx->c.des_ks, (des_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
BLOCK_CIPHER_defs(des, des_ks, NID_des, 8, 8, 8,
|
||||
0, des_init_key, NULL,
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
NULL)
|
||||
|
||||
|
||||
static int des_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
des_cblock *deskey = (des_cblock *)key;
|
||||
|
||||
des_set_key_unchecked(deskey,ctx->c.des_ks);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
161
crypto/evp/e_des3.c
Normal file
161
crypto/evp/e_des3.c
Normal file
@ -0,0 +1,161 @@
|
||||
/* crypto/evp/e_des3.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_DES
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
static int des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
/* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */
|
||||
|
||||
static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
BLOCK_CIPHER_ecb_loop()
|
||||
des_ecb3_encrypt((des_cblock *)(in + i), (des_cblock *)(out + i),
|
||||
ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
|
||||
ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
des_ede3_ofb64_encrypt(in, out, (long)inl,
|
||||
ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
|
||||
(des_cblock *)ctx->iv, &ctx->num);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
des_ede3_cbc_encrypt(in, out, (long)inl,
|
||||
ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
|
||||
(des_cblock *)ctx->iv, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
des_ede3_cfb64_encrypt(in, out, (long)inl,
|
||||
ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
|
||||
(des_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define NID_des_ede_ecb NID_des_ede
|
||||
|
||||
BLOCK_CIPHER_defs(des_ede, des_ede, NID_des_ede, 8, 16, 8,
|
||||
0, des_ede_init_key, NULL,
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
NULL)
|
||||
|
||||
#define NID_des_ede3_ecb NID_des_ede3
|
||||
#define des_ede3_cfb_cipher des_ede_cfb_cipher
|
||||
#define des_ede3_ofb_cipher des_ede_ofb_cipher
|
||||
#define des_ede3_cbc_cipher des_ede_cbc_cipher
|
||||
#define des_ede3_ecb_cipher des_ede_ecb_cipher
|
||||
|
||||
BLOCK_CIPHER_defs(des_ede3, des_ede, NID_des_ede3, 8, 24, 8,
|
||||
0, des_ede3_init_key, NULL,
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
NULL)
|
||||
|
||||
static int des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
des_cblock *deskey = (des_cblock *)key;
|
||||
|
||||
des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
|
||||
des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
|
||||
memcpy( (char *)ctx->c.des_ede.ks3,
|
||||
(char *)ctx->c.des_ede.ks1,
|
||||
sizeof(ctx->c.des_ede.ks1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
des_cblock *deskey = (des_cblock *)key;
|
||||
|
||||
des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1);
|
||||
des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2);
|
||||
des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EVP_CIPHER *EVP_des_ede(void)
|
||||
{
|
||||
return &des_ede_ecb;
|
||||
}
|
||||
|
||||
EVP_CIPHER *EVP_des_ede3(void)
|
||||
{
|
||||
return &des_ede3_ecb;
|
||||
}
|
||||
#endif
|
111
crypto/evp/e_idea.c
Normal file
111
crypto/evp/e_idea.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* crypto/evp/e_idea.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_IDEA
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
static int idea_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
/* NB idea_ecb_encrypt doesn't take an 'encrypt' argument so we treat it as a special
|
||||
* case
|
||||
*/
|
||||
|
||||
static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl)
|
||||
{
|
||||
BLOCK_CIPHER_ecb_loop()
|
||||
idea_ecb_encrypt(in + i, out + i, &ctx->c.idea_ks);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Can't use IMPLEMENT_BLOCK_CIPHER because idea_ecb_encrypt is different */
|
||||
|
||||
BLOCK_CIPHER_func_cbc(idea, idea, idea_ks)
|
||||
BLOCK_CIPHER_func_ofb(idea, idea, idea_ks)
|
||||
BLOCK_CIPHER_func_cfb(idea, idea, idea_ks)
|
||||
|
||||
BLOCK_CIPHER_defs(idea, idea_ks, NID_idea, 8, 16, 8,
|
||||
0, idea_init_key, NULL,
|
||||
EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
|
||||
|
||||
static int idea_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
if(!enc) {
|
||||
if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) enc = 1;
|
||||
else if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE) enc = 1;
|
||||
}
|
||||
if (enc) idea_set_encrypt_key(key,&(ctx->c.idea_ks));
|
||||
else
|
||||
{
|
||||
IDEA_KEY_SCHEDULE tmp;
|
||||
|
||||
idea_set_encrypt_key(key,&tmp);
|
||||
idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks));
|
||||
memset((unsigned char *)&tmp,0,
|
||||
sizeof(IDEA_KEY_SCHEDULE));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
198
crypto/evp/e_rc2.c
Normal file
198
crypto/evp/e_rc2.c
Normal file
@ -0,0 +1,198 @@
|
||||
/* crypto/evp/e_rc2.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_RC2
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
static int rc2_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
static int rc2_meth_to_magic(const EVP_CIPHER *e);
|
||||
static EVP_CIPHER *rc2_magic_to_meth(int i);
|
||||
static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
|
||||
static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
|
||||
|
||||
IMPLEMENT_BLOCK_CIPHER(rc2, rc2.ks, RC2, rc2, NID_rc2,
|
||||
8,
|
||||
EVP_RC2_KEY_SIZE, 8,
|
||||
EVP_CIPH_VARIABLE_LENGTH, rc2_init_key, NULL,
|
||||
rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, NULL)
|
||||
|
||||
#define RC2_40_MAGIC 0xa0
|
||||
#define RC2_64_MAGIC 0x78
|
||||
#define RC2_128_MAGIC 0x3a
|
||||
|
||||
static EVP_CIPHER r2_64_cbc_cipher=
|
||||
{
|
||||
NID_rc2_64_cbc,
|
||||
8,8 /* 64 bit */,8,
|
||||
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH,
|
||||
rc2_init_key,
|
||||
rc2_cbc_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2)),
|
||||
rc2_set_asn1_type_and_iv,
|
||||
rc2_get_asn1_type_and_iv,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static EVP_CIPHER r2_40_cbc_cipher=
|
||||
{
|
||||
NID_rc2_40_cbc,
|
||||
8,5 /* 40 bit */,8,
|
||||
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH,
|
||||
rc2_init_key,
|
||||
rc2_cbc_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2)),
|
||||
rc2_set_asn1_type_and_iv,
|
||||
rc2_get_asn1_type_and_iv,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EVP_CIPHER *EVP_rc2_64_cbc(void)
|
||||
{
|
||||
return(&r2_64_cbc_cipher);
|
||||
}
|
||||
|
||||
EVP_CIPHER *EVP_rc2_40_cbc(void)
|
||||
{
|
||||
return(&r2_40_cbc_cipher);
|
||||
}
|
||||
|
||||
static int rc2_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
RC2_set_key(&(ctx->c.rc2.ks),EVP_CIPHER_CTX_key_length(ctx),
|
||||
key,EVP_CIPHER_key_length(ctx->cipher)*8);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int rc2_meth_to_magic(const EVP_CIPHER *e)
|
||||
{
|
||||
int i;
|
||||
|
||||
i=EVP_CIPHER_key_length(e);
|
||||
if (i == 16) return(RC2_128_MAGIC);
|
||||
else if (i == 8) return(RC2_64_MAGIC);
|
||||
else if (i == 5) return(RC2_40_MAGIC);
|
||||
else return(0);
|
||||
}
|
||||
|
||||
static EVP_CIPHER *rc2_magic_to_meth(int i)
|
||||
{
|
||||
if (i == RC2_128_MAGIC) return(EVP_rc2_cbc());
|
||||
else if (i == RC2_64_MAGIC) return(EVP_rc2_64_cbc());
|
||||
else if (i == RC2_40_MAGIC) return(EVP_rc2_40_cbc());
|
||||
else
|
||||
{
|
||||
EVPerr(EVP_F_RC2_MAGIC_TO_METH,EVP_R_UNSUPPORTED_KEY_SIZE);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
|
||||
{
|
||||
long num=0;
|
||||
int i=0,l;
|
||||
EVP_CIPHER *e;
|
||||
|
||||
if (type != NULL)
|
||||
{
|
||||
l=EVP_CIPHER_CTX_iv_length(c);
|
||||
i=ASN1_TYPE_get_int_octetstring(type,&num,c->oiv,l);
|
||||
if (i != l)
|
||||
return(-1);
|
||||
else if (i > 0)
|
||||
memcpy(c->iv,c->oiv,l);
|
||||
e=rc2_magic_to_meth((int)num);
|
||||
if (e == NULL)
|
||||
return(-1);
|
||||
if (e != EVP_CIPHER_CTX_cipher(c))
|
||||
{
|
||||
EVP_CIPHER_CTX_cipher(c)=e;
|
||||
EVP_CIPHER_CTX_set_key_length(c, EVP_CIPHER_key_length(c));
|
||||
rc2_init_key(c,NULL,NULL,1);
|
||||
}
|
||||
}
|
||||
return(i);
|
||||
}
|
||||
|
||||
static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
|
||||
{
|
||||
long num;
|
||||
int i=0,j;
|
||||
|
||||
if (type != NULL)
|
||||
{
|
||||
num=rc2_meth_to_magic(EVP_CIPHER_CTX_cipher(c));
|
||||
j=EVP_CIPHER_CTX_iv_length(c);
|
||||
i=ASN1_TYPE_set_int_octetstring(type,num,c->oiv,j);
|
||||
}
|
||||
return(i);
|
||||
}
|
||||
|
||||
#endif
|
118
crypto/evp/e_rc5.c
Normal file
118
crypto/evp/e_rc5.c
Normal file
@ -0,0 +1,118 @@
|
||||
/* crypto/evp/e_rc5.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef NO_RC5
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/objects.h>
|
||||
#include "evp_locl.h"
|
||||
|
||||
static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv,int enc);
|
||||
|
||||
IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, rc5.ks, RC5_32, rc5, NID_rc5,
|
||||
8, EVP_RC5_32_12_16_KEY_SIZE, 8,
|
||||
0, r_32_12_16_init_key, NULL,
|
||||
NULL, NULL, NULL)
|
||||
|
||||
#if 0
|
||||
static int r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
unsigned char *in, unsigned int inl);
|
||||
static EVP_CIPHER rc5_32_12_16_cbc_cipher=
|
||||
{
|
||||
NID_rc5_cbc,
|
||||
8,EVP_RC5_32_12_16_KEY_SIZE,8,
|
||||
EVP_CIPH_CBC_MODE,
|
||||
r_32_12_16_cbc_init_key,
|
||||
r_32_12_16_cbc_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5)),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EVP_CIPHER *EVP_rc5_32_12_16_cbc(void)
|
||||
{
|
||||
return(&rc5_32_12_16_cbc_cipher);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
|
||||
unsigned char *iv, int enc)
|
||||
{
|
||||
RC5_32_set_key(&(ctx->c.rc5.ks),EVP_RC5_32_12_16_KEY_SIZE,
|
||||
key,RC5_12_ROUNDS);
|
||||
return 1;
|
||||
}
|
||||
#if 0
|
||||
static int r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
unsigned char *in, unsigned int inl)
|
||||
{
|
||||
RC5_32_cbc_encrypt(
|
||||
in,out,(long)inl,
|
||||
&(ctx->c.rc5.ks),&(ctx->iv[0]),
|
||||
ctx->encrypt);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
168
crypto/evp/evp_locl.h
Normal file
168
crypto/evp/evp_locl.h
Normal file
@ -0,0 +1,168 @@
|
||||
/* evp_locl.h */
|
||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
|
||||
* project 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
/* Macros to code block cipher wrappers */
|
||||
|
||||
/* Wrapper functions for each cipher mode */
|
||||
|
||||
#define BLOCK_CIPHER_ecb_loop() \
|
||||
unsigned int i; \
|
||||
if(inl < 8) return 1;\
|
||||
inl -= 8; \
|
||||
for(i=0; i <= inl; i+=8) \
|
||||
|
||||
#define BLOCK_CIPHER_func_ecb(cname, cprefix, kname) \
|
||||
static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
BLOCK_CIPHER_ecb_loop() \
|
||||
cprefix##_ecb_encrypt(in + i, out + i, &ctx->c.##kname, ctx->encrypt);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_func_ofb(cname, cprefix, kname) \
|
||||
static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
cprefix##_ofb64_encrypt(in, out, (long)inl, &ctx->c.##kname, ctx->iv, &ctx->num);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_func_cbc(cname, cprefix, kname) \
|
||||
static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
cprefix##_cbc_encrypt(in, out, (long)inl, &ctx->c.##kname, ctx->iv, ctx->encrypt);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_func_cfb(cname, cprefix, kname) \
|
||||
static int cname##_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
cprefix##_cfb64_encrypt(in, out, (long)inl, &ctx->c.##kname, ctx->iv, &ctx->num, ctx->encrypt);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_all_funcs(cname, cprefix, kname) \
|
||||
BLOCK_CIPHER_func_cbc(cname, cprefix, kname) \
|
||||
BLOCK_CIPHER_func_cfb(cname, cprefix, kname) \
|
||||
BLOCK_CIPHER_func_ecb(cname, cprefix, kname) \
|
||||
BLOCK_CIPHER_func_ofb(cname, cprefix, kname)
|
||||
|
||||
#define BLOCK_CIPHER_defs(cname, kstruct, \
|
||||
nid, block_size, key_len, iv_len, flags,\
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl)\
|
||||
static EVP_CIPHER cname##_cbc = {\
|
||||
nid##_cbc, block_size, key_len, iv_len, \
|
||||
flags | EVP_CIPH_CBC_MODE,\
|
||||
init_key,\
|
||||
cname##_cbc_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.##kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl, \
|
||||
NULL \
|
||||
};\
|
||||
EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
|
||||
static EVP_CIPHER cname##_cfb = {\
|
||||
nid##_cfb64, 1, key_len, iv_len, \
|
||||
flags | EVP_CIPH_CFB_MODE,\
|
||||
init_key,\
|
||||
cname##_cfb_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.##kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl,\
|
||||
NULL \
|
||||
};\
|
||||
EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
|
||||
static EVP_CIPHER cname##_ofb = {\
|
||||
nid##_ofb64, 1, key_len, iv_len, \
|
||||
flags | EVP_CIPH_OFB_MODE,\
|
||||
init_key,\
|
||||
cname##_ofb_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.##kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl,\
|
||||
NULL \
|
||||
};\
|
||||
EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
|
||||
static EVP_CIPHER cname##_ecb = {\
|
||||
nid##_ecb, block_size, key_len, iv_len, \
|
||||
flags | EVP_CIPH_ECB_MODE,\
|
||||
init_key,\
|
||||
cname##_ecb_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.##kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl,\
|
||||
NULL \
|
||||
};\
|
||||
EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
|
||||
|
||||
|
||||
|
||||
#define IMPLEMENT_BLOCK_CIPHER(cname, kname, cprefix, kstruct, \
|
||||
nid, block_size, key_len, iv_len, flags, \
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_all_funcs(cname, cprefix, kname) \
|
||||
BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, flags,\
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl)
|
||||
|
Loading…
x
Reference in New Issue
Block a user