update libtomcrypt
Karel Miko
4 years ago
294 | 294 | LTC_ARGCHK(skey != NULL); |
295 | 295 | |
296 | 296 | Nr = skey->rijndael.Nr; |
297 | ||
298 | if (Nr < 2 || Nr > 16) | |
299 | return CRYPT_INVALID_ROUNDS; | |
300 | ||
297 | 301 | rk = skey->rijndael.eK; |
298 | 302 | |
299 | 303 | /* |
474 | 478 | LTC_ARGCHK(skey != NULL); |
475 | 479 | |
476 | 480 | Nr = skey->rijndael.Nr; |
481 | ||
482 | if (Nr < 2 || Nr > 16) | |
483 | return CRYPT_INVALID_ROUNDS; | |
484 | ||
477 | 485 | rk = skey->rijndael.dK; |
478 | 486 | |
479 | 487 | /* |
269 | 269 | 16 |
270 | 270 | } |
271 | 271 | }; |
272 | int i, oldhashidx, idx; | |
272 | int i, oldhashidx, idx, err; | |
273 | 273 | unsigned char tmp[MAXBLOCKSIZE]; |
274 | 274 | hash_state md; |
275 | 275 | |
283 | 283 | chc_register(idx); |
284 | 284 | |
285 | 285 | for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) { |
286 | chc_init(&md); | |
287 | chc_process(&md, tests[i].msg, strlen((char *)tests[i].msg)); | |
288 | chc_done(&md, tmp); | |
286 | if ((err = chc_init(&md)) != CRYPT_OK) { | |
287 | return err; | |
288 | } | |
289 | if ((err = chc_process(&md, tests[i].msg, strlen((char *)tests[i].msg))) != CRYPT_OK) { | |
290 | return err; | |
291 | } | |
292 | if ((err = chc_done(&md, tmp)) != CRYPT_OK) { | |
293 | return err; | |
294 | } | |
289 | 295 | if (compare_testvector(tmp, tests[i].len, tests[i].hash, tests[i].len, "CHC", i)) { |
290 | 296 | return CRYPT_FAIL_TESTVECTOR; |
291 | 297 | } |
242 | 242 | #undef ENDIAN_32BITWORD |
243 | 243 | #undef ENDIAN_64BITWORD |
244 | 244 | #undef LTC_FAST |
245 | #define LTC_NO_BSWAP | |
245 | 246 | #define LTC_NO_ROLC |
246 | #define LTC_NO_BSWAP | |
247 | #define LTC_NO_ROTATE | |
247 | 248 | #endif |
248 | 249 | |
249 | 250 | /* No LTC_FAST if: explicitly disabled OR non-gcc/non-clang compiler OR old gcc OR using -ansi -std=c99 */ |
288 | 289 | #define LTC_HAVE_BSWAP_BUILTIN |
289 | 290 | #endif |
290 | 291 | |
292 | #if !defined(LTC_NO_ROTATE) && (__has_builtin(__builtin_rotateleft32) && __has_builtin(__builtin_rotateright32)) | |
293 | #define LTC_HAVE_ROTATE_BUILTIN | |
294 | #endif | |
295 | ||
291 | 296 | #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301) |
292 | 297 | #define LTC_DEPRECATED __attribute__((deprecated)) |
293 | 298 | #elif defined(_MSC_VER) && _MSC_VER >= 1500 |
240 | 240 | |
241 | 241 | /* 32-bit Rotates */ |
242 | 242 | #if defined(_MSC_VER) |
243 | #define LTC_ROx_ASM | |
243 | #define LTC_ROx_BUILTIN | |
244 | 244 | |
245 | 245 | /* instrinsic rotate */ |
246 | 246 | #include <stdlib.h> |
247 | #pragma intrinsic(_lrotr,_lrotl) | |
248 | #define ROR(x,n) _lrotr(x,n) | |
249 | #define ROL(x,n) _lrotl(x,n) | |
250 | #define RORc(x,n) _lrotr(x,n) | |
251 | #define ROLc(x,n) _lrotl(x,n) | |
247 | #pragma intrinsic(_rotr,_rotl) | |
248 | #define ROR(x,n) _rotr(x,n) | |
249 | #define ROL(x,n) _rotl(x,n) | |
250 | #define RORc(x,n) ROR(x,n) | |
251 | #define ROLc(x,n) ROL(x,n) | |
252 | ||
253 | #elif defined(LTC_HAVE_ROTATE_BUILTIN) | |
254 | #define LTC_ROx_BUILTIN | |
255 | ||
256 | #define ROR(x,n) __builtin_rotateright32(x,n) | |
257 | #define ROL(x,n) __builtin_rotateleft32(x,n) | |
258 | #define ROLc(x,n) ROL(x,n) | |
259 | #define RORc(x,n) ROR(x,n) | |
252 | 260 | |
253 | 261 | #elif !defined(__STRICT_ANSI__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && !defined(INTEL_CC) && !defined(LTC_NO_ASM) |
254 | 262 | #define LTC_ROx_ASM |
352 | 360 | |
353 | 361 | |
354 | 362 | /* 64-bit Rotates */ |
355 | #if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__x86_64__) && !defined(_WIN64) && !defined(LTC_NO_ASM) | |
363 | #if defined(_MSC_VER) | |
364 | ||
365 | /* instrinsic rotate */ | |
366 | #include <stdlib.h> | |
367 | #pragma intrinsic(_rotr64,_rotr64) | |
368 | #define ROR64(x,n) _rotr64(x,n) | |
369 | #define ROL64(x,n) _rotl64(x,n) | |
370 | #define ROR64c(x,n) ROR64(x,n) | |
371 | #define ROL64c(x,n) ROL64(x,n) | |
372 | ||
373 | #elif defined(LTC_HAVE_ROTATE_BUILTIN) | |
374 | ||
375 | #define ROR64(x,n) __builtin_rotateright64(x,n) | |
376 | #define ROL64(x,n) __builtin_rotateleft64(x,n) | |
377 | #define ROR64c(x,n) ROR64(x,n) | |
378 | #define ROL64c(x,n) ROL64(x,n) | |
379 | ||
380 | #elif !defined(__STRICT_ANSI__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && !defined(INTEL_CC) && !defined(LTC_NO_ASM) | |
356 | 381 | |
357 | 382 | static inline ulong64 ROL64(ulong64 word, int i) |
358 | 383 | { |
513 | 513 | #if defined(LTC_NO_ASM) |
514 | 514 | " LTC_NO_ASM " |
515 | 515 | #endif |
516 | #if defined(LTC_ROx_ASM) | |
516 | #if defined(LTC_ROx_BUILTIN) | |
517 | " LTC_ROx_BUILTIN " | |
518 | #elif defined(LTC_ROx_ASM) | |
517 | 519 | " LTC_ROx_ASM " |
518 | 520 | #if defined(LTC_NO_ROLC) |
519 | 521 | " LTC_NO_ROLC " |