summaryrefslogtreecommitdiff
path: root/lib/gc-gnulib.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2005-10-21 12:28:18 +0000
committerSimon Josefsson <simon@josefsson.org>2005-10-21 12:28:18 +0000
commit6a58cb3f05f9a3d05ce2b0e0845b7514540d81b5 (patch)
tree76d6db544ee56dd97ef46139cf3c3111ed61107a /lib/gc-gnulib.c
parent4b7432cf9a39d202337f0a2ca5d867df9fa49707 (diff)
downloadgnulib-6a58cb3f05f9a3d05ce2b0e0845b7514540d81b5.tar.gz
Add des, des-tests, gc-des, gc-des-tests modules.
Diffstat (limited to 'lib/gc-gnulib.c')
-rw-r--r--lib/gc-gnulib.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c
index bc5f24c736..6eff3e3fee 100644
--- a/lib/gc-gnulib.c
+++ b/lib/gc-gnulib.c
@@ -58,6 +58,9 @@
#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
@@ -167,6 +170,9 @@ typedef struct _gc_cipher_ctx {
#ifdef GC_USE_ARCFOUR
arcfour_context arcfourContext;
#endif
+#ifdef GC_USE_DES
+ des_ctx desContext;
+#endif
#ifdef GC_USE_RIJNDAEL
rijndaelKeyInstance aesEncKey;
rijndaelKeyInstance aesDecKey;
@@ -215,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:
@@ -263,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:
@@ -365,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:
@@ -407,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: