/*
* Copyright (C) 2015-2018 Red Hat, Inc.
*
* This file is part of GnuTLS.
*
* GnuTLS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GnuTLS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#if !defined(__linux__) || !defined(__GNUC__)
int main(int argc, char **argv)
{
exit(77);
}
#else
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "cert-common.h"
#include "utils.h"
static void terminate(void);
/* This program tests whether the gnutls_prf() works as
* expected.
*/
static void server_log_func(int level, const char *str)
{
fprintf(stderr, "server|<%d>| %s", level, str);
}
static void client_log_func(int level, const char *str)
{
fprintf(stderr, "client|<%d>| %s", level, str);
}
/* These are global */
static pid_t child;
static const
gnutls_datum_t hrnd = {(void*)"\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 32};
static const
gnutls_datum_t hsrnd = {(void*)"\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 32};
static int gnutls_rnd_works;
int __attribute__ ((visibility ("protected")))
gnutls_rnd(gnutls_rnd_level_t level, void *data, size_t len)
{
gnutls_rnd_works = 1;
memset(data, 0xff, len);
/* Flip the first byte to avoid infinite loop in the RSA
* blinding code of Nettle */
if (len > 0)
memset(data, 0x0, 1);
return 0;
}
static void dump(const char *name, const uint8_t *data, unsigned data_size)
{
unsigned i;
fprintf(stderr, "%s", name);
for (i=0;i