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

salsa20_set_iv: Deleted size argument.

parent 588e0e8f
No related branches found
No related tags found
No related merge requests found
2012-03-31 Niels Möller <nisse@lysator.liu.se> 2012-03-31 Niels Möller <nisse@lysator.liu.se>
* salsa20.c: (salsa20_set_iv): Deleted size argument, only one
size allowed.
* nettle-internal.c (salsa20_set_key_hack): Updated salsa20_set_iv
call.
* testsuite/salsa20-test.c (test_salsa20): Deleted iv_length
argument, updated all calls.
* salsa20.h (SALSA20_BLOCK_SIZE): New constant. * salsa20.h (SALSA20_BLOCK_SIZE): New constant.
(_SALSA20_INPUT_LENGTH): New constant. (_SALSA20_INPUT_LENGTH): New constant.
* salsa20.c: Use these constants. * salsa20.c: Use these constants.
......
...@@ -84,7 +84,7 @@ salsa20_set_key_hack(void *ctx, unsigned length, const uint8_t *key) ...@@ -84,7 +84,7 @@ salsa20_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
{ {
static const uint8_t iv[SALSA20_IV_SIZE]; static const uint8_t iv[SALSA20_IV_SIZE];
salsa20_set_key (ctx, length, key); salsa20_set_key (ctx, length, key);
salsa20_set_iv (ctx, SALSA20_IV_SIZE, iv); salsa20_set_iv (ctx, iv);
} }
/* Claim zero block size, to classify as a stream cipher. */ /* Claim zero block size, to classify as a stream cipher. */
......
...@@ -128,10 +128,8 @@ salsa20_set_key(struct salsa20_ctx *ctx, ...@@ -128,10 +128,8 @@ salsa20_set_key(struct salsa20_ctx *ctx,
} }
void void
salsa20_set_iv(struct salsa20_ctx *ctx, unsigned length, const uint8_t *iv) salsa20_set_iv(struct salsa20_ctx *ctx, const uint8_t *iv)
{ {
assert (length == SALSA20_IV_SIZE);
ctx->input[6] = U8TO32_LITTLE(iv + 0); ctx->input[6] = U8TO32_LITTLE(iv + 0);
ctx->input[7] = U8TO32_LITTLE(iv + 4); ctx->input[7] = U8TO32_LITTLE(iv + 4);
ctx->input[8] = 0; ctx->input[8] = 0;
......
...@@ -68,8 +68,7 @@ salsa20_set_key(struct salsa20_ctx *ctx, ...@@ -68,8 +68,7 @@ salsa20_set_key(struct salsa20_ctx *ctx,
unsigned length, const uint8_t *key); unsigned length, const uint8_t *key);
void void
salsa20_set_iv(struct salsa20_ctx *ctx, salsa20_set_iv(struct salsa20_ctx *ctx, const uint8_t *iv);
unsigned length, const uint8_t *iv);
void void
salsa20_crypt(struct salsa20_ctx *ctx, salsa20_crypt(struct salsa20_ctx *ctx,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
static void static void
test_salsa20(unsigned key_length, test_salsa20(unsigned key_length,
const uint8_t *key, const uint8_t *key,
unsigned iv_length,
const uint8_t *iv, const uint8_t *iv,
unsigned length, unsigned length,
const uint8_t *cleartext, const uint8_t *cleartext,
...@@ -14,7 +13,7 @@ test_salsa20(unsigned key_length, ...@@ -14,7 +13,7 @@ test_salsa20(unsigned key_length,
uint8_t *data = xalloc(length); uint8_t *data = xalloc(length);
salsa20_set_key(&ctx, key_length, key); salsa20_set_key(&ctx, key_length, key);
salsa20_set_iv(&ctx, iv_length, iv); salsa20_set_iv(&ctx, iv);
salsa20_crypt(&ctx, length, data, cleartext); salsa20_crypt(&ctx, length, data, cleartext);
if (!MEMEQ(length, data, ciphertext)) if (!MEMEQ(length, data, ciphertext))
...@@ -29,7 +28,7 @@ test_salsa20(unsigned key_length, ...@@ -29,7 +28,7 @@ test_salsa20(unsigned key_length,
FAIL(); FAIL();
} }
salsa20_set_key(&ctx, key_length, key); salsa20_set_key(&ctx, key_length, key);
salsa20_set_iv(&ctx, iv_length, iv); salsa20_set_iv(&ctx, iv);
salsa20_crypt(&ctx, length, data, data); salsa20_crypt(&ctx, length, data, data);
if (!MEMEQ(length, data, cleartext)) if (!MEMEQ(length, data, cleartext))
...@@ -53,35 +52,35 @@ test_main(void) ...@@ -53,35 +52,35 @@ test_main(void)
/* http://www.ecrypt.eu.org/stream/svn/viewcvs.cgi/ecrypt/trunk/submissions/salsa20/full/verified.test-vectors?logsort=rev&rev=210&view=markup */ /* http://www.ecrypt.eu.org/stream/svn/viewcvs.cgi/ecrypt/trunk/submissions/salsa20/full/verified.test-vectors?logsort=rev&rev=210&view=markup */
test_salsa20(HL("80000000 00000000 00000000 00000000"), test_salsa20(HL("80000000 00000000 00000000 00000000"),
HL("00000000 00000000"), H("00000000 00000000"),
HL("00000000 00000000"), HL("00000000 00000000"),
H("4DFA5E48 1DA23EA0")); H("4DFA5E48 1DA23EA0"));
test_salsa20(HL("00000000 00000000 00000000 00000000"), test_salsa20(HL("00000000 00000000 00000000 00000000"),
HL("80000000 00000000"), H("80000000 00000000"),
HL("00000000 00000000"), HL("00000000 00000000"),
H("B66C1E44 46DD9557")); H("B66C1E44 46DD9557"));
test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"), test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"),
HL("0D74DB42A91077DE"), H("0D74DB42A91077DE"),
HL("00000000 00000000"), HL("00000000 00000000"),
H("05E1E7BE B697D999")); H("05E1E7BE B697D999"));
test_salsa20(HL("80000000 00000000 00000000 00000000" test_salsa20(HL("80000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000"), "00000000 00000000 00000000 00000000"),
HL("00000000 00000000"), H("00000000 00000000"),
HL("00000000 00000000"), HL("00000000 00000000"),
H("E3BE8FDD 8BECA2E3")); H("E3BE8FDD 8BECA2E3"));
test_salsa20(HL("00000000 00000000 00000000 00000000" test_salsa20(HL("00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000"), "00000000 00000000 00000000 00000000"),
HL("80000000 00000000"), H("80000000 00000000"),
HL("00000000 00000000"), HL("00000000 00000000"),
H("2ABA3DC45B494700")); H("2ABA3DC45B494700"));
test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD" test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"
"3083D6297CCF2275C81B6EC11467BA0D"), "3083D6297CCF2275C81B6EC11467BA0D"),
HL("0D74DB42A91077DE"), H("0D74DB42A91077DE"),
HL("00000000 00000000"), HL("00000000 00000000"),
H("F5FAD53F 79F9DF58")); H("F5FAD53F 79F9DF58"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment