31 r = (r << 32) | rand();
35 static const uint8_t test_key[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 };
41 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
42 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01,
43 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23
49 int delay = cbc && !decrypt ? 2 : 1;
59 return res == 0xc5cecf63ecec514cULL;
61 return res == 0xcb191f85d1ed8439ULL;
64 return res == 0x8325397644091a0aULL;
66 return res == 0xdd17e8b8b437d232ULL;
77 uint64_t roundkeys[16];
83 printf(
"Test 1 failed\n");
89 printf(
"Public API decryption failed\n");
93 printf(
"Partial Monte-Carlo test failed\n");
96 for (i = 0; i < 1000; i++) {
106 printf(
"Test 2 failed\n");
111 printf(
"static const uint32_t S_boxes_P_shuffle[8][64] = {\n");
112 for (i = 0; i < 8; i++) {
115 for (j = 0; j < 64; j++) {
116 uint32_t v = S_boxes[i][j >> 1];
117 v = j & 1 ? v >> 4 : v & 0xf;
119 v =
shuffle(v, P_shuffle,
sizeof(P_shuffle));
120 printf((j & 7) == 0 ?
"\n " :
" ");
121 printf(
"0x%08X,", v);
static void gen_roundkeys(uint64_t K[16], uint64_t key)
void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypts / decrypts using the DES algorithm.
ptrdiff_t const GLvoid * data
static const uint8_t cbc_key[]
static const uint8_t plain[]
static const uint8_t crypt[]
static uint64_t rand64(void)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
int av_des_init(AVDES *d, const uint8_t *key, int key_bits, av_unused int decrypt)
int64_t av_gettime(void)
Get the current time in microseconds.
static int run_test(int cbc, int decrypt)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
static uint8_t large_buffer[10002][8]
static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt)
static const uint8_t test_key[]
static uint64_t shuffle(uint64_t in, const uint8_t *shuffle, int shuffle_len)