aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-12-27 10:51:23 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-02-04 18:37:03 +0100
commitb4823252ca1acd819a2133e7b261dc474ebcde1c (patch)
treeceb26ffd8aa703c0d473579424a88f557c75ac90 /src
parent244fa0474bb7067284a373f511dfa37dd82bf448 (diff)
downloadlibssh-b4823252ca1acd819a2133e7b261dc474ebcde1c.tar.gz
libssh-b4823252ca1acd819a2133e7b261dc474ebcde1c.tar.xz
libssh-b4823252ca1acd819a2133e7b261dc474ebcde1c.zip
pki: Add ECDSA for key compare.
Diffstat (limited to 'src')
-rw-r--r--src/pki_crypto.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pki_crypto.c b/src/pki_crypto.c
index 41505a7c..ca7a5b21 100644
--- a/src/pki_crypto.c
+++ b/src/pki_crypto.c
@@ -318,6 +318,35 @@ int pki_key_compare(const ssh_key k1,
}
break;
case SSH_KEYTYPE_ECDSA:
+#ifdef HAVE_OPENSSL_ECC
+ {
+ const EC_POINT *p1 = EC_KEY_get0_public_key(k1->ecdsa);
+ const EC_POINT *p2 = EC_KEY_get0_public_key(k2->ecdsa);
+ const EC_GROUP *g1 = EC_KEY_get0_group(k1->ecdsa);
+ const EC_GROUP *g2 = EC_KEY_get0_group(k2->ecdsa);
+
+ if (p1 == NULL || p2 == NULL) {
+ return 1;
+ }
+
+ if (EC_GROUP_cmp(g1, g2, NULL) != 0) {
+ return 1;
+ }
+
+ if (EC_POINT_cmp(g1, p1, p2, NULL) != 0) {
+ return 1;
+ }
+
+ if (what == SSH_KEY_CMP_PRIVATE) {
+ if (bignum_cmp(EC_KEY_get0_private_key(k1->ecdsa),
+ EC_KEY_get0_private_key(k2->ecdsa))) {
+ return 1;
+ }
+ }
+
+ break;
+ }
+#endif
case SSH_KEYTYPE_UNKNOWN:
return 1;
}