Commit 3c2b83bf authored by Niels Möller's avatar Niels Möller

(des3_set_key): Changed weak key detection logic.

Complete key setup also for weak keys, and don't set the status
attribute.

Rev: nettle/des3.c:1.2
parent e907011a
...@@ -33,20 +33,18 @@ ...@@ -33,20 +33,18 @@
* lsh/src/cascade.c, but as in practice it's never used for anything * lsh/src/cascade.c, but as in practice it's never used for anything
* like triple DES, it's not worth the effort. */ * like triple DES, it's not worth the effort. */
/* On success, returns 1 and sets ctx->status to DES_OK (zero). On /* Returns 1 for good keys and 0 for weak keys. */
* error, returns 0 and sets ctx->status accordingly. */
int int
des3_set_key(struct des3_ctx *ctx, const uint8_t *key) des3_set_key(struct des3_ctx *ctx, const uint8_t *key)
{ {
unsigned i; unsigned i;
int is_good = 1;
for (i = 0; i<3; i++, key += DES_KEY_SIZE) for (i = 0; i<3; i++, key += DES_KEY_SIZE)
if (!des_set_key(&ctx->des[i], key)) if (!des_set_key(&ctx->des[i], key))
{ is_good = 0;
ctx->status = ctx->des[i].status;
return 0; return is_good;
}
ctx->status = DES_OK;
return 1;
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment