OpenSSL 1.1.1-pre2
This commit is contained in:
+28
-51
@@ -28,15 +28,15 @@ static int get_cert_and_key(X509 **cert_out, EVP_PKEY **key_out)
|
||||
X509 *cert = NULL;
|
||||
EVP_PKEY *key = NULL;
|
||||
|
||||
if ((certbio = BIO_new_file(certstr, "r")) == NULL)
|
||||
if (!TEST_ptr(certbio = BIO_new_file(certstr, "r")))
|
||||
return 0;
|
||||
cert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);
|
||||
BIO_free(certbio);
|
||||
if ((keybio = BIO_new_file(privkeystr, "r")) == NULL)
|
||||
if (!TEST_ptr(keybio = BIO_new_file(privkeystr, "r")))
|
||||
goto end;
|
||||
key = PEM_read_bio_PrivateKey(keybio, NULL, NULL, NULL);
|
||||
BIO_free(keybio);
|
||||
if (cert == NULL || key == NULL)
|
||||
if (!TEST_ptr(cert) || !TEST_ptr(key))
|
||||
goto end;
|
||||
*cert_out = cert;
|
||||
*key_out = key;
|
||||
@@ -66,13 +66,13 @@ static OCSP_BASICRESP *make_dummy_resp(void)
|
||||
|| !ASN1_INTEGER_set_uint64(serial, (uint64_t)1))
|
||||
goto err;
|
||||
cid = OCSP_cert_id_new(EVP_sha256(), name, key, serial);
|
||||
if (bs == NULL
|
||||
|| thisupd == NULL
|
||||
|| nextupd == NULL
|
||||
|| cid == NULL
|
||||
|| !OCSP_basic_add1_status(bs, cid,
|
||||
V_OCSP_CERTSTATUS_UNKNOWN,
|
||||
0, NULL, thisupd, nextupd))
|
||||
if (!TEST_ptr(bs)
|
||||
|| !TEST_ptr(thisupd)
|
||||
|| !TEST_ptr(nextupd)
|
||||
|| !TEST_ptr(cid)
|
||||
|| !TEST_true(OCSP_basic_add1_status(bs, cid,
|
||||
V_OCSP_CERTSTATUS_UNKNOWN,
|
||||
0, NULL, thisupd, nextupd)))
|
||||
goto err;
|
||||
bs_out = bs;
|
||||
bs = NULL;
|
||||
@@ -101,27 +101,27 @@ static int test_resp_signer(void)
|
||||
*/
|
||||
bs = make_dummy_resp();
|
||||
extra_certs = sk_X509_new_null();
|
||||
if (bs == NULL
|
||||
|| extra_certs == NULL
|
||||
|| !get_cert_and_key(&signer, &key)
|
||||
|| !sk_X509_push(extra_certs, signer)
|
||||
|| !OCSP_basic_sign(bs, signer, key, EVP_sha1(),
|
||||
NULL, OCSP_NOCERTS))
|
||||
if (!TEST_ptr(bs)
|
||||
|| !TEST_ptr(extra_certs)
|
||||
|| !TEST_true(get_cert_and_key(&signer, &key))
|
||||
|| !TEST_true(sk_X509_push(extra_certs, signer))
|
||||
|| !TEST_true(OCSP_basic_sign(bs, signer, key, EVP_sha1(),
|
||||
NULL, OCSP_NOCERTS)))
|
||||
goto err;
|
||||
if (!OCSP_resp_get0_signer(bs, &tmp, extra_certs)
|
||||
|| X509_cmp(tmp, signer) != 0)
|
||||
if (!TEST_true(OCSP_resp_get0_signer(bs, &tmp, extra_certs))
|
||||
|| !TEST_int_eq(X509_cmp(tmp, signer), 0))
|
||||
goto err;
|
||||
OCSP_BASICRESP_free(bs);
|
||||
|
||||
/* Do it again but include the signer cert */
|
||||
bs = make_dummy_resp();
|
||||
tmp = NULL;
|
||||
if (bs == NULL
|
||||
|| !OCSP_basic_sign(bs, signer, key, EVP_sha1(),
|
||||
NULL, 0))
|
||||
if (!TEST_ptr(bs)
|
||||
|| !TEST_true(OCSP_basic_sign(bs, signer, key, EVP_sha1(),
|
||||
NULL, 0)))
|
||||
goto err;
|
||||
if (!OCSP_resp_get0_signer(bs, &tmp, NULL)
|
||||
|| X509_cmp(tmp, signer) != 0)
|
||||
if (!TEST_true(OCSP_resp_get0_signer(bs, &tmp, NULL))
|
||||
|| !TEST_int_eq(X509_cmp(tmp, signer), 0))
|
||||
goto err;
|
||||
ret = 1;
|
||||
err:
|
||||
@@ -133,36 +133,13 @@ static int test_resp_signer(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int testresult = 1;
|
||||
BIO *err = NULL;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Invalid argument count\n");
|
||||
return 1;
|
||||
}
|
||||
if ((certstr = argv[1]) == NULL
|
||||
|| (privkeystr = argv[2]) == NULL)
|
||||
return 1;
|
||||
err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
CRYPTO_set_mem_debug(1);
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
|
||||
|
||||
if (!TEST_ptr(certstr = test_get_argument(0))
|
||||
|| !TEST_ptr(privkeystr = test_get_argument(1)))
|
||||
return 0;
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
ADD_TEST(test_resp_signer);
|
||||
#endif
|
||||
testresult = run_tests(argv[0]);
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
if (CRYPTO_mem_leaks(err) <= 0)
|
||||
testresult = 1;
|
||||
#endif
|
||||
BIO_free(err);
|
||||
|
||||
if (!testresult)
|
||||
printf("PASS\n");
|
||||
|
||||
return testresult;
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user