diff options
Diffstat (limited to 'src/rsa.c')
-rw-r--r-- | src/rsa.c | 30 |
1 files changed, 14 insertions, 16 deletions
@@ -1,6 +1,4 @@ -#include "config.h" - #include "p11-tests.h" #include <stdio.h> @@ -17,8 +15,8 @@ static void test_rsa_decrypt(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, CK_MECHANISM_TYPE mech_type, RSA* rsa) { - CK_BYTE encrypted[p11t_test_data_size]; - CK_BYTE decrypted[p11t_test_data_size]; + CK_BYTE encrypted[P11T_BLOCK]; + CK_BYTE decrypted[P11T_BLOCK]; CK_MECHANISM mech; const CK_BYTE* data; CK_ULONG n_data, n_decrypted; @@ -34,7 +32,7 @@ test_rsa_decrypt(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, assert(size); assert(size < sizeof(encrypted)); assert(size < sizeof(decrypted)); - assert(size < n_data); + assert(size < (int)n_data); switch(mech_type) { @@ -113,7 +111,7 @@ hash_for_rsa_pkcs_sign(int algo, int wrap, const CK_BYTE* data, if(!wrap) { assert(*n_output >= n_hash); - *n_output = n_hash; + *n_output = (CK_ULONG)n_hash; memcpy(output, hash, n_hash); return; } @@ -127,10 +125,10 @@ hash_for_rsa_pkcs_sign(int algo, int wrap, const CK_BYTE* data, sig.algor->parameter = ¶meter; sig.digest = &digest; sig.digest->data = hash; - sig.digest->length = n_hash; + sig.digest->length = (int)n_hash; val = i2d_X509_SIG(&sig, &output); - assert(*n_output >= val); + assert(*n_output >= (CK_ULONG)val); *n_output = val; } @@ -138,8 +136,8 @@ static void test_rsa_pkcs_sign_hash(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, RSA* rsa, int algo) { - CK_BYTE hash[p11t_test_data_size]; - CK_BYTE sig[p11t_test_data_size]; + CK_BYTE hash[P11T_BLOCK]; + CK_BYTE sig[P11T_BLOCK]; CK_MECHANISM mech; CK_ULONG n_hash, n_sig; CK_RV rv; @@ -174,8 +172,8 @@ static void test_rsa_x509_sign(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, RSA* rsa) { const CK_BYTE* data; - CK_BYTE sig[p11t_test_data_size]; - CK_BYTE check[p11t_test_data_size]; + CK_BYTE sig[P11T_BLOCK]; + CK_BYTE check[P11T_BLOCK]; CK_MECHANISM mech; CK_ULONG n_data, n_sig; CK_RV rv; @@ -202,7 +200,7 @@ test_rsa_x509_sign(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, RSA* rsa) if(res < 0) p11t_check_fail("C_Sign: rsa x509 signature was invalid"); - assert(res > n_data); + assert(res > (int)n_data); if(memcmp(check + (res - n_data), data, n_data) != 0) p11t_check_fail("C_Sign: rsa x509 signature did not verify"); } @@ -267,8 +265,8 @@ static void test_rsa_encrypt(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, CK_MECHANISM_TYPE mech_type, RSA* rsa) { - CK_BYTE encrypted[p11t_test_data_size]; - CK_BYTE check[p11t_test_data_size]; + CK_BYTE encrypted[P11T_BLOCK]; + CK_BYTE check[P11T_BLOCK]; CK_OBJECT_HANDLE privkey; CK_MECHANISM mech; const CK_BYTE* data; @@ -285,7 +283,7 @@ test_rsa_encrypt(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key, assert(size); assert(size < sizeof(encrypted)); assert(size < sizeof(check)); - assert(size < n_data); + assert(size < (int)n_data); switch(mech_type) { |