- Timestamp:
- Jun 22, 2021, 9:00:19 PM (3 years ago)
- Location:
- azure_iot_hub_f767zi/trunk/wolfssl-4.7.0
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_f767zi/trunk/wolfssl-4.7.0/wolfcrypt/src/sha512.c
r457 r464 27 27 #include <wolfssl/wolfcrypt/settings.h> 28 28 29 #if (defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)) && !defined(WOLFSSL_ARMASM) 29 #if (defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)) && !defined(WOLFSSL_ARMASM) && !defined(WOLFSSL_PSOC6_CRYPTO) 30 30 31 31 #if defined(HAVE_FIPS) && \ … … 188 188 #if defined(WOLFSSL_IMX6_CAAM) && !defined(NO_IMX6_CAAM_HASH) 189 189 /* functions defined in wolfcrypt/src/port/caam/caam_sha.c */ 190 191 #elif defined(WOLFSSL_SILABS_SHA384) 192 /* functions defined in wolfcrypt/src/port/silabs/silabs_hash.c */ 190 193 191 194 #else … … 338 341 static int transform_check = 0; 339 342 static int intel_flags; 340 #define Transform_Sha512(sha512) (*Transform_Sha512_p)(sha512) 341 #define Transform_Sha512_Len(sha512, len) \ 342 (*Transform_Sha512_Len_p)(sha512, len) 343 344 static void Sha512_SetTransform() 343 static int Transform_Sha512_is_vectorized = 0; 344 345 static WC_INLINE int Transform_Sha512(wc_Sha512 *sha512) { 346 int ret; 347 if (Transform_Sha512_is_vectorized) 348 SAVE_VECTOR_REGISTERS(); 349 ret = (*Transform_Sha512_p)(sha512); 350 if (Transform_Sha512_is_vectorized) 351 RESTORE_VECTOR_REGISTERS(); 352 return ret; 353 } 354 static WC_INLINE int Transform_Sha512_Len(wc_Sha512 *sha512, word32 len) { 355 int ret; 356 if (Transform_Sha512_is_vectorized) 357 SAVE_VECTOR_REGISTERS(); 358 ret = (*Transform_Sha512_Len_p)(sha512, len); 359 if (Transform_Sha512_is_vectorized) 360 RESTORE_VECTOR_REGISTERS(); 361 return ret; 362 } 363 364 static void Sha512_SetTransform(void) 345 365 { 346 366 if (transform_check) … … 355 375 Transform_Sha512_p = Transform_Sha512_AVX2_RORX; 356 376 Transform_Sha512_Len_p = Transform_Sha512_AVX2_RORX_Len; 377 Transform_Sha512_is_vectorized = 1; 357 378 } 358 379 else … … 361 382 Transform_Sha512_p = Transform_Sha512_AVX2; 362 383 Transform_Sha512_Len_p = Transform_Sha512_AVX2_Len; 384 Transform_Sha512_is_vectorized = 1; 363 385 } 364 386 #ifdef HAVE_INTEL_RORX … … 366 388 Transform_Sha512_p = Transform_Sha512_AVX1_RORX; 367 389 Transform_Sha512_Len_p = Transform_Sha512_AVX1_RORX_Len; 390 Transform_Sha512_is_vectorized = 1; 368 391 } 369 392 #endif … … 375 398 Transform_Sha512_p = Transform_Sha512_AVX1; 376 399 Transform_Sha512_Len_p = Transform_Sha512_AVX1_Len; 400 Transform_Sha512_is_vectorized = 1; 377 401 } 378 402 else 379 403 #endif 404 { 380 405 Transform_Sha512_p = _Transform_Sha512; 406 Transform_Sha512_is_vectorized = 1; 407 } 381 408 382 409 transform_check = 1; … … 399 426 400 427 sha512->heap = heap; 428 #ifdef WOLFSSL_SMALL_STACK_CACHE 429 sha512->W = NULL; 430 #endif 401 431 402 432 ret = InitSha512(sha512); … … 406 436 #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2) 407 437 Sha512_SetTransform(); 408 #endif409 410 #ifdef WOLFSSL_SMALL_STACK_CACHE411 sha512->W = NULL;412 438 #endif 413 439 … … 508 534 word64* W = sha512->W; 509 535 if (W == NULL) { 510 W = (word64*) XMALLOC(sizeof(word64) * 16, NULL, 511 DYNAMIC_TYPE_TMP_BUFFER); 536 W = (word64*)XMALLOC(sizeof(word64) * 16, NULL,DYNAMIC_TYPE_TMP_BUFFER); 512 537 if (W == NULL) 513 538 return MEMORY_E; … … 693 718 #endif 694 719 695 if ( len > 0) {720 if (ret == 0 && len > 0) { 696 721 XMEMCPY(local, data, len); 697 722 sha512->buffLen = len; … … 722 747 #endif /* WOLFSSL_SHA512 */ 723 748 724 #endif /* WOLFSSL_IMX6_CAAM */749 #endif /* WOLFSSL_IMX6_CAAM || WOLFSSL_SILABS_SHA384 */ 725 750 726 751 static WC_INLINE int Sha512Final(wc_Sha512* sha512) … … 903 928 /* functions defined in wolfcrypt/src/port/caam/caam_sha.c */ 904 929 930 #elif defined(WOLFSSL_SILABS_SHA512) 931 /* functions defined in wolfcrypt/src/port/silabs/silabs_hash.c */ 932 905 933 #else 906 934 … … 1020 1048 1021 1049 sha384->heap = heap; 1050 #ifdef WOLFSSL_SMALL_STACK_CACHE 1051 sha384->W = NULL; 1052 #endif 1053 1022 1054 ret = InitSha384(sha384); 1023 1055 if (ret != 0) … … 1026 1058 #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2) 1027 1059 Sha512_SetTransform(); 1028 #endif1029 #ifdef WOLFSSL_SMALL_STACK_CACHE1030 sha384->W = NULL;1031 1060 #endif 1032 1061 … … 1041 1070 } 1042 1071 1043 #endif /* WOLFSSL_IMX6_CAAM */1072 #endif /* WOLFSSL_IMX6_CAAM || WOLFSSL_SILABS_SHA512 */ 1044 1073 1045 1074 int wc_InitSha384(wc_Sha384* sha384) … … 1112 1141 #endif 1113 1142 1143 #ifdef WOLFSSL_SILABS_SHA512 1144 dst->silabsCtx.hash_ctx.cmd_ctx = &(dst->silabsCtx.cmd_ctx); 1145 dst->silabsCtx.hash_ctx.hash_type_ctx = &(dst->silabsCtx.hash_type_ctx); 1146 #endif 1147 1114 1148 #ifdef WOLFSSL_ASYNC_CRYPT 1115 1149 ret = wolfAsync_DevCopy(&src->asyncDev, &dst->asyncDev); … … 1188 1222 #endif 1189 1223 1224 #ifdef WOLFSSL_SILABS_SHA384 1225 dst->silabsCtx.hash_ctx.cmd_ctx = &(dst->silabsCtx.cmd_ctx); 1226 dst->silabsCtx.hash_ctx.hash_type_ctx = &(dst->silabsCtx.hash_type_ctx); 1227 #endif 1228 1190 1229 #ifdef WOLFSSL_ASYNC_CRYPT 1191 1230 ret = wolfAsync_DevCopy(&src->asyncDev, &dst->asyncDev);
Note:
See TracChangeset
for help on using the changeset viewer.