aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2011-10-28 18:49:31 +0200
committerTobias Brunner <tobias@strongswan.org>2011-10-31 18:45:37 +0100
commitcac68531803697fa48d71a47bdde7dab21ebfb3c (patch)
tree50a3d58ee8df650906572571047ca68b54051913
parent8531106578dfe3276ab4a38829ed682848bf262b (diff)
downloadstrongswan-cac68531803697fa48d71a47bdde7dab21ebfb3c.tar.bz2
strongswan-cac68531803697fa48d71a47bdde7dab21ebfb3c.tar.xz
pkcs11: Use get_ck_attribute for DH.
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_dh.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c b/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c
index a447eb6b5..e902b0ba8 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_dh.c
@@ -64,32 +64,6 @@ struct private_pkcs11_dh_t {
};
-/**
- * Retrieve a CKA_VALUE from a CK_OBJECT_HANDLE, memory gets allocated
- */
-static bool get_cka_value(private_pkcs11_dh_t *this, CK_OBJECT_HANDLE obj,
- chunk_t *value)
-{
- CK_ATTRIBUTE attr = { CKA_VALUE, NULL, 0 };
- CK_RV rv;
- rv = this->lib->f->C_GetAttributeValue(this->session, obj, &attr, 1);
- if (rv != CKR_OK)
- {
- DBG1(DBG_CFG, "C_GetAttributeValue(NULL) error: %N", ck_rv_names, rv);
- return FALSE;
- }
- *value = chunk_alloc(attr.ulValueLen);
- attr.pValue = value->ptr;
- rv = this->lib->f->C_GetAttributeValue(this->session, obj, &attr, 1);
- if (rv != CKR_OK)
- {
- DBG1(DBG_CFG, "C_GetAttributeValue() error: %N", ck_rv_names, rv);
- chunk_free(value);
- return FALSE;
- }
- return TRUE;
-}
-
METHOD(diffie_hellman_t, set_other_public_value, void,
private_pkcs11_dh_t *this, chunk_t value)
{
@@ -114,8 +88,10 @@ METHOD(diffie_hellman_t, set_other_public_value, void,
DBG1(DBG_CFG, "C_DeriveKey() error: %N", ck_rv_names, rv);
return;
}
- if (!get_cka_value(this, secret, &this->secret))
+ if (!this->lib->get_ck_attribute(this->lib, this->session, secret,
+ CKA_VALUE, &this->secret))
{
+ chunk_free(&this->secret);
return;
}
}
@@ -183,8 +159,10 @@ static bool generate_key_pair(private_pkcs11_dh_t *this, size_t exp_len,
return FALSE;
}
- if (!get_cka_value(this, pub_key, &this->pub_key))
+ if (!this->lib->get_ck_attribute(this->lib, this->session, pub_key,
+ CKA_VALUE, &this->pub_key))
{
+ chunk_free(&this->pub_key);
return FALSE;
}
return TRUE;