summaryrefslogtreecommitdiffstats
path: root/crypto/evp/e_des.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2004-01-27 21:47:35 +0000
committerAndy Polyakov <appro@openssl.org>2004-01-27 21:47:35 +0000
commit8c6336b0aac8c34584116d2c05b6d828dc9d8ae6 (patch)
tree00d5cd5a4f49583f6defa8c4c93de1afa7ac8dbd /crypto/evp/e_des.c
parent87203dc99aeaf3ef50b3df4ac99f2471d06434eb (diff)
CFB DES sync-up with FIPS branch.
Diffstat (limited to 'crypto/evp/e_des.c')
-rw-r--r--crypto/evp/e_des.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/crypto/evp/e_des.c b/crypto/evp/e_des.c
index 92f6ebc343..f2554ecc6a 100644
--- a/crypto/evp/e_des.c
+++ b/crypto/evp/e_des.c
@@ -92,20 +92,53 @@ static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 1;
}
-static int des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
- const unsigned char *in, unsigned int inl)
+static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ const unsigned char *in, unsigned int inl)
{
DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data,
(DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
return 1;
}
+/* Although we have a CFB-r implementation for DES, it doesn't pack the right
+ way, so wrap it here */
+static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ const unsigned char *in, unsigned int inl)
+ {
+ unsigned int n;
+ unsigned char c[1],d[1];
+
+ for(n=0 ; n < inl ; ++n)
+ {
+ c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
+ DES_cfb_encrypt(c,d,1,1,ctx->cipher_data,(DES_cblock *)ctx->iv,
+ ctx->encrypt);
+ out[n/8]=(out[n/8]&~(0x80 >> (n%8)))|((d[0]&0x80) >> (n%8));
+ }
+ return 1;
+ }
+
+static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ const unsigned char *in, unsigned int inl)
+ {
+ DES_cfb_encrypt(in,out,8,inl,ctx->cipher_data,(DES_cblock *)ctx->iv,
+ ctx->encrypt);
+ return 1;
+ }
+
BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64,
0, des_init_key, NULL,
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
NULL)
+BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,0,des_init_key,NULL,
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,NULL)
+
+BLOCK_CIPHER_def_cfb(des,DES_key_schedule,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, const unsigned char *key,
const unsigned char *iv, int enc)