Migrated remaining classes in openssl plugin to INIT/METHOD macros
This commit is contained in:
@@ -138,11 +138,9 @@ static bool build_der_signature(private_openssl_ec_private_key_t *this,
|
||||
return built;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.sign.
|
||||
*/
|
||||
static bool sign(private_openssl_ec_private_key_t *this,
|
||||
signature_scheme_t scheme, chunk_t data, chunk_t *signature)
|
||||
METHOD(private_key_t, sign, bool,
|
||||
private_openssl_ec_private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature)
|
||||
{
|
||||
switch (scheme)
|
||||
{
|
||||
@@ -172,36 +170,27 @@ static bool sign(private_openssl_ec_private_key_t *this,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.destroy.
|
||||
*/
|
||||
static bool decrypt(private_openssl_ec_private_key_t *this,
|
||||
chunk_t crypto, chunk_t *plain)
|
||||
METHOD(private_key_t, decrypt, bool,
|
||||
private_openssl_ec_private_key_t *this, chunk_t crypto, chunk_t *plain)
|
||||
{
|
||||
DBG1(DBG_LIB, "EC private key decryption not implemented");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.get_keysize.
|
||||
*/
|
||||
static size_t get_keysize(private_openssl_ec_private_key_t *this)
|
||||
METHOD(private_key_t, get_keysize, size_t,
|
||||
private_openssl_ec_private_key_t *this)
|
||||
{
|
||||
return EC_FIELD_ELEMENT_LEN(EC_KEY_get0_group(this->ec));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.get_type.
|
||||
*/
|
||||
static key_type_t get_type(private_openssl_ec_private_key_t *this)
|
||||
METHOD(private_key_t, get_type, key_type_t,
|
||||
private_openssl_ec_private_key_t *this)
|
||||
{
|
||||
return KEY_ECDSA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.get_public_key.
|
||||
*/
|
||||
static public_key_t* get_public_key(private_openssl_ec_private_key_t *this)
|
||||
METHOD(private_key_t, get_public_key, public_key_t*,
|
||||
private_openssl_ec_private_key_t *this)
|
||||
{
|
||||
public_key_t *public;
|
||||
chunk_t key;
|
||||
@@ -217,20 +206,16 @@ static public_key_t* get_public_key(private_openssl_ec_private_key_t *this)
|
||||
return public;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.get_fingerprint.
|
||||
*/
|
||||
static bool get_fingerprint(private_openssl_ec_private_key_t *this,
|
||||
cred_encoding_type_t type, chunk_t *fingerprint)
|
||||
METHOD(private_key_t, get_fingerprint, bool,
|
||||
private_openssl_ec_private_key_t *this, cred_encoding_type_t type,
|
||||
chunk_t *fingerprint)
|
||||
{
|
||||
return openssl_ec_fingerprint(this->ec, type, fingerprint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.get_encoding.
|
||||
*/
|
||||
static bool get_encoding(private_openssl_ec_private_key_t *this,
|
||||
cred_encoding_type_t type, chunk_t *encoding)
|
||||
METHOD(private_key_t, get_encoding, bool,
|
||||
private_openssl_ec_private_key_t *this, cred_encoding_type_t type,
|
||||
chunk_t *encoding)
|
||||
{
|
||||
u_char *p;
|
||||
|
||||
@@ -261,19 +246,15 @@ static bool get_encoding(private_openssl_ec_private_key_t *this,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.get_ref.
|
||||
*/
|
||||
static private_key_t* get_ref(private_openssl_ec_private_key_t *this)
|
||||
METHOD(private_key_t, get_ref, private_key_t*,
|
||||
private_openssl_ec_private_key_t *this)
|
||||
{
|
||||
ref_get(&this->ref);
|
||||
return &this->public.interface;
|
||||
return &this->public.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of private_key_t.destroy.
|
||||
*/
|
||||
static void destroy(private_openssl_ec_private_key_t *this)
|
||||
METHOD(private_key_t, destroy, void,
|
||||
private_openssl_ec_private_key_t *this)
|
||||
{
|
||||
if (ref_put(&this->ref))
|
||||
{
|
||||
@@ -291,23 +272,25 @@ static void destroy(private_openssl_ec_private_key_t *this)
|
||||
*/
|
||||
static private_openssl_ec_private_key_t *create_empty(void)
|
||||
{
|
||||
private_openssl_ec_private_key_t *this = malloc_thing(private_openssl_ec_private_key_t);
|
||||
private_openssl_ec_private_key_t *this;
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*)(private_key_t *this))get_type;
|
||||
this->public.interface.sign = (bool (*)(private_key_t *this, signature_scheme_t scheme, chunk_t data, chunk_t *signature))sign;
|
||||
this->public.interface.decrypt = (bool (*)(private_key_t *this, chunk_t crypto, chunk_t *plain))decrypt;
|
||||
this->public.interface.get_keysize = (size_t (*) (private_key_t *this))get_keysize;
|
||||
this->public.interface.get_public_key = (public_key_t* (*)(private_key_t *this))get_public_key;
|
||||
this->public.interface.equals = private_key_equals;
|
||||
this->public.interface.belongs_to = private_key_belongs_to;
|
||||
this->public.interface.get_fingerprint = (bool(*)(private_key_t*, cred_encoding_type_t type, chunk_t *fp))get_fingerprint;
|
||||
this->public.interface.has_fingerprint = (bool(*)(private_key_t*, chunk_t fp))private_key_has_fingerprint;
|
||||
this->public.interface.get_encoding = (bool(*)(private_key_t*, cred_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (private_key_t* (*)(private_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*)(private_key_t *this))destroy;
|
||||
|
||||
this->ec = NULL;
|
||||
this->ref = 1;
|
||||
INIT(this,
|
||||
.public.key = {
|
||||
.get_type = _get_type,
|
||||
.sign = _sign,
|
||||
.decrypt = _decrypt,
|
||||
.get_keysize = _get_keysize,
|
||||
.get_public_key = _get_public_key,
|
||||
.equals = private_key_equals,
|
||||
.belongs_to = private_key_belongs_to,
|
||||
.get_fingerprint = _get_fingerprint,
|
||||
.has_fingerprint = private_key_has_fingerprint,
|
||||
.get_encoding = _get_encoding,
|
||||
.get_ref = _get_ref,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.ref = 1,
|
||||
);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user