-
Notifications
You must be signed in to change notification settings - Fork 0
/
testkey.c
47 lines (38 loc) · 1.43 KB
/
testkey.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
#include <stdio.h>
#include "pilsung.c"
uint8_t key[] = {
0x4c, 0xd5, 0x68, 0x79, 0x76, 0xf4, 0x37, 0x86, 0x39, 0xc4, 0xcc, 0x4d, 0xc5, 0x13, 0x4c, 0x07,
0x81, 0x48, 0x1b, 0xea, 0xcd, 0x9d, 0x73, 0x93, 0xbb, 0x69, 0x44, 0x15, 0x82, 0xad, 0x88, 0x58,
0x58, 0xd7, 0x26, 0x14, 0xd9, 0x9f, 0x3d, 0xfe, 0x14, 0x02, 0x4e, 0x6d, 0xaf, 0x6b, 0x0a, 0x78,
0x2d, 0xc6, 0x82, 0x20, 0xfc, 0xc4, 0x91, 0xcc, 0x25, 0x5b, 0xac, 0x32, 0x31, 0x59, 0xe2, 0x5f,
0x9e, 0x32, 0xe8, 0x27, 0xb3, 0xf4, 0x6a, 0x07, 0x63, 0xc6, 0x54, 0xa1, 0x46, 0x9d, 0xf8, 0x93,
0x77, 0xc4, 0x1a, 0xcc, 0xe9, 0xf6, 0xf2, 0xeb, 0x5a, 0x02, 0x98, 0xec, 0x54, 0x80, 0x9a, 0x1f
};
int nrounds = sizeof(key)/16;
void printperms(pilsung_ctx *ctx) {
printf(" Colors ");
for (int round = 1; round <= nrounds; round++)
printf(" Round %-2d ", round);
printf("\n");
for (int row = 0; row < 4; row++) {
for (int round = 0; round <= nrounds; round++) {
for (int col = 0; col < 4; col++) {
printf("\e[4%d;30m %d\e[30m%d ",
1+(ctx->pboxes[round][row * 4 + col] & 3),
(ctx->pboxes[round][row * 4 + col] & 3),
(ctx->pboxes[round][row * 4 + col] >> 2));
}
printf("\e[0m ");
}
printf("\n");
}
}
int main() {
pilsung_ctx *ctx = pilsung_ctx_alloc(0);
memset(ctx, 0, sizeof(*ctx));
memcpy(ctx->e_key + 16, key, sizeof(key));
gen_enc_perm(ctx);
for (int i = 0; i < 16; i++)
ctx->pboxes[0][i] = i;
printperms(ctx);
}