diff options
author | Andy Polyakov <appro@openssl.org> | 2008-12-23 11:33:01 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2008-12-23 11:33:01 +0000 |
commit | 5d48a66a6a4bc27b54d32721f7183077489c2e5f (patch) | |
tree | 27b158f856e0636bf349375c047a38b1fc97ee7c /crypto/seed | |
parent | 63fc7f848d4e047c3bd0f4a1c7e843191b2e9f0a (diff) | |
download | openssl-5d48a66a6a4bc27b54d32721f7183077489c2e5f.zip openssl-5d48a66a6a4bc27b54d32721f7183077489c2e5f.tar.gz openssl-5d48a66a6a4bc27b54d32721f7183077489c2e5f.tar.bz2 |
Engage crypto/modes.
Diffstat (limited to 'crypto/seed')
-rw-r--r-- | crypto/seed/Makefile | 12 | ||||
-rw-r--r-- | crypto/seed/seed_cbc.c | 76 | ||||
-rw-r--r-- | crypto/seed/seed_cfb.c | 34 | ||||
-rw-r--r-- | crypto/seed/seed_ofb.c | 18 |
4 files changed, 17 insertions, 123 deletions
diff --git a/crypto/seed/Makefile b/crypto/seed/Makefile index 4babe82..4bc55e4 100644 --- a/crypto/seed/Makefile +++ b/crypto/seed/Makefile @@ -81,17 +81,17 @@ seed.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h seed.o: ../../include/openssl/seed.h ../../include/openssl/stack.h seed.o: ../../include/openssl/symhacks.h seed.c seed_locl.h seed_cbc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h -seed_cbc.o: ../../include/openssl/opensslconf.h +seed_cbc.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h seed_cbc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h seed_cbc.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h seed_cbc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -seed_cbc.o: seed_cbc.c seed_locl.h +seed_cbc.o: seed_cbc.c seed_cfb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h -seed_cfb.o: ../../include/openssl/opensslconf.h +seed_cfb.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h seed_cfb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h seed_cfb.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h seed_cfb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -seed_cfb.o: seed_cfb.c seed_locl.h +seed_cfb.o: seed_cfb.c seed_ecb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h seed_ecb.o: ../../include/openssl/opensslconf.h seed_ecb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h @@ -99,8 +99,8 @@ seed_ecb.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h seed_ecb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h seed_ecb.o: seed_ecb.c seed_ofb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h -seed_ofb.o: ../../include/openssl/opensslconf.h +seed_ofb.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h seed_ofb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h seed_ofb.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h seed_ofb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -seed_ofb.o: seed_locl.h seed_ofb.c +seed_ofb.o: seed_ofb.c diff --git a/crypto/seed/seed_cbc.c b/crypto/seed/seed_cbc.c index 4f718cc..6c3f9b5 100644 --- a/crypto/seed/seed_cbc.c +++ b/crypto/seed/seed_cbc.c @@ -49,81 +49,15 @@ * */ -#include "seed_locl.h" -#include <string.h> +#include <openssl/seed.h> +#include <openssl/modes.h> void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int enc) { - size_t n; - unsigned char tmp[SEED_BLOCK_SIZE]; - const unsigned char *iv = ivec; - if (enc) - { - while (len >= SEED_BLOCK_SIZE) - { - for (n = 0; n < SEED_BLOCK_SIZE; ++n) - out[n] = in[n] ^ iv[n]; - SEED_encrypt(out, out, ks); - iv = out; - len -= SEED_BLOCK_SIZE; - in += SEED_BLOCK_SIZE; - out += SEED_BLOCK_SIZE; - } - if (len) - { - for (n = 0; n < len; ++n) - out[n] = in[n] ^ iv[n]; - for (n = len; n < SEED_BLOCK_SIZE; ++n) - out[n] = iv[n]; - SEED_encrypt(out, out, ks); - iv = out; - } - memcpy(ivec, iv, SEED_BLOCK_SIZE); - } - else if (in != out) /* decrypt */ - { - while (len >= SEED_BLOCK_SIZE) - { - SEED_decrypt(in, out, ks); - for (n = 0; n < SEED_BLOCK_SIZE; ++n) - out[n] ^= iv[n]; - iv = in; - len -= SEED_BLOCK_SIZE; - in += SEED_BLOCK_SIZE; - out += SEED_BLOCK_SIZE; - } - if (len) - { - SEED_decrypt(in, tmp, ks); - for (n = 0; n < len; ++n) - out[n] = tmp[n] ^ iv[n]; - iv = in; - } - memcpy(ivec, iv, SEED_BLOCK_SIZE); - } - else /* decrypt, overlap */ - { - while (len >= SEED_BLOCK_SIZE) - { - memcpy(tmp, in, SEED_BLOCK_SIZE); - SEED_decrypt(in, out, ks); - for (n = 0; n < SEED_BLOCK_SIZE; ++n) - out[n] ^= ivec[n]; - memcpy(ivec, tmp, SEED_BLOCK_SIZE); - len -= SEED_BLOCK_SIZE; - in += SEED_BLOCK_SIZE; - out += SEED_BLOCK_SIZE; - } - if (len) - { - memcpy(tmp, in, SEED_BLOCK_SIZE); - SEED_decrypt(tmp, tmp, ks); - for (n = 0; n < len; ++n) - out[n] = tmp[n] ^ ivec[n]; - memcpy(ivec, tmp, SEED_BLOCK_SIZE); - } - } + CRYPTO_cbc128_encrypt(in,out,len,ks,ivec,(block128_f)SEED_encrypt); + else + CRYPTO_cbc128_decrypt(in,out,len,ks,ivec,(block128_f)SEED_decrypt); } diff --git a/crypto/seed/seed_cfb.c b/crypto/seed/seed_cfb.c index 07d878a..694597d 100644 --- a/crypto/seed/seed_cfb.c +++ b/crypto/seed/seed_cfb.c @@ -105,40 +105,12 @@ * [including the GNU Public Licence.] */ -#include "seed_locl.h" -#include <string.h> +#include <openssl/seed.h> +#include <openssl/modes.h> void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc) { - int n; - unsigned char c; - - n = *num; - - if (enc) - { - while (len--) - { - if (n == 0) - SEED_encrypt(ivec, ivec, ks); - ivec[n] = *(out++) = *(in++) ^ ivec[n]; - n = (n+1) % SEED_BLOCK_SIZE; - } - } - else - { - while (len--) - { - if (n == 0) - SEED_encrypt(ivec, ivec, ks); - c = *(in); - *(out++) = *(in++) ^ ivec[n]; - ivec[n] = c; - n = (n+1) % SEED_BLOCK_SIZE; - } - } - - *num = n; + CRYPTO_cfb128_encrypt(in,out,len,ks,ivec,num,enc,(block128_f)SEED_encrypt); } diff --git a/crypto/seed/seed_ofb.c b/crypto/seed/seed_ofb.c index e2f3f57..3c8ba33 100644 --- a/crypto/seed/seed_ofb.c +++ b/crypto/seed/seed_ofb.c @@ -105,24 +105,12 @@ * [including the GNU Public Licence.] */ -#include "seed_locl.h" -#include <string.h> +#include <openssl/seed.h> +#include <openssl/modes.h> void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num) { - int n; - - n = *num; - - while (len--) - { - if (n == 0) - SEED_encrypt(ivec, ivec, ks); - *(out++) = *(in++) ^ ivec[n]; - n = (n+1) % SEED_BLOCK_SIZE; - } - - *num = n; + CRYPTO_ofb128_encrypt(in,out,len,ks,ivec,num,(block128_f)SEED_encrypt); } |