Lines Matching refs:skey
48 b[0] = (safer_ebox[(b[0] ^ skey->saferp.K[i][0]) & 255] + skey->saferp.K[i+1][0]) & 255; \
49 b[1] = safer_lbox[(b[1] + skey->saferp.K[i][1]) & 255] ^ skey->saferp.K[i+1][1]; \
50 b[2] = safer_lbox[(b[2] + skey->saferp.K[i][2]) & 255] ^ skey->saferp.K[i+1][2]; \
51 b[3] = (safer_ebox[(b[3] ^ skey->saferp.K[i][3]) & 255] + skey->saferp.K[i+1][3]) & 255; \
52 b[4] = (safer_ebox[(b[4] ^ skey->saferp.K[i][4]) & 255] + skey->saferp.K[i+1][4]) & 255; \
53 b[5] = safer_lbox[(b[5] + skey->saferp.K[i][5]) & 255] ^ skey->saferp.K[i+1][5]; \
54 b[6] = safer_lbox[(b[6] + skey->saferp.K[i][6]) & 255] ^ skey->saferp.K[i+1][6]; \
55 b[7] = (safer_ebox[(b[7] ^ skey->saferp.K[i][7]) & 255] + skey->saferp.K[i+1][7]) & 255; \
56 b[8] = (safer_ebox[(b[8] ^ skey->saferp.K[i][8]) & 255] + skey->saferp.K[i+1][8]) & 255; \
57 b[9] = safer_lbox[(b[9] + skey->saferp.K[i][9]) & 255] ^ skey->saferp.K[i+1][9]; \
58 b[10] = safer_lbox[(b[10] + skey->saferp.K[i][10]) & 255] ^ skey->saferp.K[i+1][10]; \
59 b[11] = (safer_ebox[(b[11] ^ skey->saferp.K[i][11]) & 255] + skey->saferp.K[i+1][11]) & 255; \
60 b[12] = (safer_ebox[(b[12] ^ skey->saferp.K[i][12]) & 255] + skey->saferp.K[i+1][12]) & 255; \
61 b[13] = safer_lbox[(b[13] + skey->saferp.K[i][13]) & 255] ^ skey->saferp.K[i+1][13]; \
62 b[14] = safer_lbox[(b[14] + skey->saferp.K[i][14]) & 255] ^ skey->saferp.K[i+1][14]; \
63 …b[15] = (safer_ebox[(b[15] ^ skey->saferp.K[i][15]) & 255] + skey->saferp.K[i+1][15]) & 255; …
67 b[0] = safer_lbox[(b[0] - skey->saferp.K[i+1][0]) & 255] ^ skey->saferp.K[i][0]; \
68 b[1] = (safer_ebox[(b[1] ^ skey->saferp.K[i+1][1]) & 255] - skey->saferp.K[i][1]) & 255; \
69 b[2] = (safer_ebox[(b[2] ^ skey->saferp.K[i+1][2]) & 255] - skey->saferp.K[i][2]) & 255; \
70 b[3] = safer_lbox[(b[3] - skey->saferp.K[i+1][3]) & 255] ^ skey->saferp.K[i][3]; \
71 b[4] = safer_lbox[(b[4] - skey->saferp.K[i+1][4]) & 255] ^ skey->saferp.K[i][4]; \
72 b[5] = (safer_ebox[(b[5] ^ skey->saferp.K[i+1][5]) & 255] - skey->saferp.K[i][5]) & 255; \
73 b[6] = (safer_ebox[(b[6] ^ skey->saferp.K[i+1][6]) & 255] - skey->saferp.K[i][6]) & 255; \
74 b[7] = safer_lbox[(b[7] - skey->saferp.K[i+1][7]) & 255] ^ skey->saferp.K[i][7]; \
75 b[8] = safer_lbox[(b[8] - skey->saferp.K[i+1][8]) & 255] ^ skey->saferp.K[i][8]; \
76 b[9] = (safer_ebox[(b[9] ^ skey->saferp.K[i+1][9]) & 255] - skey->saferp.K[i][9]) & 255; \
77 b[10] = (safer_ebox[(b[10] ^ skey->saferp.K[i+1][10]) & 255] - skey->saferp.K[i][10]) & 255; \
78 b[11] = safer_lbox[(b[11] - skey->saferp.K[i+1][11]) & 255] ^ skey->saferp.K[i][11]; \
79 b[12] = safer_lbox[(b[12] - skey->saferp.K[i+1][12]) & 255] ^ skey->saferp.K[i][12]; \
80 b[13] = (safer_ebox[(b[13] ^ skey->saferp.K[i+1][13]) & 255] - skey->saferp.K[i][13]) & 255; \
81 b[14] = (safer_ebox[(b[14] ^ skey->saferp.K[i+1][14]) & 255] - skey->saferp.K[i][14]) & 255; \
82 b[15] = safer_lbox[(b[15] - skey->saferp.K[i+1][15]) & 255] ^ skey->saferp.K[i][15];
139 static void _round(unsigned char *b, int i, symmetric_key *skey) in _round() argument
144 static void _iround(unsigned char *b, int i, symmetric_key *skey) in _iround() argument
160 #define ROUND(b, i) _round(b, i, skey)
163 #define iROUND(b, i) _iround(b, i, skey)
216 int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey) in saferp_setup() argument
223 LTC_ARGCHK(skey != NULL); in saferp_setup()
248 skey->saferp.K[0][x] = t[x]; in saferp_setup()
261 skey->saferp.K[x][y] = (t[z] + safer_bias[x-1][y]) & 255; in saferp_setup()
265 skey->saferp.rounds = 8; in saferp_setup()
276 skey->saferp.K[0][x] = t[x]; in saferp_setup()
288 skey->saferp.K[x][y] = (t[z] + safer_bias[x-1][y]) & 255; in saferp_setup()
292 skey->saferp.rounds = 12; in saferp_setup()
303 skey->saferp.K[0][x] = t[x]; in saferp_setup()
315 skey->saferp.K[x][y] = (t[z] + safer_bias[x-1][y]) & 255; in saferp_setup()
319 skey->saferp.rounds = 16; in saferp_setup()
334 int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey) in saferp_ecb_encrypt() argument
341 LTC_ARGCHK(skey != NULL); in saferp_ecb_encrypt()
356 if (skey->saferp.rounds > 8) { in saferp_ecb_encrypt()
363 if (skey->saferp.rounds > 12) { in saferp_ecb_encrypt()
369 ct[0] = b[0] ^ skey->saferp.K[skey->saferp.rounds*2][0]; in saferp_ecb_encrypt()
370 ct[1] = (b[1] + skey->saferp.K[skey->saferp.rounds*2][1]) & 255; in saferp_ecb_encrypt()
371 ct[2] = (b[2] + skey->saferp.K[skey->saferp.rounds*2][2]) & 255; in saferp_ecb_encrypt()
372 ct[3] = b[3] ^ skey->saferp.K[skey->saferp.rounds*2][3]; in saferp_ecb_encrypt()
373 ct[4] = b[4] ^ skey->saferp.K[skey->saferp.rounds*2][4]; in saferp_ecb_encrypt()
374 ct[5] = (b[5] + skey->saferp.K[skey->saferp.rounds*2][5]) & 255; in saferp_ecb_encrypt()
375 ct[6] = (b[6] + skey->saferp.K[skey->saferp.rounds*2][6]) & 255; in saferp_ecb_encrypt()
376 ct[7] = b[7] ^ skey->saferp.K[skey->saferp.rounds*2][7]; in saferp_ecb_encrypt()
377 ct[8] = b[8] ^ skey->saferp.K[skey->saferp.rounds*2][8]; in saferp_ecb_encrypt()
378 ct[9] = (b[9] + skey->saferp.K[skey->saferp.rounds*2][9]) & 255; in saferp_ecb_encrypt()
379 ct[10] = (b[10] + skey->saferp.K[skey->saferp.rounds*2][10]) & 255; in saferp_ecb_encrypt()
380 ct[11] = b[11] ^ skey->saferp.K[skey->saferp.rounds*2][11]; in saferp_ecb_encrypt()
381 ct[12] = b[12] ^ skey->saferp.K[skey->saferp.rounds*2][12]; in saferp_ecb_encrypt()
382 ct[13] = (b[13] + skey->saferp.K[skey->saferp.rounds*2][13]) & 255; in saferp_ecb_encrypt()
383 ct[14] = (b[14] + skey->saferp.K[skey->saferp.rounds*2][14]) & 255; in saferp_ecb_encrypt()
384 ct[15] = b[15] ^ skey->saferp.K[skey->saferp.rounds*2][15]; in saferp_ecb_encrypt()
398 int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey) in saferp_ecb_decrypt() argument
405 LTC_ARGCHK(skey != NULL); in saferp_ecb_decrypt()
408 b[0] = ct[0] ^ skey->saferp.K[skey->saferp.rounds*2][0]; in saferp_ecb_decrypt()
409 b[1] = (ct[1] - skey->saferp.K[skey->saferp.rounds*2][1]) & 255; in saferp_ecb_decrypt()
410 b[2] = (ct[2] - skey->saferp.K[skey->saferp.rounds*2][2]) & 255; in saferp_ecb_decrypt()
411 b[3] = ct[3] ^ skey->saferp.K[skey->saferp.rounds*2][3]; in saferp_ecb_decrypt()
412 b[4] = ct[4] ^ skey->saferp.K[skey->saferp.rounds*2][4]; in saferp_ecb_decrypt()
413 b[5] = (ct[5] - skey->saferp.K[skey->saferp.rounds*2][5]) & 255; in saferp_ecb_decrypt()
414 b[6] = (ct[6] - skey->saferp.K[skey->saferp.rounds*2][6]) & 255; in saferp_ecb_decrypt()
415 b[7] = ct[7] ^ skey->saferp.K[skey->saferp.rounds*2][7]; in saferp_ecb_decrypt()
416 b[8] = ct[8] ^ skey->saferp.K[skey->saferp.rounds*2][8]; in saferp_ecb_decrypt()
417 b[9] = (ct[9] - skey->saferp.K[skey->saferp.rounds*2][9]) & 255; in saferp_ecb_decrypt()
418 b[10] = (ct[10] - skey->saferp.K[skey->saferp.rounds*2][10]) & 255; in saferp_ecb_decrypt()
419 b[11] = ct[11] ^ skey->saferp.K[skey->saferp.rounds*2][11]; in saferp_ecb_decrypt()
420 b[12] = ct[12] ^ skey->saferp.K[skey->saferp.rounds*2][12]; in saferp_ecb_decrypt()
421 b[13] = (ct[13] - skey->saferp.K[skey->saferp.rounds*2][13]) & 255; in saferp_ecb_decrypt()
422 b[14] = (ct[14] - skey->saferp.K[skey->saferp.rounds*2][14]) & 255; in saferp_ecb_decrypt()
423 b[15] = ct[15] ^ skey->saferp.K[skey->saferp.rounds*2][15]; in saferp_ecb_decrypt()
425 if (skey->saferp.rounds > 12) { in saferp_ecb_decrypt()
432 if (skey->saferp.rounds > 8) { in saferp_ecb_decrypt()
499 symmetric_key skey; in saferp_test()
503 if ((err = saferp_setup(tests[i].key, tests[i].keylen, 0, &skey)) != CRYPT_OK) { in saferp_test()
506 saferp_ecb_encrypt(tests[i].pt, tmp[0], &skey); in saferp_test()
507 saferp_ecb_decrypt(tmp[0], tmp[1], &skey); in saferp_test()
516 for (y = 0; y < 1000; y++) saferp_ecb_encrypt(tmp[0], tmp[0], &skey); in saferp_test()
517 for (y = 0; y < 1000; y++) saferp_ecb_decrypt(tmp[0], tmp[0], &skey); in saferp_test()
528 void saferp_done(symmetric_key *skey) in saferp_done() argument