Codebase list libcryptx-perl / 006791b
ltc sync Karel Miko 6 years ago
38 changed file(s) with 68 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
1414 Process an entire GCM packet in one call.
1515 @param key The secret key
1616 @param keylen The length of the secret key
17 @param iv The initial vector
18 @param ivlen The length of the initial vector
17 @param iv The initialization vector
18 @param ivlen The length of the initialization vector
1919 @param aad The additional authentication data (header)
2020 @param aadlen The length of the aad
2121 @param in The plaintext
1919 @param cipher Index of cipher to use
2020 @param key The secret key
2121 @param keylen The length of the secret key
22 @param IV The initial vector
23 @param IVlen The length of the initial vector
22 @param IV The initialization vector
23 @param IVlen The length of the initialization vector
2424 @param adata The additional authentication data (header)
2525 @param adatalen The length of the adata
2626 @param pt The plaintext
398398 return CRYPT_NOP;
399399 #else
400400 static const struct {
401 char *msg;
401 const char *msg;
402402 unsigned char hash[64];
403403 } tests[] = {
404404 { "",
449449 return CRYPT_NOP;
450450 #else
451451 static const struct {
452 char *msg;
452 const char *msg;
453453 unsigned char hash[48];
454454 } tests[] = {
455455 { "",
496496 return CRYPT_NOP;
497497 #else
498498 static const struct {
499 char *msg;
499 const char *msg;
500500 unsigned char hash[32];
501501 } tests[] = {
502502 { "",
549549 return CRYPT_NOP;
550550 #else
551551 static const struct {
552 char *msg;
552 const char *msg;
553553 unsigned char hash[20];
554554 } tests[] = {
555555 { "",
386386 return CRYPT_NOP;
387387 #else
388388 static const struct {
389 char *msg;
389 const char *msg;
390390 unsigned char hash[32];
391391 } tests[] = {
392392 { "",
440440 return CRYPT_NOP;
441441 #else
442442 static const struct {
443 char *msg;
443 const char *msg;
444444 unsigned char hash[28];
445445 } tests[] = {
446446 { "",
484484 return CRYPT_NOP;
485485 #else
486486 static const struct {
487 char *msg;
487 const char *msg;
488488 unsigned char hash[20];
489489 } tests[] = {
490490 { "",
526526 return CRYPT_NOP;
527527 #else
528528 static const struct {
529 char *msg;
529 const char *msg;
530530 unsigned char hash[16];
531531 } tests[] = {
532532 { "",
190190 return CRYPT_NOP;
191191 #else
192192 static const struct {
193 char *msg;
193 const char *msg;
194194 unsigned char hash[16];
195195 } tests[] = {
196196 { "",
253253 return CRYPT_NOP;
254254 #else
255255 static const struct md4_test_case {
256 char *input;
256 const char *input;
257257 unsigned char hash[16];
258258 } tests[] = {
259259 { "",
313313 return CRYPT_NOP;
314314 #else
315315 static const struct {
316 char *msg;
316 const char *msg;
317317 unsigned char hash[16];
318318 } tests[] = {
319319 { "",
352352 return CRYPT_NOP;
353353 #else
354354 static const struct {
355 char *msg;
355 const char *msg;
356356 unsigned char hash[16];
357357 } tests[] = {
358358 { "",
411411 return CRYPT_NOP;
412412 #else
413413 static const struct {
414 char *msg;
414 const char *msg;
415415 unsigned char hash[20];
416416 } tests[] = {
417417 { "",
365365 return CRYPT_NOP;
366366 #else
367367 static const struct {
368 char *msg;
368 const char *msg;
369369 unsigned char hash[32];
370370 } tests[] = {
371371 { "",
430430 return CRYPT_NOP;
431431 #else
432432 static const struct {
433 char *msg;
433 const char *msg;
434434 unsigned char hash[40];
435435 } tests[] = {
436436 { "",
245245 return CRYPT_NOP;
246246 #else
247247 static const struct {
248 char *msg;
248 const char *msg;
249249 unsigned char hash[20];
250250 } tests[] = {
251251 { "abc",
8787 return CRYPT_NOP;
8888 #else
8989 static const struct {
90 char *msg;
90 const char *msg;
9191 unsigned char hash[28];
9292 } tests[] = {
9393 { "abc",
291291 return CRYPT_NOP;
292292 #else
293293 static const struct {
294 char *msg;
294 const char *msg;
295295 unsigned char hash[32];
296296 } tests[] = {
297297 { "abc",
8989 return CRYPT_NOP;
9090 #else
9191 static const struct {
92 char *msg;
92 const char *msg;
9393 unsigned char hash[48];
9494 } tests[] = {
9595 { "abc",
261261 return CRYPT_NOP;
262262 #else
263263 static const struct {
264 char *msg;
264 const char *msg;
265265 unsigned char hash[64];
266266 } tests[] = {
267267 { "abc",
8989 return CRYPT_NOP;
9090 #else
9191 static const struct {
92 char *msg;
92 const char *msg;
9393 unsigned char hash[28];
9494 } tests[] = {
9595 { "abc",
8989 return CRYPT_NOP;
9090 #else
9191 static const struct {
92 char *msg;
92 const char *msg;
9393 unsigned char hash[32];
9494 } tests[] = {
9595 { "abc",
734734 return CRYPT_NOP;
735735 #else
736736 static const struct {
737 char *msg;
737 const char *msg;
738738 unsigned char hash[24];
739739 } tests[] = {
740740 { "",
7474 zeromem((hmac->key) + keylen, (size_t)(LTC_HMAC_BLOCKSIZE - keylen));
7575 }
7676
77 /* Create the initial vector for step (3) */
77 /* Create the initialization vector for step (3) */
7878 for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
7979 buf[i] = hmac->key[i] ^ 0x36;
8080 }
4242 #else
4343 "disabled\n"
4444 #endif
45 "Ciphers built-in:\n"
45 "\nCiphers built-in:\n"
4646 #if defined(LTC_BLOWFISH)
4747 " Blowfish\n"
4848 #endif
300300 " SOBER128\n"
301301 #endif
302302
303 "\nPK Algs:\n"
303 "\nPK Crypto:\n"
304304 #if defined(LTC_MRSA)
305305 " RSA"
306306 #if defined(LTC_RSA_BLINDING) && defined(LTC_RSA_CRT_HARDENING)
328328 #if defined(LTC_MKAT)
329329 " Katja\n"
330330 #endif
331 #if defined(LTC_PK_MAX_RETRIES)
332 " "NAME_VALUE(LTC_PK_MAX_RETRIES)"\n"
333 #endif
331334
332335 "\nMPI (Math):\n"
333336 #if defined(LTC_MPI)
1313 */
1414
1515 #if (ARGTYPE == 0)
16 void crypt_argchk(char *v, char *s, int d)
16 void crypt_argchk(const char *v, const char *s, int d)
1717 {
1818 fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n",
1919 v, d, s);
77 */
88 #include "tomcrypt.h"
99
10 ltc_math_descriptor ltc_mp;
10 /* Initialize ltc_mp to nulls, to force allocation on all platforms, including macOS. */
11 ltc_math_descriptor ltc_mp = { 0 };
1112
1213 /* ref: $Format:%D$ */
1314 /* git commit: $Format:%H$ */
1919 "CRYPT_ERROR",
2020 "Non-fatal 'no-operation' requested.",
2121
22 "Invalid keysize for block cipher.",
22 "Invalid key size.",
2323 "Invalid number of rounds for block cipher.",
2424 "Algorithm failed test vectors.",
2525
1515 #ifdef LTC_CBC_MODE
1616
1717 /**
18 Get the current initial vector
19 @param IV [out] The destination of the initial vector
20 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2121 @param cbc The CBC state
2222 @return CRYPT_OK if successful
2323 */
1616 #ifdef LTC_CBC_MODE
1717
1818 /**
19 Set an initial vector
20 @param IV The initial vector
19 Set an initialization vector
20 @param IV The initialization vector
2121 @param len The length of the vector (in octets)
2222 @param cbc The CBC state
2323 @return CRYPT_OK if successful
1717 /**
1818 Initialize a CBC context
1919 @param cipher The index of the cipher desired
20 @param IV The initial vector
20 @param IV The initialization vector
2121 @param key The secret key
2222 @param keylen The length of the secret key (octets)
2323 @param num_rounds Number of rounds in the cipher desired (0 for default)
1515 #ifdef LTC_CFB_MODE
1616
1717 /**
18 Get the current initial vector
19 @param IV [out] The destination of the initial vector
20 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2121 @param cfb The CFB state
2222 @return CRYPT_OK if successful
2323 */
1515 #ifdef LTC_CFB_MODE
1616
1717 /**
18 Set an initial vector
19 @param IV The initial vector
18 Set an initialization vector
19 @param IV The initialization vector
2020 @param len The length of the vector (in octets)
2121 @param cfb The CFB state
2222 @return CRYPT_OK if successful
1818 /**
1919 Initialize a CFB context
2020 @param cipher The index of the cipher desired
21 @param IV The initial vector
21 @param IV The initialization vector
2222 @param key The secret key
2323 @param keylen The length of the secret key (octets)
2424 @param num_rounds Number of rounds in the cipher desired (0 for default)
1515 #ifdef LTC_CTR_MODE
1616
1717 /**
18 Get the current initial vector
19 @param IV [out] The destination of the initial vector
20 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2121 @param ctr The CTR state
2222 @return CRYPT_OK if successful
2323 */
1515 #ifdef LTC_CTR_MODE
1616
1717 /**
18 Set an initial vector
19 @param IV The initial vector
18 Set an initialization vector
19 @param IV The initialization vector
2020 @param len The length of the vector (in octets)
2121 @param ctr The CTR state
2222 @return CRYPT_OK if successful
1818 /**
1919 Initialize a CTR context
2020 @param cipher The index of the cipher desired
21 @param IV The initial vector
21 @param IV The initialization vector
2222 @param key The secret key
2323 @param keylen The length of the secret key (octets)
2424 @param num_rounds Number of rounds in the cipher desired (0 for default)
1515 #ifdef LTC_OFB_MODE
1616
1717 /**
18 Get the current initial vector
19 @param IV [out] The destination of the initial vector
20 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2121 @param ofb The OFB state
2222 @return CRYPT_OK if successful
2323 */
1515 #ifdef LTC_OFB_MODE
1616
1717 /**
18 Set an initial vector
19 @param IV The initial vector
18 Set an initialization vector
19 @param IV The initialization vector
2020 @param len The length of the vector (in octets)
2121 @param ofb The OFB state
2222 @return CRYPT_OK if successful
1818 /**
1919 Initialize a OFB context
2020 @param cipher The index of the cipher desired
21 @param IV The initial vector
21 @param IV The initialization vector
2222 @param key The secret key
2323 @param keylen The length of the secret key (octets)
2424 @param num_rounds Number of rounds in the cipher desired (0 for default)
5656 unsigned long i, j;
5757
5858 if (inlen == 0) return CRYPT_OK; /* nothing to do */
59 LTC_ARGCHK(st != NULL);
60 LTC_ARGCHK(in != NULL);
61 LTC_ARGCHK(out != NULL);
59
60 LTC_ARGCHK(st != NULL);
61 LTC_ARGCHK(in != NULL);
62 LTC_ARGCHK(out != NULL);
63 LTC_ARGCHK(st->ivlen != 0);
6264
6365 if (st->ksleft > 0) {
6466 j = MIN(st->ksleft, inlen);
3434 LTC_ARGCHK(key != NULL);
3535 LTC_ARGCHK(keylen == 32 || keylen == 16);
3636
37 if (rounds == 0) rounds = 20;
38
3739 LOAD32L(st->input[4], key + 0);
3840 LOAD32L(st->input[5], key + 4);
3941 LOAD32L(st->input[6], key + 8);