|
|
|
@ -523,15 +523,24 @@ static int twofish_set_key(twofish_context_t *ctx, uint8_t *key, uint8_t keylen)
|
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
|
|
/* Temporaries for CALC_K. */
|
|
|
|
|
/* cppcheck: used in macros in sys/include/crypto/twofish.h that cppcheck
|
|
|
|
|
* doesn't understand
|
|
|
|
|
*/
|
|
|
|
|
/* cppcheck-suppress unusedVariable */
|
|
|
|
|
uint32_t x, y;
|
|
|
|
|
|
|
|
|
|
/* The S vector used to key the S-boxes, split up into individual bytes.
|
|
|
|
|
* 128-bit keys use only sa through sh; 256-bit use all of them. */
|
|
|
|
|
uint8_t sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0, sh = 0;
|
|
|
|
|
/* cppcheck: moving this may introduce timing vulnerability */
|
|
|
|
|
/* cppcheck-suppress variableScope */
|
|
|
|
|
uint8_t si = 0, sj = 0, sk = 0, sl = 0, sm = 0, sn = 0, so = 0, sp = 0;
|
|
|
|
|
|
|
|
|
|
/* Temporary for CALC_S. */
|
|
|
|
|
/* cppcheck: used in macros in sys/include/crypto/twofish.h that cppcheck
|
|
|
|
|
* doesn't understand
|
|
|
|
|
*/
|
|
|
|
|
/* cppcheck-suppress unusedVariable */
|
|
|
|
|
uint8_t tmp;
|
|
|
|
|
|
|
|
|
|
/* Check key length. */
|
|
|
|
@ -674,6 +683,10 @@ int twofish_encrypt(cipher_context_t *context, uint8_t *in, uint8_t *out)
|
|
|
|
|
uint32_t a, b, c, d;
|
|
|
|
|
|
|
|
|
|
/* Temporaries used by the round function. */
|
|
|
|
|
/* cppcheck: used in macros in sys/include/crypto/twofish.h that cppcheck
|
|
|
|
|
* doesn't understand
|
|
|
|
|
*/
|
|
|
|
|
/* cppcheck-suppress unusedVariable */
|
|
|
|
|
uint32_t x, y;
|
|
|
|
|
|
|
|
|
|
/* Input whitening and packing. */
|
|
|
|
@ -727,6 +740,10 @@ int twofish_decrypt(cipher_context_t *context, uint8_t *in, uint8_t *out)
|
|
|
|
|
uint32_t a, b, c, d;
|
|
|
|
|
|
|
|
|
|
/* Temporaries used by the round function. */
|
|
|
|
|
/* cppcheck: used in macros in sys/include/crypto/twofish.h that cppcheck
|
|
|
|
|
* doesn't understand
|
|
|
|
|
*/
|
|
|
|
|
/* cppcheck-suppress unusedVariable */
|
|
|
|
|
uint32_t x, y;
|
|
|
|
|
|
|
|
|
|
/* Input whitening and packing. */
|
|
|
|
|