mirror of
https://github.com/openssl/openssl.git
synced 2024-11-23 10:03:32 +08:00
Added a fuzzer for SMIME
Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20332)
This commit is contained in:
parent
9a2f78e14a
commit
359d6a26d6
@ -9,7 +9,7 @@
|
||||
-}
|
||||
|
||||
IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
PROGRAMS{noinst}=asn1 asn1parse bignum bndiv client conf crl server x509
|
||||
PROGRAMS{noinst}=asn1 asn1parse bignum bndiv client conf crl server smime x509
|
||||
PROGRAMS{noinst}=punycode
|
||||
|
||||
IF[{- !$disabled{"cmp"} -}]
|
||||
@ -68,6 +68,10 @@ IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
INCLUDE[punycode]=../include {- $ex_inc -}
|
||||
DEPEND[punycode]=../libcrypto.a {- $ex_lib -}
|
||||
|
||||
SOURCE[smime]=smime.c driver.c
|
||||
INCLUDE[smime]=../include {- $ex_inc -}
|
||||
DEPEND[smime]=../libcrypto ../libssl {- $ex_lib -}
|
||||
|
||||
SOURCE[server]=server.c driver.c fuzz_rand.c
|
||||
INCLUDE[server]=../include {- $ex_inc -}
|
||||
DEPEND[server]=../libcrypto ../libssl {- $ex_lib -}
|
||||
@ -78,7 +82,7 @@ IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{tests} -}]
|
||||
PROGRAMS{noinst}=asn1-test asn1parse-test bignum-test bndiv-test client-test conf-test crl-test server-test x509-test
|
||||
PROGRAMS{noinst}=asn1-test asn1parse-test bignum-test bndiv-test client-test conf-test crl-test server-test smime-test x509-test
|
||||
PROGRAMS{noinst}=punycode-test
|
||||
|
||||
IF[{- !$disabled{"cmp"} -}]
|
||||
@ -138,6 +142,10 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[punycode-test]=../include
|
||||
DEPEND[punycode-test]=../libcrypto.a
|
||||
|
||||
SOURCE[smime-test]=smime.c test-corpus.c
|
||||
INCLUDE[smime-test]=../include
|
||||
DEPEND[smime-test]=../libcrypto ../libssl
|
||||
|
||||
SOURCE[server-test]=server.c test-corpus.c fuzz_rand.c
|
||||
INCLUDE[server-test]=../include
|
||||
DEPEND[server-test]=../libcrypto ../libssl
|
||||
|
91
fuzz/corpora/smime/b6cf925eec43acc9cc43c3104f17ac16d71439d0
Normal file
91
fuzz/corpora/smime/b6cf925eec43acc9cc43c3104f17ac16d71439d0
Normal file
@ -0,0 +1,91 @@
|
||||
To: recipient@testcertificates.gov
|
||||
From: sender@testcertificates.gov
|
||||
Subject: Valid UTF8String Encoded Names Test9
|
||||
MIME-Version: 1.0
|
||||
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha-256"; boundary="----BF0F19981A03F3AEBB1B40CD96D61B65"
|
||||
|
||||
This is an S/MIME signed message
|
||||
|
||||
------BF0F19981A03F3AEBB1B40CD96D61B65
|
||||
Content-Type: text/plain
|
||||
|
||||
This is a sample signed message.
|
||||
|
||||
------BF0F19981A03F3AEBB1B40CD96D61B65
|
||||
Content-Type: application/pkcs7-signature; name="smime.p7s"
|
||||
Content-Transfer-Encoding: base64
|
||||
Content-Disposition: attachment; filename="smime.p7s"
|
||||
|
||||
MIIM7gYJKoZIhvcNAQcCoIIM3zCCDNsCAQExDzANBglghkgBZQMEAgEFADALBgkq
|
||||
hkiG9w0BBwGgggciMIIDgjCCAmqgAwIBAgIBYjANBgkqhkiG9w0BAQsFADBFMQsw
|
||||
CQYDVQQGEwJVUzEfMB0GA1UEChMWVGVzdCBDZXJ0aWZpY2F0ZXMgMjAxMTEVMBMG
|
||||
A1UEAxMMVHJ1c3QgQW5jaG9yMB4XDTEwMDEwMTA4MzAwMFoXDTMwMTIzMTA4MzAw
|
||||
MFowRjELMAkGA1UEBhMCVVMxH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GJtS5s2M6CwwRe+Dfo3iupGFRIJ8TfLkAukpb
|
||||
1+ao+5hxMHYait/ds9DKkbn/JdnRhMz+SRyCgEoy9lMmEv9YG3AJziL0nQVm/+RV
|
||||
VMTRAoLUPkgTCxFwaob4yFou+o+jsk8NAzavlMIe2yWjNwMCz/sm4e9mbF4k6xKn
|
||||
3gNEaBh/KIjjQUH86hOzLIUnMb2BurnyHXQrfYGTwefAPWGACB06u5hmgk7MlQaY
|
||||
hp4=
|
||||
|
||||
------BF0F19981A03F3AEBB1B40CD96D61B65--
|
||||
|
49
fuzz/smime.c
Normal file
49
fuzz/smime.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://www.openssl.org/source/license.html
|
||||
* or in the file LICENSE in the source distribution.
|
||||
*/
|
||||
|
||||
#include "fuzzer.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pkcs7.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
BIO *b = BIO_new_mem_buf(buf, len);
|
||||
PKCS7 *p7 = SMIME_read_PKCS7(b, NULL);
|
||||
|
||||
if (p7 != NULL) {
|
||||
STACK_OF(PKCS7_SIGNER_INFO) *p7si = PKCS7_get_signer_info(p7);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(p7si); i++) {
|
||||
STACK_OF(X509_ALGOR) *algs;
|
||||
|
||||
PKCS7_cert_from_signer_info(p7,
|
||||
sk_PKCS7_SIGNER_INFO_value(p7si, i));
|
||||
algs = PKCS7_get_smimecap(sk_PKCS7_SIGNER_INFO_value(p7si, i));
|
||||
sk_X509_ALGOR_pop_free(algs, X509_ALGOR_free);
|
||||
}
|
||||
PKCS7_free(p7);
|
||||
}
|
||||
|
||||
BIO_free(b);
|
||||
ERR_clear_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
}
|
23
test/recipes/99-test_fuzz_smime.t
Normal file
23
test/recipes/99-test_fuzz_smime.t
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env perl
|
||||
# Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
my $fuzzer = "smime";
|
||||
setup("test_fuzz_${fuzzer}");
|
||||
|
||||
plan tests => 2; # one more due to below require_ok(...)
|
||||
|
||||
require_ok(srctop_file('test','recipes','fuzz.pl'));
|
||||
|
||||
fuzz_ok($fuzzer);
|
||||
|
Loading…
Reference in New Issue
Block a user