X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fgc-gnulib.c;h=6eff3e3fee4363f488d28b43f34d0e314a3227ba;hb=8de557e31178699dd6e839850056f0653cdfba89;hp=61bf12435bcdc9a3292d32a69e2d84aa9cbb8fe5;hpb=c4f00b7d32160f83e4fb811c6584e8f4e48dfa2e;p=gnulib.git diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c index 61bf12435..6eff3e3fe 100644 --- a/lib/gc-gnulib.c +++ b/lib/gc-gnulib.c @@ -55,6 +55,12 @@ #ifdef GC_USE_ARCFOUR # include "arcfour.h" #endif +#ifdef GC_USE_ARCTWO +# include "arctwo.h" +#endif +#ifdef GC_USE_DES +# include "des.h" +#endif #ifdef GC_USE_RIJNDAEL # include "rijndael-api-fst.h" #endif @@ -158,9 +164,15 @@ gc_set_allocators (gc_malloc_t func_malloc, typedef struct _gc_cipher_ctx { Gc_cipher alg; Gc_cipher_mode mode; +#ifdef GC_USE_ARCTWO + arctwo_context arctwoContext; +#endif #ifdef GC_USE_ARCFOUR arcfour_context arcfourContext; #endif +#ifdef GC_USE_DES + des_ctx desContext; +#endif #ifdef GC_USE_RIJNDAEL rijndaelKeyInstance aesEncKey; rijndaelKeyInstance aesDecKey; @@ -182,6 +194,19 @@ gc_cipher_open (Gc_cipher alg, Gc_cipher_mode mode, switch (alg) { +#ifdef GC_USE_ARCTWO + case GC_ARCTWO40: + switch (mode) + { + case GC_ECB: + break; + + default: + rc = GC_INVALID_CIPHER; + } + break; +#endif + #ifdef GC_USE_ARCFOUR case GC_ARCFOUR128: case GC_ARCFOUR40: @@ -196,6 +221,19 @@ gc_cipher_open (Gc_cipher alg, Gc_cipher_mode mode, break; #endif +#ifdef GC_USE_DES + case GC_DES: + switch (mode) + { + case GC_ECB: + break; + + default: + rc = GC_INVALID_CIPHER; + } + break; +#endif + #ifdef GC_USE_RIJNDAEL case GC_AES128: case GC_AES192: @@ -231,6 +269,12 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key) switch (ctx->alg) { +#ifdef GC_USE_ARCTWO + case GC_ARCTWO40: + arctwo_setkey (&ctx->arctwoContext, keylen, key); + break; +#endif + #ifdef GC_USE_ARCFOUR case GC_ARCFOUR128: case GC_ARCFOUR40: @@ -238,6 +282,14 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key) break; #endif +#ifdef GC_USE_DES + case GC_DES: + if (keylen != 8) + return GC_INVALID_CIPHER; + des_setkey (&ctx->desContext, key); + break; +#endif + #ifdef GC_USE_RIJNDAEL case GC_AES128: case GC_AES192: @@ -327,6 +379,12 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data) switch (ctx->alg) { +#ifdef GC_USE_ARCTWO + case GC_ARCTWO40: + arctwo_encrypt (&ctx->arctwoContext, data, data, len); + break; +#endif + #ifdef GC_USE_ARCFOUR case GC_ARCFOUR128: case GC_ARCFOUR40: @@ -334,6 +392,13 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data) break; #endif +#ifdef GC_USE_DES + case GC_DES: + for (; len >= 8; len -= 8, data += 8) + des_ecb_encrypt (&ctx->desContext, data, data); + break; +#endif + #ifdef GC_USE_RIJNDAEL case GC_AES128: case GC_AES192: @@ -363,6 +428,12 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data) switch (ctx->alg) { +#ifdef GC_USE_ARCTWO + case GC_ARCTWO40: + arctwo_decrypt (&ctx->arctwoContext, data, data, len); + break; +#endif + #ifdef GC_USE_ARCFOUR case GC_ARCFOUR128: case GC_ARCFOUR40: @@ -370,6 +441,13 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data) break; #endif +#ifdef GC_USE_DES + case GC_DES: + for (; len >= 8; len -= 8, data += 8) + des_ecb_decrypt (&ctx->desContext, data, data); + break; +#endif + #ifdef GC_USE_RIJNDAEL case GC_AES128: case GC_AES192: