diff options
author | jsing <> | 2017-08-13 16:55:31 +0000 |
---|---|---|
committer | jsing <> | 2017-08-13 16:55:31 +0000 |
commit | 0a020be0d69dd80e383f03983ec82974ac302028 (patch) | |
tree | 34b8b78ab5df75127eb2929942a643e89a959256 | |
parent | 30ea4f0a44f8383a49db321f0055b9971b9f2d67 (diff) | |
download | openbsd-0a020be0d69dd80e383f03983ec82974ac302028.tar.gz openbsd-0a020be0d69dd80e383f03983ec82974ac302028.tar.bz2 openbsd-0a020be0d69dd80e383f03983ec82974ac302028.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.c | 15 |
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 | /* |
3 | chacha-merged.c version 20080118 | 3 | chacha-merged.c version 20080118 |
4 | D. J. Bernstein | 4 | D. 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 | ||
75 | static const char sigma[16] = "expand 32-byte k"; | 75 | /* Initialise with "expand 32-byte k". */ |
76 | static const char tau[16] = "expand 16-byte k"; | 76 | static 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". */ | ||
82 | static 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 | ||
78 | static inline void | 87 | static inline void |
79 | chacha_keysetup(chacha_ctx *x, const u8 *k, u32 kbits) | 88 | chacha_keysetup(chacha_ctx *x, const u8 *k, u32 kbits) |