/** * Import a key defined by a fingerprint into the local keyring. * @param handle the context handle * @param fpr the fingerprint key ID to import * @return 0 on success, -1 on error */ int _alpm_key_import(alpm_handle_t *handle, const char *fpr) { int answer = 0, ret = -1; alpm_pgpkey_t fetch_key; memset(&fetch_key, 0, sizeof(fetch_key)); if(key_search(handle, fpr, &fetch_key) == 1) { _alpm_log(handle, ALPM_LOG_DEBUG, "unknown key, found %s on keyserver\n", fetch_key.uid); if(!_alpm_access(handle, handle->gpgdir, "pubring.gpg", W_OK)) { QUESTION(handle, ALPM_QUESTION_IMPORT_KEY, &fetch_key, NULL, NULL, &answer); if(answer) { if(key_import(handle, &fetch_key) == 0) { ret = 0; } else { _alpm_log(handle, ALPM_LOG_ERROR, _("key \"%s\" could not be imported\n"), fetch_key.uid); } } } else { /* keyring directory was not writable, so we don't even try */ _alpm_log(handle, ALPM_LOG_WARNING, _("key %s, \"%s\" found on keyserver, keyring is not writable\n"), fetch_key.fingerprint, fetch_key.uid); } } else { _alpm_log(handle, ALPM_LOG_ERROR, _("key \"%s\" could not be looked up remotely\n"), fpr); } gpgme_key_unref(fetch_key.data); return ret; }
NTSTATUS WINAPI BCryptImportKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_HANDLE decrypt_key, LPCWSTR type, BCRYPT_KEY_HANDLE *key, PUCHAR object, ULONG object_len, PUCHAR input, ULONG input_len, ULONG flags ) { struct algorithm *alg = algorithm; TRACE("%p, %p, %s, %p, %p, %u, %p, %u, %u\n", algorithm, decrypt_key, debugstr_w(type), key, object, object_len, input, input_len, flags); if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE; if (!key || !type || !input) return STATUS_INVALID_PARAMETER; if (decrypt_key) { FIXME( "decryption of key not yet supported\n" ); return STATUS_NOT_IMPLEMENTED; } return key_import( algorithm, type, key, object, object_len, input, input_len ); }