-
Notifications
You must be signed in to change notification settings - Fork 0
/
arxseq8_64_out.c
60 lines (50 loc) · 833 Bytes
/
arxseq8_64_out.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#define ROUNDS 5
//#define M 8
#define rotl(v,d) (((v)<<(d))|((v)>>(8-(d))))
#define outp(p,d) (out[((p)+(d))%8])
#define step(a,r1,r2) {\
outp(a,2)^=outp(a,0);\
outp(a,3)^=outp(a,1);\
outp(a,2)+=outp(a,1);\
outp(a,3)+=outp(a,0);\
outp(a,2)=rotl(outp(a,2),r1);\
outp(a,3)=rotl(outp(a,3),r2);}
void process_block(uint8_t out[8], uint8_t in[8])
{
int i;
for(i=0;i<8;i++)
out[i]=in[i];
/*
xor 2<-0
xor 3<-1
add 2<-1
add 3<-0
rot 2
rot 3
*/
for(i=0;i<ROUNDS;i++){
step( 0,1,6);
step( 2,3,4);
step( 4,5,2);
step( 6,7,1);
}
}
uint8_t input[8]={0,0},output[8]={0};
int main()
{
int i;
for(;;){
i=0;
input[i]++;
while(input[i]==0){
i++;
input[i]++;
}
process_block(output,input);
fwrite(output,1,8,stdout);
}
return 0;
}