Teach EVP_PKEY_HMAC keys how to EVP_PKEY_cmp()
authorNathaniel McCallum <npmccallum@redhat.com>
Mon, 20 Jun 2016 07:47:11 +0000 (03:47 -0400)
committerRich Salz <rsalz@openssl.org>
Fri, 24 Jun 2016 16:31:31 +0000 (12:31 -0400)
Fixes openssl/openssl#1236

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1237)

crypto/hmac/hm_ameth.c

index 714068dc6860351916fd97c5e05e4f726e9e0e70..78ae0ea63a867cf73fd089712da1e7080512ab28 100644 (file)
@@ -46,6 +46,11 @@ static int hmac_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
     }
 }
 
+static int hmac_pkey_public_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
+{
+    return ASN1_OCTET_STRING_cmp(EVP_PKEY_get0(a), EVP_PKEY_get0(b));
+}
+
 #ifdef HMAC_TEST_PRIVATE_KEY_FORMAT
 /*
  * A bogus private key format for test purposes. This is simply the HMAC key
@@ -101,7 +106,7 @@ const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = {
     "HMAC",
     "OpenSSL HMAC method",
 
-    0, 0, 0, 0,
+    0, 0, hmac_pkey_public_cmp, 0,
 
     0, 0, 0,