]> foleosoft.com Git - CryptoFoleo.git/commitdiff
Fri Aug 11 08:31:41 AM EDT 2023
authormiha-q <>
Fri, 11 Aug 2023 12:31:41 +0000 (08:31 -0400)
committermiha-q <>
Fri, 11 Aug 2023 12:31:41 +0000 (08:31 -0400)
tests/rfc5869.txt.pdf [new file with mode: 0644]
tests/test.c

diff --git a/tests/rfc5869.txt.pdf b/tests/rfc5869.txt.pdf
new file mode 100644 (file)
index 0000000..e1d082d
Binary files /dev/null and b/tests/rfc5869.txt.pdf differ
index cca7239688e494327870459b4a7e88442feacdd6..caf8a2fcfc32fef606fb5909e81710b95a4cf968 100644 (file)
@@ -48,48 +48,19 @@ void test_hkdf(uint16_t id, uint8_t* ikm, uint32_t ikmS, uint8_t* salt, uint32_t
 
 void main()
 {
-    //test_hmac(1, 1, NIST_HMAC_key1, sizeof(NIST_HMAC_key1), NIST_HMAC_data1, sizeof(NIST_HMAC_data1), NIST_HMAC_result1, sizeof(NIST_HMAC_result1));
-    //test_hmac(1, 2, NIST_HMAC_key2, sizeof(NIST_HMAC_key2), NIST_HMAC_data2, sizeof(NIST_HMAC_data2), NIST_HMAC_result2, sizeof(NIST_HMAC_result2));
-    //test_hmac(1, 3, NIST_HMAC_key3, sizeof(NIST_HMAC_key3), NIST_HMAC_data3, sizeof(NIST_HMAC_data3), NIST_HMAC_result3, sizeof(NIST_HMAC_result3));
-    //test_hmac(1, 4, NIST_HMAC_key4, sizeof(NIST_HMAC_key4), NIST_HMAC_data4, sizeof(NIST_HMAC_data4), NIST_HMAC_result4, sizeof(NIST_HMAC_result4));
-    //test_hmac(2, 1, RFC4231_HMAC_key1, sizeof(RFC4231_HMAC_key1), RFC4231_HMAC_data1, sizeof(RFC4231_HMAC_data1), RFC4231_HMAC_result1, sizeof(RFC4231_HMAC_result1));
-    //test_hmac(2, 2, RFC4231_HMAC_key2, sizeof(RFC4231_HMAC_key2), RFC4231_HMAC_data2, sizeof(RFC4231_HMAC_data2), RFC4231_HMAC_result2, sizeof(RFC4231_HMAC_result2));
-    //test_hmac(2, 3, RFC4231_HMAC_key3, sizeof(RFC4231_HMAC_key3), RFC4231_HMAC_data3, sizeof(RFC4231_HMAC_data3), RFC4231_HMAC_result3, sizeof(RFC4231_HMAC_result3));
-    //test_hmac(2, 4, RFC4231_HMAC_key4, sizeof(RFC4231_HMAC_key4), RFC4231_HMAC_data4, sizeof(RFC4231_HMAC_data4), RFC4231_HMAC_result4, sizeof(RFC4231_HMAC_result4));
-    //test_hmac(2, 5, RFC4231_HMAC_key5, sizeof(RFC4231_HMAC_key5), RFC4231_HMAC_data5, sizeof(RFC4231_HMAC_data5), RFC4231_HMAC_result5, sizeof(RFC4231_HMAC_result5));
-    //test_hmac(2, 6, RFC4231_HMAC_key6, sizeof(RFC4231_HMAC_key6), RFC4231_HMAC_data6, sizeof(RFC4231_HMAC_data6), RFC4231_HMAC_result6, sizeof(RFC4231_HMAC_result6));
-    //test_hmac(2, 7, RFC4231_HMAC_key7, sizeof(RFC4231_HMAC_key7), RFC4231_HMAC_data7, sizeof(RFC4231_HMAC_data7), RFC4231_HMAC_result7, sizeof(RFC4231_HMAC_result7));
+    test_hmac(1, 1, NIST_HMAC_key1, sizeof(NIST_HMAC_key1), NIST_HMAC_data1, sizeof(NIST_HMAC_data1), NIST_HMAC_result1, sizeof(NIST_HMAC_result1));
+    test_hmac(1, 2, NIST_HMAC_key2, sizeof(NIST_HMAC_key2), NIST_HMAC_data2, sizeof(NIST_HMAC_data2), NIST_HMAC_result2, sizeof(NIST_HMAC_result2));
+    test_hmac(1, 3, NIST_HMAC_key3, sizeof(NIST_HMAC_key3), NIST_HMAC_data3, sizeof(NIST_HMAC_data3), NIST_HMAC_result3, sizeof(NIST_HMAC_result3));
+    test_hmac(1, 4, NIST_HMAC_key4, sizeof(NIST_HMAC_key4), NIST_HMAC_data4, sizeof(NIST_HMAC_data4), NIST_HMAC_result4, sizeof(NIST_HMAC_result4));
+    test_hmac(2, 1, RFC4231_HMAC_key1, sizeof(RFC4231_HMAC_key1), RFC4231_HMAC_data1, sizeof(RFC4231_HMAC_data1), RFC4231_HMAC_result1, sizeof(RFC4231_HMAC_result1));
+    test_hmac(2, 2, RFC4231_HMAC_key2, sizeof(RFC4231_HMAC_key2), RFC4231_HMAC_data2, sizeof(RFC4231_HMAC_data2), RFC4231_HMAC_result2, sizeof(RFC4231_HMAC_result2));
+    test_hmac(2, 3, RFC4231_HMAC_key3, sizeof(RFC4231_HMAC_key3), RFC4231_HMAC_data3, sizeof(RFC4231_HMAC_data3), RFC4231_HMAC_result3, sizeof(RFC4231_HMAC_result3));
+    test_hmac(2, 4, RFC4231_HMAC_key4, sizeof(RFC4231_HMAC_key4), RFC4231_HMAC_data4, sizeof(RFC4231_HMAC_data4), RFC4231_HMAC_result4, sizeof(RFC4231_HMAC_result4));
+    test_hmac(2, 5, RFC4231_HMAC_key5, sizeof(RFC4231_HMAC_key5), RFC4231_HMAC_data5, sizeof(RFC4231_HMAC_data5), RFC4231_HMAC_result5, sizeof(RFC4231_HMAC_result5));
+    test_hmac(2, 6, RFC4231_HMAC_key6, sizeof(RFC4231_HMAC_key6), RFC4231_HMAC_data6, sizeof(RFC4231_HMAC_data6), RFC4231_HMAC_result6, sizeof(RFC4231_HMAC_result6));
+    test_hmac(2, 7, RFC4231_HMAC_key7, sizeof(RFC4231_HMAC_key7), RFC4231_HMAC_data7, sizeof(RFC4231_HMAC_data7), RFC4231_HMAC_result7, sizeof(RFC4231_HMAC_result7));
 //
-    //test_hkdf(1, RFC5869_HKDF_ikm1, sizeof(RFC5869_HKDF_ikm1), RFC5869_HKDF_salt1, sizeof(RFC5869_HKDF_salt1), RFC5869_HKDF_info1, sizeof(RFC5869_HKDF_info1), RFC5869_HKDF_result1, sizeof(RFC5869_HKDF_result1));
-    //test_hkdf(2, RFC5869_HKDF_ikm2, sizeof(RFC5869_HKDF_ikm2), RFC5869_HKDF_salt2, sizeof(RFC5869_HKDF_salt2), RFC5869_HKDF_info2, sizeof(RFC5869_HKDF_info2), RFC5869_HKDF_result2, sizeof(RFC5869_HKDF_result2));
-    //test_hkdf(3, RFC5869_HKDF_ikm3, sizeof(RFC5869_HKDF_ikm3), RFC5869_HKDF_salt3, sizeof(RFC5869_HKDF_salt3), RFC5869_HKDF_info3, sizeof(RFC5869_HKDF_info3), RFC5869_HKDF_result3, sizeof(RFC5869_HKDF_result3));
-
-    //Randomly generate a private and public key
-    rsakey_t pub, prv;
-    foleo_rsa_keygen(1024, &pub, &prv);
-
-    uint8_t* tmp = foleo_rsa_export(&prv);
-    printf("%s\n", tmp);
-    ////Encrypt some plaintext into ciphertext
-    //uint8_t plaintext[] = "here is some plaintext to encrypt";
-    //uint8_t* ciphertext = foleo_rsa_encrypt(pub, FOLEO_RSA_OAEP, plaintext, sizeof(plaintext));
-    //
-    ////Display them
-    //test_pbuf("plaintext", plaintext, sizeof(plaintext));
-    //test_pbuf("ciphertext", ciphertext, 2048 / 8);
- //
-    ////Decrypt the ciphertext
-    //uint16_t newSize;
-    //uint8_t* new_plaintext = foleo_rsa_decrypt(prv, FOLEO_RSA_OAEP, ciphertext, &newSize);
-//
-    ////Display it
-    //test_pbuf("new_plaintext", plaintext, newSize);
-
-    //free(ciphertext);
-    foleo_rsa_free(&pub);
-    foleo_rsa_free(&prv);
-
-
-
-
+    test_hkdf(1, RFC5869_HKDF_ikm1, sizeof(RFC5869_HKDF_ikm1), RFC5869_HKDF_salt1, sizeof(RFC5869_HKDF_salt1), RFC5869_HKDF_info1, sizeof(RFC5869_HKDF_info1), RFC5869_HKDF_result1, sizeof(RFC5869_HKDF_result1));
+    test_hkdf(2, RFC5869_HKDF_ikm2, sizeof(RFC5869_HKDF_ikm2), RFC5869_HKDF_salt2, sizeof(RFC5869_HKDF_salt2), RFC5869_HKDF_info2, sizeof(RFC5869_HKDF_info2), RFC5869_HKDF_result2, sizeof(RFC5869_HKDF_result2));
+    test_hkdf(3, RFC5869_HKDF_ikm3, sizeof(RFC5869_HKDF_ikm3), RFC5869_HKDF_salt3, sizeof(RFC5869_HKDF_salt3), RFC5869_HKDF_info3, sizeof(RFC5869_HKDF_info3), RFC5869_HKDF_result3, sizeof(RFC5869_HKDF_result3));
 }