Migrated gmp plugin to INIT/METHOD macros
This commit is contained in:
@@ -273,19 +273,15 @@ end:
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.get_type.
|
||||
*/
|
||||
static key_type_t get_type(private_gmp_rsa_public_key_t *this)
|
||||
METHOD(public_key_t, get_type, key_type_t,
|
||||
private_gmp_rsa_public_key_t *this)
|
||||
{
|
||||
return KEY_RSA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.verify.
|
||||
*/
|
||||
static bool verify(private_gmp_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
METHOD(public_key_t, verify, bool,
|
||||
private_gmp_rsa_public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature)
|
||||
{
|
||||
switch (scheme)
|
||||
{
|
||||
@@ -312,11 +308,8 @@ static bool verify(private_gmp_rsa_public_key_t *this, signature_scheme_t scheme
|
||||
|
||||
#define MIN_PS_PADDING 8
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.encrypt.
|
||||
*/
|
||||
static bool encrypt_(private_gmp_rsa_public_key_t *this, chunk_t plain,
|
||||
chunk_t *crypto)
|
||||
METHOD(public_key_t, encrypt_, bool,
|
||||
private_gmp_rsa_public_key_t *this, chunk_t plain, chunk_t *crypto)
|
||||
{
|
||||
chunk_t em;
|
||||
u_char *pos;
|
||||
@@ -376,27 +369,15 @@ static bool encrypt_(private_gmp_rsa_public_key_t *this, chunk_t plain,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of gmp_rsa_public_key.equals.
|
||||
*/
|
||||
static bool equals(private_gmp_rsa_public_key_t *this, public_key_t *other)
|
||||
{
|
||||
return public_key_equals(&this->public.interface, other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.get_keysize.
|
||||
*/
|
||||
static size_t get_keysize(private_gmp_rsa_public_key_t *this)
|
||||
METHOD(public_key_t, get_keysize, size_t,
|
||||
private_gmp_rsa_public_key_t *this)
|
||||
{
|
||||
return this->k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.get_encoding
|
||||
*/
|
||||
static bool get_encoding(private_gmp_rsa_public_key_t *this,
|
||||
cred_encoding_type_t type, chunk_t *encoding)
|
||||
METHOD(public_key_t, get_encoding, bool,
|
||||
private_gmp_rsa_public_key_t *this, cred_encoding_type_t type,
|
||||
chunk_t *encoding)
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
@@ -412,11 +393,8 @@ static bool get_encoding(private_gmp_rsa_public_key_t *this,
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.get_fingerprint
|
||||
*/
|
||||
static bool get_fingerprint(private_gmp_rsa_public_key_t *this,
|
||||
cred_encoding_type_t type, chunk_t *fp)
|
||||
METHOD(public_key_t, get_fingerprint, bool,
|
||||
private_gmp_rsa_public_key_t *this, cred_encoding_type_t type, chunk_t *fp)
|
||||
{
|
||||
chunk_t n, e;
|
||||
bool success;
|
||||
@@ -436,19 +414,15 @@ static bool get_fingerprint(private_gmp_rsa_public_key_t *this,
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of public_key_t.get_ref.
|
||||
*/
|
||||
static private_gmp_rsa_public_key_t* get_ref(private_gmp_rsa_public_key_t *this)
|
||||
METHOD(public_key_t, get_ref, public_key_t*,
|
||||
private_gmp_rsa_public_key_t *this)
|
||||
{
|
||||
ref_get(&this->ref);
|
||||
return this;
|
||||
return &this->public.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of gmp_rsa_public_key.destroy.
|
||||
*/
|
||||
static void destroy(private_gmp_rsa_public_key_t *this)
|
||||
METHOD(public_key_t, destroy, void,
|
||||
private_gmp_rsa_public_key_t *this)
|
||||
{
|
||||
if (ref_put(&this->ref))
|
||||
{
|
||||
@@ -490,20 +464,21 @@ gmp_rsa_public_key_t *gmp_rsa_public_key_load(key_type_t type, va_list args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
this = malloc_thing(private_gmp_rsa_public_key_t);
|
||||
|
||||
this->public.interface.get_type = (key_type_t (*) (public_key_t*))get_type;
|
||||
this->public.interface.verify = (bool (*) (public_key_t*, signature_scheme_t, chunk_t, chunk_t))verify;
|
||||
this->public.interface.encrypt = (bool (*) (public_key_t*, chunk_t, chunk_t*))encrypt_;
|
||||
this->public.interface.equals = (bool (*) (public_key_t*, public_key_t*))equals;
|
||||
this->public.interface.get_keysize = (size_t (*) (public_key_t*))get_keysize;
|
||||
this->public.interface.get_fingerprint = (bool(*)(public_key_t*, cred_encoding_type_t type, chunk_t *fp))get_fingerprint;
|
||||
this->public.interface.has_fingerprint = (bool(*)(public_key_t*, chunk_t fp))public_key_has_fingerprint;
|
||||
this->public.interface.get_encoding = (bool(*)(public_key_t*, cred_encoding_type_t type, chunk_t *encoding))get_encoding;
|
||||
this->public.interface.get_ref = (public_key_t* (*) (public_key_t *this))get_ref;
|
||||
this->public.interface.destroy = (void (*) (public_key_t *this))destroy;
|
||||
|
||||
this->ref = 1;
|
||||
INIT(this,
|
||||
.public.key = {
|
||||
.get_type = _get_type,
|
||||
.verify = _verify,
|
||||
.encrypt = _encrypt_,
|
||||
.equals = public_key_equals,
|
||||
.get_keysize = _get_keysize,
|
||||
.get_fingerprint = _get_fingerprint,
|
||||
.has_fingerprint = public_key_has_fingerprint,
|
||||
.get_encoding = _get_encoding,
|
||||
.get_ref = _get_ref,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.ref = 1,
|
||||
);
|
||||
|
||||
mpz_init(this->n);
|
||||
mpz_init(this->e);
|
||||
|
||||
Reference in New Issue
Block a user