Commit 43b72688 authored by Niels Möller's avatar Niels Möller

Support 3des-ctr.

parent f36de37c
2013-09-17 Niels Möller <nisse@lysator.liu.se> 2013-09-17 Niels Möller <nisse@lysator.liu.se>
* src/testsuite/lsh-6-test (ALGORITHMS): Test both 3des-cbc and
3des-ctr.
* src/algorithms.c (all_symmetric_algorithms): Added ATOM_3DES_CTR.
(all_crypto_algorithms): Likewise.
(lookup_crypto): For parsng the -c option, make just "3des" mean
"3des-ctr" rather than "3des-cbc".
* src/crypto.c (des3_ctr_instance): New class.
(do_des3_ctr_crypt): New function.
(make_des3_ctr_instance): New function.
(crypto_des3_ctr_algorithm): New struct.
* src/crypto.h (crypto_des3_ctr_algorithm): Declare.
* src/dsa.c (do_dsa_sign): Fixed failure message. * src/dsa.c (do_dsa_sign): Fixed failure message.
2013-09-02 Niels Möller <nisse@lysator.liu.se> 2013-09-02 Niels Möller <nisse@lysator.liu.se>
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
struct alist * struct alist *
all_symmetric_algorithms() all_symmetric_algorithms()
{ {
return make_alist(12 return make_alist(13
#if WITH_ZLIB #if WITH_ZLIB
+1 +1
#endif #endif
...@@ -61,6 +61,7 @@ all_symmetric_algorithms() ...@@ -61,6 +61,7 @@ all_symmetric_algorithms()
ATOM_AES256_CTR, &crypto_aes256_ctr_algorithm, ATOM_AES256_CTR, &crypto_aes256_ctr_algorithm,
ATOM_SERPENT256_CBC, &crypto_serpent256_cbc_algorithm, ATOM_SERPENT256_CBC, &crypto_serpent256_cbc_algorithm,
ATOM_3DES_CBC, &crypto_des3_cbc_algorithm, ATOM_3DES_CBC, &crypto_des3_cbc_algorithm,
ATOM_3DES_CTR, &crypto_des3_ctr_algorithm,
ATOM_CAST128_CBC, &crypto_cast128_cbc_algorithm, ATOM_CAST128_CBC, &crypto_cast128_cbc_algorithm,
ATOM_HMAC_SHA1, ATOM_HMAC_SHA1,
make_hmac_algorithm(&nettle_sha1), make_hmac_algorithm(&nettle_sha1),
...@@ -105,12 +106,13 @@ default_crypto_algorithms(struct alist *algorithms) ...@@ -105,12 +106,13 @@ default_crypto_algorithms(struct alist *algorithms)
static struct int_list * static struct int_list *
all_crypto_algorithms(struct alist *algorithms) all_crypto_algorithms(struct alist *algorithms)
{ {
return filter_algorithms_l(algorithms, 10, return filter_algorithms_l(algorithms, 11,
ATOM_AES128_CBC, ATOM_AES128_CBC,
ATOM_AES128_CTR, ATOM_AES128_CTR,
ATOM_AES256_CBC, ATOM_AES256_CBC,
ATOM_AES256_CTR, ATOM_AES256_CTR,
ATOM_3DES_CBC, ATOM_3DES_CBC,
ATOM_3DES_CTR,
ATOM_TWOFISH_CBC, ATOM_TWOFISH_CBC,
ATOM_CAST128_CBC, ATOM_CAST128_CBC,
ATOM_SERPENT256_CBC, ATOM_SERPENT256_CBC,
...@@ -190,8 +192,10 @@ lookup_crypto(struct alist *algorithms, const char *name, struct crypto_algorith ...@@ -190,8 +192,10 @@ lookup_crypto(struct alist *algorithms, const char *name, struct crypto_algorith
atom = ATOM_TWOFISH_CBC; atom = ATOM_TWOFISH_CBC;
else if (strcasecmp_list(name, "blowfish-cbc", "blowfish", NULL)) else if (strcasecmp_list(name, "blowfish-cbc", "blowfish", NULL))
atom = ATOM_BLOWFISH_CBC; atom = ATOM_BLOWFISH_CBC;
else if (strcasecmp_list(name, "3des-cbc", "3des", NULL)) else if (strcasecmp_list(name, "3des-cbc", NULL))
atom = ATOM_3DES_CBC; atom = ATOM_3DES_CBC;
else if (strcasecmp_list(name, "3des-ctr", "3des", NULL))
atom = ATOM_3DES_CTR;
else if (strcasecmp_list(name, "aes128-cbc", "aes-cbc", NULL)) else if (strcasecmp_list(name, "aes128-cbc", "aes-cbc", NULL))
atom = ATOM_AES128_CBC; atom = ATOM_AES128_CBC;
else if (strcasecmp_list(name, "aes128-ctr", "aes-ctr", "aes", "aes128", NULL)) else if (strcasecmp_list(name, "aes128-ctr", "aes-ctr", "aes", "aes128", NULL))
......
...@@ -276,6 +276,47 @@ struct crypto_algorithm crypto_des3_cbc_algorithm = ...@@ -276,6 +276,47 @@ struct crypto_algorithm crypto_des3_cbc_algorithm =
{ STATIC_HEADER, { STATIC_HEADER,
DES3_BLOCK_SIZE, DES3_KEY_SIZE, DES3_BLOCK_SIZE, make_des3_cbc_instance }; DES3_BLOCK_SIZE, DES3_KEY_SIZE, DES3_BLOCK_SIZE, make_des3_cbc_instance };
/* GABA:
(class
(name des3_ctr_instance)
(super crypto_instance)
(vars
(ctx . "struct CTR_CTX(struct des3_ctx, DES_BLOCK_SIZE)")))
*/
static void
do_des3_ctr_crypt(struct crypto_instance *s,
uint32_t length,
struct lsh_string *dst, uint32_t di,
const struct lsh_string *src, uint32_t si)
{
CAST(des3_ctr_instance, self, s);
lsh_string_ctr_crypt(dst, di, src, si, length,
DES3_BLOCK_SIZE, self->ctx.ctr,
(nettle_crypt_func *) des3_encrypt,
&self->ctx.ctx);
}
static struct crypto_instance *
make_des3_ctr_instance(struct crypto_algorithm *algorithm UNUSED, int mode UNUSED,
const uint8_t *key, const uint8_t *iv)
{
NEW(des3_ctr_instance, self);
self->super.block_size = DES3_BLOCK_SIZE;
self->super.crypt = do_des3_ctr_crypt;
des3_set_key(&self->ctx.ctx, key);
CTR_SET_COUNTER(&self->ctx, iv);
return(&self->super);
}
struct crypto_algorithm crypto_des3_ctr_algorithm =
{ STATIC_HEADER,
DES3_BLOCK_SIZE, DES3_KEY_SIZE, DES3_BLOCK_SIZE, make_des3_ctr_instance};
/* Cast-128 */ /* Cast-128 */
/* GABA: /* GABA:
......
...@@ -85,6 +85,7 @@ extern struct crypto_algorithm crypto_arcfour_algorithm; ...@@ -85,6 +85,7 @@ extern struct crypto_algorithm crypto_arcfour_algorithm;
extern struct crypto_algorithm crypto_blowfish_cbc_algorithm; extern struct crypto_algorithm crypto_blowfish_cbc_algorithm;
extern struct crypto_algorithm crypto_cast128_cbc_algorithm; extern struct crypto_algorithm crypto_cast128_cbc_algorithm;
extern struct crypto_algorithm crypto_des3_cbc_algorithm; extern struct crypto_algorithm crypto_des3_cbc_algorithm;
extern struct crypto_algorithm crypto_des3_ctr_algorithm;
extern struct crypto_algorithm crypto_serpent256_cbc_algorithm; extern struct crypto_algorithm crypto_serpent256_cbc_algorithm;
extern struct crypto_algorithm crypto_twofish256_cbc_algorithm; extern struct crypto_algorithm crypto_twofish256_cbc_algorithm;
......
...@@ -10,7 +10,7 @@ fi ...@@ -10,7 +10,7 @@ fi
OLD_FLAGS="$LSH_FLAGS" OLD_FLAGS="$LSH_FLAGS"
ALGORITHMS="arcfour twofish blowfish 3des aes128-cbc aes128-ctr aes256-cbc aes256-ctr cast128 all" ALGORITHMS="arcfour twofish blowfish 3des-cbc 3des-ctr aes128-cbc aes128-ctr aes256-cbc aes256-ctr cast128 all"
LSHD_FLAGS="$LSHD_FLAGS -c all" LSHD_FLAGS="$LSHD_FLAGS -c all"
......
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