-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.c
61 lines (46 loc) · 1.02 KB
/
sample.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
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
int val __attribute__ ((aligned(8), bitsliced)) = 2;
/*
void encrypt(uint8_t *ptext, uint8_t *key){
int i;
for(i=0; i<8; i++){
ptext[i] = ptext[i] ^ key[i+16];
}
}
*/
int main(){
uint8_t __attribute__ ((bitsliced)) ptext[8];
uint8_t __attribute__ ((bitsliced)) Mkey[8];
uint8_t __attribute__ ((bitsliced)) v1;
int i;
//srand(time(NULL));
v1 = 0x04;
for(i=0;i<8;i++){
ptext[i] = i;
}
for(i=0;i<10;i++){
Mkey[i] = 0x5a;
}
//encrypt(ptext, Mkey);
v1 = v1 * 2;
for(i=0; i<8; i++){
ptext[i] = Mkey[i+16];
}
for(i=0; i<8; i++){
ptext[i] = ptext[i] ^ Mkey[i+16];
}
/*
for(i=0;i<8;i++){
v2 = A[i];
}
*/
ptext[3] = ((ptext[0] ^ 0xff) & (ptext[2] ^ 0xff) & (ptext[3] ^ 0xff)) |
((ptext[0] ^ 0xff) & ptext[2] & ptext[3]) |
((ptext[0] ^ 0xff)&ptext[1] & ptext[2] & (ptext[3] ^ 0xff)) |
(ptext[0] & (ptext[1] ^ 0xff)&ptext[3]) |
(ptext[0] & (ptext[1] ^ 0xff)&ptext[2] & (ptext[3] ^ 0xff));
return 0;
}