]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(des3_set_key): Changed weak key detection logic.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 5 Jul 2010 19:52:38 +0000 (21:52 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 5 Jul 2010 19:52:38 +0000 (21:52 +0200)
Complete key setup also for weak keys, and don't set the status
attribute.

Rev: nettle/des3.c:1.2

des3.c

diff --git a/des3.c b/des3.c
index ea7bfef3d37638c26d3c545db4a4992f2a38210a..e574abfd8888a8142cfd748be4c5e2acdae8f232 100644 (file)
--- a/des3.c
+++ b/des3.c
  * lsh/src/cascade.c, but as in practice it's never used for anything
  * like triple DES, it's not worth the effort. */
 
-/* On success, returns 1 and sets ctx->status to DES_OK (zero). On
- * error, returns 0 and sets ctx->status accordingly. */
+/* Returns 1 for good keys and 0 for weak keys. */
 int
 des3_set_key(struct des3_ctx *ctx, const uint8_t *key)
 {
   unsigned i;
+  int is_good = 1;
+  
   for (i = 0; i<3; i++, key += DES_KEY_SIZE)
     if (!des_set_key(&ctx->des[i], key))
-      {
-       ctx->status = ctx->des[i].status;
-       return 0;
-      }
-  ctx->status = DES_OK;
-  return 1;
+      is_good = 0;
+
+  return is_good;
 }
 
 void