]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
botan: Replace deprecated FFI function calls
authorTobias Brunner <tobias@strongswan.org>
Tue, 2 Jul 2019 08:47:54 +0000 (10:47 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 2 Jul 2019 09:35:21 +0000 (11:35 +0200)
Several "wrapper" functions have been marked deprecated with 2.11.0.

src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c
src/libstrongswan/plugins/botan/botan_ec_private_key.c
src/libstrongswan/plugins/botan/botan_rsa_private_key.c
src/libstrongswan/plugins/botan/botan_rsa_public_key.c
src/libstrongswan/plugins/botan/botan_x25519.c
src/libstrongswan/tests/suites/test_rsa.c
src/libstrongswan/utils/leak_detective.c

index ed28b46390a5d03541d53b843d6de88dfe3fe5d1..50234b2e02e32e8e8373e8239635ab77fd686d19 100644 (file)
@@ -211,7 +211,7 @@ botan_ec_diffie_hellman_t *botan_ec_diffie_hellman_create(
                return NULL;
        }
 
-       if (botan_privkey_create_ecdh(&this->key, rng, this->curve_name))
+       if (botan_privkey_create(&this->key, "ECDH", this->curve_name, rng))
        {
                DBG1(DBG_LIB, "ECDH private key generation failed");
                botan_rng_destroy(rng);
index f8dbb66d78808e422005d44654cb09f672e1385d..d9469e916bac054978edbf5c25c13e34d8512491 100644 (file)
@@ -336,7 +336,7 @@ botan_ec_private_key_t *botan_ec_private_key_gen(key_type_t type, va_list args)
 
        this = create_empty(oid);
 
-       if (botan_privkey_create_ecdsa(&this->key, rng, curve))
+       if (botan_privkey_create(&this->key, "ECDSA", curve, rng))
        {
                DBG1(DBG_LIB, "EC private key generation failed");
                botan_rng_destroy(rng);
index 02820b297f355eb82a4718d04ad9f328db2d6c4f..06a9345624a6ad6fde86bfc55abc037e85bf008a 100644 (file)
@@ -225,7 +225,7 @@ METHOD(private_key_t, get_keysize, int,
                return 0;
        }
 
-       if (botan_privkey_rsa_get_n(n, this->key) ||
+       if (botan_privkey_get_field(n, this->key, "n") ||
                botan_mp_num_bits(n, &bits))
        {
                botan_mp_destroy(n);
@@ -346,6 +346,7 @@ botan_rsa_private_key_t *botan_rsa_private_key_gen(key_type_t type,
 {
        private_botan_rsa_private_key_t *this;
        botan_rng_t rng;
+       char buf[BUF_LEN];
        u_int key_size = 0;
 
        while (TRUE)
@@ -375,7 +376,9 @@ botan_rsa_private_key_t *botan_rsa_private_key_gen(key_type_t type,
 
        this = create_empty();
 
-       if (botan_privkey_create_rsa(&this->key, rng, key_size))
+       snprintf(buf, sizeof(buf), "%u", key_size);
+
+       if (botan_privkey_create(&this->key, "RSA", buf, rng))
        {
                botan_rng_destroy(rng);
                free(this);
@@ -412,7 +415,7 @@ static bool calculate_pq(botan_mp_t *n, botan_mp_t *e, botan_mp_t *d,
        }
 
        /* k must be even */
-       if (!botan_mp_is_even(k))
+       if (botan_mp_get_bit(k, 0) != 0)
        {
                goto error;
        }
@@ -424,7 +427,7 @@ static bool calculate_pq(botan_mp_t *n, botan_mp_t *e, botan_mp_t *d,
                goto error;
        }
 
-       for (t = 0; !botan_mp_is_odd(r); t++)
+       for (t = 0; botan_mp_get_bit(r, 0) != 1; t++)
        {
                if (botan_mp_rshift(r, r, 1))
                {
index 244caa5856dcb4c4c90315a1c01017b1331ba86b..af573b7c036f648c35dde367a77ede79472f3371 100644 (file)
@@ -215,7 +215,7 @@ METHOD(public_key_t, get_keysize, int,
                return 0;
        }
 
-       if (botan_pubkey_rsa_get_n(n, this->key) ||
+       if (botan_pubkey_get_field(n, this->key, "n") ||
                botan_mp_num_bits(n, &bits))
        {
                botan_mp_destroy(n);
index 519f29f55f362c20b97dc1a03dfd86dfc15922b2..8863f3fa63d9b94ecce347f122795859b2381e2a 100644 (file)
@@ -161,7 +161,7 @@ diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group)
                return NULL;
        }
 
-       if (botan_privkey_create_ecdh(&this->key, rng, "curve25519"))
+       if (botan_privkey_create(&this->key, "Curve25519", "", rng))
        {
                DBG1(DBG_LIB, "x25519 private key generation failed");
                botan_rng_destroy(rng);
index c90196f559ffbde6572b388fe08a4f892bc989dc..db6a09dda891069ee4124ce931ba9c83dfb636c5 100644 (file)
@@ -157,8 +157,10 @@ START_TEST(test_gen)
        privkey = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
                                                                 BUILD_KEY_SIZE, key_sizes[_i], BUILD_END);
        ck_assert(privkey != NULL);
+       ck_assert_int_eq(key_sizes[_i], privkey->get_keysize(privkey));
        pubkey = privkey->get_public_key(privkey);
        ck_assert(pubkey != NULL);
+       ck_assert_int_eq(key_sizes[_i], pubkey->get_keysize(pubkey));
 
        test_good_sig(privkey, pubkey);
 
index 63b7453f3ea53894f418d9cff69c52dc88fb2bc9..d4ebfeac78c6e2e9ba5b153f99798d779efabca8 100644 (file)
@@ -626,8 +626,7 @@ static char *whitelist[] = {
        "TNC_IMV_NotifyConnectionChange",
        /* Botan */
        "botan_public_key_load",
-       "botan_privkey_create_ecdsa",
-       "botan_privkey_create_ecdh",
+       "botan_privkey_create",
        "botan_privkey_load_ecdh",
        "botan_privkey_load",
 };