diff options
author | Martin Willi <martin@strongswan.org> | 2006-04-04 12:45:29 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2006-04-04 12:45:29 +0000 |
commit | f2ee13a7e844c5b107137ca21136684c610f2864 (patch) | |
tree | f90e948f8ad1f356c1d326ba8c302aace5cb6e98 /Source/charon/transforms/rsa | |
parent | efadbf79e9c864578bfd1277d824e69b2989aac5 (diff) | |
download | strongswan-f2ee13a7e844c5b107137ca21136684c610f2864.tar.bz2 strongswan-f2ee13a7e844c5b107137ca21136684c610f2864.tar.xz |
- improved strokeing
- down connection
- status
- some other tweaks
Diffstat (limited to 'Source/charon/transforms/rsa')
-rw-r--r-- | Source/charon/transforms/rsa/rsa_private_key.c | 22 | ||||
-rw-r--r-- | Source/charon/transforms/rsa/rsa_private_key.h | 8 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Source/charon/transforms/rsa/rsa_private_key.c b/Source/charon/transforms/rsa/rsa_private_key.c index 4da3baf7c..231aee962 100644 --- a/Source/charon/transforms/rsa/rsa_private_key.c +++ b/Source/charon/transforms/rsa/rsa_private_key.c @@ -155,6 +155,8 @@ static asn1_rule_t rsa_private_key_rules[] = { {ASN1_END, 0, 0, 0}, }; +static private_rsa_private_key_t *rsa_private_key_create_empty(); + /** * Implementation of private_rsa_private_key_t.compute_prime. */ @@ -389,6 +391,25 @@ bool belongs_to(private_rsa_private_key_t *this, rsa_public_key_t *public) return FALSE; } +/** + * Implementation of rsa_private_key.clone. + */ +static rsa_private_key_t* _clone(private_rsa_private_key_t *this) +{ + private_rsa_private_key_t *clone = rsa_private_key_create_empty(); + + mpz_init_set(clone->n, this->n); + mpz_init_set(clone->e, this->e); + mpz_init_set(clone->p, this->p); + mpz_init_set(clone->q, this->q); + mpz_init_set(clone->d, this->d); + mpz_init_set(clone->exp1, this->exp1); + mpz_init_set(clone->exp2, this->exp2); + mpz_init_set(clone->coeff, this->coeff); + clone->k = this->k; + + return &clone->public; +} /** * Implementation of rsa_private_key.destroy. @@ -419,6 +440,7 @@ static private_rsa_private_key_t *rsa_private_key_create_empty() 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.belongs_to = (bool (*) (rsa_private_key_t*,rsa_public_key_t*))belongs_to; + this->public.clone = (rsa_private_key_t*(*)(rsa_private_key_t*))_clone; this->public.destroy = (void (*) (rsa_private_key_t*))destroy; /* private functions */ diff --git a/Source/charon/transforms/rsa/rsa_private_key.h b/Source/charon/transforms/rsa/rsa_private_key.h index ffbe419f5..3ca760042 100644 --- a/Source/charon/transforms/rsa/rsa_private_key.h +++ b/Source/charon/transforms/rsa/rsa_private_key.h @@ -126,6 +126,14 @@ struct rsa_private_key_t { bool (*belongs_to) (rsa_private_key_t *this, rsa_public_key_t *public); /** + * @brief Clone the private key. + * + * @param this private key to clone + * @return clone of this + */ + rsa_private_key_t *(*clone) (rsa_private_key_t *this); + + /** * @brief Destroys the private key. * * @param this private key to destroy |