Blame fuzz/gnutls_private_key_parser_fuzzer.c

Packit 549fdc
/*
Packit 549fdc
# Copyright 2016 Google Inc.
Packit 549fdc
#
Packit 549fdc
# Licensed under the Apache License, Version 2.0 (the "License");
Packit 549fdc
# you may not use this file except in compliance with the License.
Packit 549fdc
# You may obtain a copy of the License at
Packit 549fdc
#
Packit 549fdc
#      http://www.apache.org/licenses/LICENSE-2.0
Packit 549fdc
#
Packit 549fdc
# Unless required by applicable law or agreed to in writing, software
Packit 549fdc
# distributed under the License is distributed on an "AS IS" BASIS,
Packit 549fdc
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 549fdc
# See the License for the specific language governing permissions and
Packit 549fdc
# limitations under the License.
Packit 549fdc
#
Packit 549fdc
################################################################################
Packit 549fdc
*/
Packit 549fdc
Packit 549fdc
#include <assert.h>
Packit 549fdc
#include <stdint.h>
Packit 549fdc
Packit 549fdc
#include <gnutls/gnutls.h>
Packit 549fdc
#include <gnutls/x509.h>
Packit 549fdc
Packit 549fdc
#include "fuzzer.h"
Packit 549fdc
Packit 549fdc
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Packit 549fdc
{
Packit 549fdc
	gnutls_datum_t raw;
Packit 549fdc
	gnutls_x509_privkey_t key;
Packit 549fdc
	int ret;
Packit 549fdc
Packit 549fdc
	raw.data = (unsigned char *)data;
Packit 549fdc
	raw.size = size;
Packit 549fdc
Packit 549fdc
	ret = gnutls_x509_privkey_init(&key);
Packit 549fdc
	assert(ret >= 0);
Packit 549fdc
Packit 549fdc
	ret = gnutls_x509_privkey_import(key, &raw, GNUTLS_X509_FMT_DER);
Packit 549fdc
Packit 549fdc
	gnutls_x509_privkey_deinit(key);
Packit 549fdc
	return 0;
Packit 549fdc
}