diff --git a/Source/charon/transforms/rsa/rsa_private_key.c b/Source/charon/transforms/rsa/rsa_private_key.c index ce409979d..60673d746 100644 --- a/Source/charon/transforms/rsa/rsa_private_key.c +++ b/Source/charon/transforms/rsa/rsa_private_key.c @@ -28,8 +28,9 @@ #include -/* oids for hash algorithms are defined in - * rsa_public_key.c +/* + * Oids for hash algorithms are defined in + * rsa_public_key.c. */ extern u_int8_t md2_oid[18]; extern u_int8_t md5_oid[18]; @@ -39,7 +40,7 @@ extern u_int8_t sha384_oid[19]; extern u_int8_t sha512_oid[19]; /** - * Public exponent to use for key generation + * Public exponent to use for key generation. */ #define PUBLIC_EXPONENT 0x10001 @@ -47,7 +48,7 @@ extern u_int8_t sha512_oid[19]; typedef struct private_rsa_private_key_t private_rsa_private_key_t; /** - * private data structure for rsa_private_key. + * Private data of a rsa_private_key_t object. */ struct private_rsa_private_key_t { /** @@ -56,70 +57,76 @@ struct private_rsa_private_key_t { rsa_private_key_t public; /** - * is the key already set ? + * Is the key already set ? */ bool is_key_set; /** - * public modulus + * Public modulus. */ mpz_t n; /** - * public exponent + * Public exponent. */ mpz_t e; /** - * private Prime 1 + * Private prime 1. */ mpz_t p; /** - * private Prime 2 + * Private Prime 2. */ mpz_t q; /** - * private exponent + * Private exponent. */ mpz_t d; /** - * private exponent 1 + * Private exponent 1. */ mpz_t exp1; /** - * private exponent 2 + * Private exponent 2. */ mpz_t exp2; /** - * private coefficient + * Private coefficient. */ mpz_t coeff; /** - * keysize in bytes + * Keysize in bytes. */ size_t k; /** * @brief Implements the RSADP algorithm specified in PKCS#1. + * + * @param this calling object + * @param data data to process + * @return processed data */ chunk_t (*rsadp) (private_rsa_private_key_t *this, chunk_t data); /** * @brief Implements the RSASP1 algorithm specified in PKCS#1. + * @param this calling object + * @param data data to process + * @return processed data */ chunk_t (*rsasp1) (private_rsa_private_key_t *this, chunk_t data); }; /** - * Implements private_rsa_private_key_t.rsadp - * Implements private_rsa_private_key_t.rsasp1 + * Implementation of private_rsa_private_key_t.rsadp and private_rsa_private_key_t.rsasp1. */ static chunk_t rsadp(private_rsa_private_key_t *this, chunk_t data) { @@ -151,7 +158,7 @@ static chunk_t rsadp(private_rsa_private_key_t *this, chunk_t data) } /** - * implementation of rsa_private_key.build_emsa_signature. + * Implementation of rsa_private_key.build_emsa_signature. */ static status_t build_emsa_pkcs1_signature(private_rsa_private_key_t *this, hash_algorithm_t hash_algorithm, chunk_t data, chunk_t *signature) { @@ -247,7 +254,7 @@ static status_t build_emsa_pkcs1_signature(private_rsa_private_key_t *this, hash /** - * implementation of rsa_private_key.set_key. + * Implementation of rsa_private_key.set_key. */ static status_t set_key(private_rsa_private_key_t *this, chunk_t key) { @@ -288,7 +295,7 @@ static status_t set_key(private_rsa_private_key_t *this, chunk_t key) } /** - * implementation of rsa_private_key.get_key. + * Implementation of rsa_private_key.get_key. */ static status_t get_key(private_rsa_private_key_t *this, chunk_t *key) { @@ -340,7 +347,7 @@ static status_t get_key(private_rsa_private_key_t *this, chunk_t *key) } /** - * implementation of rsa_private_key.load_key. + * Implementation of rsa_private_key.load_key. */ static status_t load_key(private_rsa_private_key_t *this, char *file) { @@ -348,7 +355,7 @@ static status_t load_key(private_rsa_private_key_t *this, char *file) } /** - * implementation of rsa_private_key.save_key. + * Implementation of rsa_private_key.save_key. */ static status_t save_key(private_rsa_private_key_t *this, char *file) { @@ -356,7 +363,7 @@ static status_t save_key(private_rsa_private_key_t *this, char *file) } /** - * implementation of rsa_private_key.generate_key. + * Implementation of rsa_private_key.generate_key. */ static status_t generate_key(private_rsa_private_key_t *this, size_t key_size) { @@ -450,7 +457,9 @@ static status_t generate_key(private_rsa_private_key_t *this, size_t key_size) return SUCCESS; } - +/** + * Implementation of rsa_private_key.get_public_key. + */ rsa_public_key_t *get_public_key(private_rsa_private_key_t *this) { rsa_public_key_t *public_key; @@ -485,7 +494,7 @@ rsa_public_key_t *get_public_key(private_rsa_private_key_t *this) /** - * implementation of rsa_private_key.destroy. + * Implementation of rsa_private_key.destroy. */ static void destroy(private_rsa_private_key_t *this) { @@ -504,7 +513,7 @@ static void destroy(private_rsa_private_key_t *this) } /* - * Described in header + * Described in header. */ rsa_private_key_t *rsa_private_key_create(hash_algorithm_t hash_algoritm) { diff --git a/Source/charon/transforms/rsa/rsa_private_key.h b/Source/charon/transforms/rsa/rsa_private_key.h index 5a56364e0..2e24c34ec 100644 --- a/Source/charon/transforms/rsa/rsa_private_key.h +++ b/Source/charon/transforms/rsa/rsa_private_key.h @@ -36,14 +36,13 @@ typedef struct rsa_private_key_t rsa_private_key_t; * * Currently only supports signing using EMSA encoding. * - * @TODO Implement proper key set/get load/save - * methods using ASN1. - * * @b Constructors: * - rsa_private_key_create() * * @see rsa_public_key_t * + * @todo Implement proper key set/get load/save methods using ASN1. + * * @ingroup rsa */ struct rsa_private_key_t { @@ -55,7 +54,7 @@ struct rsa_private_key_t { * it with an ASN1-OID of the hash algorithm and runs the RSASP1 function * on it. * - * @param this rsa_private_key to use + * @param this calling object * @param hash_algorithm hash algorithm to use for hashing * @param data data to sign * @param[out] signature allocated signature diff --git a/Source/charon/transforms/rsa/rsa_public_key.c b/Source/charon/transforms/rsa/rsa_public_key.c index 72520cd22..9547b23d6 100644 --- a/Source/charon/transforms/rsa/rsa_public_key.c +++ b/Source/charon/transforms/rsa/rsa_public_key.c @@ -28,11 +28,12 @@ #include #include -/* since we don't have an ASN1 parser/generator, +/* + * Since we don't have an ASN1 parser/generator, * we use these predefined values for * hash algorithm oids. These also contain * the length of the following hash. - * These values are also used in rsa_private_key.c + * These values are also used in rsa_private_key.c. */ u_int8_t md2_oid[18] = { @@ -74,7 +75,7 @@ u_int8_t sha512_oid[] = { typedef struct private_rsa_public_key_t private_rsa_public_key_t; /** - * private data structure with signing context. + * Private data structure with signing context. */ struct private_rsa_public_key_t { /** @@ -83,38 +84,45 @@ struct private_rsa_public_key_t { rsa_public_key_t public; /** - * is the key already set ? + * Is the key already set ? */ bool is_key_set; /** - * public modulus + * Public modulus. */ mpz_t n; /** - * public exponent + * Public exponent. */ mpz_t e; /** - * keysize in bytes + * Keysize in bytes. */ size_t k; /** * @brief Implements the RSAEP algorithm specified in PKCS#1. + * + * @param this calling object + * @param data data to process + * @return processed data */ chunk_t (*rsaep) (private_rsa_public_key_t *this, chunk_t data); /** * @brief Implements the RSASVP1 algorithm specified in PKCS#1. + * + * @param this calling object + * @param data data to process + * @return processed data */ chunk_t (*rsavp1) (private_rsa_public_key_t *this, chunk_t data); }; /** - * Implements private_rsa_public_key_t.rsadp - * Implements private_rsa_public_key_t.rsavp1 + * Implementation of private_rsa_public_key_t.rsadp and private_rsa_public_key_t.rsavp1 */ static chunk_t rsaep(private_rsa_public_key_t *this, chunk_t data) { @@ -138,7 +146,7 @@ static chunk_t rsaep(private_rsa_public_key_t *this, chunk_t data) } /** - * implementation of rsa_public_key.verify_emsa_signature. + * Implementation of rsa_public_key.verify_emsa_signature. */ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chunk_t data, chunk_t signature) { @@ -266,7 +274,7 @@ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chun } /** - * implementation of rsa_public_key.set_key. + * Implementation of rsa_public_key.set_key. */ static status_t set_key(private_rsa_public_key_t *this, chunk_t key) { @@ -289,7 +297,7 @@ static status_t set_key(private_rsa_public_key_t *this, chunk_t key) /** - * implementation of rsa_public_key.get_key. + * Implementation of rsa_public_key.get_key. */ static status_t get_key(private_rsa_public_key_t *this, chunk_t *key) { @@ -316,7 +324,7 @@ static status_t get_key(private_rsa_public_key_t *this, chunk_t *key) } /** - * implementation of rsa_public_key.load_key. + * Implementation of rsa_public_key.load_key. */ static status_t load_key(private_rsa_public_key_t *this, char *file) { @@ -324,7 +332,7 @@ static status_t load_key(private_rsa_public_key_t *this, char *file) } /** - * implementation of rsa_public_key.save_key. + * Implementation of rsa_public_key.save_key. */ static status_t save_key(private_rsa_public_key_t *this, char *file) { @@ -332,7 +340,7 @@ static status_t save_key(private_rsa_public_key_t *this, char *file) } /** - * implementation of rsa_public_key.destroy. + * Implementation of rsa_public_key.destroy. */ static void destroy(private_rsa_public_key_t *this) { @@ -345,7 +353,7 @@ static void destroy(private_rsa_public_key_t *this) } /* - * Described in header + * Described in header. */ rsa_public_key_t *rsa_public_key_create() { diff --git a/Source/charon/transforms/rsa/rsa_public_key.h b/Source/charon/transforms/rsa/rsa_public_key.h index 5225d61f4..657f7f5a6 100644 --- a/Source/charon/transforms/rsa/rsa_public_key.h +++ b/Source/charon/transforms/rsa/rsa_public_key.h @@ -42,6 +42,8 @@ typedef struct rsa_public_key_t rsa_public_key_t; * * @see rsa_private_key_t * + * @todo Implement proper key set/get load/save methods using ASN1. + * * @ingroup rsa */ struct rsa_public_key_t {