diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/evp/e_ecb_3d.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/evp/e_ecb_3d.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_ecb_3d.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/src/lib/libcrypto/evp/e_ecb_3d.c b/src/lib/libcrypto/evp/e_ecb_3d.c index 908fc0760a..354a8b79a7 100644 --- a/src/lib/libcrypto/evp/e_ecb_3d.c +++ b/src/lib/libcrypto/evp/e_ecb_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 | ||
65 | static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | 65 | static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, |
66 | unsigned char *iv,int enc); | 66 | unsigned char *iv,int enc); |
67 | static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | 67 | static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, |
68 | unsigned char *iv,int enc); | 68 | unsigned char *iv,int enc); |
69 | static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 69 | static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
70 | unsigned char *in, unsigned int inl); | 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= | 71 | static EVP_CIPHER d_ede_cipher2= |
78 | { | 72 | { |
79 | NID_des_ede, | 73 | NID_des_ede, |
@@ -99,63 +93,66 @@ static EVP_CIPHER d_ede3_cipher3= | |||
99 | NULL, | 93 | NULL, |
100 | }; | 94 | }; |
101 | 95 | ||
102 | EVP_CIPHER *EVP_des_ede() | 96 | EVP_CIPHER *EVP_des_ede(void) |
103 | { | 97 | { |
104 | return(&d_ede_cipher2); | 98 | return(&d_ede_cipher2); |
105 | } | 99 | } |
106 | 100 | ||
107 | EVP_CIPHER *EVP_des_ede3() | 101 | EVP_CIPHER *EVP_des_ede3(void) |
108 | { | 102 | { |
109 | return(&d_ede3_cipher3); | 103 | return(&d_ede3_cipher3); |
110 | } | 104 | } |
111 | 105 | ||
112 | static void des_ede_init_key(ctx,key,iv,enc) | 106 | static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, |
113 | EVP_CIPHER_CTX *ctx; | 107 | unsigned char *iv, int enc) |
114 | unsigned char *key; | ||
115 | unsigned char *iv; | ||
116 | int enc; | ||
117 | { | 108 | { |
118 | if (key != NULL) | 109 | des_cblock *deskey = (des_cblock *)key; |
110 | |||
111 | if (deskey != NULL) | ||
119 | { | 112 | { |
120 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | 113 | des_set_key(&deskey[0],ctx->c.des_ede.ks1); |
121 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | 114 | des_set_key(&deskey[1],ctx->c.des_ede.ks2); |
122 | memcpy( (char *)ctx->c.des_ede.ks3, | 115 | memcpy( (char *)ctx->c.des_ede.ks3, |
123 | (char *)ctx->c.des_ede.ks1, | 116 | (char *)ctx->c.des_ede.ks1, |
124 | sizeof(ctx->c.des_ede.ks1)); | 117 | sizeof(ctx->c.des_ede.ks1)); |
125 | } | 118 | } |
126 | } | 119 | } |
127 | 120 | ||
128 | static void des_ede3_init_key(ctx,key,iv,enc) | 121 | static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, |
129 | EVP_CIPHER_CTX *ctx; | 122 | unsigned char *iv, int enc) |
130 | unsigned char *key; | ||
131 | unsigned char *iv; | ||
132 | int enc; | ||
133 | { | 123 | { |
134 | if (key != NULL) | 124 | des_cblock *deskey = (des_cblock *)key; |
125 | |||
126 | if (deskey != NULL) | ||
135 | { | 127 | { |
136 | des_set_key((des_cblock *)key,ctx->c.des_ede.ks1); | 128 | des_set_key(&deskey[0],ctx->c.des_ede.ks1); |
137 | des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2); | 129 | des_set_key(&deskey[1],ctx->c.des_ede.ks2); |
138 | des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3); | 130 | des_set_key(&deskey[2],ctx->c.des_ede.ks3); |
139 | } | 131 | } |
140 | } | 132 | } |
141 | 133 | ||
142 | static void des_ede_cipher(ctx,out,in,inl) | 134 | static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
143 | EVP_CIPHER_CTX *ctx; | 135 | unsigned char *in, unsigned int inl) |
144 | unsigned char *out; | ||
145 | unsigned char *in; | ||
146 | unsigned int inl; | ||
147 | { | 136 | { |
148 | unsigned int i; | 137 | unsigned int i; |
138 | des_cblock *output /* = (des_cblock *)out */; | ||
139 | des_cblock *input /* = (des_cblock *)in */; | ||
149 | 140 | ||
150 | if (inl < 8) return; | 141 | if (inl < 8) return; |
151 | inl-=8; | 142 | inl-=8; |
152 | for (i=0; i<=inl; i+=8) | 143 | for (i=0; i<=inl; i+=8) |
153 | { | 144 | { |
154 | des_ecb3_encrypt( | 145 | output = (des_cblock *)(out + i); |
155 | (des_cblock *)&(in[i]),(des_cblock *)&(out[i]), | 146 | input = (des_cblock *)(in + i); |
147 | |||
148 | des_ecb3_encrypt(input,output, | ||
156 | ctx->c.des_ede.ks1, | 149 | ctx->c.des_ede.ks1, |
157 | ctx->c.des_ede.ks2, | 150 | ctx->c.des_ede.ks2, |
158 | ctx->c.des_ede.ks3, | 151 | ctx->c.des_ede.ks3, |
159 | ctx->encrypt); | 152 | ctx->encrypt); |
153 | |||
154 | /* output++; */ | ||
155 | /* input++; */ | ||
160 | } | 156 | } |
161 | } | 157 | } |
158 | #endif | ||