summaryrefslogtreecommitdiff
path: root/tests/slow/cipher-test.c
blob: da7e7e7673fd54bd3e73470a0feda130bcd5d615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <config.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <utils.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include <gnutls/self-test.h>
#include <signal.h>

/* This does check the AES and SHA implementation against test vectors.
 * This should not run under valgrind in order to use the native
 * cpu instructions (AES-NI or padlock).
 */

#if defined(WIN32)
int main(int argc, char **argv)
{
	exit(77);
}
#else
# include <unistd.h>

static void handle_sigill(int sig)
{
	_exit(0);
}

static void tls_log_func(int level, const char *str)
{
	fprintf(stderr, "<%d>| %s", level, str);
}

int main(int argc, char **argv)
{
	gnutls_global_set_log_function(tls_log_func);
	if (argc > 1)
		gnutls_global_set_log_level(4711);

	global_init();
	signal(SIGILL, handle_sigill);

	/* ciphers */
	if (gnutls_cipher_self_test(1, 0) < 0)
		return 1;

	/* message digests */
	if (gnutls_digest_self_test(1, 0) < 0)
		return 1;

	/* MAC */
	if (gnutls_mac_self_test(1, 0) < 0)
		return 1;

	/* PK */
	if (gnutls_pk_self_test(1, 0) < 0)
		return 1;

	gnutls_global_deinit();
	return 0;
}

#endif