utc-yaca-seal.c
utc-yaca-sign.c
utc-yaca-simple.c
+ utc-yaca-rsa.c
)
PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
extern void utc_yaca_sign_cleanup(void);
extern void utc_yaca_simple_startup(void);
extern void utc_yaca_simple_cleanup(void);
+extern void utc_yaca_rsa_startup(void);
+extern void utc_yaca_rsa_cleanup(void);
extern int utc_yaca_initialize_p(void);
extern int utc_yaca_cleanup_p(void);
extern int utc_yaca_decrypt_update_p(void);
extern int utc_yaca_decrypt_update_n(void);
extern int utc_yaca_decrypt_finalize_p(void);
+extern int utc_yaca_decrypt_finalize_p2(void);
+extern int utc_yaca_decrypt_finalize_p3(void);
+extern int utc_yaca_decrypt_finalize_p4(void);
extern int utc_yaca_decrypt_finalize_n(void);
extern int utc_yaca_key_get_type_p(void);
extern int utc_yaca_key_get_type_n(void);
extern int utc_yaca_key_get_bit_length_p(void);
extern int utc_yaca_key_get_bit_length_n(void);
extern int utc_yaca_key_import_p(void);
+extern int utc_yaca_key_import_p2(void);
+extern int utc_yaca_key_import_p3(void);
+extern int utc_yaca_key_import_p4(void);
+extern int utc_yaca_key_import_p5(void);
+extern int utc_yaca_key_import_p6(void);
+extern int utc_yaca_key_import_p7(void);
+extern int utc_yaca_key_import_p8(void);
+extern int utc_yaca_key_import_p9(void);
extern int utc_yaca_key_import_n(void);
extern int utc_yaca_key_export_p(void);
extern int utc_yaca_key_export_n(void);
extern int utc_yaca_key_generate_p(void);
extern int utc_yaca_key_generate_n(void);
+extern int utc_yaca_key_generate_from_parameters_p(void);
+extern int utc_yaca_key_generate_from_parameters_n(void);
extern int utc_yaca_key_extract_public_p(void);
extern int utc_yaca_key_extract_public_n(void);
+extern int utc_yaca_key_extract_parameters_p(void);
+extern int utc_yaca_key_extract_parameters_n(void);
extern int utc_yaca_key_destroy_p(void);
extern int utc_yaca_key_derive_pbkdf2_p(void);
extern int utc_yaca_key_derive_pbkdf2_n(void);
+extern int utc_yaca_key_derive_dh_p(void);
+extern int utc_yaca_key_derive_dh_n(void);
+extern int utc_yaca_key_derive_kdf_p(void);
+extern int utc_yaca_key_derive_kdf_n(void);
extern int utc_yaca_seal_initialize_p(void);
extern int utc_yaca_seal_initialize_n(void);
extern int utc_yaca_seal_update_p(void);
extern int utc_yaca_simple_calculate_hmac_n(void);
extern int utc_yaca_simple_calculate_cmac_p(void);
extern int utc_yaca_simple_calculate_cmac_n(void);
+extern int utc_yaca_rsa_public_encrypt_p(void);
+extern int utc_yaca_rsa_public_encrypt_n(void);
+extern int utc_yaca_rsa_private_decrypt_p(void);
+extern int utc_yaca_rsa_private_decrypt_n(void);
+extern int utc_yaca_rsa_private_encrypt_p(void);
+extern int utc_yaca_rsa_private_encrypt_n(void);
+extern int utc_yaca_rsa_public_decrypt_p(void);
+extern int utc_yaca_rsa_public_decrypt_n(void);
+
testcase tc_array[] = {
{"utc_yaca_initialize_p", utc_yaca_initialize_p, utc_yaca_crypto_startup, utc_yaca_crypto_cleanup},
{"utc_yaca_decrypt_update_p", utc_yaca_decrypt_update_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_update_n", utc_yaca_decrypt_update_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_p", utc_yaca_decrypt_finalize_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p2", utc_yaca_decrypt_finalize_p2, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p3", utc_yaca_decrypt_finalize_p3, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p4", utc_yaca_decrypt_finalize_p4, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_n", utc_yaca_decrypt_finalize_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_key_get_type_p", utc_yaca_key_get_type_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_type_n", utc_yaca_key_get_type_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_p", utc_yaca_key_get_bit_length_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_n", utc_yaca_key_get_bit_length_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_p", utc_yaca_key_import_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p2", utc_yaca_key_import_p2, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p3", utc_yaca_key_import_p3, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p4", utc_yaca_key_import_p4, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p5", utc_yaca_key_import_p5, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p6", utc_yaca_key_import_p6, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p7", utc_yaca_key_import_p7, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p8", utc_yaca_key_import_p8, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p9", utc_yaca_key_import_p9, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_n", utc_yaca_key_import_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_p", utc_yaca_key_export_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_n", utc_yaca_key_export_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_p", utc_yaca_key_generate_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_n", utc_yaca_key_generate_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_p", utc_yaca_key_generate_from_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_n", utc_yaca_key_generate_from_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_p", utc_yaca_key_extract_public_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_n", utc_yaca_key_extract_public_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_p", utc_yaca_key_extract_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_n", utc_yaca_key_extract_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_destroy_p", utc_yaca_key_destroy_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_p", utc_yaca_key_derive_pbkdf2_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_n", utc_yaca_key_derive_pbkdf2_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_p", utc_yaca_key_derive_dh_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_n", utc_yaca_key_derive_dh_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_p", utc_yaca_key_derive_kdf_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_n", utc_yaca_key_derive_kdf_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_seal_initialize_p", utc_yaca_seal_initialize_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_initialize_n", utc_yaca_seal_initialize_n, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_update_p", utc_yaca_seal_update_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_simple_calculate_hmac_n", utc_yaca_simple_calculate_hmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_p", utc_yaca_simple_calculate_cmac_p, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_n", utc_yaca_simple_calculate_cmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
+ {"utc_yaca_rsa_public_encrypt_p", utc_yaca_rsa_public_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_encrypt_n", utc_yaca_rsa_public_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_p", utc_yaca_rsa_private_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_n", utc_yaca_rsa_private_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_p", utc_yaca_rsa_private_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_n", utc_yaca_rsa_private_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_p", utc_yaca_rsa_public_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_n", utc_yaca_rsa_public_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
{NULL, NULL}
};
+
#endif // __TCT_YACA_NATIVE_H__
extern void utc_yaca_sign_cleanup(void);
extern void utc_yaca_simple_startup(void);
extern void utc_yaca_simple_cleanup(void);
+extern void utc_yaca_rsa_startup(void);
+extern void utc_yaca_rsa_cleanup(void);
extern int utc_yaca_initialize_p(void);
extern int utc_yaca_cleanup_p(void);
extern int utc_yaca_decrypt_update_p(void);
extern int utc_yaca_decrypt_update_n(void);
extern int utc_yaca_decrypt_finalize_p(void);
+extern int utc_yaca_decrypt_finalize_p2(void);
+extern int utc_yaca_decrypt_finalize_p3(void);
+extern int utc_yaca_decrypt_finalize_p4(void);
extern int utc_yaca_decrypt_finalize_n(void);
extern int utc_yaca_key_get_type_p(void);
extern int utc_yaca_key_get_type_n(void);
extern int utc_yaca_key_get_bit_length_p(void);
extern int utc_yaca_key_get_bit_length_n(void);
extern int utc_yaca_key_import_p(void);
+extern int utc_yaca_key_import_p2(void);
+extern int utc_yaca_key_import_p3(void);
+extern int utc_yaca_key_import_p4(void);
+extern int utc_yaca_key_import_p5(void);
+extern int utc_yaca_key_import_p6(void);
+extern int utc_yaca_key_import_p7(void);
+extern int utc_yaca_key_import_p8(void);
+extern int utc_yaca_key_import_p9(void);
extern int utc_yaca_key_import_n(void);
extern int utc_yaca_key_export_p(void);
extern int utc_yaca_key_export_n(void);
extern int utc_yaca_key_generate_p(void);
extern int utc_yaca_key_generate_n(void);
+extern int utc_yaca_key_generate_from_parameters_p(void);
+extern int utc_yaca_key_generate_from_parameters_n(void);
extern int utc_yaca_key_extract_public_p(void);
extern int utc_yaca_key_extract_public_n(void);
+extern int utc_yaca_key_extract_parameters_p(void);
+extern int utc_yaca_key_extract_parameters_n(void);
extern int utc_yaca_key_destroy_p(void);
extern int utc_yaca_key_derive_pbkdf2_p(void);
extern int utc_yaca_key_derive_pbkdf2_n(void);
+extern int utc_yaca_key_derive_dh_p(void);
+extern int utc_yaca_key_derive_dh_n(void);
+extern int utc_yaca_key_derive_kdf_p(void);
+extern int utc_yaca_key_derive_kdf_n(void);
extern int utc_yaca_seal_initialize_p(void);
extern int utc_yaca_seal_initialize_n(void);
extern int utc_yaca_seal_update_p(void);
extern int utc_yaca_simple_calculate_hmac_n(void);
extern int utc_yaca_simple_calculate_cmac_p(void);
extern int utc_yaca_simple_calculate_cmac_n(void);
+extern int utc_yaca_rsa_public_encrypt_p(void);
+extern int utc_yaca_rsa_public_encrypt_n(void);
+extern int utc_yaca_rsa_private_decrypt_p(void);
+extern int utc_yaca_rsa_private_decrypt_n(void);
+extern int utc_yaca_rsa_private_encrypt_p(void);
+extern int utc_yaca_rsa_private_encrypt_n(void);
+extern int utc_yaca_rsa_public_decrypt_p(void);
+extern int utc_yaca_rsa_public_decrypt_n(void);
+
testcase tc_array[] = {
{"utc_yaca_initialize_p", utc_yaca_initialize_p, utc_yaca_crypto_startup, utc_yaca_crypto_cleanup},
{"utc_yaca_decrypt_update_p", utc_yaca_decrypt_update_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_update_n", utc_yaca_decrypt_update_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_p", utc_yaca_decrypt_finalize_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p2", utc_yaca_decrypt_finalize_p2, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p3", utc_yaca_decrypt_finalize_p3, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p4", utc_yaca_decrypt_finalize_p4, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_n", utc_yaca_decrypt_finalize_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_key_get_type_p", utc_yaca_key_get_type_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_type_n", utc_yaca_key_get_type_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_p", utc_yaca_key_get_bit_length_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_n", utc_yaca_key_get_bit_length_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_p", utc_yaca_key_import_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p2", utc_yaca_key_import_p2, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p3", utc_yaca_key_import_p3, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p4", utc_yaca_key_import_p4, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p5", utc_yaca_key_import_p5, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p6", utc_yaca_key_import_p6, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p7", utc_yaca_key_import_p7, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p8", utc_yaca_key_import_p8, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p9", utc_yaca_key_import_p9, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_n", utc_yaca_key_import_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_p", utc_yaca_key_export_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_n", utc_yaca_key_export_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_p", utc_yaca_key_generate_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_n", utc_yaca_key_generate_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_p", utc_yaca_key_generate_from_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_n", utc_yaca_key_generate_from_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_p", utc_yaca_key_extract_public_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_n", utc_yaca_key_extract_public_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_p", utc_yaca_key_extract_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_n", utc_yaca_key_extract_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_destroy_p", utc_yaca_key_destroy_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_p", utc_yaca_key_derive_pbkdf2_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_n", utc_yaca_key_derive_pbkdf2_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_p", utc_yaca_key_derive_dh_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_n", utc_yaca_key_derive_dh_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_p", utc_yaca_key_derive_kdf_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_n", utc_yaca_key_derive_kdf_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_seal_initialize_p", utc_yaca_seal_initialize_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_initialize_n", utc_yaca_seal_initialize_n, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_update_p", utc_yaca_seal_update_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_simple_calculate_hmac_n", utc_yaca_simple_calculate_hmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_p", utc_yaca_simple_calculate_cmac_p, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_n", utc_yaca_simple_calculate_cmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
+ {"utc_yaca_rsa_public_encrypt_p", utc_yaca_rsa_public_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_encrypt_n", utc_yaca_rsa_public_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_p", utc_yaca_rsa_private_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_n", utc_yaca_rsa_private_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_p", utc_yaca_rsa_private_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_n", utc_yaca_rsa_private_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_p", utc_yaca_rsa_public_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_n", utc_yaca_rsa_public_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
{NULL, NULL}
};
+
#endif // __TCT_YACA_NATIVE_H__
extern void utc_yaca_sign_cleanup(void);
extern void utc_yaca_simple_startup(void);
extern void utc_yaca_simple_cleanup(void);
+extern void utc_yaca_rsa_startup(void);
+extern void utc_yaca_rsa_cleanup(void);
extern int utc_yaca_initialize_p(void);
extern int utc_yaca_cleanup_p(void);
extern int utc_yaca_decrypt_update_p(void);
extern int utc_yaca_decrypt_update_n(void);
extern int utc_yaca_decrypt_finalize_p(void);
+extern int utc_yaca_decrypt_finalize_p2(void);
+extern int utc_yaca_decrypt_finalize_p3(void);
+extern int utc_yaca_decrypt_finalize_p4(void);
extern int utc_yaca_decrypt_finalize_n(void);
extern int utc_yaca_key_get_type_p(void);
extern int utc_yaca_key_get_type_n(void);
extern int utc_yaca_key_get_bit_length_p(void);
extern int utc_yaca_key_get_bit_length_n(void);
extern int utc_yaca_key_import_p(void);
+extern int utc_yaca_key_import_p2(void);
+extern int utc_yaca_key_import_p3(void);
+extern int utc_yaca_key_import_p4(void);
+extern int utc_yaca_key_import_p5(void);
+extern int utc_yaca_key_import_p6(void);
+extern int utc_yaca_key_import_p7(void);
+extern int utc_yaca_key_import_p8(void);
+extern int utc_yaca_key_import_p9(void);
extern int utc_yaca_key_import_n(void);
extern int utc_yaca_key_export_p(void);
extern int utc_yaca_key_export_n(void);
extern int utc_yaca_key_generate_p(void);
extern int utc_yaca_key_generate_n(void);
+extern int utc_yaca_key_generate_from_parameters_p(void);
+extern int utc_yaca_key_generate_from_parameters_n(void);
extern int utc_yaca_key_extract_public_p(void);
extern int utc_yaca_key_extract_public_n(void);
+extern int utc_yaca_key_extract_parameters_p(void);
+extern int utc_yaca_key_extract_parameters_n(void);
extern int utc_yaca_key_destroy_p(void);
extern int utc_yaca_key_derive_pbkdf2_p(void);
extern int utc_yaca_key_derive_pbkdf2_n(void);
+extern int utc_yaca_key_derive_dh_p(void);
+extern int utc_yaca_key_derive_dh_n(void);
+extern int utc_yaca_key_derive_kdf_p(void);
+extern int utc_yaca_key_derive_kdf_n(void);
extern int utc_yaca_seal_initialize_p(void);
extern int utc_yaca_seal_initialize_n(void);
extern int utc_yaca_seal_update_p(void);
extern int utc_yaca_simple_calculate_hmac_n(void);
extern int utc_yaca_simple_calculate_cmac_p(void);
extern int utc_yaca_simple_calculate_cmac_n(void);
+extern int utc_yaca_rsa_public_encrypt_p(void);
+extern int utc_yaca_rsa_public_encrypt_n(void);
+extern int utc_yaca_rsa_private_decrypt_p(void);
+extern int utc_yaca_rsa_private_decrypt_n(void);
+extern int utc_yaca_rsa_private_encrypt_p(void);
+extern int utc_yaca_rsa_private_encrypt_n(void);
+extern int utc_yaca_rsa_public_decrypt_p(void);
+extern int utc_yaca_rsa_public_decrypt_n(void);
+
testcase tc_array[] = {
{"utc_yaca_initialize_p", utc_yaca_initialize_p, utc_yaca_crypto_startup, utc_yaca_crypto_cleanup},
{"utc_yaca_decrypt_update_p", utc_yaca_decrypt_update_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_update_n", utc_yaca_decrypt_update_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_p", utc_yaca_decrypt_finalize_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p2", utc_yaca_decrypt_finalize_p2, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p3", utc_yaca_decrypt_finalize_p3, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p4", utc_yaca_decrypt_finalize_p4, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_n", utc_yaca_decrypt_finalize_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_key_get_type_p", utc_yaca_key_get_type_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_type_n", utc_yaca_key_get_type_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_p", utc_yaca_key_get_bit_length_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_n", utc_yaca_key_get_bit_length_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_p", utc_yaca_key_import_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p2", utc_yaca_key_import_p2, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p3", utc_yaca_key_import_p3, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p4", utc_yaca_key_import_p4, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p5", utc_yaca_key_import_p5, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p6", utc_yaca_key_import_p6, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p7", utc_yaca_key_import_p7, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p8", utc_yaca_key_import_p8, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p9", utc_yaca_key_import_p9, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_n", utc_yaca_key_import_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_p", utc_yaca_key_export_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_n", utc_yaca_key_export_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_p", utc_yaca_key_generate_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_n", utc_yaca_key_generate_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_p", utc_yaca_key_generate_from_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_n", utc_yaca_key_generate_from_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_p", utc_yaca_key_extract_public_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_n", utc_yaca_key_extract_public_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_p", utc_yaca_key_extract_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_n", utc_yaca_key_extract_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_destroy_p", utc_yaca_key_destroy_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_p", utc_yaca_key_derive_pbkdf2_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_n", utc_yaca_key_derive_pbkdf2_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_p", utc_yaca_key_derive_dh_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_n", utc_yaca_key_derive_dh_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_p", utc_yaca_key_derive_kdf_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_n", utc_yaca_key_derive_kdf_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_seal_initialize_p", utc_yaca_seal_initialize_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_initialize_n", utc_yaca_seal_initialize_n, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_update_p", utc_yaca_seal_update_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_simple_calculate_hmac_n", utc_yaca_simple_calculate_hmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_p", utc_yaca_simple_calculate_cmac_p, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_n", utc_yaca_simple_calculate_cmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
+ {"utc_yaca_rsa_public_encrypt_p", utc_yaca_rsa_public_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_encrypt_n", utc_yaca_rsa_public_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_p", utc_yaca_rsa_private_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_n", utc_yaca_rsa_private_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_p", utc_yaca_rsa_private_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_n", utc_yaca_rsa_private_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_p", utc_yaca_rsa_public_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_n", utc_yaca_rsa_public_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
{NULL, NULL}
};
+
#endif // __TCT_YACA_NATIVE_H__
extern void utc_yaca_sign_cleanup(void);
extern void utc_yaca_simple_startup(void);
extern void utc_yaca_simple_cleanup(void);
+extern void utc_yaca_rsa_startup(void);
+extern void utc_yaca_rsa_cleanup(void);
extern int utc_yaca_initialize_p(void);
extern int utc_yaca_cleanup_p(void);
extern int utc_yaca_decrypt_update_p(void);
extern int utc_yaca_decrypt_update_n(void);
extern int utc_yaca_decrypt_finalize_p(void);
+extern int utc_yaca_decrypt_finalize_p2(void);
+extern int utc_yaca_decrypt_finalize_p3(void);
+extern int utc_yaca_decrypt_finalize_p4(void);
extern int utc_yaca_decrypt_finalize_n(void);
extern int utc_yaca_key_get_type_p(void);
extern int utc_yaca_key_get_type_n(void);
extern int utc_yaca_key_get_bit_length_p(void);
extern int utc_yaca_key_get_bit_length_n(void);
extern int utc_yaca_key_import_p(void);
+extern int utc_yaca_key_import_p2(void);
+extern int utc_yaca_key_import_p3(void);
+extern int utc_yaca_key_import_p4(void);
+extern int utc_yaca_key_import_p5(void);
+extern int utc_yaca_key_import_p6(void);
+extern int utc_yaca_key_import_p7(void);
+extern int utc_yaca_key_import_p8(void);
+extern int utc_yaca_key_import_p9(void);
extern int utc_yaca_key_import_n(void);
extern int utc_yaca_key_export_p(void);
extern int utc_yaca_key_export_n(void);
extern int utc_yaca_key_generate_p(void);
extern int utc_yaca_key_generate_n(void);
+extern int utc_yaca_key_generate_from_parameters_p(void);
+extern int utc_yaca_key_generate_from_parameters_n(void);
extern int utc_yaca_key_extract_public_p(void);
extern int utc_yaca_key_extract_public_n(void);
+extern int utc_yaca_key_extract_parameters_p(void);
+extern int utc_yaca_key_extract_parameters_n(void);
extern int utc_yaca_key_destroy_p(void);
extern int utc_yaca_key_derive_pbkdf2_p(void);
extern int utc_yaca_key_derive_pbkdf2_n(void);
+extern int utc_yaca_key_derive_dh_p(void);
+extern int utc_yaca_key_derive_dh_n(void);
+extern int utc_yaca_key_derive_kdf_p(void);
+extern int utc_yaca_key_derive_kdf_n(void);
extern int utc_yaca_seal_initialize_p(void);
extern int utc_yaca_seal_initialize_n(void);
extern int utc_yaca_seal_update_p(void);
extern int utc_yaca_simple_calculate_hmac_n(void);
extern int utc_yaca_simple_calculate_cmac_p(void);
extern int utc_yaca_simple_calculate_cmac_n(void);
+extern int utc_yaca_rsa_public_encrypt_p(void);
+extern int utc_yaca_rsa_public_encrypt_n(void);
+extern int utc_yaca_rsa_private_decrypt_p(void);
+extern int utc_yaca_rsa_private_decrypt_n(void);
+extern int utc_yaca_rsa_private_encrypt_p(void);
+extern int utc_yaca_rsa_private_encrypt_n(void);
+extern int utc_yaca_rsa_public_decrypt_p(void);
+extern int utc_yaca_rsa_public_decrypt_n(void);
+
testcase tc_array[] = {
{"utc_yaca_initialize_p", utc_yaca_initialize_p, utc_yaca_crypto_startup, utc_yaca_crypto_cleanup},
{"utc_yaca_decrypt_update_p", utc_yaca_decrypt_update_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_update_n", utc_yaca_decrypt_update_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_p", utc_yaca_decrypt_finalize_p, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p2", utc_yaca_decrypt_finalize_p2, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p3", utc_yaca_decrypt_finalize_p3, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
+ {"utc_yaca_decrypt_finalize_p4", utc_yaca_decrypt_finalize_p4, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_decrypt_finalize_n", utc_yaca_decrypt_finalize_n, utc_yaca_encrypt_startup, utc_yaca_encrypt_cleanup},
{"utc_yaca_key_get_type_p", utc_yaca_key_get_type_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_type_n", utc_yaca_key_get_type_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_p", utc_yaca_key_get_bit_length_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_get_bit_length_n", utc_yaca_key_get_bit_length_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_p", utc_yaca_key_import_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p2", utc_yaca_key_import_p2, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p3", utc_yaca_key_import_p3, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p4", utc_yaca_key_import_p4, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p5", utc_yaca_key_import_p5, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p6", utc_yaca_key_import_p6, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p7", utc_yaca_key_import_p7, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p8", utc_yaca_key_import_p8, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_import_p9", utc_yaca_key_import_p9, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_import_n", utc_yaca_key_import_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_p", utc_yaca_key_export_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_export_n", utc_yaca_key_export_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_p", utc_yaca_key_generate_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_generate_n", utc_yaca_key_generate_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_p", utc_yaca_key_generate_from_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_generate_from_parameters_n", utc_yaca_key_generate_from_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_p", utc_yaca_key_extract_public_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_extract_public_n", utc_yaca_key_extract_public_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_p", utc_yaca_key_extract_parameters_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_extract_parameters_n", utc_yaca_key_extract_parameters_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_destroy_p", utc_yaca_key_destroy_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_p", utc_yaca_key_derive_pbkdf2_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_key_derive_pbkdf2_n", utc_yaca_key_derive_pbkdf2_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_p", utc_yaca_key_derive_dh_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_dh_n", utc_yaca_key_derive_dh_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_p", utc_yaca_key_derive_kdf_p, utc_yaca_key_startup, utc_yaca_key_cleanup},
+ {"utc_yaca_key_derive_kdf_n", utc_yaca_key_derive_kdf_n, utc_yaca_key_startup, utc_yaca_key_cleanup},
{"utc_yaca_seal_initialize_p", utc_yaca_seal_initialize_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_initialize_n", utc_yaca_seal_initialize_n, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_seal_update_p", utc_yaca_seal_update_p, utc_yaca_seal_startup, utc_yaca_seal_cleanup},
{"utc_yaca_simple_calculate_hmac_n", utc_yaca_simple_calculate_hmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_p", utc_yaca_simple_calculate_cmac_p, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
{"utc_yaca_simple_calculate_cmac_n", utc_yaca_simple_calculate_cmac_n, utc_yaca_simple_startup, utc_yaca_simple_cleanup},
+ {"utc_yaca_rsa_public_encrypt_p", utc_yaca_rsa_public_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_encrypt_n", utc_yaca_rsa_public_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_p", utc_yaca_rsa_private_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_decrypt_n", utc_yaca_rsa_private_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_p", utc_yaca_rsa_private_encrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_private_encrypt_n", utc_yaca_rsa_private_encrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_p", utc_yaca_rsa_public_decrypt_p, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
+ {"utc_yaca_rsa_public_decrypt_n", utc_yaca_rsa_public_decrypt_n, utc_yaca_rsa_startup, utc_yaca_rsa_cleanup},
{NULL, NULL}
};
+
#endif // __TCT_YACA_NATIVE_H__
return 0;
}
-/*
- * @testcase utc_yaca_decrypt_finalize_p
- * @since_tizen 3.0
- * @description Encrypts the final chunk of the data.
- * @scenario Encrypts the final chunk of the data with valid parameters.
- */
-int utc_yaca_decrypt_finalize_p(void)
+void encrypt_advanced(const yaca_encrypt_algorithm_e algo,
+ const yaca_block_cipher_mode_e bcm,
+ const yaca_key_type_e key_type,
+ const size_t key_bit_len)
{
- yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
- yaca_block_cipher_mode_e bcm = YACA_BCM_ECB;
- yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
- size_t key_bit_len = YACA_KEY_LENGTH_256BIT;
-
yaca_context_h ctx = YACA_CONTEXT_NULL;
yaca_key_h key = YACA_KEY_NULL;
yaca_key_h iv = YACA_KEY_NULL;
size_t iv_bit_len;
char *enc = NULL;
- size_t enc_len;
char *dec = NULL;
+ size_t enc_len;
size_t dec_len;
size_t block_len;
size_t output_len;
size_t written_len;
- size_t rem;
- int ret = YACA_ERROR_NONE;
+ /* Key generation */
+ assert_eq(yaca_key_generate(key_type, key_bit_len, &key), YACA_ERROR_NONE);
- ret = yaca_key_generate(key_type, key_bit_len, &key);
- assert_eq(ret, YACA_ERROR_NONE);
+ assert_eq(yaca_encrypt_get_iv_bit_length(algo, bcm, key_bit_len, &iv_bit_len), YACA_ERROR_NONE);
- ret = yaca_encrypt_get_iv_bit_length(algo, bcm, key_bit_len, &iv_bit_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ assert_eq(iv_bit_len > 0 && yaca_key_generate(YACA_KEY_TYPE_IV, iv_bit_len, &iv), YACA_ERROR_NONE);
- if (iv_bit_len > 0) {
- ret = yaca_key_generate(YACA_KEY_TYPE_IV, iv_bit_len, &iv);
- assert_eq(ret, YACA_ERROR_NONE);
- }
+ /* Encryption */
+ {
+ assert_eq(yaca_encrypt_initialize(&ctx, algo, bcm, key, iv), YACA_ERROR_NONE);
- // encrypt
- ret = yaca_encrypt_initialize(&ctx, algo, bcm, key, iv);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* For the update */
+ assert_eq(yaca_context_get_output_length(ctx, LOREM4096_SIZE, &output_len), YACA_ERROR_NONE);
- // For the update
- ret = yaca_context_get_output_length(ctx, LOREM4096_SIZE, &output_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* For the finalize */
+ assert_eq(yaca_context_get_output_length(ctx, 0, &block_len), YACA_ERROR_NONE);
- // For the finalize
- ret = yaca_context_get_output_length(ctx, 0, &block_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* Calculate max output: size of update + final chunks */
+ enc_len = output_len + block_len;
+ assert_eq(yaca_malloc(enc_len, (void**)&enc), YACA_ERROR_NONE);
- enc_len = output_len + block_len;
- ret = yaca_malloc(enc_len, (void**)&enc);
- assert_eq(ret, YACA_ERROR_NONE);
+ assert_eq(yaca_encrypt_update(ctx, lorem4096, LOREM4096_SIZE, enc, &written_len), YACA_ERROR_NONE);
- written_len = enc_len;
- ret = yaca_encrypt_update(ctx, lorem4096, LOREM4096_SIZE, enc, &written_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ enc_len = written_len;
- rem = enc_len - written_len;
- ret = yaca_encrypt_finalize(ctx, enc + written_len, &rem);
- assert_eq(ret, YACA_ERROR_NONE);
+ assert_eq(yaca_encrypt_finalize(ctx, enc + written_len, &written_len), YACA_ERROR_NONE);
- enc_len = rem + written_len;
+ enc_len += written_len;
- yaca_context_destroy(ctx);
- ctx = YACA_CONTEXT_NULL;
+ yaca_context_destroy(ctx);
+ ctx = YACA_CONTEXT_NULL;
+ }
- // decrypt
- ret = yaca_decrypt_initialize(&ctx, algo, bcm, key, iv);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* Decryption */
+ {
+ assert_eq(yaca_decrypt_initialize(&ctx, algo, bcm, key, iv), YACA_ERROR_NONE);
- // For the update
- ret = yaca_context_get_output_length(ctx, LOREM4096_SIZE, &output_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* For the update */
+ assert_eq(yaca_context_get_output_length(ctx, enc_len, &output_len), YACA_ERROR_NONE);
- // For the finalize
- ret = yaca_context_get_output_length(ctx, 0, &block_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* For the finalize */
+ assert_eq(yaca_context_get_output_length(ctx, 0, &block_len), YACA_ERROR_NONE);
- dec_len = output_len + block_len;
- ret = yaca_malloc(dec_len, (void**)&dec);
- assert_eq(ret, YACA_ERROR_NONE);
+ /* Calculate max output: size of update + final chunks */
+ dec_len = output_len + block_len;
+ assert_eq(yaca_malloc(dec_len, (void**)&dec), YACA_ERROR_NONE);
- written_len = dec_len;
- ret = yaca_decrypt_update(ctx, enc, enc_len, dec, &written_len);
- assert_eq(ret, YACA_ERROR_NONE);
+ assert_eq(yaca_decrypt_update(ctx, enc, enc_len, dec, &written_len), YACA_ERROR_NONE);
- rem = dec_len - written_len;
- ret = yaca_decrypt_finalize(ctx, dec + written_len, &rem);
- assert_eq(ret, YACA_ERROR_NONE);
+ dec_len = written_len;
- // compare
- dec_len = rem + written_len;
- assert_eq(LOREM4096_SIZE, dec_len);
- int idx;
- for (idx = 0; idx < LOREM4096_SIZE; idx++) {
- assert_eq(lorem4096[idx], dec[idx]);
+ assert_eq(yaca_decrypt_finalize(ctx, dec + written_len, &written_len), YACA_ERROR_NONE);
+
+ dec_len += written_len;
}
- yaca_context_destroy(ctx);
- yaca_free(enc);
yaca_free(dec);
+ yaca_free(enc);
+ yaca_context_destroy(ctx);
yaca_key_destroy(iv);
yaca_key_destroy(key);
+}
+
+
+/*
+ * @testcase utc_yaca_decrypt_finalize_p
+ * @since_tizen 3.0
+ * @description Encrypts the final chunk of the data.
+ * @scenario Encrypts the final chunk of the data with valid parameters.
+ */
+int utc_yaca_decrypt_finalize_p(void)
+{
+ yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
+ yaca_block_cipher_mode_e bcm = YACA_BCM_ECB;
+ yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
+ size_t key_bit_len = YACA_KEY_LENGTH_256BIT;
+
+ encrypt_advanced(algo, bcm, key_type, key_bit_len);
+
+ algo = YACA_ENCRYPT_3DES_3TDEA;
+ bcm = YACA_BCM_OFB;
+ key_type = YACA_KEY_TYPE_DES;
+ key_bit_len = YACA_KEY_LENGTH_192BIT;
+
+ encrypt_advanced(algo, bcm, key_type, key_bit_len);
+
+ algo = YACA_ENCRYPT_CAST5;
+ bcm = YACA_BCM_CFB;
+ key_type = YACA_KEY_TYPE_SYMMETRIC;
+ key_bit_len = YACA_KEY_LENGTH_UNSAFE_40BIT;
+
+ encrypt_advanced(algo, bcm, key_type, key_bit_len);
+
+ algo = YACA_ENCRYPT_UNSAFE_RC2;
+ bcm = YACA_BCM_CBC;
+ key_type = YACA_KEY_TYPE_SYMMETRIC;
+ key_bit_len = YACA_KEY_LENGTH_UNSAFE_8BIT;
+
+ encrypt_advanced(algo, bcm, key_type, key_bit_len);
+
+ algo = YACA_ENCRYPT_UNSAFE_RC4;
+ bcm = YACA_BCM_NONE;
+ key_type = YACA_KEY_TYPE_SYMMETRIC;
+ key_bit_len = YACA_KEY_LENGTH_2048BIT;
+
+ encrypt_advanced(algo, bcm, key_type, key_bit_len);
return 0;
}
/*
- * @testcase utc_yaca_decrypt_finalize_p
+ * @testcase utc_yaca_decrypt_finalize_p2
* @since_tizen 3.0
* @description Encrypts the final chunk of the data.
* @scenario Encrypts the final chunk of the data with AES GCM.
return 0;
}
+/*
+ * @testcase utc_yaca_decrypt_finalize_p3
+ * @since_tizen 3.0
+ * @description Encrypts the final chunk of the data with AES CCM.
+ * @scenario Encrypts the final chunk of the data with AES CCM.
+ */
+int utc_yaca_decrypt_finalize_p3(void)
+{
+ yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
+ yaca_block_cipher_mode_e bcm = YACA_BCM_CCM;
+ yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
+ size_t key_bit_len = YACA_KEY_LENGTH_256BIT;
+ size_t iv_bit_len = YACA_KEY_LENGTH_IV_64BIT;
+
+ yaca_context_h ctx = YACA_CONTEXT_NULL;
+ yaca_key_h key = YACA_KEY_NULL;
+ yaca_key_h iv = YACA_KEY_NULL;
+
+ char *enc = NULL;
+ char *dec = NULL;
+ size_t enc_len;
+ size_t dec_len;
+
+ char *aad = NULL;
+ char *tag = NULL;
+ size_t aad_len = 16;
+ size_t tag_len = 14;
+
+ size_t block_len;
+ size_t output_len;
+ size_t written_len;
+ size_t len;
+
+ /* Key generation */
+ assert_eq(yaca_key_generate(key_type, key_bit_len, &key), YACA_ERROR_NONE);
+
+ /* IV generation */
+ assert_eq(yaca_key_generate(YACA_KEY_TYPE_IV, iv_bit_len, &iv), YACA_ERROR_NONE);
+
+ assert_eq(yaca_zalloc(aad_len, (void**)&aad), YACA_ERROR_NONE);
+
+ assert_eq(yaca_randomize_bytes(aad, aad_len), YACA_ERROR_NONE);
+
+ assert_eq(yaca_zalloc(tag_len, (void**)&tag), YACA_ERROR_NONE);
+
+ /* Encryption */
+ {
+ assert_eq(yaca_encrypt_initialize(&ctx, algo, bcm, key, iv), YACA_ERROR_NONE);
+
+ /* Set tag length (optionally) */
+ assert_eq(yaca_context_set_property(ctx, YACA_PROPERTY_CCM_TAG_LEN,
+ (void*)&tag_len, sizeof(tag_len)), YACA_ERROR_NONE);
+
+ /* The total plain text length must be passed (only needed if AAD is passed) */
+ assert_eq(yaca_encrypt_update(ctx, NULL, LOREM4096_SIZE , NULL, &len), YACA_ERROR_NONE);
+
+ assert_eq(yaca_context_set_property(ctx, YACA_PROPERTY_CCM_AAD, aad, aad_len), YACA_ERROR_NONE);
+
+ /* For the update */
+ assert_eq(yaca_context_get_output_length(ctx, LOREM4096_SIZE, &output_len), YACA_ERROR_NONE);
+
+ /* For the finalize */
+ assert_eq(yaca_context_get_output_length(ctx, 0, &block_len), YACA_ERROR_NONE);
+
+ /* Calculate max output: size of update + final chunks */
+ enc_len = output_len + block_len;
+ assert_eq(yaca_malloc(enc_len, (void**)&enc), YACA_ERROR_NONE);
+
+ assert_eq(yaca_encrypt_update(ctx, lorem4096, LOREM4096_SIZE, enc, &written_len), YACA_ERROR_NONE);
+
+ enc_len = written_len;
+
+ assert_eq(yaca_encrypt_finalize(ctx, enc + written_len, &written_len), YACA_ERROR_NONE);
+
+ enc_len += written_len;
+
+ /* Get the tag after final encryption */
+ assert_eq(yaca_context_get_property(ctx, YACA_PROPERTY_CCM_TAG, (void**)tag, &tag_len), YACA_ERROR_NONE);
+
+ yaca_context_destroy(ctx);
+ ctx = YACA_CONTEXT_NULL;
+ }
+
+ /* Decryption */
+ {
+ assert_eq(yaca_decrypt_initialize(&ctx, algo, bcm, key, iv), YACA_ERROR_NONE);
+
+ /* Set expected tag value */
+ assert_eq(yaca_context_set_property(ctx, YACA_PROPERTY_CCM_TAG, tag, tag_len), YACA_ERROR_NONE);
+
+ /* The total encrypted text length must be passed (only needed if AAD is passed) */
+ assert_eq(yaca_decrypt_update(ctx, NULL, enc_len , NULL, &len), YACA_ERROR_NONE);
+
+ assert_eq(yaca_context_set_property(ctx, YACA_PROPERTY_CCM_AAD, aad, aad_len), YACA_ERROR_NONE);
+
+ /* For the update */
+ assert_eq(yaca_context_get_output_length(ctx, enc_len, &output_len), YACA_ERROR_NONE);
+
+ /* For the finalize */
+ assert_eq(yaca_context_get_output_length(ctx, 0, &block_len), YACA_ERROR_NONE);
+
+ /* Calculate max output: size of update + final chunks */
+ dec_len = output_len + block_len;
+ assert_eq(yaca_malloc(dec_len, (void**)&dec), YACA_ERROR_NONE);
+
+ /* The tag verify is performed when you call the final yaca_decrypt_update(),
+ * there is no call to yaca_decrypt_finalize() */
+ assert_eq(yaca_decrypt_update(ctx, enc, enc_len, dec, &written_len), YACA_ERROR_NONE);
+
+ dec_len = written_len;
+ }
+
+ yaca_free(enc);
+ yaca_free(dec);
+ yaca_free(tag);
+ yaca_free(aad);
+ yaca_context_destroy(ctx);
+ yaca_key_destroy(iv);
+ yaca_key_destroy(key);
+
+ return 0;
+}
+
+/*
+ * @testcase utc_yaca_decrypt_finalize_p4
+ * @since_tizen 3.0
+ * @description Wrap and Unwrap a key with a AES key.
+ * @scenario Wrap and Unwrap a key.
+ */
+int utc_yaca_decrypt_finalize_p4(void)
+{
+ int ret;
+ yaca_key_h sym_key = YACA_KEY_NULL;
+ yaca_key_h iv = YACA_KEY_NULL;
+ yaca_key_h aes_key = YACA_KEY_NULL;
+
+ size_t iv_bit_len;
+ char *key_data = NULL;
+ size_t key_data_len;
+ char *wrapped_key = NULL;
+ size_t wrapped_key_len;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &aes_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_192BIT, &sym_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_encrypt_get_iv_bit_length(YACA_ENCRYPT_AES,
+ YACA_BCM_WRAP,
+ YACA_KEY_LENGTH_192BIT,
+ &iv_bit_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ if (iv_bit_len > 0) {
+ ret = yaca_key_generate(YACA_KEY_TYPE_IV, iv_bit_len, &iv);
+ assert_eq(ret, YACA_ERROR_NONE);
+ }
+
+ /* Key wrapping */
+ {
+ ret = yaca_key_export(aes_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_RAW, NULL,
+ &key_data, &key_data_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_simple_encrypt(YACA_ENCRYPT_AES, YACA_BCM_WRAP, sym_key, iv,
+ key_data, key_data_len,
+ &wrapped_key, &wrapped_key_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ }
+
+ yaca_free(key_data);
+ key_data = NULL;
+ yaca_key_destroy(aes_key);
+ aes_key = YACA_KEY_NULL;
+
+ /* Key unwrapping */
+ {
+ ret = yaca_simple_decrypt(YACA_ENCRYPT_AES, YACA_BCM_WRAP, sym_key, iv,
+ wrapped_key, wrapped_key_len,
+ &key_data, &key_data_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_import(YACA_KEY_TYPE_SYMMETRIC, NULL, key_data, key_data_len, &aes_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+ }
+
+ yaca_key_destroy(aes_key);
+ yaca_key_destroy(sym_key);
+ yaca_key_destroy(iv);
+ yaca_free(key_data);
+ yaca_free(wrapped_key);
+
+ return 0;
+}
+
/**
* @testcase utc_yaca_decrypt_finalize_n
* @since_tizen 3.0
return 0;
}
-/**
- * @testcase utc_yaca_key_import_p3
- * @since_tizen 3.0
- * @description Imports a key.
- * @scenario Imports a key with RSA key type.
- */
-int utc_yaca_key_import_p3(void)
+void export_import_asymmetric_keys(yaca_key_type_e pri_key_type, yaca_key_type_e pub_key_type, size_t key_bit_len)
{
yaca_key_h pri_key = YACA_KEY_NULL;
yaca_key_h pub_key = YACA_KEY_NULL;
- yaca_key_type_e key_type = YACA_KEY_TYPE_RSA_PRIV;
- size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
char * password = "test_password";
int ret = YACA_ERROR_NONE;
char *pkcs8 = NULL;
size_t pkcs8_len;
- ret = yaca_key_generate(key_type, key_bit_len, &pri_key);
+ ret = yaca_key_generate(pri_key_type, key_bit_len, &pri_key);
assert_eq(ret, YACA_ERROR_NONE);
ret = yaca_key_extract_public(pri_key, &pub_key);
ret = yaca_key_export(pri_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_DER, NULL, &der, &der_len);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_import(YACA_KEY_TYPE_RSA_PRIV, NULL, der, der_len, &der_imported);
+ ret = yaca_key_import(pri_key_type, NULL, der, der_len, &der_imported);
assert_eq(ret, YACA_ERROR_NONE);
ret = yaca_key_export(pub_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_PEM, NULL, &pem, &pem_len);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_import(YACA_KEY_TYPE_RSA_PUB, NULL, pem, pem_len, &pem_imported);
+ ret = yaca_key_import(pub_key_type, NULL, pem, pem_len, &pem_imported);
assert_eq(ret, YACA_ERROR_NONE);
ret = yaca_key_export(pri_key, YACA_KEY_FORMAT_PKCS8, YACA_KEY_FILE_FORMAT_DER, password, &pkcs8, &pkcs8_len);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_import(YACA_KEY_TYPE_RSA_PRIV, password, pkcs8, pkcs8_len, &pkcs8_imported);
+ ret = yaca_key_import(pri_key_type, password, pkcs8, pkcs8_len, &pkcs8_imported);
assert_eq(ret, YACA_ERROR_NONE);
yaca_key_destroy(pri_key);
yaca_free(der);
yaca_free(pem);
yaca_free(pkcs8);
+}
+
+/**
+ * @testcase utc_yaca_key_import_p3
+ * @since_tizen 3.0
+ * @description Imports a key.
+ * @scenario Imports a key with RSA key type.
+ */
+int utc_yaca_key_import_p3(void)
+{
+ export_import_asymmetric_keys(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_TYPE_RSA_PUB, YACA_KEY_LENGTH_1024BIT);
return 0;
}
*/
int utc_yaca_key_import_p4(void)
{
- yaca_key_h pri_key = YACA_KEY_NULL;
- yaca_key_h pub_key = YACA_KEY_NULL;
- yaca_key_type_e key_type = YACA_KEY_TYPE_DSA_PRIV;
- size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ export_import_asymmetric_keys(YACA_KEY_TYPE_DSA_PRIV, YACA_KEY_TYPE_DSA_PUB, YACA_KEY_LENGTH_1024BIT);
+ return 0;
+}
+
+/*
+ * @testcase utc_yaca_key_import_p5
+ * @since_tizen 3.0
+ * @description Imports a key.
+ * @scenario Imports a key with ECDSA key type.
+ */
+int utc_yaca_key_import_p5(void)
+{
+ export_import_asymmetric_keys(YACA_KEY_TYPE_EC_PRIV, YACA_KEY_TYPE_EC_PUB, YACA_KEY_LENGTH_EC_SECP384R1);
+ return 0;
+}
+
+/*
+ * @testcase utc_yaca_key_import_p6
+ * @since_tizen 3.0
+ * @description Imports a key.
+ * @scenario Imports a key with Diffie-Helmann key type.
+ */
+int utc_yaca_key_import_p6(void)
+{
+ export_import_asymmetric_keys(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_TYPE_DH_PUB, YACA_KEY_LENGTH_DH_RFC_2048_224);
+ return 0;
+}
+
+void export_import_asymmetric_params(yaca_key_type_e param_key_type, size_t key_bit_len)
+{
+ yaca_key_h param_key = YACA_KEY_NULL;
int ret = YACA_ERROR_NONE;
yaca_key_h pem_imported = YACA_KEY_NULL;
char *pem = NULL;
size_t pem_len;
- ret = yaca_key_generate(key_type, key_bit_len, &pri_key);
- assert_eq(ret, YACA_ERROR_NONE);
-
- ret = yaca_key_extract_public(pri_key, &pub_key);
+ ret = yaca_key_generate(param_key_type, key_bit_len, ¶m_key);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_export(pri_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_PEM, NULL, &pem, &pem_len);
+ ret = yaca_key_export(param_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_DER, NULL, &der, &der_len);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_import(YACA_KEY_TYPE_DSA_PRIV, NULL, pem, pem_len, &pem_imported);
+ ret = yaca_key_import(param_key_type, NULL, der, der_len, &der_imported);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_export(pub_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_DER, NULL, &der, &der_len);
+ ret = yaca_key_export(param_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_PEM, NULL, &pem, &pem_len);
assert_eq(ret, YACA_ERROR_NONE);
- ret = yaca_key_import(YACA_KEY_TYPE_DSA_PUB, NULL, der, der_len, &der_imported);
+ ret = yaca_key_import(param_key_type, NULL, pem, pem_len, &pem_imported);
assert_eq(ret, YACA_ERROR_NONE);
- yaca_key_destroy(pri_key);
- yaca_key_destroy(pub_key);
+ yaca_key_destroy(param_key);
yaca_key_destroy(pem_imported);
yaca_key_destroy(der_imported);
yaca_free(der);
yaca_free(pem);
+}
+/*
+ * @testcase utc_yaca_key_import_p7
+ * @since_tizen 3.0
+ * @description Imports parameters.
+ * @scenario Imports parameters for DSA algorithm.
+ */
+int utc_yaca_key_import_p7(void)
+{
+ export_import_asymmetric_params(YACA_KEY_TYPE_DSA_PARAMS, YACA_KEY_LENGTH_512BIT);
return 0;
}
+/*
+ * @testcase utc_yaca_key_import_p8
+ * @since_tizen 3.0
+ * @description Imports parameters.
+ * @scenario Imports parameters for DSA algorithm.
+ */
+int utc_yaca_key_import_p8(void)
+{
+ export_import_asymmetric_params(YACA_KEY_TYPE_DH_PARAMS, YACA_KEY_LENGTH_DH_RFC_2048_256);
+ return 0;
+}
+
+/*
+ * @testcase utc_yaca_key_import_p9
+ * @since_tizen 3.0
+ * @description Imports parameters.
+ * @scenario Imports parameters for ECDSA algorithm.
+ */
+int utc_yaca_key_import_p9(void)
+{
+ export_import_asymmetric_params(YACA_KEY_TYPE_EC_PARAMS, YACA_KEY_LENGTH_EC_PRIME256V1);
+ return 0;
+}
+
+
+
+
/**
* @testcase utc_yaca_key_import_n
}
/**
+ * @testcase utc_yaca_key_generate_from_parameters_p
+ * @since_tizen 3.0
+ * @description Generates a secure key from parameters.
+ * @scenario Generates a secure key from parameters with valid parameters.
+ */
+int utc_yaca_key_generate_from_parameters_p(void)
+{
+ int ret = YACA_ERROR_NONE;
+ yaca_key_h key = YACA_KEY_NULL;
+ yaca_key_h key_params = YACA_KEY_NULL;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_DSA_PARAMS, YACA_KEY_LENGTH_512BIT, &key_params);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate_from_parameters(key_params, &key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ yaca_key_destroy(key);
+ yaca_key_destroy(key_params);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_key_generate_from_parameters_n
+ * @since_tizen 3.0
+ * @description Generates a secure key from parameters.
+ * @scenario Generates a secure key from parameters with invalid parameters.
+ */
+int utc_yaca_key_generate_from_parameters_n(void)
+{
+ int ret = YACA_ERROR_NONE;
+ yaca_key_h key = YACA_KEY_NULL;
+ yaca_key_h key_params = YACA_KEY_NULL;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_DSA_PARAMS, YACA_KEY_LENGTH_512BIT, &key_params);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate_from_parameters(NULL, &key);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_generate_from_parameters(key_params, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_key_destroy(key_params);
+
+ return 0;
+}
+
+/**
* @testcase utc_yaca_key_extract_public_p
* @since_tizen 3.0
* @description Extracts public key from a private one.
}
/**
+ * @testcase utc_yaca_key_extract_parameters_p
+ * @since_tizen 3.0
+ * @description Extracts parameters from a key.
+ * @scenario Extracts parameters from a key with valid parameters.
+ */
+int utc_yaca_key_extract_parameters_p(void)
+{
+ yaca_key_h priv = YACA_KEY_NULL;
+ yaca_key_h pub = YACA_KEY_NULL;
+ yaca_key_h params = YACA_KEY_NULL;
+
+ int ret = YACA_ERROR_NONE;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_EC_PRIV, YACA_KEY_LENGTH_EC_PRIME256V1, &priv);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(priv, &pub);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_parameters(pub, ¶ms);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ yaca_key_destroy(pub);
+ yaca_key_destroy(priv);
+ yaca_key_destroy(params);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_key_extract_parameters_n
+ * @since_tizen 3.0
+ * @description Extracts parameters from a key.
+ * @scenario Extracts parameters from a key with invalid parameters.
+ */
+int utc_yaca_key_extract_parameters_n(void)
+{
+ yaca_key_h priv = YACA_KEY_NULL;
+ yaca_key_h pub = YACA_KEY_NULL;
+ yaca_key_h params = YACA_KEY_NULL;
+
+ int ret = YACA_ERROR_NONE;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_EC_PRIV, YACA_KEY_LENGTH_EC_PRIME256V1, &priv);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(priv, &pub);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_parameters(NULL, ¶ms);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_extract_parameters(pub, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_key_destroy(pub);
+ yaca_key_destroy(priv);
+ yaca_key_destroy(params);
+
+ return 0;
+}
+
+
+/**
* @testcase utc_yaca_key_destroy_p
* @since_tizen 3.0
* @description Release the key created by the library.
return 0;
}
+/**
+ * @testcase utc_yaca_key_derive_dh_p
+ * @since_tizen 3.0
+ * @description Derives a key from Diffie-Hellman keys.
+ * @scenario Derives a key from Diffie-Hellman keys with valid parameters.
+ */
+int utc_yaca_key_derive_dh_p(void)
+{
+ yaca_key_h dh_peer_pri_key = YACA_KEY_NULL;
+ yaca_key_h dh_peer_pub_key = YACA_KEY_NULL;
+ yaca_key_h dh_pri_key = YACA_KEY_NULL;
+ yaca_key_h params = YACA_KEY_NULL;
+ char *secret = NULL;
+ size_t secret_len;
+
+ int ret = YACA_ERROR_NONE;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_LENGTH_DH_RFC_2048_256, &dh_peer_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(dh_peer_pri_key, &dh_peer_pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_parameters(dh_peer_pub_key, ¶ms);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate_from_parameters(params, &dh_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_derive_dh(dh_pri_key, dh_peer_pub_key, &secret, &secret_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ yaca_key_destroy(dh_peer_pri_key);
+ yaca_key_destroy(dh_peer_pub_key);
+ yaca_key_destroy(dh_pri_key);
+ yaca_key_destroy(params);
+ yaca_free(secret);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_key_derive_dh_n
+ * @since_tizen 3.0
+ * @description Derives a key from Diffie-Hellman keys.
+ * @scenario Derives a key from Diffie-Hellman keys with invalid parameters.
+ */
+int utc_yaca_key_derive_dh_n(void)
+{
+ yaca_key_h dh_peer_pri_key = YACA_KEY_NULL;
+ yaca_key_h dh_peer_pub_key = YACA_KEY_NULL;
+ yaca_key_h dh_pri_key = YACA_KEY_NULL;
+ yaca_key_h params = YACA_KEY_NULL;
+ char *secret = NULL;
+ size_t secret_len;
+
+ int ret = YACA_ERROR_NONE;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_LENGTH_DH_RFC_2048_256, &dh_peer_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(dh_peer_pri_key, &dh_peer_pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_parameters(dh_peer_pub_key, ¶ms);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate_from_parameters(params, &dh_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_derive_dh(NULL, dh_peer_pub_key, &secret, &secret_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_dh(dh_pri_key, NULL, &secret, &secret_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_dh(dh_pri_key, dh_peer_pub_key, NULL, &secret_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_dh(dh_pri_key, dh_peer_pub_key, &secret, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_key_destroy(dh_peer_pri_key);
+ yaca_key_destroy(dh_peer_pub_key);
+ yaca_key_destroy(dh_pri_key);
+ yaca_key_destroy(params);
+ yaca_free(secret);
+
+ return 0;
+}
+
+
+/**
+ * @testcase utc_yaca_key_derive_kdf_p
+ * @since_tizen 3.0
+ * @description Derives a key from a secret.
+ * @scenario Derives a key from a secret with valid parameters.
+ */
+int utc_yaca_key_derive_kdf_p(void)
+{
+ yaca_key_h dh_peer_pri_key = YACA_KEY_NULL;
+ yaca_key_h dh_peer_pub_key = YACA_KEY_NULL;
+ yaca_key_h dh_pri_key = YACA_KEY_NULL;
+ yaca_key_h params = YACA_KEY_NULL;
+ char *secret = NULL;
+ size_t secret_len;
+ char *temp_material = NULL;
+ size_t temp_material_len;
+ size_t key_material_len;
+ size_t iv_material_len;
+
+ int ret = YACA_ERROR_NONE;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_LENGTH_DH_RFC_2048_256, &dh_peer_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(dh_peer_pri_key, &dh_peer_pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_parameters(dh_peer_pub_key, ¶ms);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate_from_parameters(params, &dh_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+ ret = yaca_key_derive_dh(dh_pri_key, dh_peer_pub_key, &secret, &secret_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+ key_material_len = YACA_KEY_LENGTH_192BIT / 8;
+ iv_material_len = YACA_KEY_LENGTH_IV_128BIT / 8;
+ temp_material_len = key_material_len + iv_material_len;
+ ret = yaca_key_derive_kdf(YACA_KDF_X962, YACA_DIGEST_SHA512, secret, secret_len,
+ NULL, 0, temp_material_len, &temp_material);
+ assert_eq(ret, YACA_ERROR_NONE);
+ yaca_key_destroy(dh_peer_pri_key);
+ yaca_key_destroy(dh_peer_pub_key);
+ yaca_key_destroy(dh_pri_key);
+ yaca_key_destroy(params);
+ yaca_free(secret);
+ yaca_free(temp_material);
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_key_derive_kdf_n
+ * @since_tizen 3.0
+ * @description Derives a key from a secret.
+ * @scenario Derives a key from a secret with invalid parameters.
+ */
+int utc_yaca_key_derive_kdf_n(void)
+{
+ yaca_key_h dh_peer_pri_key = YACA_KEY_NULL;
+ yaca_key_h dh_peer_pub_key = YACA_KEY_NULL;
+ yaca_key_h dh_pri_key = YACA_KEY_NULL;
+ yaca_key_h params = YACA_KEY_NULL;
+ char *secret = NULL;
+ size_t secret_len;
+ char *temp_material = NULL;
+ size_t temp_material_len;
+ size_t key_material_len;
+ size_t iv_material_len;
+
+ int ret = YACA_ERROR_NONE;
+
+ ret = yaca_key_generate(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_LENGTH_DH_RFC_2048_256, &dh_peer_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(dh_peer_pri_key, &dh_peer_pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_parameters(dh_peer_pub_key, ¶ms);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_generate_from_parameters(params, &dh_pri_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_derive_dh(dh_pri_key, dh_peer_pub_key, &secret, &secret_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ key_material_len = YACA_KEY_LENGTH_192BIT / 8;
+ iv_material_len = YACA_KEY_LENGTH_IV_128BIT / 8;
+ temp_material_len = key_material_len + iv_material_len;
+
+ ret = yaca_key_derive_kdf((yaca_kdf_e) -1, YACA_DIGEST_SHA512, secret, secret_len,
+ NULL, 0, temp_material_len, &temp_material);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_kdf(YACA_KDF_X962, (yaca_digest_algorithm_e) -1, secret, secret_len,
+ NULL, 0, temp_material_len, &temp_material);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_kdf(YACA_KDF_X962, YACA_DIGEST_SHA512, NULL, secret_len,
+ NULL, 0, temp_material_len, &temp_material);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_kdf(YACA_KDF_X962, YACA_DIGEST_SHA512, secret, 0,
+ NULL, 0, temp_material_len, &temp_material);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_kdf(YACA_KDF_X962, YACA_DIGEST_SHA512, secret, secret_len,
+ NULL, 0, 0, &temp_material);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_key_derive_kdf(YACA_KDF_X962, YACA_DIGEST_SHA512, secret, secret_len,
+ NULL, 0, temp_material_len, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_key_destroy(dh_peer_pri_key);
+ yaca_key_destroy(dh_peer_pub_key);
+ yaca_key_destroy(dh_pri_key);
+ yaca_key_destroy(params);
+ yaca_free(secret);
+ yaca_free(temp_material);
+
+ return 0;
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include "assert.h"
+
+#include <yaca_error.h>
+#include <yaca_rsa.h>
+#include <yaca_crypto.h>
+#include <yaca_key.h>
+
+#include "lorem.h"
+
+#include <dlog.h>
+
+//& set: Yaca
+
+/**
+ * @function utc_yaca_rsa_startup
+ * @description Called before each test
+ * @parameter NA
+ * @return NA
+ */
+void utc_yaca_rsa_startup(void)
+{
+ yaca_initialize();
+}
+
+/**
+ * @function utc_yaca_rsa_cleanup
+ * @description Called after each test
+ * @parameter NA
+ * @return NA
+ */
+void utc_yaca_rsa_cleanup(void)
+{
+ yaca_cleanup();
+}
+
+/**
+ * @testcase utc_yaca_rsa_public_encrypt_p
+ * @since_tizen 3.0
+ * @description Encrypts data using a RSA public key.
+ * @scenario Encrypts data using a RSA public key with valid parameters.
+ */
+int utc_yaca_rsa_public_encrypt_p(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ yaca_key_h pub_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(prv_key, &pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ /* encrypt with PKCS1 padding */
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key,
+ lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ yaca_free(ciphertext);
+ yaca_key_destroy(prv_key);
+ yaca_key_destroy(pub_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_public_encrypt_n
+ * @since_tizen 3.0
+ * @description Encrypts data using a RSA public key.
+ * @scenario Encrypts data using a RSA public key with invalid parameters.
+ */
+int utc_yaca_rsa_public_encrypt_n(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ yaca_key_h pub_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(prv_key, &pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ /* encrypt with PKCS1 padding */
+ ret = yaca_rsa_public_encrypt((yaca_padding_e) -1, pub_key, lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, NULL, lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key, NULL, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key, lorem1024, 0,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key, lorem1024, input_len,
+ NULL, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key, lorem1024, input_len,
+ &ciphertext, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_free(ciphertext);
+ yaca_key_destroy(prv_key);
+ yaca_key_destroy(pub_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_private_decrypt_p
+ * @since_tizen 3.0
+ * @description Decrypts data using a RSA private key.
+ * @scenario Decrypts data using a RSA private key with valid parameters.
+ */
+int utc_yaca_rsa_private_decrypt_p(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ yaca_key_h pub_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ char *plaintext = NULL;
+ size_t plaintext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(prv_key, &pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ /* encrypt with PKCS1 padding */
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key,
+ lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ /*
+ * YACA_PADDING_PKCS1_SSLV23 is compatible with YACA_PADDING_PKCS1. It is used to detect if
+ * both the encrypting and decrypting side used YACA_PADDING_PKCS1_SSLV23, that is, both are
+ * SSL3 capable but use the SSL2 (rollback attack detection).
+ */
+ ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1_SSLV23, prv_key,
+ ciphertext, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ // compare
+ assert_eq(input_len, plaintext_len);
+ int idx;
+ for (idx = 0; idx < input_len; idx++) {
+ assert_eq(lorem1024[idx], plaintext[idx]);
+ }
+
+ yaca_free(ciphertext);
+ yaca_free(plaintext);
+ yaca_key_destroy(prv_key);
+ yaca_key_destroy(pub_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_private_decrypt_n
+ * @since_tizen 3.0
+ * @description Decrypts data using a RSA private key.
+ * @scenario Decrypts data using a RSA private key with invalid parameters.
+ */
+int utc_yaca_rsa_private_decrypt_n(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ yaca_key_h pub_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ char *plaintext = NULL;
+ size_t plaintext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(prv_key, &pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ /* encrypt with PKCS1 padding */
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, pub_key,
+ lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_private_decrypt((yaca_padding_e) -1, prv_key, ciphertext, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1_SSLV23, NULL, ciphertext, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1_SSLV23, prv_key, NULL, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1_SSLV23, prv_key, ciphertext, 0,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1_SSLV23, prv_key, ciphertext, ciphertext_len,
+ NULL, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1_SSLV23, prv_key, ciphertext, ciphertext_len,
+ &plaintext, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_free(ciphertext);
+ yaca_free(plaintext);
+ yaca_key_destroy(prv_key);
+ yaca_key_destroy(pub_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_private_encrypt_p
+ * @since_tizen 3.0
+ * @description Encrypts data using a RSA private key.
+ * @scenario Encrypts data using a RSA private key with valid parameters.
+ */
+int utc_yaca_rsa_private_encrypt_p(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key,
+ lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ yaca_free(ciphertext);
+ yaca_key_destroy(prv_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_private_encrypt_n
+ * @since_tizen 3.0
+ * @description Encrypts data using a RSA private key.
+ * @scenario Encrypts data using a RSA private key with invalid parameters.
+ */
+int utc_yaca_rsa_private_encrypt_n(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_private_encrypt((yaca_padding_e) -1, prv_key, lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, NULL, lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key, NULL, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key, lorem1024, 0,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key, lorem1024, input_len,
+ NULL, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key, lorem1024, input_len,
+ &ciphertext, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_free(ciphertext);
+ yaca_key_destroy(prv_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_public_decrypt_p
+ * @since_tizen 3.0
+ * @description Encrypts data using a RSA public key.
+ * @scenario Encrypts data using a RSA public key with valid parameters.
+ */
+int utc_yaca_rsa_public_decrypt_p(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ yaca_key_h pub_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ char *plaintext = NULL;
+ size_t plaintext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(prv_key, &pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key,
+ lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, pub_key,
+ ciphertext, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ yaca_free(ciphertext);
+ yaca_free(plaintext);
+ yaca_key_destroy(prv_key);
+ yaca_key_destroy(pub_key);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_yaca_rsa_public_decrypt_n
+ * @since_tizen 3.0
+ * @description Encrypts data using a RSA public key.
+ * @scenario Encrypts data using a RSA public key with invalid parameters.
+ */
+int utc_yaca_rsa_public_decrypt_n(void)
+{
+ yaca_key_h prv_key = YACA_KEY_NULL;
+ yaca_key_h pub_key = YACA_KEY_NULL;
+ char *ciphertext = NULL;
+ size_t ciphertext_len;
+ char *plaintext = NULL;
+ size_t plaintext_len;
+ const size_t key_bit_len = YACA_KEY_LENGTH_1024BIT;
+ const size_t input_len = key_bit_len / 8 - 12;
+ int ret;
+
+ /* Key generation */
+ ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, key_bit_len, &prv_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_key_extract_public(prv_key, &pub_key);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, prv_key,
+ lorem1024, input_len,
+ &ciphertext, &ciphertext_len);
+ assert_eq(ret, YACA_ERROR_NONE);
+
+ ret = yaca_rsa_public_decrypt((yaca_padding_e) -1, pub_key, ciphertext, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, NULL, ciphertext, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, pub_key, NULL, ciphertext_len,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, pub_key, ciphertext, 0,
+ &plaintext, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, pub_key, ciphertext, ciphertext_len,
+ NULL, &plaintext_len);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, pub_key, ciphertext, ciphertext_len,
+ &plaintext, NULL);
+ assert_eq(ret, YACA_ERROR_INVALID_PARAMETER);
+
+ yaca_free(ciphertext);
+ yaca_free(plaintext);
+ yaca_key_destroy(prv_key);
+ yaca_key_destroy(pub_key);
+
+ return 0;
+}
+
+
YACA_DIGEST_SHA256, key_bit_len, &key)) != YACA_ERROR_NONE)
return ret;
- if (ret = yaca_encrypt_get_iv_bit_length(algo, bcm, key_bit_len, &iv_bit_len) != YACA_ERROR_NONE)
+ if ((ret = yaca_encrypt_get_iv_bit_length(algo, bcm, key_bit_len, &iv_bit_len)) != YACA_ERROR_NONE)
goto exit;
if (iv_bit_len > 0 && (ret = yaca_key_generate(YACA_KEY_TYPE_IV, iv_bit_len, &iv)) != YACA_ERROR_NONE)