Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
39 #if (TRIVIUM_SUPPORT == ENABLED)
42 #define TRIVIUM_GET_BIT(s, n) ((s[(n - 1) / 8] >> ((n - 1) % 8)) & 1)
45 #define TRIVIUM_SET_BIT(s, n, v) s[(n - 1) / 8] = \
46 (s[(n - 1) / 8] & ~(1 << ((n - 1) % 8))) | (v) << ((n - 1) % 8)
60 size_t keyLen,
const uint8_t *
iv,
size_t ivLen)
65 if(context == NULL || key == NULL ||
iv == NULL)
69 if(keyLen != 10 && ivLen != 10)
76 for(i = 0; i < 10; i++)
82 for(i = 0; i < 10; i++)
88 for(i = 11; i < 22; i++)
90 context->
s[i] = (context->
s[i + 1] << 5) | (context->
s[i] >> 3);
99 for(i = 0; i < (4 * 288); i++)
118 uint8_t *output,
size_t length)
124 for(i = 0; i <
length; i++)
136 output[i] = input[i] ^ ks;
190 for(i = 35; i > 0; i--)
192 context->
s[i] = (context->
s[i] << 1) | (context->
s[i - 1] >> 7);
195 context->
s[0] = context->
s[0] << 1;
224 for(i = 0; i < 8; i++)
error_t triviumInit(TriviumContext *context, const uint8_t *key, size_t keyLen, const uint8_t *iv, size_t ivLen)
Initialize Trivium context using the supplied key and IV.
void triviumDeinit(TriviumContext *context)
Release Trivium context.
@ ERROR_INVALID_PARAMETER
Invalid parameter.
uint8_t triviumGenerateByte(TriviumContext *context)
Generate one byte of key stream.
uint8_t triviumGenerateBit(TriviumContext *context)
Generate one bit of key stream.
General definitions for cryptographic algorithms.
void triviumCipher(TriviumContext *context, const uint8_t *input, uint8_t *output, size_t length)
Encrypt/decrypt data with the Trivium algorithm.
Trivium algorithm context.
#define TRIVIUM_GET_BIT(s, n)
#define TRIVIUM_SET_BIT(s, n, v)
uint8_t reverseInt8(uint8_t value)
Reverse bit order in a byte.
#define osMemset(p, value, length)