Commit 2c994fad authored by Yann Garcia's avatar Yann Garcia

Bug fixed in Native API

parent cb8cf8a4
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@
extern "C" {
#include "lib_its_security.h"
#ifndef _Win64
uint8_t* hex_to_bin(const int8_t* p_buffer, size_t* p_buffer_length);
uint8_t* hex_to_bin(const int8_t* p_buffer, size_t* p_buffer_length);
#endif
}
......@@ -19,7 +19,7 @@ uint8_t* hex_to_bin(const int8_t* p_buffer, size_t* p_buffer_length) {
}
if ((len = strlen((const char*)p_buffer)) & 1) {
return NULL;
}
}
retval = (uint8_t*)malloc(len >> 1);
for (i = 0; i < len; i++) {
......@@ -427,7 +427,7 @@ TEST(lib_its_security_test_suite, sign_with_ecdsa_nistp256_with_sha256_2) {
// Test body
EXPECT_TRUE(verify_with_ecdsa_nistp256_with_sha256(lib_its_security_context, public_key_y, 32, issuer, sig, public_key_compressed, public_key_compressed_mode) == 0);
// Postamble
free(sig);
free(private_key);
......@@ -978,7 +978,7 @@ TEST(lib_its_security_test_suite, decrypt_aes_ccm_4) {
EXPECT_TRUE(decrypt(lib_its_security_context, encrypted_secured_message, encrypted_secured_message_length, &new_plain_text_message, &new_plain_text_message_length) == 0);
EXPECT_TRUE(new_plain_text_message != NULL);
EXPECT_TRUE(plain_text_message_length == new_plain_text_message_length);
for(size_t i = 0; i < new_plain_text_message_length; i++) {
for (size_t i = 0; i < new_plain_text_message_length; i++) {
EXPECT_TRUE(*(new_plain_text_message + i) == *(plain_text_message + i));
}
......@@ -1047,7 +1047,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_2) {
uint8_t* encrypted_secured_message = NULL;
size_t encrypted_secured_message_length = 0;
EXPECT_TRUE(encrypt_with_ecies_nistp256_with_sha256(lib_its_security_context/*recipient's public keys*/, plain_text_message, plain_text_message_length, lib_its_security_context->public_key_c, lib_its_security_context->compressed_mode, salt, salt_length, &ephemeral_key_compressed, &ephemeral_compressed_mode, &aes_sym_key, &encrypted_sym_key, &authentication_vector, &nonce, &encrypted_secured_message, &encrypted_secured_message_length) == 0);
// Test body
size_t new_plain_text_message_length = 0;
uint8_t* new_plain_text_message = NULL;
......@@ -1062,7 +1062,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_2) {
}
free(new_plain_text_message);
free(new_aes_enc_sym_key);
// Postamble
free(plain_text_message);
free(salt);
......@@ -1097,7 +1097,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_3) {
uint8_t* encrypted_secured_message = NULL;
size_t encrypted_secured_message_length = 0;
EXPECT_TRUE(encrypt_with_ecies_nistp256_with_sha256(lib_its_security_context/*recipient's public keys*/, plain_text_message, plain_text_message_length, lib_its_security_context->public_key_c, lib_its_security_context->compressed_mode, salt, salt_length, &ephemeral_key_compressed, &ephemeral_compressed_mode, &aes_sym_key, &encrypted_sym_key, &authentication_vector, &nonce, &encrypted_secured_message, &encrypted_secured_message_length) == 0);
// Test body
size_t new_plain_text_message_length = 0;
uint8_t* new_plain_text_message = NULL;
......@@ -1106,7 +1106,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_3) {
EXPECT_TRUE(decrypt_with_ecies_nistp256_with_sha256(lib_its_security_context, encrypted_secured_message, encrypted_secured_message_length, lib_its_security_context->private_key, ephemeral_key_compressed, ephemeral_compressed_mode, encrypted_sym_key, authentication_vector, nonce, salt, salt_length, &new_aes_enc_sym_key, &new_plain_text_message, &new_plain_text_message_length) == -1);
free(new_plain_text_message);
free(new_aes_enc_sym_key);
// Postamble
free(plain_text_message);
free(salt);
......@@ -1141,7 +1141,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_4) {
uint8_t* encrypted_secured_message = NULL;
size_t encrypted_secured_message_length = 0;
EXPECT_TRUE(encrypt_with_ecies_nistp256_with_sha256(lib_its_security_context/*recipient's public keys*/, plain_text_message, plain_text_message_length, lib_its_security_context->public_key_c, lib_its_security_context->compressed_mode, salt, salt_length, &ephemeral_key_compressed, &ephemeral_compressed_mode, &aes_sym_key, &encrypted_sym_key, &authentication_vector, &nonce, &encrypted_secured_message, &encrypted_secured_message_length) == 0);
// Test body
size_t new_plain_text_message_length = 0;
uint8_t* new_plain_text_message = NULL;
......@@ -1150,7 +1150,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_4) {
EXPECT_TRUE(decrypt_with_ecies_nistp256_with_sha256(lib_its_security_context, encrypted_secured_message, encrypted_secured_message_length, lib_its_security_context->private_key, ephemeral_key_compressed, ephemeral_compressed_mode, encrypted_sym_key, authentication_vector, nonce, salt, salt_length, &new_aes_enc_sym_key, &new_plain_text_message, &new_plain_text_message_length) == -1);
free(new_plain_text_message);
free(new_aes_enc_sym_key);
// Postamble
free(plain_text_message);
free(salt);
......@@ -1185,7 +1185,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_5) {
uint8_t* encrypted_secured_message = NULL;
size_t encrypted_secured_message_length = 0;
EXPECT_TRUE(encrypt_with_ecies_nistp256_with_sha256(lib_its_security_context/*recipient's public keys*/, plain_text_message, plain_text_message_length, lib_its_security_context->public_key_c, lib_its_security_context->compressed_mode, salt, salt_length, &ephemeral_key_compressed, &ephemeral_compressed_mode, &aes_sym_key, &encrypted_sym_key, &authentication_vector, &nonce, &encrypted_secured_message, &encrypted_secured_message_length) == 0);
// Test body
size_t new_plain_text_message_length = 0;
uint8_t* new_plain_text_message = NULL;
......@@ -1194,7 +1194,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_5) {
EXPECT_TRUE(decrypt_with_ecies_nistp256_with_sha256(lib_its_security_context, encrypted_secured_message, encrypted_secured_message_length, lib_its_security_context->private_key, ephemeral_key_compressed, ephemeral_compressed_mode, encrypted_sym_key, authentication_vector, nonce, salt, salt_length, &new_aes_enc_sym_key, &new_plain_text_message, &new_plain_text_message_length) == -1);
free(new_plain_text_message);
free(new_aes_enc_sym_key);
// Postamble
free(plain_text_message);
free(salt);
......@@ -1229,7 +1229,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_6) {
uint8_t* encrypted_secured_message = NULL;
size_t encrypted_secured_message_length = 0;
EXPECT_TRUE(encrypt_with_ecies_nistp256_with_sha256(lib_its_security_context/*recipient's public keys*/, plain_text_message, plain_text_message_length, lib_its_security_context->public_key_c, lib_its_security_context->compressed_mode, salt, salt_length, &ephemeral_key_compressed, &ephemeral_compressed_mode, &aes_sym_key, &encrypted_sym_key, &authentication_vector, &nonce, &encrypted_secured_message, &encrypted_secured_message_length) == 0);
// Test body
size_t new_plain_text_message_length = 0;
uint8_t* new_plain_text_message = NULL;
......@@ -1238,7 +1238,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_nistp256_with_sha256_6) {
EXPECT_TRUE(decrypt_with_ecies_nistp256_with_sha256(lib_its_security_context, encrypted_secured_message, encrypted_secured_message_length, lib_its_security_context->private_key, ephemeral_key_compressed, ephemeral_compressed_mode, encrypted_sym_key, authentication_vector, nonce, salt, salt_length, &new_aes_enc_sym_key, &new_plain_text_message, &new_plain_text_message_length) == -1);
free(new_plain_text_message);
free(new_aes_enc_sym_key);
// Postamble
free(plain_text_message);
free(salt);
......@@ -1520,8 +1520,7 @@ TEST(lib_its_security_test_suite, encrypt_with_ecies_brainpoolp256r1_with_sha256
* @param[in] p_argc Number of argumrnt
* @param[in] p_argv List of the arguments
*/
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment