Skip to content
Snippets Groups Projects
Commit 36c36ef1 authored by Niels Möller's avatar Niels Möller
Browse files

* src/crypto.c (crypto_aes256_cbc_algorithm): Renamed, was

aes256_cbc_algorithm.
(crypto_des3_cbc_algorithm): New algorithm, to replace the code in
des.c. Doesn't quite work yet.

Rev: src/crypto.c:1.27
Rev: src/crypto.h:1.26
Rev: src/des.c:1.12
parent 09e831f2
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,13 @@ ...@@ -25,11 +25,13 @@
#include "crypto.h" #include "crypto.h"
#include "werror.h"
#include "xalloc.h" #include "xalloc.h"
#include "nettle/arcfour.h" #include "nettle/arcfour.h"
#include "nettle/cbc.h"
#include "nettle/aes.h" #include "nettle/aes.h"
#include "nettle/des.h"
#include "nettle/cbc.h" #include "nettle/cbc.h"
#include <assert.h> #include <assert.h>
...@@ -121,14 +123,12 @@ make_aes_instance(struct crypto_algorithm *algorithm, int mode, ...@@ -121,14 +123,12 @@ make_aes_instance(struct crypto_algorithm *algorithm, int mode,
return(&self->super); return(&self->super);
} }
struct crypto_algorithm aes256_cbc_algorithm = struct crypto_algorithm crypto_aes256_cbc_algorithm =
{ STATIC_HEADER, AES_BLOCK_SIZE, 32, AES_BLOCK_SIZE, make_aes_instance}; { STATIC_HEADER, AES_BLOCK_SIZE, 32, AES_BLOCK_SIZE, make_aes_instance};
#if 0
/* Triple DES */ /* Triple DES */
/* ;;GABA: /* GABA:
(class (class
(name des3_instance) (name des3_instance)
(super crypto_instance) (super crypto_instance)
...@@ -142,7 +142,7 @@ do_des3_encrypt(struct crypto_instance *s, ...@@ -142,7 +142,7 @@ do_des3_encrypt(struct crypto_instance *s,
{ {
CAST(des3_instance, self, s); CAST(des3_instance, self, s);
CBC_ENCRYPT(&self->ctx, length, dst, src); CBC_ENCRYPT(&self->ctx, des3_encrypt, length, dst, src);
} }
static void static void
...@@ -151,11 +151,12 @@ do_des3_decrypt(struct crypto_instance *s, ...@@ -151,11 +151,12 @@ do_des3_decrypt(struct crypto_instance *s,
{ {
CAST(des3_instance, self, s); CAST(des3_instance, self, s);
CBC_DECRYPT(&self->ctx, length, dst, src); CBC_DECRYPT(&self->ctx, des3_decrypt, length, dst, src);
} }
static struct crypto_instance * static struct crypto_instance *
make_des3_instance(struct crypto_algorithm *algorithm, int mode, make_des3_instance(struct crypto_algorithm *algorithm UNUSED,
int mode,
const UINT8 *key, const UINT8 *iv UNUSED) const UINT8 *key, const UINT8 *iv UNUSED)
{ {
NEW(des3_instance, self); NEW(des3_instance, self);
...@@ -169,10 +170,10 @@ make_des3_instance(struct crypto_algorithm *algorithm, int mode, ...@@ -169,10 +170,10 @@ make_des3_instance(struct crypto_algorithm *algorithm, int mode,
? do_des3_encrypt ? do_des3_encrypt
: do_des3_decrypt); : do_des3_decrypt);
if (des3_set_key(&self->ctx, key)) if (des3_set_key(&self->ctx.ctx, key))
return(&self->super); return(&self->super);
switch(self->ctx.status) switch(self->ctx.ctx.status)
{ {
case DES_BAD_PARITY: case DES_BAD_PARITY:
fatal("Internal error! Bad parity in make_des3_instance.\n"); fatal("Internal error! Bad parity in make_des3_instance.\n");
...@@ -185,10 +186,11 @@ make_des3_instance(struct crypto_algorithm *algorithm, int mode, ...@@ -185,10 +186,11 @@ make_des3_instance(struct crypto_algorithm *algorithm, int mode,
} }
} }
struct crypto_algorithm crypto_des3_algorithm = struct crypto_algorithm crypto_des3_cbc_algorithm =
{ STATIC_HEADER, { STATIC_HEADER,
DES3_BLOCK_SIZE, DES3_KEY_SIZE, DES3_BLOCK_SIZE, make_des3_instance }; DES3_BLOCK_SIZE, DES3_KEY_SIZE, DES3_BLOCK_SIZE, make_des3_instance };
#if 0
/* Twofish */ /* Twofish */
/* ;;GABA: /* ;;GABA:
...@@ -228,7 +230,7 @@ make_twofish_instance(struct crypto_algorithm *algorithm, int mode, ...@@ -228,7 +230,7 @@ make_twofish_instance(struct crypto_algorithm *algorithm, int mode,
? do_twofish_encrypt ? do_twofish_encrypt
: do_twofish_decrypt); : do_twofish_decrypt);
twofish_set_key(&self->ctx, algorithm->key_size, key); twofish_set_key(&self->ctx.ctx, algorithm->key_size, key);
return(&self->super); return(&self->super);
} }
......
...@@ -36,8 +36,13 @@ ...@@ -36,8 +36,13 @@
(dst) += (blocksize)) ) (dst) += (blocksize)) )
extern struct crypto_algorithm crypto_arcfour_algorithm; extern struct crypto_algorithm crypto_arcfour_algorithm;
#if 0
extern struct crypto_algorithm crypto_des_algorithm; extern struct crypto_algorithm crypto_des_algorithm;
struct crypto_algorithm *make_des3(void); struct crypto_algorithm *make_des3(void);
#endif
extern struct crypto_algorithm crypto_des3_cbc_algorithm;
struct crypto_algorithm *make_cast_algorithm(UINT32 key_size); struct crypto_algorithm *make_cast_algorithm(UINT32 key_size);
extern struct crypto_algorithm cast128_algorithm; extern struct crypto_algorithm cast128_algorithm;
...@@ -57,7 +62,7 @@ extern struct crypto_algorithm rijndael192_algorithm; ...@@ -57,7 +62,7 @@ extern struct crypto_algorithm rijndael192_algorithm;
extern struct crypto_algorithm rijndael256_algorithm; extern struct crypto_algorithm rijndael256_algorithm;
#endif #endif
extern struct crypto_algorithm aes256_cbc_algorithm; extern struct crypto_algorithm crypto_aes256_cbc_algorithm;
struct crypto_algorithm *make_serpent_algorithm(UINT32 key_size); struct crypto_algorithm *make_serpent_algorithm(UINT32 key_size);
extern struct crypto_algorithm serpent128_algorithm; extern struct crypto_algorithm serpent128_algorithm;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "crypto.h" #include "crypto.h"
#warning des.c is obsolete
#include "werror.h" #include "werror.h"
#include "xalloc.h" #include "xalloc.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment