diff options
author | Martin Willi <martin@strongswan.org> | 2009-08-18 09:47:41 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-08-26 11:23:51 +0200 |
commit | 8380503168bbed036679883d488bd52eca688f18 (patch) | |
tree | 01683a6c0e5d36d570fc3c5f7eb5bfca06f958f3 /src | |
parent | b457e08fcabd567ff0ff5d8403e62094f4c191aa (diff) | |
download | strongswan-8380503168bbed036679883d488bd52eca688f18.tar.bz2 strongswan-8380503168bbed036679883d488bd52eca688f18.tar.xz |
gcrypt uses component builder to build public- from private-key
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c | 18 | ||||
-rw-r--r-- | src/libstrongswan/plugins/gcrypt/gcrypt_rsa_public_key.c | 31 |
2 files changed, 12 insertions, 37 deletions
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c index d433d5ea7..eac5c7f48 100644 --- a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c +++ b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c @@ -56,11 +56,6 @@ struct private_gcrypt_rsa_private_key_t { }; /** - * Implemented in gcrypt_rsa_public_key.c - */ -public_key_t *gcrypt_rsa_public_key_create_from_sexp(gcry_sexp_t key); - -/** * find a token in a S-expression. If a key is given, its length is used to * pad the output to a given length. */ @@ -320,7 +315,18 @@ static identification_t* get_id(private_gcrypt_rsa_private_key_t *this, */ static public_key_t* get_public_key(private_gcrypt_rsa_private_key_t *this) { - return gcrypt_rsa_public_key_create_from_sexp(this->key); + chunk_t n, e; + public_key_t *public; + + n = gcrypt_rsa_find_token(this->key, "n", NULL); + e = gcrypt_rsa_find_token(this->key, "e", NULL); + + public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA, + BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END); + chunk_free(&n); + chunk_free(&e); + + return public; } /** diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_public_key.c b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_public_key.c index f574b7186..4eb9cbaac 100644 --- a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_public_key.c +++ b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_public_key.c @@ -344,37 +344,6 @@ static private_gcrypt_rsa_public_key_t *gcrypt_rsa_public_key_create_empty() } /** - * Create a public key from a S-expression, used in gcrypt_rsa_private_key - */ -public_key_t *gcrypt_rsa_public_key_create_from_sexp(gcry_sexp_t key) -{ - private_gcrypt_rsa_public_key_t *this; - gcry_error_t err; - chunk_t n, e; - - this = gcrypt_rsa_public_key_create_empty(); - n = gcrypt_rsa_find_token(key, "n", NULL); - e = gcrypt_rsa_find_token(key, "e", NULL); - - err = gcry_sexp_build(&this->key, NULL, "(public-key(rsa(n %b)(e %b)))", - n.len, n.ptr, e.len, e.ptr); - chunk_free(&n); - chunk_free(&e); - if (err) - { - DBG1("loading public key failed: %s", gpg_strerror(err)); - free(this); - return NULL; - } - if (!gcrypt_rsa_build_keyids(this->key, &this->keyid, &this->keyid_info)) - { - destroy(this); - return NULL; - } - return &this->public.interface; -} - -/** * Load a public key from components */ static gcrypt_rsa_public_key_t *load(chunk_t n, chunk_t e) |