|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2017 Red Hat, Inc.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
* under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
* along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <sys/types.h>
|
|
Packit Service |
4684c1 |
#include <unistd.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "utils.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CHECK_SECURE_SIG(sig) \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure2(sig, 0); \
|
|
Packit Service |
4684c1 |
if (ret == 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
} \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure(sig); \
|
|
Packit Service |
4684c1 |
if (ret == 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CHECK_INSECURE_SIG(sig) \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure2(sig, 0); \
|
|
Packit Service |
4684c1 |
if (ret != 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
} \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure2(sig, GNUTLS_SIGN_FLAG_SECURE_FOR_CERTS); \
|
|
Packit Service |
4684c1 |
if (ret != 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
} \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure(sig); \
|
|
Packit Service |
4684c1 |
if (ret != 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifndef ALLOW_SHA1
|
|
Packit Service |
4684c1 |
#define CHECK_INSECURE_FOR_CERTS_SIG(sig) \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure2(sig, 0); \
|
|
Packit Service |
4684c1 |
if (ret == 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
} \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure2(sig, GNUTLS_SIGN_FLAG_SECURE_FOR_CERTS); \
|
|
Packit Service |
4684c1 |
if (ret != 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
} \
|
|
Packit Service |
4684c1 |
ret = gnutls_sign_is_secure(sig); \
|
|
Packit Service |
4684c1 |
if (ret == 0) { \
|
|
Packit Service |
4684c1 |
fail("error testing %d/%s\n", sig, gnutls_sign_get_name(sig)); \
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#else
|
|
Packit Service |
4684c1 |
#define CHECK_INSECURE_FOR_CERTS_SIG(sig)
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void doit(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
unsigned i;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
CHECK_INSECURE_FOR_CERTS_SIG(GNUTLS_SIGN_RSA_SHA1);
|
|
Packit Service |
4684c1 |
CHECK_INSECURE_FOR_CERTS_SIG(GNUTLS_SIGN_DSA_SHA1);
|
|
Packit Service |
4684c1 |
CHECK_INSECURE_FOR_CERTS_SIG(GNUTLS_SIGN_ECDSA_SHA1);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
CHECK_INSECURE_SIG(GNUTLS_SIGN_RSA_MD5);
|
|
Packit Service |
4684c1 |
CHECK_INSECURE_SIG(GNUTLS_SIGN_RSA_MD2);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i=1;i<=GNUTLS_SIGN_MAX;i++) {
|
|
Packit Service |
4684c1 |
#ifndef ALLOW_SHA1
|
|
Packit Service |
4684c1 |
if (i==GNUTLS_SIGN_RSA_SHA1||i==GNUTLS_SIGN_DSA_SHA1||i==GNUTLS_SIGN_ECDSA_SHA1)
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
if (i==GNUTLS_SIGN_RSA_MD5||i==GNUTLS_SIGN_RSA_MD2||i==GNUTLS_SIGN_UNKNOWN)
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
/* skip any unused elements */
|
|
Packit Service |
4684c1 |
if (gnutls_sign_algorithm_get_name(i)==NULL)
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
CHECK_SECURE_SIG(i);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|