OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASN1_FUZZER_TEMPLATE_H_ |
| 6 #define ASN1_FUZZER_TEMPLATE_H_ |
| 7 |
| 8 #include <nspr.h> |
| 9 #include <nss.h> |
| 10 #include <secasn1.h> |
| 11 #include <secder.h> |
| 12 #include <secitem.h> |
| 13 #include <secport.h> |
| 14 #include <stddef.h> |
| 15 #include <stdint.h> |
| 16 |
| 17 template <typename DestinationType, |
| 18 SECStatus (*DecodeFunction)(PLArenaPool*, |
| 19 void*, |
| 20 const SEC_ASN1Template*, |
| 21 const SECItem*)> |
| 22 void NSSFuzzOneInput(const SEC_ASN1Template* the_template, |
| 23 const uint8_t* data, |
| 24 size_t size) { |
| 25 DestinationType* destination = new DestinationType(); |
| 26 memset(destination, 0, sizeof(DestinationType)); |
| 27 |
| 28 PLArenaPool* arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
| 29 if (!arena) { |
| 30 delete destination; |
| 31 return; |
| 32 } |
| 33 |
| 34 SECItem source; |
| 35 source.type = siBuffer; |
| 36 source.data = static_cast<unsigned char*>(const_cast<uint8_t*>(data)); |
| 37 source.len = static_cast<unsigned int>(size); |
| 38 |
| 39 DecodeFunction(arena, destination, the_template, &source); |
| 40 |
| 41 PORT_FreeArena(arena, PR_FALSE); |
| 42 delete destination; |
| 43 } |
| 44 |
| 45 #endif // ASN1_FUZZER_TEMPLATE_H_ |
OLD | NEW |