diff --git a/src/libstrongswan/crypto/pkcs7.c b/src/libstrongswan/crypto/pkcs7.c index f17a15fee..5c9550af4 100644 --- a/src/libstrongswan/crypto/pkcs7.c +++ b/src/libstrongswan/crypto/pkcs7.c @@ -519,7 +519,7 @@ static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber, } break; case PKCS7_ENCRYPTED_KEY: - if (key->eme_pkcs1_decrypt(key, object, &symmetric_key) != SUCCESS) + if (key->pkcs1_decrypt(key, object, &symmetric_key) != SUCCESS) { DBG1("symmetric key could not be decrypted with rsa"); goto failed; diff --git a/src/libstrongswan/crypto/rsa/rsa_private_key.c b/src/libstrongswan/crypto/rsa/rsa_private_key.c index 0fb3d12b6..b6854aa6a 100644 --- a/src/libstrongswan/crypto/rsa/rsa_private_key.c +++ b/src/libstrongswan/crypto/rsa/rsa_private_key.c @@ -271,8 +271,8 @@ static chunk_t rsadp(private_rsa_private_key_t *this, chunk_t data) /** * Implementation of rsa_private_key_t.eme_pkcs1_decrypt. */ -static status_t eme_pkcs1_decrypt(private_rsa_private_key_t *this, - chunk_t in, chunk_t *out) +static status_t pkcs1_decrypt(private_rsa_private_key_t *this, + chunk_t in, chunk_t *out) { status_t status = FAILED; chunk_t em, em_ori; @@ -413,11 +413,11 @@ static status_t save_key(private_rsa_private_key_t *this, char *file) } /** - * Implementation of rsa_private_key.get_public_key. + * Implementation of rsa_public_key.get_keysize. */ -rsa_public_key_t *get_public_key(private_rsa_private_key_t *this) +static size_t get_keysize(const private_rsa_private_key_t *this) { - return NULL; + return this->k; } /** @@ -547,10 +547,10 @@ static private_rsa_private_key_t *rsa_private_key_create_empty(void) private_rsa_private_key_t *this = malloc_thing(private_rsa_private_key_t); /* public functions */ - this->public.eme_pkcs1_decrypt = (status_t (*) (rsa_private_key_t*,chunk_t,chunk_t*))eme_pkcs1_decrypt; + this->public.pkcs1_decrypt = (status_t (*) (rsa_private_key_t*,chunk_t,chunk_t*))pkcs1_decrypt; this->public.build_emsa_pkcs1_signature = (status_t (*) (rsa_private_key_t*,hash_algorithm_t,chunk_t,chunk_t*))build_emsa_pkcs1_signature; this->public.save_key = (status_t (*) (rsa_private_key_t*,char*))save_key; - this->public.get_public_key = (rsa_public_key_t *(*) (rsa_private_key_t*))get_public_key; + this->public.get_keysize = (size_t (*) (const rsa_private_key_t*))get_keysize; this->public.belongs_to = (bool (*) (rsa_private_key_t*,rsa_public_key_t*))belongs_to; this->public.destroy = (void (*) (rsa_private_key_t*))destroy; diff --git a/src/libstrongswan/crypto/rsa/rsa_private_key.h b/src/libstrongswan/crypto/rsa/rsa_private_key.h index a332cad78..bad74bc23 100644 --- a/src/libstrongswan/crypto/rsa/rsa_private_key.h +++ b/src/libstrongswan/crypto/rsa/rsa_private_key.h @@ -61,7 +61,7 @@ struct rsa_private_key_t { * - SUCCESS * - FAILED if padding is not correct */ - status_t (*eme_pkcs1_decrypt) (rsa_private_key_t *this, chunk_t in, chunk_t *out); + status_t (*pkcs1_decrypt) (rsa_private_key_t *this, chunk_t in, chunk_t *out); /** * @brief Build a signature over a chunk using EMSA-PKCS1 encoding. @@ -93,12 +93,13 @@ struct rsa_private_key_t { status_t (*save_key) (rsa_private_key_t *this, char *file); /** - * @brief Create a rsa_public_key_t with the public parts of the key. + * @brief Get the size of the modulus in bytes. * * @param this calling object - * @return public_key + * @return size of the modulus (n) in bytes */ - rsa_public_key_t *(*get_public_key) (rsa_private_key_t *this); + size_t (*get_keysize) (rsa_private_key_t *this); + /** * @brief Check if a private key belongs to a public key.