2019-05-29 17:18:13 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2021-03-18 15:44:20 +03:00
|
|
|
/*
|
2015-02-06 19:56:50 +03:00
|
|
|
* Routines supporting VMX instructions on the Power 8
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 International Business Machines Inc.
|
|
|
|
*
|
|
|
|
* Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/err.h>
|
2016-07-19 07:03:53 +03:00
|
|
|
#include <linux/cpufeature.h>
|
2015-02-06 19:56:50 +03:00
|
|
|
#include <linux/crypto.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <crypto/internal/hash.h>
|
2019-05-20 19:44:48 +03:00
|
|
|
#include <crypto/internal/skcipher.h>
|
2015-02-06 19:56:50 +03:00
|
|
|
|
2021-01-03 00:56:18 +03:00
|
|
|
#include "aesp8-ppc.h"
|
2015-02-06 19:56:50 +03:00
|
|
|
|
2019-03-21 18:11:48 +03:00
|
|
|
static int __init p8_init(void)
|
2015-02-06 19:56:50 +03:00
|
|
|
{
|
2019-05-20 19:44:48 +03:00
|
|
|
int ret;
|
2015-02-06 19:56:50 +03:00
|
|
|
|
2019-05-20 19:44:48 +03:00
|
|
|
ret = crypto_register_shash(&p8_ghash_alg);
|
2015-06-15 11:55:46 +03:00
|
|
|
if (ret)
|
2019-05-20 19:44:48 +03:00
|
|
|
goto err;
|
2015-02-06 19:56:50 +03:00
|
|
|
|
2019-05-20 19:44:48 +03:00
|
|
|
ret = crypto_register_alg(&p8_aes_alg);
|
|
|
|
if (ret)
|
|
|
|
goto err_unregister_ghash;
|
|
|
|
|
|
|
|
ret = crypto_register_skcipher(&p8_aes_cbc_alg);
|
|
|
|
if (ret)
|
|
|
|
goto err_unregister_aes;
|
|
|
|
|
|
|
|
ret = crypto_register_skcipher(&p8_aes_ctr_alg);
|
|
|
|
if (ret)
|
|
|
|
goto err_unregister_aes_cbc;
|
|
|
|
|
|
|
|
ret = crypto_register_skcipher(&p8_aes_xts_alg);
|
|
|
|
if (ret)
|
|
|
|
goto err_unregister_aes_ctr;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_unregister_aes_ctr:
|
|
|
|
crypto_unregister_skcipher(&p8_aes_ctr_alg);
|
|
|
|
err_unregister_aes_cbc:
|
|
|
|
crypto_unregister_skcipher(&p8_aes_cbc_alg);
|
|
|
|
err_unregister_aes:
|
|
|
|
crypto_unregister_alg(&p8_aes_alg);
|
|
|
|
err_unregister_ghash:
|
|
|
|
crypto_unregister_shash(&p8_ghash_alg);
|
|
|
|
err:
|
2015-06-15 11:55:46 +03:00
|
|
|
return ret;
|
2015-02-06 19:56:50 +03:00
|
|
|
}
|
|
|
|
|
2019-03-21 18:11:48 +03:00
|
|
|
static void __exit p8_exit(void)
|
2015-02-06 19:56:50 +03:00
|
|
|
{
|
2019-05-20 19:44:48 +03:00
|
|
|
crypto_unregister_skcipher(&p8_aes_xts_alg);
|
|
|
|
crypto_unregister_skcipher(&p8_aes_ctr_alg);
|
|
|
|
crypto_unregister_skcipher(&p8_aes_cbc_alg);
|
|
|
|
crypto_unregister_alg(&p8_aes_alg);
|
2015-06-15 11:55:46 +03:00
|
|
|
crypto_unregister_shash(&p8_ghash_alg);
|
2015-02-06 19:56:50 +03:00
|
|
|
}
|
|
|
|
|
2016-07-19 07:03:53 +03:00
|
|
|
module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, p8_init);
|
2015-02-06 19:56:50 +03:00
|
|
|
module_exit(p8_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Marcelo Cerri<mhcerri@br.ibm.com>");
|
2015-06-15 11:55:46 +03:00
|
|
|
MODULE_DESCRIPTION("IBM VMX cryptographic acceleration instructions "
|
|
|
|
"support on Power 8");
|
2015-02-06 19:56:50 +03:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_VERSION("1.0.0");
|
2020-12-11 15:27:15 +03:00
|
|
|
MODULE_IMPORT_NS(CRYPTO_INTERNAL);
|