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
......@@ -25,11 +25,13 @@
#include "crypto.h"
#include "werror.h"
#include "xalloc.h"
#include "nettle/arcfour.h"
#include "nettle/cbc.h"
#include "nettle/aes.h"
#include "nettle/des.h"
#include "nettle/cbc.h"
#include <assert.h>
......@@ -121,14 +123,12 @@ make_aes_instance(struct crypto_algorithm *algorithm, int mode,
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};
#if 0
/* Triple DES */
/* ;;GABA:
/* GABA:
(class
(name des3_instance)
(super crypto_instance)
......@@ -142,7 +142,7 @@ do_des3_encrypt(struct crypto_instance *s,
{
CAST(des3_instance, self, s);
CBC_ENCRYPT(&self->ctx, length, dst, src);
CBC_ENCRYPT(&self->ctx, des3_encrypt, length, dst, src);
}
static void
......@@ -151,11 +151,12 @@ do_des3_decrypt(struct crypto_instance *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 *
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)
{
NEW(des3_instance, self);
......@@ -169,10 +170,10 @@ make_des3_instance(struct crypto_algorithm *algorithm, int mode,
? do_des3_encrypt
: do_des3_decrypt);
if (des3_set_key(&self->ctx, key))
if (des3_set_key(&self->ctx.ctx, key))
return(&self->super);
switch(self->ctx.status)
switch(self->ctx.ctx.status)
{
case DES_BAD_PARITY:
fatal("Internal error! Bad parity in make_des3_instance.\n");
......@@ -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,
DES3_BLOCK_SIZE, DES3_KEY_SIZE, DES3_BLOCK_SIZE, make_des3_instance };
#if 0
/* Twofish */
/* ;;GABA:
......@@ -219,7 +221,7 @@ do_twofish_decrypt(struct crypto_instance *s,
static struct crypto_instance *
make_twofish_instance(struct crypto_algorithm *algorithm, int mode,
const UINT8 *key, const UINT8 *iv UNUSED)
const UINT8 *key, const UINT8 *iv UNUSED)
{
NEW(twofish_instance, self);
......@@ -228,7 +230,7 @@ make_twofish_instance(struct crypto_algorithm *algorithm, int mode,
? do_twofish_encrypt
: 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);
}
......
......@@ -36,8 +36,13 @@
(dst) += (blocksize)) )
extern struct crypto_algorithm crypto_arcfour_algorithm;
#if 0
extern struct crypto_algorithm crypto_des_algorithm;
struct crypto_algorithm *make_des3(void);
#endif
extern struct crypto_algorithm crypto_des3_cbc_algorithm;
struct crypto_algorithm *make_cast_algorithm(UINT32 key_size);
extern struct crypto_algorithm cast128_algorithm;
......@@ -57,7 +62,7 @@ extern struct crypto_algorithm rijndael192_algorithm;
extern struct crypto_algorithm rijndael256_algorithm;
#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);
extern struct crypto_algorithm serpent128_algorithm;
......
......@@ -23,6 +23,8 @@
#include "crypto.h"
#warning des.c is obsolete
#include "werror.h"
#include "xalloc.h"
......
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