bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "mail_crypt_global_private_key",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZ1lJdWZKWlplMlk2aUZ6NXgKa29Jb3lzYjNkWkxaV3N5ZWtqT2MvR2pzTGQyaFJBTkNBQVNuSVdnUXVoRThqcUFMY21maXVuUnlFazd2a3EveQphOXZZSzUwYjNjRmhDc0xVNHRmVlRMa0IxWS82VmxaajYzUUtNelhOdms1RzVPRDFvZkVsY3B5agotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "mail_crypt_global_public_key",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFcHlGb0VMb1JQSTZnQzNKbjRycDBjaEpPNzVLdgo4bXZiMkN1ZEc5M0JZUXJDMU9MWDFVeTVBZFdQK2xaV1krdDBDak0xemI1T1J1VGc5YUh4SlhLY293PT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "mail_crypt_global_private_key2",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "LS0tLS1CRUdJTiBFTkNSWVBURUQgUFJJVkFURSBLRVktLS0tLQpNSUhlTUVrR0NTcUdTSWIzRFFFRkRUQThNQnNHQ1NxR1NJYjNEUUVGRERBT0JBaXA2cUpja1FET3F3SUNDQUF3CkhRWUpZSVpJQVdVREJBRXFCQkFXN09oUFRlU0xSOExLcGYwZjZHa3ZCSUdRZk5rYUpodnM2VWVWS2RkN2NzdFMKMURSNXJYTWtON09FbVNjTTljRlk2UDVrMzdnY1VJUFZudTQrOTFYZUE1MTU2cnBpUEpycEdkZnprcjhPNVFqZApsMWRycmR6Z0hqZHE4T2VmbUR1MEEzMjRZd25SS3hGRExUcjlHMkxVMkhoYmV6a0xjV1FwMVJISDZsNXRRcUtwCjZid05iMnc3OXhCb01YSjN6MVZqcElOZk9wRnJ6M3lucVlqUXhseTIrQjg2Ci0tLS0tRU5EIEVOQ1JZUFRFRCBQUklWQVRFIEtFWS0tLS0tCg==",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi "mail_crypt_global_private_key2_password",
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomimail_crypt_load_global_private_keys(const struct fs_crypt_settings *set,
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi const char **error_r);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi .module_dir = top_builddir "/src/lib-dcrypt/.libs"
beec8b0a6a3ece557c9acec524e82542a9641662Aki Tuomi i_info("No functional dcrypt backend found - skipping tests");
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi array_append(&fs_set.plugin_envs, settings, N_ELEMENTS(settings));
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi const char *pubid1 = "c79e262924842de291a8bcd413f4122a570abd033adeff7c1cdfdc9d05998c75";
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi const char *pubid2 = "aaf927444bff8b63425e852c6b3f769e8221b952b42cf886fae7d326c5be098e";
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi const char *set_key = t_strconcat(set_prefix, "_public_key", NULL);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi const char *key_data = mail_crypt_plugin_getenv(&fs_set, set_key);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(mail_crypt_load_global_public_key(set_key, key_data,
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(mail_crypt_load_global_private_keys(&fs_set, set_prefix,
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi /* did we get two private keys? */
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(array_count(&keys.private_keys) == 2);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi /* public key id checks */
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(dcrypt_key_id_public(keys.public_key, MAIL_CRYPT_KEY_ID_ALGORITHM, key_id, &error) == TRUE);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(strcmp(binary_to_hex(key_id->data, key_id->used), pubid1) == 0);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(dcrypt_key_id_private(key->key, MAIL_CRYPT_KEY_ID_ALGORITHM, key_id, &error) == TRUE);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(strcmp(binary_to_hex(key_id->data, key_id->used), pubid1) == 0);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(dcrypt_key_id_private(key->key, MAIL_CRYPT_KEY_ID_ALGORITHM, key_id, &error) == TRUE);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi test_assert(strcmp(binary_to_hex(key_id->data, key_id->used), pubid2) == 0);
e41e5d5456fb6c78693a385239ef5b0cbbd57408Aki Tuomi /* this should not crash */
e41e5d5456fb6c78693a385239ef5b0cbbd57408Aki Tuomi test_assert(mail_crypt_global_key_find(&keys, "423423423423") == NULL);
4c78d9e646c4a1158d7167806937c02d86cdfc25Aki Tuomi void (*tests[])(void) = {