use more static and fix [-Wmissing-prototypes], ongoing...

This commit is contained in:
Philippe Teuwen
2019-04-13 00:25:43 +02:00
parent 05374fce07
commit 4f32655004
25 changed files with 167 additions and 151 deletions

View File

@@ -67,7 +67,7 @@ typedef struct {
* is defined as
* T (x 0 x 1 . . . . . . x 15 ) = x 0 ⊕ x 1 ⊕ x 5 ⊕ x 7 ⊕ x 10 ⊕ x 11 ⊕ x 14 ⊕ x 15 .
**/
bool T(State state) {
static bool T(State state) {
bool x0 = state.t & 0x8000;
bool x1 = state.t & 0x4000;
bool x5 = state.t & 0x0400;
@@ -82,7 +82,7 @@ bool T(State state) {
* Similarly, the feedback function for the bottom register B : F 8/2 → F 2 is defined as
* B(x 0 x 1 . . . x 7 ) = x 1 ⊕ x 2 ⊕ x 3 ⊕ x 7 .
**/
bool B(State state) {
static bool B(State state) {
bool x1 = state.b & 0x40;
bool x2 = state.b & 0x20;
bool x3 = state.b & 0x10;
@@ -98,7 +98,7 @@ bool B(State state) {
* z 1 = (r 0 r 2 ) ⊕ (r 5 r 7 ) ⊕ r 1 ⊕ r 6 ⊕ x ⊕ y
* z 2 = (r 3 ∧ r 5 ) ⊕ (r 4 ∧ r 6 ) ⊕ r 7 ⊕ x
**/
uint8_t _select(bool x, bool y, uint8_t r) {
static uint8_t _select(bool x, bool y, uint8_t r) {
bool r0 = r >> 7 & 0x1;
bool r1 = r >> 6 & 0x1;
bool r2 = r >> 5 & 0x1;
@@ -134,7 +134,7 @@ uint8_t _select(bool x, bool y, uint8_t r) {
* @param s - state
* @param k - array containing 8 bytes
**/
State successor(uint8_t *k, State s, bool y) {
static State successor(uint8_t *k, State s, bool y) {
bool r0 = s.r >> 7 & 0x1;
bool r4 = s.r >> 3 & 0x1;
bool r7 = s.r & 0x1;
@@ -160,7 +160,7 @@ State successor(uint8_t *k, State s, bool y) {
* to multiple bit input x ∈ F n 2 which we define as
* @param k - array containing 8 bytes
**/
State suc(uint8_t *k, State s, BitstreamIn *bitstream) {
static State suc(uint8_t *k, State s, BitstreamIn *bitstream) {
if (bitsLeft(bitstream) == 0) {
return s;
}
@@ -176,7 +176,7 @@ State suc(uint8_t *k, State s, BitstreamIn *bitstream) {
* output(k, s, x 0 . . . x n ) = output(s) · output(k, s , x 1 . . . x n )
* where s = suc(k, s, x 0 ).
**/
void output(uint8_t *k, State s, BitstreamIn *in, BitstreamOut *out) {
static void output(uint8_t *k, State s, BitstreamIn *in, BitstreamOut *out) {
if (bitsLeft(in) == 0) {
return;
}
@@ -192,7 +192,7 @@ void output(uint8_t *k, State s, BitstreamIn *in, BitstreamOut *out) {
* key k ∈ (F 82 ) 8 and outputs the initial cipher state s =< l, r, t, b >
**/
State init(uint8_t *k) {
static State init(uint8_t *k) {
State s = {
((k[0] ^ 0x4c) + 0xEC) & 0xFF,// l
((k[0] ^ 0x4c) + 0x21) & 0xFF,// r
@@ -201,7 +201,8 @@ State init(uint8_t *k) {
};
return s;
}
void MAC(uint8_t *k, BitstreamIn input, BitstreamOut out) {
static void MAC(uint8_t *k, BitstreamIn input, BitstreamOut out) {
uint8_t zeroes_32[] = {0, 0, 0, 0};
BitstreamIn input_32_zeroes = {zeroes_32, sizeof(zeroes_32) * 8, 0};
State initState = suc(k, init(k), &input);