|
60 | 60 | #include <wolfssl/wolfcrypt/types.h> |
61 | 61 | #include <wolfssl/version.h> |
62 | 62 |
|
63 | | -#ifndef NO_WOLFCRYPT_WARMUP |
64 | | - #define HAVE_WOLFCRYPT_WARMUP |
65 | | - #if !defined(NO_AES) && defined(HAVE_AESGCM) |
66 | | - #include <wolfssl/wolfcrypt/aes.h> |
67 | | - #endif |
68 | | -#endif |
69 | 63 | /* |
70 | 64 | ** Version / Platform info. |
71 | 65 | ** |
@@ -383,113 +377,6 @@ static int ShowExtendedSystemInfo_platform_espressif(void) |
383 | 377 | ******************************************************************************* |
384 | 378 | */ |
385 | 379 |
|
386 | | -/* |
387 | | -** All platforms: Warmup wolfssl |
388 | | -*/ |
389 | | -esp_err_t esp_sdk_wolfssl_warmup(void) |
390 | | -{ |
391 | | - esp_err_t ret = ESP_OK; |
392 | | - int ret_i = 0; /* intermediate wolfssl results*/ |
393 | | -#ifdef NO_WOLFCRYPT_WARMUP |
394 | | - ESP_LOGW(TAG, "esp_sdk_wolfssl_warmup called with NO_WOLFCRYPT_WARMUP"); |
395 | | -#else |
396 | | - /* Even though some [name]_NO_MALLOC may defined, there's always the host |
397 | | - * freeRTOS heap. So here, we'll initialize things early on to attempt |
398 | | - * having the heap allocate long term items near the edge of free memory, |
399 | | - * rather than in the middle. */ |
400 | | - WC_RNG rng; |
401 | | - int rng_inited = 0; |
402 | | - unsigned char dummy; |
403 | | -#if !defined(NO_AES) && defined(HAVE_AESGCM) |
404 | | - Aes aes; |
405 | | - unsigned char key16[WC_AES_BLOCK_SIZE]; |
406 | | - unsigned char out[WC_AES_BLOCK_SIZE]; |
407 | | - unsigned char in[WC_AES_BLOCK_SIZE]; |
408 | | - unsigned char iv[WC_AES_BLOCK_SIZE]; |
409 | | - int devId; |
410 | | - int aes_inited = 0; |
411 | | -#endif /* NO_AES && HAVE_AESGCM declarations */ |
412 | | - |
413 | | -#if defined(DEBUG_WOLFSSL_MALLOC_VERBOSE) |
414 | | - ESP_LOGI(TAG, "Warming up RNG"); |
415 | | -#endif |
416 | | - |
417 | | - ret_i = wc_InitRng(&rng); |
418 | | - if (ret_i == 0) { |
419 | | - rng_inited = 1; |
420 | | - /* forces Hash_DRBG/SHA */ |
421 | | - ret_i = wc_RNG_GenerateBlock(&rng, &dummy, sizeof(dummy)); |
422 | | - if (ret_i != 0) { |
423 | | - ESP_LOGE(TAG, "esp_sdk_wolfssl_warmup wc_RNG_GenerateBlock failed"); |
424 | | - } |
425 | | - } |
426 | | - if (ret_i != 0) { |
427 | | - ret = ESP_FAIL; |
428 | | - ESP_LOGE(TAG, "esp_sdk_wolfssl_warmup RNG warmup failed"); |
429 | | - } |
430 | | - if (rng_inited == 1) { |
431 | | - ret_i = wc_FreeRng(&rng); |
432 | | - if (ret_i != 0) { |
433 | | - ret = ESP_FAIL; |
434 | | - ESP_LOGE(TAG, "esp_sdk_wolfssl_warmup wc_FreeRng failed"); |
435 | | - } |
436 | | - } |
437 | | - |
438 | | -#if !defined(NO_AES) && defined(HAVE_AESGCM) |
439 | | -#if defined(DEBUG_WOLFSSL_MALLOC_VERBOSE) |
440 | | - ESP_LOGI(TAG, "Warming up AES"); |
441 | | -#endif |
442 | | - XMEMSET(key16, 0, (word32)sizeof(key16)); |
443 | | - XMEMSET(iv, 0, (word32)sizeof(iv)); |
444 | | - XMEMSET(in, 0, (word32)sizeof(in)); |
445 | | -#ifdef INVALID_DEVID |
446 | | - devId = INVALID_DEVID; /* software by default */ |
447 | | -#else |
448 | | - devId = 0; |
449 | | -#endif |
450 | | - |
451 | | - ret_i = wc_AesInit(&aes, NULL, devId); |
452 | | - if (ret_i == 0) { |
453 | | - aes_inited = 1; |
454 | | - /* Set an ECB key (no IV). This avoids pulling in GCM/GHASH. */ |
455 | | - ret_i = wc_AesSetKey(&aes, key16, (word32)sizeof(key16), NULL, |
456 | | - AES_ENCRYPTION); |
457 | | - } |
458 | | - if (ret_i == 0) { |
459 | | -#ifdef WOLFSSL_AES_DIRECT |
460 | | - /* Single direct block encrypt to exercise the core/driver. */ |
461 | | - ret_i = wc_AesEncryptDirect(&aes, out, in); |
462 | | -#elif !defined(NO_AES_CBC) |
463 | | - /* One-block CBC (tiny; no padding; does not pull GCM). */ |
464 | | - ret_i = wc_AesSetIV(&aes, iv); |
465 | | - if (ret_i == 0) { |
466 | | - ret_i = wc_AesCbcEncrypt(&aes, out, in, (word32)sizeof(in)); |
467 | | - } |
468 | | -#elif defined(WOLFSSL_AES_COUNTER) |
469 | | - /* As another lightweight option, CTR one-block. */ |
470 | | - ret_i = wc_AesSetIV(&aes, iv); |
471 | | - if (ret_i == 0) { |
472 | | - ret_i = wc_AesCtrEncrypt(&aes, out, in, (word32)sizeof(in)); |
473 | | - } |
474 | | -#else |
475 | | - /* No small mode available; setting key already did most of the warmup. */ |
476 | | - ret_i = 0; |
477 | | -#endif /* WOLFSSL_AES_DIRECT, NO_AES_CBC, HAVE_AES_CTR, etc*/ |
478 | | - } |
479 | | - if (ret_i != 0) { |
480 | | - ret = ESP_FAIL; |
481 | | - ESP_LOGE(TAG, "AES warmup failed during esp_sdk_wolfssl_warmup"); |
482 | | - } |
483 | | - if (aes_inited == 1) { |
484 | | - wc_AesFree(&aes); |
485 | | - } |
486 | | - |
487 | | -#endif /* !NO_AES && HAVE_AESGCM */ |
488 | | -#endif /* !NO_WOLFCRYPT_WARMUP */ |
489 | | - |
490 | | - return ret; |
491 | | -} |
492 | | - |
493 | 380 | /* |
494 | 381 | ** All platforms: git details |
495 | 382 | */ |
|
0 commit comments