int len, EVP_KEYMGMT *keymgmt);
static void evp_pkey_free_it(EVP_PKEY *key);
-#ifndef FIPS_MODULE
-
/* The type of parameters selected in key parameter functions */
# define SELECT_PARAMETERS OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS
+#ifndef FIPS_MODULE
int EVP_PKEY_get_bits(const EVP_PKEY *pkey)
{
int size = 0;
{
return CRYPTO_get_ex_data(&key->ex_data, idx);
}
+#endif /* !FIPS_MODULE */
int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
{
EVP_PKEY *downgraded_from = NULL;
int ok = 0;
+#ifndef FIPS_MODULE
/*
* If |to| is a legacy key and |from| isn't, we must make a downgraded
* copy of |from|. If that fails, this function fails.
goto end;
from = downgraded_from;
}
+#endif /* !FIPS_MODULE */
/*
* Make sure |to| is typed. Content is less important at this early
* further down help us find out if they are the same or not.
*/
if (evp_pkey_is_blank(to)) {
+#ifndef FIPS_MODULE
if (evp_pkey_is_legacy(from)) {
if (EVP_PKEY_set_type(to, from->type) == 0)
goto end;
- } else {
+ } else
+#endif /* !FIPS_MODULE */
+ {
if (EVP_PKEY_set_type_by_keymgmt(to, from->keymgmt) == 0)
goto end;
}
- } else if (evp_pkey_is_legacy(to)) {
+ }
+#ifndef FIPS_MODULE
+ else if (evp_pkey_is_legacy(to)) {
if (to->type != from->type) {
ERR_raise(ERR_LIB_EVP, EVP_R_DIFFERENT_KEY_TYPES);
goto end;
}
}
+#endif /* !FIPS_MODULE */
if (EVP_PKEY_missing_parameters(from)) {
ERR_raise(ERR_LIB_EVP, EVP_R_MISSING_PARAMETERS);
goto end;
}
+#ifndef FIPS_MODULE
/*
* If |to| is provided, we know that |from| is legacy at this point.
* Try exporting |from| to |to|'s keymgmt, then use evp_keymgmt_dup()
/* Both keys are legacy */
if (from->ameth != NULL && from->ameth->param_copy != NULL)
ok = from->ameth->param_copy(to, from);
+#endif /* !FIPS_MODULE */
end:
EVP_PKEY_free(downgraded_from);
return ok;
int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)
{
if (pkey != NULL) {
+#ifdef FIPS_MODULE
+ return !evp_keymgmt_util_has((EVP_PKEY *)pkey, SELECT_PARAMETERS);
+#else
if (pkey->keymgmt != NULL)
return !evp_keymgmt_util_has((EVP_PKEY *)pkey, SELECT_PARAMETERS);
- else if (pkey->ameth != NULL && pkey->ameth->param_missing != NULL)
+ if (pkey->ameth != NULL && pkey->ameth->param_missing != NULL)
return pkey->ameth->param_missing(pkey);
+#endif /* FIPS_MODULE */
}
return 0;
}
static int evp_pkey_cmp_any(const EVP_PKEY *a, const EVP_PKEY *b,
int selection)
{
+#ifdef FIPS_MODULE
+ return evp_keymgmt_util_match((EVP_PKEY *)a, (EVP_PKEY *)b, selection);
+#else
EVP_KEYMGMT *keymgmt1 = NULL, *keymgmt2 = NULL;
void *keydata1 = NULL, *keydata2 = NULL, *tmp_keydata = NULL;
return -2;
return evp_keymgmt_match(keymgmt1, keydata1, keydata2, selection);
+#endif /* FIPS_MODULE */
}
+#ifndef FIPS_MODULE
# ifndef OPENSSL_NO_DEPRECATED_3_0
int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
{
return EVP_PKEY_parameters_eq(a, b);
}
-#endif
+# endif
+#endif /* FIPS_MODULE */
int EVP_PKEY_parameters_eq(const EVP_PKEY *a, const EVP_PKEY *b)
{
+#ifdef FIPS_MODULE
+ return evp_pkey_cmp_any(a, b, SELECT_PARAMETERS);
+#else
/*
* This will just call evp_keymgmt_util_match when legacy support
* is gone.
if (a->ameth != NULL && a->ameth->param_cmp != NULL)
return a->ameth->param_cmp(a, b);
return -2;
+#endif /* !FIPS_MODULE */
}
+#ifndef FIPS_MODULE
# ifndef OPENSSL_NO_DEPRECATED_3_0
int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
{
return EVP_PKEY_eq(a, b);
}
-#endif
+# endif
+#endif /* !FIPS_MODULE */
int EVP_PKEY_eq(const EVP_PKEY *a, const EVP_PKEY *b)
{
if (a == NULL || b == NULL)
return 0;
- if (a->keymgmt != NULL || b->keymgmt != NULL) {
+#ifndef FIPS_MODULE
+ if (a->keymgmt != NULL || b->keymgmt != NULL)
+#endif /* !FIPS_MODULE */
+ {
int selection = SELECT_PARAMETERS;
if (evp_keymgmt_util_has((EVP_PKEY *)a, OSSL_KEYMGMT_SELECT_PUBLIC_KEY)
return evp_pkey_cmp_any(a, b, selection);
}
+#ifndef FIPS_MODULE
/* All legacy keys */
if (a->type != b->type)
return -1;
}
return -2;
+#endif /* !FIPS_MODULE */
}
-
+#ifndef FIPS_MODULE
static EVP_PKEY *new_raw_key_int(OSSL_LIB_CTX *libctx,
const char *strtype,
const char *propq,
EVP_MD_CTX_free(ctx);
return rv;
}
+#endif /* !FIPS_MODULE */
int EVP_PKEY_set1_encoded_public_key(EVP_PKEY *pkey, const unsigned char *pub,
size_t publen)
{
if (pkey == NULL)
return 0;
+#ifndef FIPS_MODULE
if (evp_pkey_is_provided(pkey))
+#endif /* !FIPS_MODULE */
return
EVP_PKEY_set_octet_string_param(pkey,
OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY,
(unsigned char *)pub, publen);
+#ifndef FIPS_MODULE
if (publen > INT_MAX)
return 0;
/* Historically this function was EVP_PKEY_set1_tls_encodedpoint */
(void *)pub) <= 0)
return 0;
return 1;
+#endif /* !FIPS_MODULE */
}
size_t EVP_PKEY_get1_encoded_public_key(EVP_PKEY *pkey, unsigned char **ppub)
{
- int rv;
-
if (pkey == NULL)
return 0;
- if (evp_pkey_is_provided(pkey)) {
+#ifndef FIPS_MODULE
+ if (evp_pkey_is_provided(pkey))
+#endif
+ {
size_t return_size = OSSL_PARAM_UNMODIFIED;
unsigned char *buf;
return return_size;
}
-
- rv = evp_pkey_asn1_ctrl(pkey, ASN1_PKEY_CTRL_GET1_TLS_ENCPT, 0, ppub);
- if (rv <= 0)
- return 0;
- return rv;
+#ifndef FIPS_MODULE
+ {
+ int rv = evp_pkey_asn1_ctrl(pkey, ASN1_PKEY_CTRL_GET1_TLS_ENCPT, 0, ppub);
+ if (rv <= 0)
+ return 0;
+ return rv;
+ }
+#endif /* !FIPS_MODULE */
}
-#endif /* FIPS_MODULE */
-
/*- All methods below can also be used in FIPS_MODULE */
EVP_PKEY *EVP_PKEY_new(void)
return ((i > 1) ? 1 : 0);
}
-#ifndef FIPS_MODULE
EVP_PKEY *EVP_PKEY_dup(EVP_PKEY *pkey)
{
EVP_PKEY *dup_pk;
if (evp_pkey_is_blank(pkey))
goto done;
- if (evp_pkey_is_provided(pkey)) {
+#ifndef FIPS_MODULE
+ if (evp_pkey_is_provided(pkey))
+#endif /* !FIPS_MODULE */
+ {
if (!evp_keymgmt_util_copy(dup_pk, pkey,
OSSL_KEYMGMT_SELECT_ALL))
goto err;
goto done;
}
+#ifndef FIPS_MODULE
if (evp_pkey_is_legacy(pkey)) {
const EVP_PKEY_ASN1_METHOD *ameth = pkey->ameth;
goto err;
goto done;
}
+#endif /* !FIPS_MODULE */
goto err;
done:
+#ifndef FIPS_MODULE
/* copy auxiliary data */
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_EVP_PKEY,
&dup_pk->ex_data, &pkey->ex_data))
if ((dup_pk->attributes = ossl_x509at_dup(pkey->attributes)) == NULL)
goto err;
}
+#endif /* !FIPS_MODULE */
return dup_pk;
err:
EVP_PKEY_free(dup_pk);
return NULL;
}
+#ifndef FIPS_MODULE
void evp_pkey_free_legacy(EVP_PKEY *x)
{
const EVP_PKEY_ASN1_METHOD *ameth = x->ameth;