diff options
author | Martin Willi <martin@strongswan.org> | 2006-03-30 07:22:01 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2006-03-30 07:22:01 +0000 |
commit | efadbf79e9c864578bfd1277d824e69b2989aac5 (patch) | |
tree | cf5cde05d140a07f2ffe21c8e61a47610199145b /Source/charon/transforms/rsa/rsa_public_key.h | |
parent | 9c781c152ad66a73139447e40a2081c38080c651 (diff) | |
download | strongswan-efadbf79e9c864578bfd1277d824e69b2989aac5.tar.bz2 strongswan-efadbf79e9c864578bfd1277d824e69b2989aac5.tar.xz |
- rewrote a lot of RSA stuff
- done major work for ASN1/decoder
- allow loading of ASN1 der encoded private keys, public keys and certificates
- extracting public key from certificates
- passing certificates from stroke to charon
=> basic authentication with RSA certificates works!
Diffstat (limited to 'Source/charon/transforms/rsa/rsa_public_key.h')
-rw-r--r-- | Source/charon/transforms/rsa/rsa_public_key.h | 72 |
1 files changed, 43 insertions, 29 deletions
diff --git a/Source/charon/transforms/rsa/rsa_public_key.h b/Source/charon/transforms/rsa/rsa_public_key.h index a4671b148..ef79153d6 100644 --- a/Source/charon/transforms/rsa/rsa_public_key.h +++ b/Source/charon/transforms/rsa/rsa_public_key.h @@ -38,11 +38,13 @@ typedef struct rsa_public_key_t rsa_public_key_t; * the EMSA encoding (see PKCS1) * * @b Constructors: - * - rsa_public_key_create() + * - rsa_public_key_create_from_chunk() + * - rsa_public_key_create_from_file() + * - rsa_private_key_t.get_public_key() * * @see rsa_private_key_t * - * @todo Implement proper key set/get load/save methods using ASN1. + * @todo Implement getkey() and savekey() * * @ingroup rsa */ @@ -55,7 +57,7 @@ struct rsa_public_key_t { * selects the hash algorithm form the resultign ASN1-OID and * verifies the hash against the supplied data. * - * @param this rsa_private_key to use + * @param this rsa_public_key to use * @param data data to sign * @param signature signature to verify * @return @@ -68,20 +70,6 @@ struct rsa_public_key_t { status_t (*verify_emsa_pkcs1_signature) (rsa_public_key_t *this, chunk_t data, chunk_t signature); /** - * @brief Set the key. - * - * Currently uses a proprietary format which is only inteded - * for testing. This should be replaced with a proper - * ASN1 encoded key format, when charon gets the ASN1 - * capabilities. - * - * @param this calling object - * @param key key (in a propriarity format) - * @return currently SUCCESS in any case - */ - status_t (*set_key) (rsa_public_key_t *this, chunk_t key); - - /** * @brief Gets the key. * * Currently uses a proprietary format which is only inteded @@ -98,26 +86,31 @@ struct rsa_public_key_t { status_t (*get_key) (rsa_public_key_t *this, chunk_t *key); /** - * @brief Loads a key from a file. + * @brief Saves a key to a file. * * Not implemented! * * @param this calling object - * @param file file from which key should be read + * @param file file to which the key should be written. * @return NOT_SUPPORTED */ - status_t (*load_key) (rsa_public_key_t *this, char *file); + status_t (*save_key) (rsa_public_key_t *this, char *file); /** - * @brief Saves a key to a file. - * - * Not implemented! + * @brief Get the modulus of the key. * * @param this calling object - * @param file file to which the key should be written. - * @return NOT_SUPPORTED + * @return modulus (n) of the key */ - status_t (*save_key) (rsa_public_key_t *this, char *file); + mpz_t *(*get_modulus) (rsa_public_key_t *this); + + /** + * @brief Clone the public key. + * + * @param this public key to clone + * @return clone of this + */ + rsa_public_key_t *(*clone) (rsa_public_key_t *this); /** * @brief Destroys the public key. @@ -128,12 +121,33 @@ struct rsa_public_key_t { }; /** - * @brief Create a public key without any key inside. + * @brief Load an RSA public key from a chunk. + * + * Load a key from a chunk, encoded in the more frequently + * used PublicKeyInfo struct (ASN1 DER encoded). + * + * @param chunk chunk containing the DER encoded key + * @return loaded rsa_public_key_t, or NULL + * + * @todo Check OID in PublicKeyInfo + * + * @ingroup rsa + */ +rsa_public_key_t *rsa_public_key_create_from_chunk(chunk_t chunk); + +/** + * @brief Load an RSA public key from a file. + * + * Load a key from a file, which is either in binary + * format (DER), or in PEM format. + * + * @param filename filename which holds the key + * @return loaded rsa_public_key_t, or NULL * - * @return created rsa_public_key_t. + * @todo Implement PEM file loading * * @ingroup rsa */ -rsa_public_key_t *rsa_public_key_create(); +rsa_public_key_t *rsa_public_key_create_from_file(char *filename); #endif /*RSA_PUBLIC_KEY_H_*/ |