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