Store DH generator in a chunk, hide non-public data in a private struct
[strongswan.git] / src / libstrongswan / plugins / openssl / openssl_diffie_hellman.c
index 92ba348..9a032c5 100644 (file)
@@ -103,7 +103,7 @@ static void set_other_public_value(private_openssl_diffie_hellman_t *this,
        len = DH_compute_key(this->shared_secret.ptr, this->pub_key, this->dh);
        if (len < 0)
        {
        len = DH_compute_key(this->shared_secret.ptr, this->pub_key, this->dh);
        if (len < 0)
        {
-               DBG1("DH shared secret computation failed");
+               DBG1(DBG_LIB, "DH shared secret computation failed");
                return;
        }
        this->shared_secret.len = len;
                return;
        }
        this->shared_secret.len = len;
@@ -128,10 +128,9 @@ static status_t set_modulus(private_openssl_diffie_hellman_t *this)
        {
                return NOT_FOUND;
        }
        {
                return NOT_FOUND;
        }
-       this->dh->p = BN_bin2bn(params->prime, params->prime_len, NULL);
-       this->dh->g = BN_new();
-       BN_set_word(this->dh->g, params->generator);
-       if (params->exp_len != params->prime_len)
+       this->dh->p = BN_bin2bn(params->prime.ptr, params->prime.len, NULL);
+       this->dh->g = BN_bin2bn(params->generator.ptr, params->generator.len, NULL);
+       if (params->exp_len != params->prime.len)
        {
                this->dh->length = params->exp_len * 8;
        }
        {
                this->dh->length = params->exp_len * 8;
        }
@@ -187,7 +186,8 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(diffie_hellman_group_t g
                destroy(this);
                return NULL;
        }
                destroy(this);
                return NULL;
        }
-       DBG2("size of DH secret exponent: %d bits", BN_num_bits(this->dh->priv_key));
+       DBG2(DBG_LIB, "size of DH secret exponent: %d bits",
+                BN_num_bits(this->dh->priv_key));
 
        return &this->public;
 }
 
        return &this->public;
 }