Skip to content

Commit 9a1682e

Browse files
Add PKCS7_print_ctx as a no-op
1 parent 92b771f commit 9a1682e

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

crypto/pkcs7/pkcs7_asn1.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,13 @@ ASN1_SEQUENCE(PKCS7_ENVELOPE) = {
186186
PKCS7_ENC_CONTENT)} ASN1_SEQUENCE_END(PKCS7_ENVELOPE)
187187

188188
IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
189+
190+
int PKCS7_print_ctx(BIO *bio, PKCS7 *pkcs7, int indent, const ASN1_PCTX *pctx) {
191+
GUARD_PTR(bio);
192+
GUARD_PTR(pkcs7);
193+
194+
if (BIO_printf(bio, "PKCS7 printing is not supported") <= 0) {
195+
return 0;
196+
}
197+
return 1;
198+
}

crypto/pkcs7/pkcs7_test.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,3 +2032,14 @@ TEST(PKCS7Test, TestSigned) {
20322032
EXPECT_FALSE(PKCS7_verify(p7.get(), certs.get(), store.get(), bio_in.get(),
20332033
bio_out.get(), /*flags*/ 0));
20342034
}
2035+
2036+
TEST(PKCS7Test, PKCS7PrintNoop) {
2037+
bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
2038+
bssl::UniquePtr<PKCS7> p7(PKCS7_new());
2039+
ASSERT_TRUE(PKCS7_print_ctx(bio.get(), p7.get(), 0, nullptr));
2040+
2041+
const uint8_t *contents;
2042+
size_t len;
2043+
ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len));
2044+
EXPECT_EQ(Bytes(contents, len), Bytes("PKCS7 printing is not supported"));
2045+
}

include/openssl/pkcs7.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ OPENSSL_EXPORT OPENSSL_DEPRECATED PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont);
523523
OPENSSL_EXPORT OPENSSL_DEPRECATED int SMIME_write_PKCS7(BIO *out, PKCS7 *p7,
524524
BIO *data, int flags);
525525

526+
// PKCS7_print_ctx prints "PKCS7 printing is not supported" and returns 1.
527+
OPENSSL_EXPORT OPENSSL_DEPRECATED int PKCS7_print_ctx(BIO *bio, PKCS7 *pkcs7,
528+
int indent,
529+
const ASN1_PCTX *pctx);
530+
526531
#if defined(__cplusplus)
527532
} // extern C
528533

0 commit comments

Comments
 (0)