diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-03-29 06:42:43 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-03-29 06:42:43 +0000 |
commit | 4d9ce1fac64ae5f054ec4733b44b00a2a2887fa3 (patch) | |
tree | d4661c03dfe327d3b57d4364252d9e7cb708f7af /regress | |
parent | e9450e1d56a61a8a4a2eb6cd704e15e04f901f0c (diff) |
Add regress coverage for EdDSA in CMS
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libcrypto/cms/cmstest.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/regress/lib/libcrypto/cms/cmstest.c b/regress/lib/libcrypto/cms/cmstest.c index c207b9ebd86..8b2faf68916 100644 --- a/regress/lib/libcrypto/cms/cmstest.c +++ b/regress/lib/libcrypto/cms/cmstest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmstest.c,v 1.7 2023/03/02 21:08:14 tb Exp $ */ +/* $OpenBSD: cmstest.c,v 1.8 2024/03/29 06:42:42 tb Exp $ */ /* * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> * @@ -97,6 +97,40 @@ static const char cms_key_1[] = "pFtLoXoGoVXRjAtpNvX7fh/G\n" "-----END PRIVATE KEY-----\n"; +const char cms_ca_2[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIBvTCCAW+gAwIBAgIQHioe49U1R3LcahmTCOUmoTAFBgMrZXAwXTEUMBIGA1UE\n" + "ChMLQ01TIFRlc3QgQ0ExHTAbBgNVBAsMFGNtc3Rlc3RAbGlicmVzc2wub3JnMSYw\n" + "JAYDVQQDDB1DTVMgVGVzdCBjbXN0ZXN0QGxpYnJlc3NsLm9yZzAeFw0yMzEwMDkw\n" + "OTAzNDhaFw0zMzEwMDkwOTAzNDhaMF0xFDASBgNVBAoTC0NNUyBUZXN0IENBMR0w\n" + "GwYDVQQLDBRjbXN0ZXN0QGxpYnJlc3NsLm9yZzEmMCQGA1UEAwwdQ01TIFRlc3Qg\n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\n" + "wup36c05XQA=\n" + "-----END CERTIFICATE-----\n"; + +const char cms_key_2[] = + "-----BEGIN PRIVATE KEY-----\n" + "MC4CAQAwBQYDK2VwBCIEIO88YApnGRDewzSwtxAnBvhlTPz9MjSz51mEpE2oi+9g\n" + "-----END PRIVATE KEY-----\n"; + static void hexdump(const unsigned char *buf, size_t len) { @@ -204,7 +238,8 @@ test_cms_encrypt_decrypt(void) } static int -test_cms_sign_verify(void) +test_cms_sign_verify(const char *ca_pem, const char *cert_pem, + const char *key_pem) { STACK_OF(X509) *certs = NULL; CMS_ContentInfo *ci = NULL; @@ -224,7 +259,7 @@ test_cms_sign_verify(void) if ((certs = sk_X509_new_null()) == NULL) errx(1, "failed to create certs"); - if ((bio_mem = BIO_new_mem_buf(cms_cert_1, -1)) == NULL) + if ((bio_mem = BIO_new_mem_buf(cert_pem, -1)) == NULL) errx(1, "failed to create BIO for cert"); if ((cert = PEM_read_bio_X509(bio_mem, NULL, NULL, NULL)) == NULL) errx(1, "failed to read cert"); @@ -232,7 +267,7 @@ test_cms_sign_verify(void) errx(1, "failed to push cert"); BIO_free(bio_mem); - if ((bio_mem = BIO_new_mem_buf(cms_ca_1, -1)) == NULL) + if ((bio_mem = BIO_new_mem_buf(ca_pem, -1)) == NULL) errx(1, "failed to create BIO for cert"); if ((ca = PEM_read_bio_X509(bio_mem, NULL, NULL, NULL)) == NULL) errx(1, "failed to read cert"); @@ -242,7 +277,7 @@ test_cms_sign_verify(void) errx(1, "failed to add cert to store"); BIO_free(bio_mem); - if ((bio_mem = BIO_new_mem_buf(cms_key_1, -1)) == NULL) + if ((bio_mem = BIO_new_mem_buf(key_pem, -1)) == NULL) errx(1, "failed to create BIO for key"); if ((pkey = PEM_read_bio_PrivateKey(bio_mem, NULL, NULL, NULL)) == NULL) errx(1, "failed to read key"); @@ -320,7 +355,8 @@ main(int argc, char **argv) ERR_load_crypto_strings(); failed |= test_cms_encrypt_decrypt(); - failed |= test_cms_sign_verify(); + failed |= test_cms_sign_verify(cms_ca_1, cms_cert_1, cms_key_1); + failed |= test_cms_sign_verify(cms_ca_2, cms_cert_2, cms_key_2); return failed; } |