Skip to content

Commit

Permalink
Cover {d2i,i2d}_PKCS7_bio
Browse files Browse the repository at this point in the history
  • Loading branch information
WillChilds-Klein committed Jul 25, 2024
1 parent 28ca61f commit 5850129
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crypto/pkcs7/pkcs7_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2030,10 +2030,19 @@ TEST(PKCS7Test, GettersSetters) {
ASSERT_TRUE(p7_dup);
EXPECT_TRUE(PKCS7_type_is_signed(p7_dup.get()));

p7_der = kPKCS7Signed;
PKCS7 *p7_ptr = nullptr;
bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(p7_der, p7_der_len));
p7.reset(d2i_PKCS7_bio(bio.get(), &p7_ptr));
ASSERT_TRUE(p7);
ASSERT_TRUE(PKCS7_type_is_signed(p7_signed.get()));
bio.reset(BIO_new(BIO_s_mem()));
ASSERT_TRUE(i2d_PKCS7_bio(bio.get(), p7.get()));

bssl::UniquePtr<PKCS7> p7_cert(PKCS7_new());
ASSERT_TRUE(p7_cert);
ASSERT_TRUE(PKCS7_set_type(p7_cert.get(), NID_pkcs7_signed));
bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(kPEMCert, strlen(kPEMCert)));
bio.reset(BIO_new_mem_buf(kPEMCert, strlen(kPEMCert)));
ASSERT_TRUE(bio);
bssl::UniquePtr<STACK_OF(X509)> certs(sk_X509_new_null());
ASSERT_TRUE(certs);
Expand Down

0 comments on commit 5850129

Please sign in to comment.