@@ -8622,6 +8622,31 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t des_test(void)
86228622 0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b
86238623 };
86248624
8625+ #ifdef WOLFSSL_DES_ECB
8626+
8627+ /* "Stay strong and move on!"" */
8628+ WOLFSSL_SMALL_STACK_STATIC const byte vector_ecb[] =
8629+ {
8630+ 0x53,0x74,0x61,0x79,0x20,0x73,0x74,0x72,
8631+ 0x6F,0x6E,0x67,0x20,0x61,0x6E,0x64,0x20,
8632+ 0x6D,0x6F,0x76,0x65,0x20,0x6F,0x6E,0x21
8633+ };
8634+
8635+ WOLFSSL_SMALL_STACK_STATIC const byte verify_ecb[] =
8636+ {
8637+ 0x70,0x4F,0x20,0xF6,0x72,0xB4,0xD0,0x2A,
8638+ 0xB5,0xA9,0x94,0x9F,0x11,0xCF,0x87,0xED,
8639+ 0x13,0x33,0x82,0xCB,0x8B,0xF1,0x82,0x56
8640+ };
8641+
8642+ /* "Lemmings" */
8643+ WOLFSSL_SMALL_STACK_STATIC const byte key_ecb[] =
8644+ {
8645+ 0x4C,0x65,0x6D,0x6D,0x69,0x6E,0x67,0x73
8646+ };
8647+
8648+ #endif /* WOLFSSL_DES_ECB */
8649+
86258650 wc_test_ret_t ret;
86268651 WOLFSSL_ENTER("des_test");
86278652
@@ -8651,6 +8676,32 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t des_test(void)
86518676 if (ret != 0)
86528677 return WC_TEST_RET_ENC_EC(ret);
86538678
8679+ /* Test basic ECB Process for DES*/
8680+ #ifdef WOLFSSL_DES_ECB
8681+ ret = wc_Des_SetKey(&enc, key_ecb, iv, DES_ENCRYPTION);
8682+ if (ret != 0)
8683+ return WC_TEST_RET_ENC_EC(ret);
8684+
8685+ ret = wc_Des_EcbEncrypt(&enc, cipher, vector_ecb, sizeof(vector));
8686+ if (ret != 0)
8687+ return WC_TEST_RET_ENC_EC(ret);
8688+
8689+ ret = wc_Des_SetKey(&dec, key_ecb, iv, DES_DECRYPTION);
8690+ if (ret != 0)
8691+ return WC_TEST_RET_ENC_EC(ret);
8692+
8693+ ret = wc_Des_EcbDecrypt(&dec, plain, cipher, sizeof(cipher));
8694+ if (ret != 0)
8695+ return WC_TEST_RET_ENC_EC(ret);
8696+
8697+ if (XMEMCMP(plain, vector_ecb, sizeof(plain)))
8698+ return WC_TEST_RET_ENC_NC;
8699+
8700+ if (XMEMCMP(cipher, verify_ecb, sizeof(cipher)))
8701+ return WC_TEST_RET_ENC_NC;
8702+
8703+ #endif /* WOLFSSL_DES_ECB */
8704+
86548705#if defined(WOLFSSL_ENCRYPTED_KEYS) && !defined(NO_SHA)
86558706 {
86568707 EncryptedInfo info;
@@ -8722,6 +8773,33 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t des3_test(void)
87228773 0x18,0x94,0x15,0x74,0x87,0x12,0x7d,0xb0
87238774 };
87248775
8776+ #ifdef WOLFSSL_DES_ECB
8777+
8778+ /* Stay strong and move on! */
8779+ WOLFSSL_SMALL_STACK_STATIC const byte vector_ecb[] =
8780+ {
8781+ 0x53,0x74,0x61,0x79,0x20,0x73,0x74,0x72,
8782+ 0x6F,0x6E,0x67,0x20,0x61,0x6E,0x64,0x20,
8783+ 0x6D,0x6F,0x76,0x65,0x20,0x6F,0x6E,0x21
8784+ };
8785+
8786+ WOLFSSL_SMALL_STACK_STATIC const byte verify3_ecb[] =
8787+ {
8788+ 0x45,0x7E,0xFA,0xA1,0x05,0xDD,0x48,0x86,
8789+ 0x4D,0xB2,0xAB,0xE4,0xF9,0x63,0xD6,0x54,
8790+ 0x7C,0x5A,0xB3,0x67,0x32,0x25,0x67,0x3D
8791+ };
8792+
8793+ /* "Life is what you make it" */
8794+ WOLFSSL_SMALL_STACK_STATIC const byte key3_ecb[] =
8795+ {
8796+ 0x4C,0x69,0x66,0x65,0x20,0x69,0x73,0x20,
8797+ 0x77,0x68,0x61,0x74,0x20,0x79,0x6F,0x75,
8798+ 0x20,0x6D,0x61,0x6B,0x65,0x20,0x69,0x74
8799+ };
8800+
8801+ #endif /* WOLFSSL_DES_ECB */
8802+
87258803 wc_test_ret_t ret;
87268804#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
87278805 size_t i;
@@ -8760,6 +8838,42 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t des3_test(void)
87608838 if (XMEMCMP(cipher, verify3, sizeof(cipher)))
87618839 return WC_TEST_RET_ENC_NC;
87628840
8841+ /* Test basic ECB Process for DES3*/
8842+ #ifdef WOLFSSL_DES_ECB
8843+ ret = wc_Des3Init(&enc, HEAP_HINT, devId);
8844+ if (ret != 0)
8845+ return WC_TEST_RET_ENC_EC(ret);
8846+ ret = wc_Des3Init(&dec, HEAP_HINT, devId);
8847+ if (ret != 0)
8848+ return WC_TEST_RET_ENC_EC(ret);
8849+
8850+ ret = wc_Des3_SetKey(&enc, key3_ecb, NULL, DES_ENCRYPTION);
8851+ if (ret != 0)
8852+ return WC_TEST_RET_ENC_EC(ret);
8853+ ret = wc_Des3_SetKey(&dec, key3_ecb, NULL, DES_DECRYPTION);
8854+ if (ret != 0)
8855+ return WC_TEST_RET_ENC_EC(ret);
8856+ ret = wc_Des3_EcbEncrypt(&enc, cipher, vector_ecb, sizeof(vector_ecb));
8857+ #if defined(WOLFSSL_ASYNC_CRYPT)
8858+ ret = wc_AsyncWait(ret, &enc.asyncDev, WC_ASYNC_FLAG_NONE);
8859+ #endif
8860+ if (ret != 0)
8861+ return WC_TEST_RET_ENC_EC(ret);
8862+ ret = wc_Des3_EcbDecrypt(&dec, plain, cipher, sizeof(cipher));
8863+ #if defined(WOLFSSL_ASYNC_CRYPT)
8864+ ret = wc_AsyncWait(ret, &dec.asyncDev, WC_ASYNC_FLAG_NONE);
8865+ #endif
8866+ if (ret != 0)
8867+ return WC_TEST_RET_ENC_EC(ret);
8868+
8869+ if (XMEMCMP(plain, vector_ecb, sizeof(plain)))
8870+ return WC_TEST_RET_ENC_NC;
8871+
8872+ if (XMEMCMP(cipher, verify3_ecb, sizeof(cipher)))
8873+ return WC_TEST_RET_ENC_NC;
8874+
8875+ #endif /* WOLFSSL_DES_ECB */
8876+
87638877#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
87648878 /* test the same vectors with using compatibility layer */
87658879 for (i = 0; i < sizeof(vector); i += DES_BLOCK_SIZE){
0 commit comments