FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/fips_test.c
/* do all tests, 0 on success */
do all tests, 0 on success
do all tests 0 on success
int DoKnownAnswerTests(char* base16_hash, int base16_hashSz)
{
    if (DoInCoreCheck(base16_hash, base16_hashSz) != 0) {
        printf("In core integrity check error: hash = %s\n", base16_hash);
        return IN_CORE_FIPS_E;
    }
#if !defined(NO_AES) && !defined(NO_AES_CBC)
    if (AesKnownAnswerTest(
             "2b7e151628aed2a6abf7158809cf4f3c",  
             "000102030405060708090a0b0c0d0e0f",  
             "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac" 
             "9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a"
             "52eff69f2445df4f9b17ad2b417be66c3710",
             "7649abac8119b246cee98e9b12e9197d5086cb9b507219" 
             "ee95db113a917678b273bed6b8e3c1743b7116e69e2222"
             "95163ff1caa1681fac09120eca307586e1a7"
             ) != 0) {
        return AES_KAT_FIPS_E;
    }
#endif
#ifdef HAVE_AESGCM
    if (AesGcm_KnownAnswerTest(0,
             "298efa1ccf29cf62ae6824bfc19557fc",                
             "6f58a93fe1d207fae4ed2f6d",                        
             "cc38bccd6bc536ad919b1395f5d63801f99f8068d65ca5ac" 
             "63872daf16b93901",
             "021fafd238463973ffe80256e5b1c6b1",                
             "dfce4e9cd291103d7fe4e63351d9e79d3dfd391e32671046" 
             "58212da96521b7db",
             "542465ef599316f73a7a560509a2d9f2"                 
             ) != 0) {
        return AESGCM_KAT_FIPS_E;
    }
    if (AesGcm_KnownAnswerTest(1,
             "afa272c03d0343f882008f6e163d6047",                
             "271ba21f8fdcac34dc93be54",                        
             "f3ee01423f192c36033542221c5545dd939de52ada18b9e8" 
             "b72ba17d02c5dddd",
             "cdf5496a50214683304aec0a80337f9a",                
             "36a4029c9e7d0307d31c29cea885bb6c8022452016a29754" 
             "ba8a344c5bbfc3e1",
             "ed8d916c171f0688d7e7cca547ab3ab2"                 
             ) != 0) {
        return AESGCM_KAT_FIPS_E;
    }
#endif
#ifndef NO_DES3
    if (Des3_KnownAnswerTest(
            "385D7189A5C3D485E1370AA5D408082B5CCCCB5E19F2D90E",  
            "C141B5FCCD28DC8A",                                  
            "6E1BD7C6120947A464A6AAB293A0F89A563D8D40D3461B68",  
            "6235A461AFD312973E3B4F7AA7D23E34E03371F8E8C376C9"   
             ) != 0) {
        return DES3_KAT_FIPS_E;
    }
#endif
#ifndef NO_SHA
    if (HMAC_KnownAnswerTest(WC_SHA,                          
            "303132333435363738393a3b3c3d3e3f40414243",       
            "Sample #2",                                      
            "0922D3405FAA3D194F82A45830737D5CC6C75D24"        
            ) != 0) {
        return HMAC_KAT_FIPS_E;
    }
#endif
#ifdef WOLFSSL_SHA512
    if (HMAC_KnownAnswerTest(WC_SHA512,                       
            "303132333435363738393a3b3c3d3e3f40414243",       
            "Sample #2",                                      
            "809d44057c5b954105bd041316db0fac44d5a4d5d0892bd04e866412c0907768"
            "f187b77c4fae2c2f21a5b5659a4f4ba74702a3de9b51f145bd4f252742989905"
            ) != 0) {
        return HMAC_KAT_FIPS_E;
    }
#endif
#ifdef WOLFSSL_SHA3
    if (HMAC_KnownAnswerTest(WC_SHA3_256,                     
            "302132333435363738393a3b3c3d3e3f"
            "302132333435363738393a3b3c3d3e3f",               
            "Sample #2",                                      
            "1c91ce1a0cbf7501f432a8e23a17cd98"
            "3c96c9b5a16742016c179ff73eb8aa83"                
            ) != 0) {
        return HMAC_KAT_FIPS_E;
    }
#endif
#ifndef NO_RSA
    if (RsaSignPKCS1v15_KnownAnswerTest(WC_SHA256,            
            "Everyone gets Friday off.",                      
            "8CFA57979578B9D781C7F7EEDD21E962FC45D8B7CCDA68837"
            "D84E8345973856089C025A06F89F77D7C3694C483A6EF6B42"
            "EE69B8C2E01CC113F137F498890752EF6C6094D3819979122"
            "7928ED82D5BB50FB96A754F977D66FE75ABCF70F5D9448352"
            "26D30BF6F62D7B9CAFFA18179C5DABCE58BA497424A5AC8D6"
            "11814B726CF3294D0C238000DC2B775791925CA528F6B4947"
            "D3E4BA1F8CDF4C3E88E1AA2FCDAE461F6DF245DD3C39F980F"
            "D0FEC213FCB7B7D1679F4689D08538E16A8E0F357BADFD1F0"
            "D56C635B9E6E7CBD6E2F32F347AB9E07685166016EEF8F857"
            "37542185635688469BC08AF743B02B5C6FB5CED8924B20C14"
            "7B9F349FAA1943DBF677CA"
            ) != 0) {
        return RSA_KAT_FIPS_E;
    }
#endif
#ifdef HAVE_HASHDRBG
    if (DRBG_KnownAnswerTest(0,
            "a65ad0f345db4e0effe875c3a2e71f42"
            "c7129d620ff5c119a9ef55f05185e0fb"
            "8581f9317517276e06e9607ddbcbcc2e", 
            NULL,                               
            "d3e160c35b99f340b2628264d1751060"
            "e0045da383ff57a57d73a673d2b8d80d"
            "aaf6a6c35a91bb4579d73fd0c8fed111"
            "b0391306828adfed528f018121b3febd"
            "c343e797b87dbb63db1333ded9d1ece1"
            "77cfa6b71fe8ab1da46624ed6415e51c"
            "cde2c7ca86e283990eeaeb9112041552"
            "8b2295910281b02dd431f4c9f70427df"  
            ) != 0) {
        return DRBG_KAT_FIPS_E;
    }
    if (DRBG_KnownAnswerTest(1,
            "63363377e41e86468deb0ab4a8ed683f"
            "6a134e47e014c700454e81e95358a569"
            "808aa38f2a72a62359915a9f8a04ca68", 
            "e62b8a8ee8f141b6980566e3bfe3c049"
            "03dad4ac2cdf9f2280010a6739bc83d3", 
            "04eec63bb231df2c630a1afbe724949d"
            "005a587851e1aa795e477347c8b05662"
            "1c18bddcdd8d99fc5fc2b92053d8cfac"
            "fb0bb8831205fad1ddd6c071318a6018"
            "f03b73f5ede4d4d071f9de03fd7aea10"
            "5d9299b8af99aa075bdb4db9aa28c18d"
            "174b56ee2a014d098896ff2282c955a8"
            "1969e069fa8ce007a180183a07dfae17"  
            ) != 0) {
        return DRBG_KAT_FIPS_E;
    }
#endif
#ifdef HAVE_ECC_CDH
    if (ECC_CDH_KnownAnswerTest(
        "700c48f77f56584c5cc632ca65640db91b6bacce3a4df6b42ce7cc838833d287",
        "db71e509e3fd9b060ddb20ba5c51dcc5948d46fbf640dfe0441782cab85fa4ac",
        "7d7dc5f71eb29ddaf80d6214632eeae03d9058af1fb6d22ed80badb62bc1a534",
        "ead218590119e8876b29146ff89ca61770c4edbbf97d38ce385ed281d8a6b230",
        "28af61281fd35e2fa7002523acc85a429cb06ee6648325389f59edfce1405141",
        "46fc62106420ff012e54a434fbdd2d25ccc5852060561e68040dd7778997bd7b"
            ) != 0) {
        return ECC_CDH_KAT_FIPS_E;
    }
#endif
#ifdef HAVE_ECC_DHE
    if (EccPrimitiveZ_KnownAnswerTest(
            "a2f5af030e280c76512f4591c200a3aac5b3f464fe7b598b2677af1df90f7c16",
            "0052d0fcf017d89126e51c837705826c6b954cf3ce4513706ab3cd1cf69287f7",
            "6483453e74522854c940d9817e464f846975aeddbde3742e46ff10110178b5d4",
            "e3a66b3758279713ff594f485e9f7e0c34215090575ac4b4595ebaa301bda0b3",
            "02697f40772eb4bc12dd43436b0f8c9f5852e8df1e994f5857e18ef26e78d8e0",
            "322f2e5a51d78300e5ec692e7c592a25e65c960f76de8729ee0b678dc9d0e99e"
            ) != 0) {
        return ECDHE_KAT_FIPS_E;
    }
#endif
#ifndef NO_DH
    if (DhPrimitiveZ_KnownAnswerTest(
            "c7a528b2747cd4080d5da193285ef3eddf7bea8be391df9503c9f6a73372f6ee"
            "4e8b2cc0577bf7f8366a29b59286be32e1a13e60bea187e654b6c71268e39c97"
            "3ff220e4a8545cef5a85980d1c9687193faac4355370dee4a37acfc3a29c3e1c"
            "82faad94a2afc004ea1861fde4a9c25950a85264eb87175d047af23ad048d840"
            "50f8f0ea071672a6d210b545656c0556e94d2b4ab0b739eaf4d6c2d8d09c464f"
            "8d6afc1a8283ef3a6227d87ab6fef5e6208645a468bbba478d4b84dedb398689"
            "15e28317a7111ee75c028fe2ecfcf92453b89ff7d8c860e875b266d4455c2ac2"
            "626b6a748af0597ca9907405981d4e9af12451dad23a46f4219da89cc5be7453",
            "bc611c3b67b20c469972651de49b3b879d624d72ea41951615a04cc5b7f04a1f",
            "2fa3f79bb9cfb3fbaa4b19b8c0b5fb1e791da1c3426fb33c979ad2fcde6f984c"
            "c1578fb79125b646694ef937e2a4b1c45ff1ecb7847d4e2cc5761fa483116a9c"
            "cf628aa9c71c15cb37547ec1bd64930fb9a7569e90219b2d6ed82ad2cfee8b04"
            "4aefb475dfd0f89acb690b5021d7cacba9cbdcb517416bdbade00003dd9ea18d"
            "310e9c5734f8508ca57eb523b84b199600c130ce7bd0ab2f3dc151c10301fefc"
            "11bcd7f4fc628a84e58e4b34eb9e17406cfece2db09d7966b76582a13b31ebd7"
            "fd51bf57495144598300c9c1dc2f69237aba4e0d6d6aee1bdff125f5fee62735"
            "6759ba8c2f64dbef44565dde7875362b8e681cdf63aa2add4fa83b0a7509c3cc",
            "5b359fb62eea923b26727316a2a54126bd89a5b5015be6ac1b294ffaf180d1cb",
            "b503c9e08cf1461540eed4d794a8dc103fa47c3e1689cc3145b8f9bdeb1df99b"
            "d029f4431ce36b5854c7e16b8d076cf58023f7696fad93789a730a8b42d11345"
            "0903cea3555a39b3c1a9756dcd22915e5bb2ac62e4607f0c455da951b43135db"
            "37e171ddb4da8ae671a90f1bd288d634d4f18481d25c139d44672bbef0245928"
            "a9a78d1f5d28665eed690acdf0e06a82a3e4fdb9776a2705248f10ac638f6525"
            "03fd69d73ed46b4d0e47beb738d90913a48840d4a05f059aee4050572d6432c0"
            "a4a50e455d2b92195eadb7193c96f31e89d469b16ef9b5ddef006102652a90cd"
            "1d6d29f366f88321eb6ce0bdf6c567b302670df28ad42424dc8475a6b0153826",
            "288cc3c9b62c6af7ae8ceaa61c1ebe3de7fe8040928b7154428fa3a08e148b27"
            ) != 0) {
        return DH_KAT_FIPS_E;
    }
#endif
#ifdef HAVE_ECC
    if (ECDSA_PairwiseAgreeTest(WC_SHA256, "Everyone gets Friday off.") != 0) {
        return ECDSA_PAT_FIPS_E;
    }
#endif
    return 0;  
}
int DoKnownAnswerTests ( char * base16_hash , int base16_hashSz ) { if ( DoInCoreCheck ( base16_hash , base16_hashSz ) != 0 ) { printf ( " \n " , base16_hash ) ; return IN_CORE_FIPS_E ; } #if ! defined ( NO_AES ) && ! defined ( NO_AES_CBC ) if ( AesKnownAnswerTest ( " " , " " , " " " " " " , " " " " " " ) != 0 ) { return AES_KAT_FIPS_E ; } #endif #ifdef HAVE_AESGCM if ( AesGcm_KnownAnswerTest ( 0 , " " , " " , " " " " , " " , " " " " , " " ) != 0 ) { return AESGCM_KAT_FIPS_E ; } if ( AesGcm_KnownAnswerTest ( 1 , " " , " " , " " " " , " " , " " " " , " " ) != 0 ) { return AESGCM_KAT_FIPS_E ; } #endif #ifndef NO_DES3 if ( Des3_KnownAnswerTest ( " " , " " , " " , " " ) != 0 ) { return DES3_KAT_FIPS_E ; } #endif #ifndef NO_SHA if ( HMAC_KnownAnswerTest ( WC_SHA , " " , " " , " " ) != 0 ) { return HMAC_KAT_FIPS_E ; } #endif #ifdef WOLFSSL_SHA512 if ( HMAC_KnownAnswerTest ( WC_SHA512 , " " , " " , " " " " ) != 0 ) { return HMAC_KAT_FIPS_E ; } #endif #ifdef WOLFSSL_SHA3 if ( HMAC_KnownAnswerTest ( WC_SHA3_256 , " " " " , " " , " " " " ) != 0 ) { return HMAC_KAT_FIPS_E ; } #endif #ifndef NO_RSA if ( RsaSignPKCS1v15_KnownAnswerTest ( WC_SHA256 , " " , " " " " " " " " " " " " " " " " " " " " " " ) != 0 ) { return RSA_KAT_FIPS_E ; } #endif #ifdef HAVE_HASHDRBG if ( DRBG_KnownAnswerTest ( 0 , " " " " " " , NULL , " " " " " " " " " " " " " " " " ) != 0 ) { return DRBG_KAT_FIPS_E ; } if ( DRBG_KnownAnswerTest ( 1 , " " " " " " , " " " " , " " " " " " " " " " " " " " " " ) != 0 ) { return DRBG_KAT_FIPS_E ; } #endif #ifdef HAVE_ECC_CDH if ( ECC_CDH_KnownAnswerTest ( " " , " " , " " , " " , " " , " " ) != 0 ) { return ECC_CDH_KAT_FIPS_E ; } #endif #ifdef HAVE_ECC_DHE if ( EccPrimitiveZ_KnownAnswerTest ( " " , " " , " " , " " , " " , " " ) != 0 ) { return ECDHE_KAT_FIPS_E ; } #endif #ifndef NO_DH if ( DhPrimitiveZ_KnownAnswerTest ( " " " " " " " " " " " " " " " " , " " , " " " " " " " " " " " " " " " " , " " , " " " " " " " " " " " " " " " " , " " ) != 0 ) { return DH_KAT_FIPS_E ; } #endif #ifdef HAVE_ECC if ( ECDSA_PairwiseAgreeTest ( WC_SHA256 , " " ) != 0 ) { return ECDSA_PAT_FIPS_E ; } #endif return 0 ; }
do all tests, 0 on success
do all tests 0 on success
/* key */ /* iv */ /* plainText */ /* cbc */ /* key */ /* iv */ /* plain */ /* auth */ /* cipher */ /* tag */ /* key */ /* iv */ /* plain */ /* auth */ /* cipher */ /* tag */ /* key */ /* iv  */ /* plain */ /* cbc */ /* type */ /* key */ /* msg */ /* digest */ /* type */ /* key */ /* msg */ /* digest */ /* type */ /* key */ /* msg */ /* digest */ /* type */ /* msg */ /* signature */ /* entropy + nonce input */ /* no reseed */ /* pseudorandom output */ /* entropy + nonce input */ /* reseed entropy input */ /* pseudorandom output */ /* ax */ /* ay */ /* d */ /* ix */ /* iy */ /* z */ /* qexServer */ /* qeyServer */ /* qexClient */ /* qeyClient */ /* deClient */ /* zVerify */ /* p */ /* q */ /* g */ /* xClient */ /* yServer */ /* zVerify */ /* success */