Blob Blame History Raw
From 3cc1bcebd9da74f8d2fa8648e076ba715e76c657 Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Fri, 25 May 2018 18:43:32 +0200
Subject: [PATCH] Fix the build with older gcrypt in RHEL 7

Use deprecated GCRY_PK_ECDSA instead of GCRY_PK_ECC (which will be
mapped to GCRY_PK_ECC in newer versions).
---
 pkcs11/gkm/gkm-crypto.c            |  4 ++--
 pkcs11/gkm/gkm-data-der.c          | 10 +++++-----
 pkcs11/gkm/gkm-private-xsa-key.c   |  4 ++--
 pkcs11/gkm/gkm-public-xsa-key.c    |  4 ++--
 pkcs11/gkm/gkm-sexp-key.c          |  4 ++--
 pkcs11/gkm/gkm-sexp.c              |  2 +-
 pkcs11/gkm/test-sexp.c             |  2 +-
 pkcs11/ssh-store/gkm-ssh-openssh.c |  4 ++--
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/pkcs11/gkm/gkm-crypto.c b/pkcs11/gkm/gkm-crypto.c
index 7195e0a..cafe251 100644
--- a/pkcs11/gkm/gkm-crypto.c
+++ b/pkcs11/gkm/gkm-crypto.c
@@ -306,7 +306,7 @@ gkm_crypto_sign_xsa (gcry_sexp_t sexp, CK_MECHANISM_TYPE mech, CK_BYTE_PTR data,
 		rv = gkm_dsa_mechanism_sign (sexp, data, n_data, signature, n_signature);
 		break;
 	case CKM_ECDSA:
-		g_return_val_if_fail (algorithm == GCRY_PK_ECC, CKR_GENERAL_ERROR);
+		g_return_val_if_fail (algorithm == GCRY_PK_ECDSA, CKR_GENERAL_ERROR);
 		rv = gkm_ecdsa_mechanism_sign (sexp, data, n_data, signature, n_signature);
 		break;
 	default:
@@ -370,7 +370,7 @@ gkm_crypto_verify_xsa (gcry_sexp_t sexp, CK_MECHANISM_TYPE mech, CK_BYTE_PTR dat
 		rv = gkm_dsa_mechanism_verify (sexp, data, n_data, signature, n_signature);
 		break;
 	case CKM_ECDSA:
-		g_return_val_if_fail (algorithm == GCRY_PK_ECC, CKR_GENERAL_ERROR);
+		g_return_val_if_fail (algorithm == GCRY_PK_ECDSA, CKR_GENERAL_ERROR);
 		rv = gkm_ecdsa_mechanism_verify (sexp, data, n_data, signature, n_signature);
 		break;
 	default:
diff --git a/pkcs11/gkm/gkm-data-der.c b/pkcs11/gkm/gkm-data-der.c
index 68f41d4..2f91eaf 100644
--- a/pkcs11/gkm/gkm-data-der.c
+++ b/pkcs11/gkm/gkm-data-der.c
@@ -800,7 +800,7 @@ gkm_data_der_read_private_pkcs8_plain (GBytes *data,
 	else if (key_algo == OID_PKIX1_DSA)
 		algorithm = GCRY_PK_DSA;
 	else if (key_algo == OID_PKIX1_ECDSA)
-		algorithm = GCRY_PK_ECC;
+		algorithm = GCRY_PK_ECDSA;
 
 	if (!algorithm) {
 		ret = GKM_DATA_UNRECOGNIZED;
@@ -829,7 +829,7 @@ done:
 			if (ret == GKM_DATA_UNRECOGNIZED && params)
 				ret = gkm_data_der_read_private_key_dsa_parts (keydata, params, s_key);
 			break;
-		case GCRY_PK_ECC:
+		case GCRY_PK_ECDSA:
 			ret = gkm_data_der_read_private_key_ecdsa (keydata, s_key);
 			break;
 		default:
@@ -1325,7 +1325,7 @@ gkm_data_der_write_public_key (gcry_sexp_t s_key)
 		return gkm_data_der_write_public_key_rsa (s_key);
 	case GCRY_PK_DSA:
 		return gkm_data_der_write_public_key_dsa (s_key);
-	case GCRY_PK_ECC:
+	case GCRY_PK_ECDSA:
 		return gkm_data_der_write_public_key_ecdsa (s_key);
 	default:
 		g_return_val_if_reached (NULL);
@@ -1350,7 +1350,7 @@ gkm_data_der_write_private_key (gcry_sexp_t s_key)
 		return gkm_data_der_write_private_key_rsa (s_key);
 	case GCRY_PK_DSA:
 		return gkm_data_der_write_private_key_dsa (s_key);
-	case GCRY_PK_ECC:
+	case GCRY_PK_ECDSA:
 		return gkm_data_der_write_private_key_ecdsa (s_key);
 	default:
 		g_return_val_if_reached (NULL);
@@ -1460,7 +1460,7 @@ gkm_data_der_write_private_pkcs8_plain (gcry_sexp_t skey)
 		params = gkm_data_der_write_private_key_dsa_params (skey);
 		break;
 
-	case GCRY_PK_ECC:
+	case GCRY_PK_ECDSA:
 		oid = OID_PKIX1_ECDSA;
 		params = NULL;
 		key = gkm_data_der_write_private_key_ecdsa (skey);
diff --git a/pkcs11/gkm/gkm-private-xsa-key.c b/pkcs11/gkm/gkm-private-xsa-key.c
index 3dbbd12..878d5f0 100644
--- a/pkcs11/gkm/gkm-private-xsa-key.c
+++ b/pkcs11/gkm/gkm-private-xsa-key.c
@@ -361,10 +361,10 @@ gkm_private_xsa_key_real_get_attribute (GkmObject *base, GkmSession *session, CK
 		return gkm_sexp_key_set_part (GKM_SEXP_KEY (self), GCRY_PK_DSA, "g", attr);
 
 	case CKA_EC_POINT:
-		return gkm_sexp_key_set_ec_q (GKM_SEXP_KEY (self), GCRY_PK_ECC, attr);
+		return gkm_sexp_key_set_ec_q (GKM_SEXP_KEY (self), GCRY_PK_ECDSA, attr);
 
 	case CKA_EC_PARAMS:
-		return gkm_sexp_key_set_ec_params (GKM_SEXP_KEY (self), GCRY_PK_ECC, attr);
+		return gkm_sexp_key_set_ec_params (GKM_SEXP_KEY (self), GCRY_PK_ECDSA, attr);
 
 	/* (EC)DSA private parts */
 	case CKA_VALUE:
diff --git a/pkcs11/gkm/gkm-public-xsa-key.c b/pkcs11/gkm/gkm-public-xsa-key.c
index 5cc93f3..fced172 100644
--- a/pkcs11/gkm/gkm-public-xsa-key.c
+++ b/pkcs11/gkm/gkm-public-xsa-key.c
@@ -267,10 +267,10 @@ gkm_public_xsa_key_real_get_attribute (GkmObject *base, GkmSession *session, CK_
 		return gkm_sexp_key_set_part (GKM_SEXP_KEY (self), GCRY_PK_DSA, "y", attr);
 
 	case CKA_EC_POINT:
-		return gkm_sexp_key_set_ec_q (GKM_SEXP_KEY (self), GCRY_PK_ECC, attr);
+		return gkm_sexp_key_set_ec_q (GKM_SEXP_KEY (self), GCRY_PK_ECDSA, attr);
 
 	case CKA_EC_PARAMS:
-		return gkm_sexp_key_set_ec_params (GKM_SEXP_KEY (self), GCRY_PK_ECC, attr);
+		return gkm_sexp_key_set_ec_params (GKM_SEXP_KEY (self), GCRY_PK_ECDSA, attr);
 	};
 
 	return GKM_OBJECT_CLASS (gkm_public_xsa_key_parent_class)->get_attribute (base, session, attr);
diff --git a/pkcs11/gkm/gkm-sexp-key.c b/pkcs11/gkm/gkm-sexp-key.c
index 8b98bdc..9d0f233 100644
--- a/pkcs11/gkm/gkm-sexp-key.c
+++ b/pkcs11/gkm/gkm-sexp-key.c
@@ -65,7 +65,7 @@ gkm_sexp_key_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATTRIB
 				return gkm_attribute_set_ulong (attr, CKK_RSA);
 			case GCRY_PK_DSA:
 				return gkm_attribute_set_ulong (attr, CKK_DSA);
-			case GCRY_PK_ECC:
+			case GCRY_PK_ECDSA:
 				return gkm_attribute_set_ulong (attr, CKK_ECDSA);
 			default:
 				g_return_val_if_reached (CKR_GENERAL_ERROR);
@@ -104,7 +104,7 @@ gkm_sexp_key_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATTRIB
 		case GCRY_PK_DSA:
 			return gkm_attribute_set_data (attr, (CK_VOID_PTR)GKM_DSA_MECHANISMS,
 			                               sizeof (GKM_DSA_MECHANISMS));
-		case GCRY_PK_ECC:
+		case GCRY_PK_ECDSA:
 			return gkm_attribute_set_data (attr, (CK_VOID_PTR)GKM_ECDSA_MECHANISMS,
 			                               sizeof (GKM_ECDSA_MECHANISMS));
 		default:
diff --git a/pkcs11/gkm/gkm-sexp.c b/pkcs11/gkm/gkm-sexp.c
index 287f874..d2c8a53 100644
--- a/pkcs11/gkm/gkm-sexp.c
+++ b/pkcs11/gkm/gkm-sexp.c
@@ -235,7 +235,7 @@ gkm_sexp_key_to_public (gcry_sexp_t privkey, gcry_sexp_t *pubkey)
 	case GCRY_PK_DSA:
 		*pubkey = dsa_numbers_to_public (numbers);
 		break;
-	case GCRY_PK_ECC:
+	case GCRY_PK_ECDSA:
 		*pubkey = ecdsa_numbers_to_public (numbers);
 		break;
 	default:
diff --git a/pkcs11/gkm/test-sexp.c b/pkcs11/gkm/test-sexp.c
index ba104a0..78cc08e 100644
--- a/pkcs11/gkm/test-sexp.c
+++ b/pkcs11/gkm/test-sexp.c
@@ -152,7 +152,7 @@ test_parse_key (Test *test, gconstpointer unused)
 	/* Get the private key out */
 	ret = gkm_sexp_parse_key (test->ecdsakey, &algorithm, &is_priv, &sexp);
 	g_assert (ret);
-	g_assert (algorithm == GCRY_PK_ECC);
+	g_assert (algorithm == GCRY_PK_ECDSA);
 	g_assert (is_priv == TRUE);
 	g_assert (sexp != NULL);
 	gcry_sexp_release (sexp);
diff --git a/pkcs11/ssh-store/gkm-ssh-openssh.c b/pkcs11/ssh-store/gkm-ssh-openssh.c
index 6c21264..c1644d5 100644
--- a/pkcs11/ssh-store/gkm-ssh-openssh.c
+++ b/pkcs11/ssh-store/gkm-ssh-openssh.c
@@ -34,7 +34,7 @@ keytype_to_algo (const gchar *salgo)
 	else if ((strcmp (salgo, "ecdsa-sha2-nistp256") == 0)
 	    || (strcmp (salgo, "ecdsa-sha2-nistp384") == 0)
 	    || (strcmp (salgo, "ecdsa-sha2-nistp521") == 0))
-		return GCRY_PK_ECC;
+		return GCRY_PK_ECDSA;
 	return 0;
 }
 
@@ -190,7 +190,7 @@ read_public (EggBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo)
 	case GCRY_PK_DSA:
 		ret = read_public_dsa (req, offset, key);
 		break;
-	case GCRY_PK_ECC:
+	case GCRY_PK_ECDSA:
 		ret = read_public_ecdsa (req, offset, key);
 		break;
 	default:
-- 
1.8.3.1