mem-cred: Add method to remove a private key with a specific fingerprint
This commit is contained in:
@@ -370,6 +370,32 @@ METHOD(mem_cred_t, add_key, void,
|
|||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHOD(mem_cred_t, remove_key, bool,
|
||||||
|
private_mem_cred_t *this, chunk_t fp)
|
||||||
|
{
|
||||||
|
enumerator_t *enumerator;
|
||||||
|
private_key_t *current;
|
||||||
|
bool found = FALSE;
|
||||||
|
|
||||||
|
this->lock->write_lock(this->lock);
|
||||||
|
|
||||||
|
enumerator = this->keys->create_enumerator(this->keys);
|
||||||
|
while (enumerator->enumerate(enumerator, ¤t))
|
||||||
|
{
|
||||||
|
if (current->has_fingerprint(current, fp))
|
||||||
|
{
|
||||||
|
this->keys->remove_at(this->keys, enumerator);
|
||||||
|
current->destroy(current);
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
|
this->lock->unlock(this->lock);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared key entry
|
* Shared key entry
|
||||||
*/
|
*/
|
||||||
@@ -817,6 +843,7 @@ mem_cred_t *mem_cred_create()
|
|||||||
.get_cert_ref = _get_cert_ref,
|
.get_cert_ref = _get_cert_ref,
|
||||||
.add_crl = _add_crl,
|
.add_crl = _add_crl,
|
||||||
.add_key = _add_key,
|
.add_key = _add_key,
|
||||||
|
.remove_key = _remove_key,
|
||||||
.add_shared = _add_shared,
|
.add_shared = _add_shared,
|
||||||
.add_shared_list = _add_shared_list,
|
.add_shared_list = _add_shared_list,
|
||||||
.add_cdp = _add_cdp,
|
.add_cdp = _add_cdp,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2015 Tobias Brunner
|
* Copyright (C) 2010-2016 Tobias Brunner
|
||||||
* Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
|
*
|
||||||
* Copyright (C) 2010 Martin Willi
|
* Copyright (C) 2010 Martin Willi
|
||||||
* Copyright (C) 2010 revosec AG
|
* Copyright (C) 2010 revosec AG
|
||||||
*
|
*
|
||||||
@@ -86,6 +87,14 @@ struct mem_cred_t {
|
|||||||
*/
|
*/
|
||||||
void (*add_key)(mem_cred_t *this, private_key_t *key);
|
void (*add_key)(mem_cred_t *this, private_key_t *key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a private key from the credential set.
|
||||||
|
*
|
||||||
|
* @param fp fingerprint of the key to remove
|
||||||
|
* @return TRUE if the key was found and removed
|
||||||
|
*/
|
||||||
|
bool (*remove_key)(mem_cred_t *this, chunk_t fp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a shared key to the credential set.
|
* Add a shared key to the credential set.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user