1 1.1 christos /* 2 1.1 christos * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the OpenSSL licenses, (the "License"); 5 1.1 christos * you may not use this file except in compliance with the License. 6 1.1 christos * You may obtain a copy of the License at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos * or in the file LICENSE in the source distribution. 9 1.1 christos */ 10 1.1 christos 11 1.1 christos /* 12 1.1 christos * Test CMS DER parsing. 13 1.1 christos */ 14 1.1 christos 15 1.1 christos #include <openssl/bio.h> 16 1.1 christos #include <openssl/cms.h> 17 1.1 christos #include <openssl/err.h> 18 1.1 christos #include "fuzzer.h" 19 1.1 christos 20 1.1 christos int FuzzerInitialize(int *argc, char ***argv) 21 1.1 christos { 22 1.1 christos OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); 23 1.1 christos ERR_get_state(); 24 1.1 christos CRYPTO_free_ex_index(0, -1); 25 1.1 christos return 1; 26 1.1 christos } 27 1.1 christos 28 1.1 christos int FuzzerTestOneInput(const uint8_t *buf, size_t len) 29 1.1 christos { 30 1.1 christos CMS_ContentInfo *cms; 31 1.1 christos BIO *in; 32 1.1 christos 33 1.1 christos if (len == 0) 34 1.1 christos return 0; 35 1.1 christos 36 1.1 christos in = BIO_new(BIO_s_mem()); 37 1.1 christos OPENSSL_assert((size_t)BIO_write(in, buf, len) == len); 38 1.1 christos cms = d2i_CMS_bio(in, NULL); 39 1.1 christos if (cms != NULL) { 40 1.1 christos BIO *out = BIO_new(BIO_s_null()); 41 1.1 christos 42 1.1 christos i2d_CMS_bio(out, cms); 43 1.1 christos BIO_free(out); 44 1.1 christos CMS_ContentInfo_free(cms); 45 1.1 christos } 46 1.1 christos 47 1.1 christos BIO_free(in); 48 1.1 christos ERR_clear_error(); 49 1.1 christos 50 1.1 christos return 0; 51 1.1 christos } 52 1.1 christos 53 1.1 christos void FuzzerCleanup(void) 54 1.1 christos { 55 1.1 christos } 56