summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_ofb_3d.c
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/evp/e_ofb_3d.c
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/evp/e_ofb_3d.c')
-rw-r--r--src/lib/libcrypto/evp/e_ofb_3d.c65
1 files changed, 26 insertions, 39 deletions
diff --git a/src/lib/libcrypto/evp/e_ofb_3d.c b/src/lib/libcrypto/evp/e_ofb_3d.c
index c3add18e93..5233567c0c 100644
--- a/src/lib/libcrypto/evp/e_ofb_3d.c
+++ b/src/lib/libcrypto/evp/e_ofb_3d.c
@@ -56,24 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DES
59#include <stdio.h> 60#include <stdio.h>
60#include "cryptlib.h" 61#include "cryptlib.h"
61#include "evp.h" 62#include <openssl/evp.h>
62#include "objects.h" 63#include <openssl/objects.h>
63 64
64#ifndef NOPROTO
65static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 65static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc); 66 unsigned char *iv,int enc);
67static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 67static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc); 68 unsigned char *iv,int enc);
69static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 69static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl); 70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_ofb_init_key();
73static void des_ede3_ofb_init_key();
74static void des_ede_ofb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_ofb_cipher2= 71static EVP_CIPHER d_ede_ofb_cipher2=
78 { 72 {
79 NID_des_ede_ofb64, 73 NID_des_ede_ofb64,
@@ -100,66 +94,59 @@ static EVP_CIPHER d_ede3_ofb_cipher3=
100 EVP_CIPHER_get_asn1_iv, 94 EVP_CIPHER_get_asn1_iv,
101 }; 95 };
102 96
103EVP_CIPHER *EVP_des_ede_ofb() 97EVP_CIPHER *EVP_des_ede_ofb(void)
104 { 98 {
105 return(&d_ede_ofb_cipher2); 99 return(&d_ede_ofb_cipher2);
106 } 100 }
107 101
108EVP_CIPHER *EVP_des_ede3_ofb() 102EVP_CIPHER *EVP_des_ede3_ofb(void)
109 { 103 {
110 return(&d_ede3_ofb_cipher3); 104 return(&d_ede3_ofb_cipher3);
111 } 105 }
112 106
113static void des_ede_ofb_init_key(ctx,key,iv,enc) 107static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
114EVP_CIPHER_CTX *ctx; 108 unsigned char *iv, int enc)
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 { 109 {
110 des_cblock *deskey = (des_cblock *)key;
111
119 ctx->num=0; 112 ctx->num=0;
120 113
121 if (iv != NULL) 114 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8); 115 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 116 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL) 117 if (deskey != NULL)
125 { 118 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); 119 des_set_key(&deskey[0],ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); 120 des_set_key(&deskey[1],ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3, 121 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1, 122 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1)); 123 sizeof(ctx->c.des_ede.ks1));
131 } 124 }
132 } 125 }
133 126
134static void des_ede3_ofb_init_key(ctx,key,iv,enc) 127static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
135EVP_CIPHER_CTX *ctx; 128 unsigned char *iv, int enc)
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 { 129 {
130 des_cblock *deskey = (des_cblock *)key;
131
140 ctx->num=0; 132 ctx->num=0;
141 133
142 if (iv != NULL) 134 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8); 135 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); 136 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL) 137 if (deskey != NULL)
146 { 138 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); 139 des_set_key(&deskey[0],ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); 140 des_set_key(&deskey[1],ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); 141 des_set_key(&deskey[2],ctx->c.des_ede.ks3);
150 } 142 }
151 } 143 }
152 144
153static void des_ede_ofb_cipher(ctx,out,in,inl) 145static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
154EVP_CIPHER_CTX *ctx; 146 unsigned char *in, unsigned int inl)
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 { 147 {
159 des_ede3_ofb64_encrypt( 148 des_ede3_ofb64_encrypt(in,out,inl,ctx->c.des_ede.ks1,
160 in,out, 149 ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
161 (long)inl, 150 (des_cblock *)&(ctx->iv[0]),&ctx->num);
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 } 151 }
152#endif