diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-10-27 11:13:07 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-10-27 11:13:07 +0000 |
commit | 931aa3112215a67bda2355a47f4b2892e35007cf (patch) | |
tree | 1497000a7cd4910620bc4c843695ea78b3c3d6c6 /sys/crypto/chacha_private.h | |
parent | b6b87b40f849f7fc9d3cc186809ab6a33110dc4d (diff) |
Sync chacha_ivsetup to the version in ssh so that we could
specify custom counter value when setting up Chacha context.
ok reyk djm
Diffstat (limited to 'sys/crypto/chacha_private.h')
-rw-r--r-- | sys/crypto/chacha_private.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/crypto/chacha_private.h b/sys/crypto/chacha_private.h index 66b57c59d7b..662c074de4e 100644 --- a/sys/crypto/chacha_private.h +++ b/sys/crypto/chacha_private.h @@ -50,7 +50,7 @@ static const char sigma[16] = "expand 32-byte k"; static const char tau[16] = "expand 16-byte k"; static void -chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits) +chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) { const char *constants; @@ -75,10 +75,10 @@ chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits) } static void -chacha_ivsetup(chacha_ctx *x,const u8 *iv) +chacha_ivsetup(chacha_ctx *x, const u8 *iv, const u8 *counter) { - x->input[12] = 0; - x->input[13] = 0; + x->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0); + x->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4); x->input[14] = U8TO32_LITTLE(iv + 0); x->input[15] = U8TO32_LITTLE(iv + 4); } |