crypt_s390_query.c 3.5 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 35 36
		crypt_s390_func_available(KM_TDEA_192_ENCRYPT));

	/* query available KMC functions */
L
Linus Torvalds 已提交
37
	printk(KERN_INFO "KMC_QUERY: %d\n",
38
		crypt_s390_func_available(KMC_QUERY));
L
Linus Torvalds 已提交
39
	printk(KERN_INFO "KMC_DEA: %d\n",
40
		crypt_s390_func_available(KMC_DEA_ENCRYPT));
L
Linus Torvalds 已提交
41
	printk(KERN_INFO "KMC_TDEA_128: %d\n",
42
		crypt_s390_func_available(KMC_TDEA_128_ENCRYPT));
L
Linus Torvalds 已提交
43
	printk(KERN_INFO "KMC_TDEA_192: %d\n",
44 45 46
		crypt_s390_func_available(KMC_TDEA_192_ENCRYPT));

	/* query available KIMD fucntions */
L
Linus Torvalds 已提交
47
	printk(KERN_INFO "KIMD_QUERY: %d\n",
48
		crypt_s390_func_available(KIMD_QUERY));
L
Linus Torvalds 已提交
49
	printk(KERN_INFO "KIMD_SHA_1: %d\n",
50 51 52
		crypt_s390_func_available(KIMD_SHA_1));

	/* query available KLMD functions */
L
Linus Torvalds 已提交
53
	printk(KERN_INFO "KLMD_QUERY: %d\n",
54
		crypt_s390_func_available(KLMD_QUERY));
L
Linus Torvalds 已提交
55
	printk(KERN_INFO "KLMD_SHA_1: %d\n",
56 57 58
		crypt_s390_func_available(KLMD_SHA_1));

	/* query available KMAC functions */
L
Linus Torvalds 已提交
59
	printk(KERN_INFO "KMAC_QUERY: %d\n",
60
		crypt_s3990_func_available(KMAC_QUERY));
L
Linus Torvalds 已提交
61
	printk(KERN_INFO "KMAC_DEA: %d\n",
62
		crypt_s390_func_available(KMAC_DEA));
L
Linus Torvalds 已提交
63
	printk(KERN_INFO "KMAC_TDEA_128: %d\n",
64
		crypt_s390_func_available(KMAC_TDEA_128));
L
Linus Torvalds 已提交
65
	printk(KERN_INFO "KMAC_TDEA_192: %d\n",
66
		crypt_s390_func_available(KMAC_TDEA_192));
L
Linus Torvalds 已提交
67 68
}

69
static int init(void)
L
Linus Torvalds 已提交
70
{
71
	struct crypt_s390_query_status status = {
L
Linus Torvalds 已提交
72 73 74 75
		.high = 0,
		.low = 0
	};

76 77 78
	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 已提交
79 80 81
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
82 83
	crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0);
	printk(KERN_INFO "KMC:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
84 85 86
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
87 88
	crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0);
	printk(KERN_INFO "KIMD:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
89 90 91
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
92 93
	crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0);
	printk(KERN_INFO "KLMD:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
94 95 96
			(unsigned long long) status.high,
			(unsigned long long) status.low);
	status.high = status.low = 0;
97 98
	crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0);
	printk(KERN_INFO "KMAC:\t%016llx %016llx\n",
L
Linus Torvalds 已提交
99 100 101 102
			(unsigned long long) status.high,
			(unsigned long long) status.low);

	query_available_functions();
103
	return -ECANCELED;
L
Linus Torvalds 已提交
104 105
}

106
static void __exit cleanup(void)
L
Linus Torvalds 已提交
107 108 109 110 111 112 113
{
}

module_init(init);
module_exit(cleanup);

MODULE_LICENSE("GPL");