aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2019-08-22 18:25:09 +0200
committerAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2019-09-24 16:49:35 +0200
commit7452f0ded89795d16f0c7e82eca84f6e2bd89b3f (patch)
tree2f2beef4815cfce4e22c79cd8023fdfbc0581ab2 /tests
parent7ffa3c358d727a711dc26806f3c07c9add584e5c (diff)
downloadlibssh-7452f0ded89795d16f0c7e82eca84f6e2bd89b3f.tar.gz
libssh-7452f0ded89795d16f0c7e82eca84f6e2bd89b3f.tar.xz
libssh-7452f0ded89795d16f0c7e82eca84f6e2bd89b3f.zip
torture_pki_ed25519: Use public key to verify signatures
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/torture_pki_ed25519.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/unittests/torture_pki_ed25519.c b/tests/unittests/torture_pki_ed25519.c
index 56b3e0b1..94d9c7f9 100644
--- a/tests/unittests/torture_pki_ed25519.c
+++ b/tests/unittests/torture_pki_ed25519.c
@@ -417,7 +417,7 @@ static void torture_pki_ed25519_generate_pubkey_from_privkey(void **state)
static void torture_pki_ed25519_generate_key(void **state)
{
int rc;
- ssh_key key = NULL;
+ ssh_key key = NULL, pubkey = NULL;
ssh_signature sign = NULL;
enum ssh_keytypes_e type = SSH_KEYTYPE_UNKNOWN;
const char *type_char = NULL;
@@ -427,9 +427,12 @@ static void torture_pki_ed25519_generate_key(void **state)
rc = ssh_pki_generate(SSH_KEYTYPE_ED25519, 256, &key);
assert_true(rc == SSH_OK);
assert_non_null(key);
+ rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey);
+ assert_int_equal(rc, SSH_OK);
+ assert_non_null(pubkey);
sign = pki_do_sign(key, HASH, 20, SSH_DIGEST_AUTO);
assert_non_null(sign);
- rc = pki_signature_verify(session,sign,key,HASH,20);
+ rc = pki_signature_verify(session, sign, pubkey, HASH, 20);
assert_true(rc == SSH_OK);
type = ssh_key_type(key);
assert_true(type == SSH_KEYTYPE_ED25519);
@@ -438,11 +441,12 @@ static void torture_pki_ed25519_generate_key(void **state)
/* try an invalid signature */
(*sign->ed25519_sig)[3]^= 0xff;
- rc = pki_signature_verify(session,sign,key,HASH,20);
+ rc = pki_signature_verify(session, sign, pubkey, HASH, 20);
assert_true(rc == SSH_ERROR);
ssh_signature_free(sign);
SSH_KEY_FREE(key);
+ SSH_KEY_FREE(pubkey);
ssh_free(session);
}