# endif
#endif
-/*
- * TODO(3.0) Modify PEM_write_bio_PrivateKey_traditional() to handle
- * provider side EVP_PKEYs (which don't necessarily have an ameth)
- *
- * In the mean time, we use separate "downgraded" EVP_PKEYs to test
- * encoding/decoding with "traditional" keys.
- */
-
static EVP_PKEY *make_template(const char *type, OSSL_PARAM *genparams)
{
EVP_PKEY *pkey = NULL;
}
static EVP_PKEY *make_key(const char *type, EVP_PKEY *template,
- OSSL_PARAM *genparams, int make_legacy)
+ OSSL_PARAM *genparams)
{
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *ctx =
|| EVP_PKEY_CTX_set_params(ctx, genparams) > 0)
&& EVP_PKEY_keygen(ctx, &pkey) > 0);
EVP_PKEY_CTX_free(ctx);
- if (make_legacy && EVP_PKEY_get0(pkey) == NULL) {
- EVP_PKEY_free(pkey);
- pkey = NULL;
- }
-
return pkey;
}
*/
typedef int (encoder)(void **encoded, long *encoded_len,
- void *object, const char *pass, const char *pcipher,
- const char *encoder_propq);
+ void *object, const char *pass, const char *pcipher,
+ const char *encoder_propq);
typedef int (decoder)(void **object,
- void *encoded, long encoded_len,
- const char *pass);
+ void *encoded, long encoded_len,
+ const char *pass);
typedef int (tester)(const void *data1, size_t data1_len,
const void *data2, size_t data2_len);
typedef int (checker)(const char *type, const void *data, size_t data_len);
typedef void (dumper)(const char *label, const void *data, size_t data_len);
static int test_encode_decode(const char *type, EVP_PKEY *pkey,
- const char *pass, const char *pcipher,
- encoder *encode_cb,
- decoder *decode_cb,
- tester *test_cb,
- checker *check_cb, dumper *dump_cb,
- const char *encoder_propq, int make_legacy)
+ const char *pass, const char *pcipher,
+ encoder *encode_cb, decoder *decode_cb,
+ tester *test_cb, checker *check_cb,
+ dumper *dump_cb, const char *encoder_propq)
{
void *encoded = NULL;
long encoded_len = 0;
|| !TEST_int_eq(EVP_PKEY_eq(pkey, pkey2), 1))
goto end;
- /*
- * TODO(3.0) Remove this when PEM_write_bio_PrivateKey_traditional()
- * handles provider side keys.
- */
- if (make_legacy
- && !TEST_ptr(EVP_PKEY_get0(pkey2)))
- goto end;
-
/*
* Double check the encoding, but only for unprotected keys,
* as protected keys have a random component, which makes the output
/* Encoding and desencoding methods */
static int encode_EVP_PKEY_prov(void **encoded, long *encoded_len,
- void *object,
- const char *pass, const char *pcipher,
- const char *encoder_propq)
+ void *object,
+ const char *pass, const char *pcipher,
+ const char *encoder_propq)
{
EVP_PKEY *pkey = object;
OSSL_ENCODER_CTX *ectx = NULL;
}
static int decode_EVP_PKEY_prov(void **object,
- void *encoded, long encoded_len,
- const char *pass)
+ void *encoded, long encoded_len,
+ const char *pass)
{
EVP_PKEY *pkey = NULL;
OSSL_DECODER_CTX *dctx = NULL;
}
static int encode_EVP_PKEY_legacy_PEM(void **encoded,
- long *encoded_len,
- void *object,
- const char *pass, const char *pcipher,
- ossl_unused const char *encoder_propq)
+ long *encoded_len,
+ void *object,
+ const char *pass, const char *pcipher,
+ ossl_unused const char *encoder_propq)
{
EVP_PKEY *pkey = object;
EVP_CIPHER *cipher = NULL;
}
#ifndef OPENSSL_NO_DSA
-static int encode_EVP_PKEY_MSBLOB(void **encoded,
- long *encoded_len,
- void *object,
- ossl_unused const char *pass,
- ossl_unused const char *pcipher,
- ossl_unused const char *encoder_propq)
+static int encode_EVP_PKEY_MSBLOB(void **encoded, long *encoded_len,
+ void *object,
+ ossl_unused const char *pass,
+ ossl_unused const char *pcipher,
+ ossl_unused const char *encoder_propq)
{
EVP_PKEY *pkey = object;
BIO *mem_ser = NULL;
return ok;
}
-static int encode_public_EVP_PKEY_MSBLOB(void **encoded,
- long *encoded_len,
- void *object,
- ossl_unused const char *pass,
- ossl_unused const char *pcipher,
- ossl_unused const char *encoder_propq)
+static int encode_public_EVP_PKEY_MSBLOB(void **encoded, long *encoded_len,
+ void *object,
+ ossl_unused const char *pass,
+ ossl_unused const char *pcipher,
+ ossl_unused const char *encoder_propq)
{
EVP_PKEY *pkey = object;
BIO *mem_ser = NULL;
}
static int encode_EVP_PKEY_PVK(void **encoded, long *encoded_len,
- void *object,
- const char *pass,
- ossl_unused const char *pcipher,
- ossl_unused const char *encoder_propq)
+ void *object,
+ const char *pass,
+ ossl_unused const char *pcipher,
+ ossl_unused const char *encoder_propq)
{
EVP_PKEY *pkey = object;
BIO *mem_ser = NULL;
static int test_unprotected_via_DER(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_prov,
- decode_EVP_PKEY_prov,
- test_mem,
- check_unprotected_PKCS8_DER, dump_der,
- OSSL_ENCODER_PrivateKey_TO_DER_PQ,
- 0);
+ encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
+ test_mem, check_unprotected_PKCS8_DER, dump_der,
+ OSSL_ENCODER_PrivateKey_TO_DER_PQ);
}
static int check_unprotected_PKCS8_PEM(const char *type,
static int test_unprotected_via_PEM(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_prov,
- decode_EVP_PKEY_prov,
- test_text,
- check_unprotected_PKCS8_PEM, dump_pem,
- OSSL_ENCODER_PrivateKey_TO_PEM_PQ,
- 0);
+ encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
+ test_text, check_unprotected_PKCS8_PEM, dump_pem,
+ OSSL_ENCODER_PrivateKey_TO_PEM_PQ);
}
static int check_unprotected_legacy_PEM(const char *type,
static int test_unprotected_via_legacy_PEM(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_legacy_PEM,
- decode_EVP_PKEY_prov,
- test_text,
- check_unprotected_legacy_PEM, dump_pem,
- NULL, 1);
+ encode_EVP_PKEY_legacy_PEM, decode_EVP_PKEY_prov,
+ test_text, check_unprotected_legacy_PEM, dump_pem,
+ NULL);
}
#ifndef OPENSSL_NO_DSA
static int test_unprotected_via_MSBLOB(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_MSBLOB,
- decode_EVP_PKEY_prov,
- test_mem,
- check_MSBLOB, dump_der,
- NULL, 0);
+ encode_EVP_PKEY_MSBLOB, decode_EVP_PKEY_prov,
+ test_mem, check_MSBLOB, dump_der,
+ NULL);
}
# ifndef OPENSSL_NO_RC4
static int test_unprotected_via_PVK(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_PVK,
- decode_EVP_PKEY_prov,
- test_mem,
- check_PVK, dump_der,
- NULL, 0);
+ encode_EVP_PKEY_PVK, decode_EVP_PKEY_prov,
+ test_mem, check_PVK, dump_der,
+ NULL);
}
# endif
#endif
static int test_protected_via_DER(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, pass, pass_cipher,
- encode_EVP_PKEY_prov,
- decode_EVP_PKEY_prov,
- test_mem,
- check_protected_PKCS8_DER, dump_der,
- OSSL_ENCODER_PrivateKey_TO_DER_PQ,
- 0);
+ encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
+ test_mem, check_protected_PKCS8_DER, dump_der,
+ OSSL_ENCODER_PrivateKey_TO_DER_PQ);
}
static int check_protected_PKCS8_PEM(const char *type,
static int test_protected_via_PEM(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, pass, pass_cipher,
- encode_EVP_PKEY_prov,
- decode_EVP_PKEY_prov,
- test_text,
- check_protected_PKCS8_PEM, dump_pem,
- OSSL_ENCODER_PrivateKey_TO_PEM_PQ,
- 0);
+ encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
+ test_text, check_protected_PKCS8_PEM, dump_pem,
+ OSSL_ENCODER_PrivateKey_TO_PEM_PQ);
}
static int check_protected_legacy_PEM(const char *type,
static int test_protected_via_legacy_PEM(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, pass, pass_cipher,
- encode_EVP_PKEY_legacy_PEM,
- decode_EVP_PKEY_prov,
- test_text,
- check_protected_legacy_PEM, dump_pem,
- NULL, 1);
+ encode_EVP_PKEY_legacy_PEM, decode_EVP_PKEY_prov,
+ test_text, check_protected_legacy_PEM, dump_pem,
+ NULL);
}
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
static int test_protected_via_PVK(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, pass, NULL,
- encode_EVP_PKEY_PVK,
- decode_EVP_PKEY_prov,
- test_mem,
- check_PVK, dump_der,
- NULL, 0);
+ encode_EVP_PKEY_PVK, decode_EVP_PKEY_prov,
+ test_mem, check_PVK, dump_der,
+ NULL);
}
#endif
static int test_public_via_DER(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_prov,
- decode_EVP_PKEY_prov,
- test_mem,
- check_public_DER, dump_der,
- OSSL_ENCODER_PUBKEY_TO_DER_PQ,
- 0);
+ encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
+ test_mem, check_public_DER, dump_der,
+ OSSL_ENCODER_PUBKEY_TO_DER_PQ);
}
static int check_public_PEM(const char *type, const void *data, size_t data_len)
static int test_public_via_PEM(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_EVP_PKEY_prov,
- decode_EVP_PKEY_prov,
- test_text,
- check_public_PEM, dump_pem,
- OSSL_ENCODER_PUBKEY_TO_PEM_PQ,
- 0);
+ encode_EVP_PKEY_prov, decode_EVP_PKEY_prov,
+ test_text, check_public_PEM, dump_pem,
+ OSSL_ENCODER_PUBKEY_TO_PEM_PQ);
}
#ifndef OPENSSL_NO_DSA
static int test_public_via_MSBLOB(const char *type, EVP_PKEY *key)
{
return test_encode_decode(type, key, NULL, NULL,
- encode_public_EVP_PKEY_MSBLOB,
- decode_EVP_PKEY_prov,
- test_mem,
- check_public_MSBLOB, dump_der,
- NULL, 0);
+ encode_public_EVP_PKEY_MSBLOB,
+ decode_EVP_PKEY_prov,
+ test_mem, check_public_MSBLOB, dump_der,
+ NULL);
}
#endif
#define KEYS(KEYTYPE) \
- static EVP_PKEY *key_##KEYTYPE = NULL; \
- static EVP_PKEY *legacy_key_##KEYTYPE = NULL
+ static EVP_PKEY *key_##KEYTYPE = NULL
#define MAKE_KEYS(KEYTYPE, KEYTYPEstr, params) \
ok = ok \
- && TEST_ptr(key_##KEYTYPE = \
- make_key(KEYTYPEstr, NULL, params, 0)) \
- && TEST_ptr(legacy_key_##KEYTYPE = \
- make_key(KEYTYPEstr, NULL, params, 1))
+ && TEST_ptr(key_##KEYTYPE = make_key(KEYTYPEstr, NULL, params))
#define FREE_KEYS(KEYTYPE) \
EVP_PKEY_free(key_##KEYTYPE); \
- EVP_PKEY_free(legacy_key_##KEYTYPE)
#define DOMAIN_KEYS(KEYTYPE) \
static EVP_PKEY *template_##KEYTYPE = NULL; \
- static EVP_PKEY *key_##KEYTYPE = NULL; \
- static EVP_PKEY *legacy_key_##KEYTYPE = NULL
+ static EVP_PKEY *key_##KEYTYPE = NULL
#define MAKE_DOMAIN_KEYS(KEYTYPE, KEYTYPEstr, params) \
ok = ok \
&& TEST_ptr(template_##KEYTYPE = \
make_template(KEYTYPEstr, params)) \
&& TEST_ptr(key_##KEYTYPE = \
- make_key(KEYTYPEstr, template_##KEYTYPE, NULL, 0)) \
- && TEST_ptr(legacy_key_##KEYTYPE = \
- make_key(KEYTYPEstr, template_##KEYTYPE, NULL, 1))
+ make_key(KEYTYPEstr, template_##KEYTYPE, NULL))
#define FREE_DOMAIN_KEYS(KEYTYPE) \
EVP_PKEY_free(template_##KEYTYPE); \
- EVP_PKEY_free(key_##KEYTYPE); \
- EVP_PKEY_free(legacy_key_##KEYTYPE)
+ EVP_PKEY_free(key_##KEYTYPE)
#define IMPLEMENT_TEST_SUITE(KEYTYPE, KEYTYPEstr) \
static int test_unprotected_##KEYTYPE##_via_DER(void) \
#define IMPLEMENT_TEST_SUITE_LEGACY(KEYTYPE, KEYTYPEstr) \
static int test_unprotected_##KEYTYPE##_via_legacy_PEM(void) \
{ \
- return test_unprotected_via_legacy_PEM(KEYTYPEstr, \
- legacy_key_##KEYTYPE); \
+ return \
+ test_unprotected_via_legacy_PEM(KEYTYPEstr, key_##KEYTYPE); \
} \
static int test_protected_##KEYTYPE##_via_legacy_PEM(void) \
{ \
- return test_protected_via_legacy_PEM(KEYTYPEstr, \
- legacy_key_##KEYTYPE); \
+ return \
+ test_protected_via_legacy_PEM(KEYTYPEstr, key_##KEYTYPE); \
}
#define ADD_TEST_SUITE_LEGACY(KEYTYPE) \
- ADD_TEST(test_unprotected_##KEYTYPE##_via_legacy_PEM); \
+ ADD_TEST(test_unprotected_##KEYTYPE##_via_legacy_PEM); \
ADD_TEST(test_protected_##KEYTYPE##_via_legacy_PEM)
#ifndef OPENSSL_NO_DSA