crypt_s390_query.c 4.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
/*
 * Cryptographic API.
 *
4
 * Support for s390 cryptographic instructions.
L
Linus Torvalds 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * Testing module for querying processor crypto capabilities.
 *
 * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
 * Author(s): Thomas Spatzier (tspat@de.ibm.com)
 *
 * This program 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 2 of the License, or (at your option)
 * any later version.
 *
 */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <asm/errno.h>
20
#include "crypt_s390.h"
L
Linus Torvalds 已提交
21

22
static void query_available_functions(void)
L
Linus Torvalds 已提交
23 24
{
	printk(KERN_INFO "#####################\n");
25 26

	/* query available KM functions */
L
Linus Torvalds 已提交
27
	printk(KERN_INFO "KM_QUERY: %d\n",
28
		crypt_s390_func_available(KM_QUERY));
L
Linus Torvalds 已提交
29
	printk(KERN_INFO "KM_DEA: %d\n",
30
		crypt_s390_func_available(KM_DEA_ENCRYPT));
L
Linus Torvalds 已提交
31
	printk(KERN_INFO "KM_TDEA_128: %d\n",
32
		crypt_s390_func_available(KM_TDEA_128_ENCRYPT));
L
Linus Torvalds 已提交
33
	printk(KERN_INFO "KM_TDEA_192: %d\n",
34
		crypt_s390_func_available(KM_TDEA_192_ENCRYPT));
J
Jan Glauber 已提交
35 36 37 38 39 40
	printk(KERN_INFO "KM_AES_128: %d\n",
		crypt_s390_func_available(KM_AES_128_ENCRYPT));
	printk(KERN_INFO "KM_AES_192: %d\n",
		crypt_s390_func_available(KM_AES_192_ENCRYPT));
	printk(KERN_INFO "KM_AES_256: %d\n",
		crypt_s390_func_available(KM_AES_256_ENCRYPT));
41 42

	/* query available KMC functions */
L
Linus Torvalds 已提交
43
	printk(KERN_INFO "KMC_QUERY: %d\n",
44
		crypt_s390_func_available(KMC_QUERY));
L
Linus Torvalds 已提交
45
	printk(KERN_INFO "KMC_DEA: %d\n",
46
		crypt_s390_func_available(KMC_DEA_ENCRYPT));
L
Linus Torvalds 已提交
47
	printk(KERN_INFO "KMC_TDEA_128: %d\n",
48
		crypt_s390_func_available(KMC_TDEA_128_ENCRYPT));
L
Linus Torvalds 已提交
49
	printk(KERN_INFO "KMC_TDEA_192: %d\n",
50
		crypt_s390_func_available(KMC_TDEA_192_ENCRYPT));
J
Jan Glauber 已提交
51 52 53 54 55 56
	printk(KERN_INFO "KMC_AES_128: %d\n",
		crypt_s390_func_available(KMC_AES_128_ENCRYPT));
	printk(KERN_INFO "KMC_AES_192: %d\n",
		crypt_s390_func_available(KMC_AES_192_ENCRYPT));
	printk(KERN_INFO "KMC_AES_256: %d\n",
		crypt_s390_func_available(KMC_AES_256_ENCRYPT));
57

58
	/* query available KIMD functions */
L
Linus Torvalds 已提交
59
	printk(KERN_INFO "KIMD_QUERY: %d\n",
60
		crypt_s390_func_available(KIMD_QUERY));
L
Linus Torvalds 已提交
61
	printk(KERN_INFO "KIMD_SHA_1: %d\n",
62
		crypt_s390_func_available(KIMD_SHA_1));
J
Jan Glauber 已提交
63 64
	printk(KERN_INFO "KIMD_SHA_256: %d\n",
		crypt_s390_func_available(KIMD_SHA_256));
65 66

	/* query available KLMD functions */
L
Linus Torvalds 已提交
67
	printk(KERN_INFO "KLMD_QUERY: %d\n",
68
		crypt_s390_func_available(KLMD_QUERY));
L
Linus Torvalds 已提交
69
	printk(KERN_INFO "KLMD_SHA_1: %d\n",
70
		crypt_s390_func_available(KLMD_SHA_1));
J
Jan Glauber 已提交
71 72
	printk(KERN_INFO "KLMD_SHA_256: %d\n",
		crypt_s390_func_available(KLMD_SHA_256));
73 74

	/* query available KMAC functions */
L
Linus Torvalds 已提交
75
	printk(KERN_INFO "KMAC_QUERY: %d\n",
J
Jan Glauber 已提交
76
		crypt_s390_func_available(KMAC_QUERY));
L
Linus Torvalds 已提交
77
	printk(KERN_INFO "KMAC_DEA: %d\n",
78
		crypt_s390_func_available(KMAC_DEA));
L
Linus Torvalds 已提交
79
	printk(KERN_INFO "KMAC_TDEA_128: %d\n",
80
		crypt_s390_func_available(KMAC_TDEA_128));
L
Linus Torvalds 已提交
81
	printk(KERN_INFO "KMAC_TDEA_192: %d\n",
82
		crypt_s390_func_available(KMAC_TDEA_192));
L
Linus Torvalds 已提交
83 84
}

85
static int init(void)
L
Linus Torvalds 已提交
86
{
87
	struct crypt_s390_query_status status = {
L
Linus Torvalds 已提交
88 89 90 91
		.high = 0,
		.low = 0
	};

92 93 94
	printk(KERN_INFO "crypt_s390: querying available crypto functions\n");
	crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0);
	printk(KERN_INFO "KM:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
95 96 97
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
98 99
	crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0);
	printk(KERN_INFO "KMC:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
100 101 102
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
103 104
	crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0);
	printk(KERN_INFO "KIMD:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
105 106 107
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
108 109
	crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0);
	printk(KERN_INFO "KLMD:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
110 111 112
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
113 114
	crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0);
	printk(KERN_INFO "KMAC:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
115 116 117 118
			(unsigned long long) status.high,
			(unsigned long long) status.low);

	query_available_functions();
119
	return -ECANCELED;
L
Linus Torvalds 已提交
120 121
}

122
static void __exit cleanup(void)
L
Linus Torvalds 已提交
123 124 125 126 127 128 129
{
}

module_init(init);
module_exit(cleanup);

MODULE_LICENSE("GPL");