aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/transforms/diffie_hellman.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-12-04 01:30:35 +0000
committerMartin Willi <martin@strongswan.org>2005-12-04 01:30:35 +0000
commit8ff8c33d1d720a227db193c2105cbdcf119e5746 (patch)
tree7de51ee9de420cf13eca9c91f4dfb70901d41e10 /Source/charon/transforms/diffie_hellman.c
parenta374d1ee669a6b7674f242119369770cb9e5705c (diff)
downloadstrongswan-8ff8c33d1d720a227db193c2105cbdcf119e5746.tar.bz2
strongswan-8ff8c33d1d720a227db193c2105cbdcf119e5746.tar.xz
- implemented RSA, only signing and verifying esma_pkcs1 padded
- removed gmp-helper: chunk_to_mpz is now done with gmp functions, prime generation in prime-pool - added prime-pool (needs priority fix) - proof of concept RSA authentication - mpz uses LEAK_DETECTIVE - configuration-manager supports rsa keys
Diffstat (limited to 'Source/charon/transforms/diffie_hellman.c')
-rw-r--r--Source/charon/transforms/diffie_hellman.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/Source/charon/transforms/diffie_hellman.c b/Source/charon/transforms/diffie_hellman.c
index dc2acc6ab..266c4b3dd 100644
--- a/Source/charon/transforms/diffie_hellman.c
+++ b/Source/charon/transforms/diffie_hellman.c
@@ -27,9 +27,9 @@
#include "diffie_hellman.h"
+#include <daemon.h>
#include <utils/allocator.h>
#include <utils/randomizer.h>
-#include <utils/gmp_helper.h>
/**
@@ -404,11 +404,6 @@ struct private_diffie_hellman_t {
* True if shared secret is computed and stored in my_public_value.
*/
bool shared_secret_is_computed;
-
- /**
- * helper class for gmp functions.
- */
- gmp_helper_t *gmp_helper;
/**
* Sets the modulus for a specific diffie hellman group.
@@ -450,7 +445,7 @@ static status_t set_modulus(private_diffie_hellman_t *this)
chunk_t modulus_chunk;
modulus_chunk.ptr = modulus_info_entries[i].modulus;
modulus_chunk.len = modulus_info_entries[i].modulus_length;
- this->gmp_helper->chunk_to_mpz(this->gmp_helper,&(this->modulus),modulus_chunk);
+ mpz_import(this->modulus, modulus_chunk.len, 1, 1, 1, 0, modulus_chunk.ptr);
this->modulus_length = modulus_chunk.len;
this->generator = modulus_info_entries[i].generator;
status = SUCCESS;
@@ -465,7 +460,7 @@ static status_t set_modulus(private_diffie_hellman_t *this)
*/
static void set_other_public_value(private_diffie_hellman_t *this,chunk_t public_value)
{
- this->gmp_helper->chunk_to_mpz(this->gmp_helper,&(this->other_public_value),public_value);
+ mpz_import(this->other_public_value, public_value.len, 1, 1, 1, 0, public_value.ptr);
this->compute_shared_secret(this);
}
@@ -478,7 +473,8 @@ static status_t get_other_public_value(private_diffie_hellman_t *this,chunk_t *p
{
return FAILED;
}
- this->gmp_helper->mpz_to_chunk(this->gmp_helper,&(this->other_public_value), public_value,this->modulus_length);
+ public_value->len = this->modulus_length;
+ public_value->ptr = mpz_export(NULL, NULL, 1, public_value->len, 1, 0, this->other_public_value);
return SUCCESS;
}
@@ -517,7 +513,8 @@ static void compute_public_value (private_diffie_hellman_t *this)
*/
static void get_my_public_value(private_diffie_hellman_t *this,chunk_t *public_value)
{
- this->gmp_helper->mpz_to_chunk(this->gmp_helper,&(this->my_public_value), public_value,this->modulus_length);
+ public_value->len = this->modulus_length;
+ public_value->ptr = mpz_export(NULL, NULL, 1, public_value->len, 1, 0, this->my_public_value);
}
/**
@@ -529,7 +526,8 @@ static status_t get_shared_secret(private_diffie_hellman_t *this,chunk_t *secret
{
return FAILED;
}
- this->gmp_helper->mpz_to_chunk(this->gmp_helper,&(this->shared_secret), secret,this->modulus_length);
+ secret->len = this->modulus_length;
+ secret->ptr = mpz_export(NULL, NULL, 1, secret->len, 1, 0, this->shared_secret);
return SUCCESS;
}
@@ -538,7 +536,6 @@ static status_t get_shared_secret(private_diffie_hellman_t *this,chunk_t *secret
*/
static void destroy(private_diffie_hellman_t *this)
{
- this->gmp_helper->destroy(this->gmp_helper);
mpz_clear(this->modulus);
mpz_clear(this->my_prime);
mpz_clear(this->my_public_value);
@@ -575,17 +572,14 @@ diffie_hellman_t *diffie_hellman_create(diffie_hellman_group_t dh_group_number)
/* private variables */
this->dh_group_number = dh_group_number;
- this->gmp_helper = gmp_helper_create();
-
/* set this->modulus */
if (this->set_modulus(this) != SUCCESS)
{
- this->gmp_helper->destroy(this->gmp_helper);
allocator_free(this);
return NULL;
}
- this->gmp_helper->init_prime(this->gmp_helper,&(this->my_prime),this->modulus_length);
+ charon->prime_pool->get_prime(charon->prime_pool, this->modulus_length, &(this->my_prime));
this->compute_public_value(this);