9 #include <talloc/talloc.h>
10 #include <file/file.h>
11 #include <security/security.h>
13 #define SECURITY_TEST_DATA_DIR TEST_LIB_DATA_BASE "/security/"
17 char *verify_data = NULL;
18 char *compare_data = NULL;
19 char *filename = NULL;
21 int ret = EXIT_FAILURE;
27 keyfile = fopen(SECURITY_TEST_DATA_DIR "cert.p12", "r");
31 if (read_file(NULL, SECURITY_TEST_DATA_DIR "rootdata.txt", &verify_data, &verify_len))
34 /* first basic CMS decrypt case */
37 * these calls overwrite so need a temp file
38 * copy_file_secure_dest is having some permission issues
40 if (copy_file_secure_dest(NULL,
41 SECURITY_TEST_DATA_DIR "rootdata.cmsencver",
45 if (decrypt_file(filename, keyfile, NULL))
48 if (read_file(verify_data, filename, &compare_data, &compare_len))
51 if (verify_len != compare_len)
54 if (memcmp(verify_data, compare_data, verify_len))
57 /* check an encrypted but unverified message fails */
59 talloc_free(filename);
61 if (copy_file_secure_dest(NULL,
62 SECURITY_TEST_DATA_DIR "rootdata.cmsenc",
67 if (!decrypt_file(filename, keyfile, NULL))
70 /* got here, all fine */
78 talloc_free(filename);
80 talloc_free(verify_data);