diff --git a/ChangeLog b/ChangeLog index 3b07ac51c056f0098c0e7fd82fd2dd1d70cf94d3..8f8f2aa948e6f71b34cf8ed140e4e366176fe28a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 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_INPUT_LENGTH): New constant. * salsa20.c: Use these constants. diff --git a/nettle-internal.c b/nettle-internal.c index 93199a987a24f4c9100310d3b4c834694325f070..5360c48aab3a8dd36ead1cfd248c1a1644e4d5b0 100644 --- a/nettle-internal.c +++ b/nettle-internal.c @@ -84,7 +84,7 @@ salsa20_set_key_hack(void *ctx, unsigned length, const uint8_t *key) { static const uint8_t iv[SALSA20_IV_SIZE]; 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. */ diff --git a/salsa20.c b/salsa20.c index 7cab650066d51d58a93e44329c8d5217dd4b5141..4627637d3f843e9976d2ed42e2fa902ed3dcce16 100644 --- a/salsa20.c +++ b/salsa20.c @@ -128,10 +128,8 @@ salsa20_set_key(struct salsa20_ctx *ctx, } 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[7] = U8TO32_LITTLE(iv + 4); ctx->input[8] = 0; diff --git a/salsa20.h b/salsa20.h index c4b98cae125fa1df8215c42a848f558c63a6f5c1..f9beb213d55ad4bda41d98d4d8e746c1a7a83de6 100644 --- a/salsa20.h +++ b/salsa20.h @@ -68,8 +68,7 @@ salsa20_set_key(struct salsa20_ctx *ctx, unsigned length, const uint8_t *key); 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); void salsa20_crypt(struct salsa20_ctx *ctx, diff --git a/testsuite/salsa20-test.c b/testsuite/salsa20-test.c index 82fc140696f0b35a90cb73266d756c3b10c67759..57363f8ccd2604054b165f90504e716756309480 100644 --- a/testsuite/salsa20-test.c +++ b/testsuite/salsa20-test.c @@ -4,7 +4,6 @@ static void test_salsa20(unsigned key_length, const uint8_t *key, - unsigned iv_length, const uint8_t *iv, unsigned length, const uint8_t *cleartext, @@ -14,7 +13,7 @@ test_salsa20(unsigned key_length, uint8_t *data = xalloc(length); 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); if (!MEMEQ(length, data, ciphertext)) @@ -29,7 +28,7 @@ test_salsa20(unsigned key_length, FAIL(); } 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); if (!MEMEQ(length, data, cleartext)) @@ -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 */ test_salsa20(HL("80000000 00000000 00000000 00000000"), - HL("00000000 00000000"), + H("00000000 00000000"), HL("00000000 00000000"), H("4DFA5E48 1DA23EA0")); test_salsa20(HL("00000000 00000000 00000000 00000000"), - HL("80000000 00000000"), + H("80000000 00000000"), HL("00000000 00000000"), H("B66C1E44 46DD9557")); test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"), - HL("0D74DB42A91077DE"), + H("0D74DB42A91077DE"), HL("00000000 00000000"), H("05E1E7BE B697D999")); test_salsa20(HL("80000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"), - HL("00000000 00000000"), + H("00000000 00000000"), HL("00000000 00000000"), H("E3BE8FDD 8BECA2E3")); test_salsa20(HL("00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"), - HL("80000000 00000000"), + H("80000000 00000000"), HL("00000000 00000000"), H("2ABA3DC45B494700")); test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD" "3083D6297CCF2275C81B6EC11467BA0D"), - HL("0D74DB42A91077DE"), + H("0D74DB42A91077DE"), HL("00000000 00000000"), H("F5FAD53F 79F9DF58"));