Package list libcryptx-perl / 32f1d21
update libtomcrypt Karel Miko 2 years ago
6 changed file(s) with 60 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
294294 LTC_ARGCHK(skey != NULL);
295295
296296 Nr = skey->rijndael.Nr;
297
298 if (Nr < 2 || Nr > 16)
299 return CRYPT_INVALID_ROUNDS;
300
297301 rk = skey->rijndael.eK;
298302
299303 /*
474478 LTC_ARGCHK(skey != NULL);
475479
476480 Nr = skey->rijndael.Nr;
481
482 if (Nr < 2 || Nr > 16)
483 return CRYPT_INVALID_ROUNDS;
484
477485 rk = skey->rijndael.dK;
478486
479487 /*
269269 16
270270 }
271271 };
272 int i, oldhashidx, idx;
272 int i, oldhashidx, idx, err;
273273 unsigned char tmp[MAXBLOCKSIZE];
274274 hash_state md;
275275
283283 chc_register(idx);
284284
285285 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 }
289295 if (compare_testvector(tmp, tests[i].len, tests[i].hash, tests[i].len, "CHC", i)) {
290296 return CRYPT_FAIL_TESTVECTOR;
291297 }
242242 #undef ENDIAN_32BITWORD
243243 #undef ENDIAN_64BITWORD
244244 #undef LTC_FAST
245 #define LTC_NO_BSWAP
245246 #define LTC_NO_ROLC
246 #define LTC_NO_BSWAP
247 #define LTC_NO_ROTATE
247248 #endif
248249
249250 /* No LTC_FAST if: explicitly disabled OR non-gcc/non-clang compiler OR old gcc OR using -ansi -std=c99 */
288289 #define LTC_HAVE_BSWAP_BUILTIN
289290 #endif
290291
292 #if !defined(LTC_NO_ROTATE) && (__has_builtin(__builtin_rotateleft32) && __has_builtin(__builtin_rotateright32))
293 #define LTC_HAVE_ROTATE_BUILTIN
294 #endif
295
291296 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
292297 #define LTC_DEPRECATED __attribute__((deprecated))
293298 #elif defined(_MSC_VER) && _MSC_VER >= 1500
240240
241241 /* 32-bit Rotates */
242242 #if defined(_MSC_VER)
243 #define LTC_ROx_ASM
243 #define LTC_ROx_BUILTIN
244244
245245 /* instrinsic rotate */
246246 #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)
252260
253261 #elif !defined(__STRICT_ANSI__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && !defined(INTEL_CC) && !defined(LTC_NO_ASM)
254262 #define LTC_ROx_ASM
352360
353361
354362 /* 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)
356381
357382 static inline ulong64 ROL64(ulong64 word, int i)
358383 {
513513 #if defined(LTC_NO_ASM)
514514 " LTC_NO_ASM "
515515 #endif
516 #if defined(LTC_ROx_ASM)
516 #if defined(LTC_ROx_BUILTIN)
517 " LTC_ROx_BUILTIN "
518 #elif defined(LTC_ROx_ASM)
517519 " LTC_ROx_ASM "
518520 #if defined(LTC_NO_ROLC)
519521 " LTC_NO_ROLC "
6464 /* count number of bytes */
6565 for (z = 0; (tmp & 0x80) && (z <= 4); z++, tmp = (tmp << 1) & 0xFF);
6666
67 if (z > 4 || (x + (z - 1) > inlen)) {
67 if (z == 1 || z > 4 || (x + (z - 1) > inlen)) {
6868 return CRYPT_INVALID_PACKET;
6969 }
7070