summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2017-08-13 16:55:31 +0000
committerjsing <>2017-08-13 16:55:31 +0000
commitae4d6b8586e285ed1d7d18a7a183f18f35fc8b1c (patch)
tree34b8b78ab5df75127eb2929942a643e89a959256
parent381a21d855dceb0f5601e64ddfef5427a2647170 (diff)
downloadopenbsd-ae4d6b8586e285ed1d7d18a7a183f18f35fc8b1c.tar.gz
openbsd-ae4d6b8586e285ed1d7d18a7a183f18f35fc8b1c.tar.bz2
openbsd-ae4d6b8586e285ed1d7d18a7a183f18f35fc8b1c.zip
Convert the sigma and tau initialisers to byte arrays, rather than using
strings. The original code is perfectly valid C, however it causes some compilers to complain since it lacks room for a string NUL terminator and the compiler is not smart enough to realise that these are only used as byte arrays and never treated as strings. ok bcook@ beck@ inoguchi@
-rw-r--r--src/lib/libcrypto/chacha/chacha-merged.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/libcrypto/chacha/chacha-merged.c b/src/lib/libcrypto/chacha/chacha-merged.c
index 557dfd5b56..08511ed273 100644
--- a/src/lib/libcrypto/chacha/chacha-merged.c
+++ b/src/lib/libcrypto/chacha/chacha-merged.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: chacha-merged.c,v 1.7 2014/07/11 08:47:47 bcook Exp $ */ 1/* $OpenBSD: chacha-merged.c,v 1.8 2017/08/13 16:55:31 jsing Exp $ */
2/* 2/*
3chacha-merged.c version 20080118 3chacha-merged.c version 20080118
4D. J. Bernstein 4D. J. Bernstein
@@ -72,8 +72,17 @@ typedef struct chacha_ctx chacha_ctx;
72 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ 72 a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
73 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); 73 c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
74 74
75static const char sigma[16] = "expand 32-byte k"; 75/* Initialise with "expand 32-byte k". */
76static const char tau[16] = "expand 16-byte k"; 76static const char sigma[16] = {
77 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33,
78 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b,
79};
80
81/* Initialise with "expand 16-byte k". */
82static const char tau[16] = {
83 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x31,
84 0x36, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b,
85};
77 86
78static inline void 87static inline void
79chacha_keysetup(chacha_ctx *x, const u8 *k, u32 kbits) 88chacha_keysetup(chacha_ctx *x, const u8 *k, u32 kbits)