if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
test x$enable_nistp521 = x1; then
AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
+ AC_CHECK_FUNCS([EC_KEY_METHOD_new])
fi
if test x$enable_nistp256 = x1; then
AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
return (ret);
}
+#ifdef HAVE_EC_KEY_METHOD_NEW
static ECDSA_SIG *
ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv,
const BIGNUM *rp, EC_KEY *ec)
sshbuf_free(msg);
return (ret);
}
+#endif /* HAVE_EC_KEY_METHOD_NEW */
static RSA_METHOD *helper_rsa;
+#ifdef HAVE_EC_KEY_METHOD_NEW
static EC_KEY_METHOD *helper_ecdsa;
+#endif /* HAVE_EC_KEY_METHOD_NEW */
/* redirect private key crypto operations to the ssh-pkcs11-helper */
static void
{
if (k->type == KEY_RSA)
RSA_set_method(k->rsa, helper_rsa);
+#ifdef HAVE_EC_KEY_METHOD_NEW
else if (k->type == KEY_ECDSA)
EC_KEY_set_method(k->ecdsa, helper_ecdsa);
+#endif /* HAVE_EC_KEY_METHOD_NEW */
else
fatal("%s: unknown key type", __func__);
}
static int
pkcs11_start_helper_methods(void)
{
- if (helper_ecdsa != NULL)
+ if (helper_rsa != NULL)
return (0);
+#ifdef HAVE_EC_KEY_METHOD_NEW
int (*orig_sign)(int, const unsigned char *, int, unsigned char *,
unsigned int *, const BIGNUM *, const BIGNUM *, EC_KEY *) = NULL;
if (helper_ecdsa != NULL)
return (-1);
EC_KEY_METHOD_get_sign(helper_ecdsa, &orig_sign, NULL, NULL);
EC_KEY_METHOD_set_sign(helper_ecdsa, orig_sign, NULL, ecdsa_do_sign);
+#endif /* HAVE_EC_KEY_METHOD_NEW */
if ((helper_rsa = RSA_meth_dup(RSA_get_default_method())) == NULL)
fatal("%s: RSA_meth_dup failed", __func__);
return (0);
}
+#ifdef HAVE_EC_KEY_METHOD_NEW
/* openssl callback doing the actual signing operation */
static ECDSA_SIG *
ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv,
return (0);
}
+#endif /* HAVE_EC_KEY_METHOD_NEW */
/* remove trailing spaces */
static void
return (0);
}
+#ifdef HAVE_EC_KEY_METHOD_NEW
static struct sshkey *
pkcs11_fetch_ecdsa_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx,
CK_OBJECT_HANDLE *obj)
return (key);
}
+#endif /* HAVE_EC_KEY_METHOD_NEW */
static struct sshkey *
pkcs11_fetch_rsa_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx,
EC_KEY *ec = NULL;
struct sshkey *key = NULL;
int i;
+#ifdef HAVE_EC_KEY_METHOD_NEW
int nid;
+#endif
const u_char *cp;
memset(&cert_attr, 0, sizeof(cert_attr));
key->type = KEY_RSA;
key->flags |= SSHKEY_FLAG_EXT;
rsa = NULL; /* now owned by key */
+#ifdef HAVE_EC_KEY_METHOD_NEW
} else if (EVP_PKEY_base_id(evp) == EVP_PKEY_EC) {
if (EVP_PKEY_get0_EC_KEY(evp) == NULL) {
error("invalid x509; no ec key");
key->type = KEY_ECDSA;
key->flags |= SSHKEY_FLAG_EXT;
ec = NULL; /* now owned by key */
+#endif /* HAVE_EC_KEY_METHOD_NEW */
} else
error("unknown certificate key type");
case CKK_RSA:
key = pkcs11_fetch_rsa_pubkey(p, slotidx, &obj);
break;
+#ifdef HAVE_EC_KEY_METHOD_NEW
case CKK_ECDSA:
key = pkcs11_fetch_ecdsa_pubkey(p, slotidx, &obj);
break;
+#endif /* HAVE_EC_KEY_METHOD_NEW */
default:
/* XXX print key type? */
error("skipping unsupported key type");