crypto: inside-secure - Added support for authenc HMAC-SHA2/3DES-CBC
This patch adds support for the authenc(hmac(sha224),cbc(des3_ede)), authenc(hmac(sha256),cbc(des3_ede)), authenc(hmac(sha384),cbc(des3_ede)) and authenc(hmac(sha512),cbc(des3_ede)) aead's changes since v1: - nothing Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
bb7679b840
commit
f0a8bdf0b1
|
@ -1196,6 +1196,10 @@ static struct safexcel_alg_template *safexcel_algs[] = {
|
|||
&safexcel_alg_hmac_sha3_384,
|
||||
&safexcel_alg_hmac_sha3_512,
|
||||
&safexcel_alg_authenc_hmac_sha1_cbc_des,
|
||||
&safexcel_alg_authenc_hmac_sha256_cbc_des3_ede,
|
||||
&safexcel_alg_authenc_hmac_sha224_cbc_des3_ede,
|
||||
&safexcel_alg_authenc_hmac_sha512_cbc_des3_ede,
|
||||
&safexcel_alg_authenc_hmac_sha384_cbc_des3_ede,
|
||||
};
|
||||
|
||||
static int safexcel_register_algorithms(struct safexcel_crypto_priv *priv)
|
||||
|
|
|
@ -902,5 +902,9 @@ extern struct safexcel_alg_template safexcel_alg_hmac_sha3_256;
|
|||
extern struct safexcel_alg_template safexcel_alg_hmac_sha3_384;
|
||||
extern struct safexcel_alg_template safexcel_alg_hmac_sha3_512;
|
||||
extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des;
|
||||
extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des3_ede;
|
||||
extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des3_ede;
|
||||
extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des3_ede;
|
||||
extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des3_ede;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1846,6 +1846,142 @@ struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des3_ede = {
|
|||
},
|
||||
};
|
||||
|
||||
static int safexcel_aead_sha256_des3_cra_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
safexcel_aead_sha256_cra_init(tfm);
|
||||
ctx->alg = SAFEXCEL_3DES; /* override default */
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des3_ede = {
|
||||
.type = SAFEXCEL_ALG_TYPE_AEAD,
|
||||
.algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_256,
|
||||
.alg.aead = {
|
||||
.setkey = safexcel_aead_setkey,
|
||||
.encrypt = safexcel_aead_encrypt,
|
||||
.decrypt = safexcel_aead_decrypt,
|
||||
.ivsize = DES3_EDE_BLOCK_SIZE,
|
||||
.maxauthsize = SHA256_DIGEST_SIZE,
|
||||
.base = {
|
||||
.cra_name = "authenc(hmac(sha256),cbc(des3_ede))",
|
||||
.cra_driver_name = "safexcel-authenc-hmac-sha256-cbc-des3_ede",
|
||||
.cra_priority = SAFEXCEL_CRA_PRIORITY,
|
||||
.cra_flags = CRYPTO_ALG_ASYNC |
|
||||
CRYPTO_ALG_KERN_DRIVER_ONLY,
|
||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
|
||||
.cra_alignmask = 0,
|
||||
.cra_init = safexcel_aead_sha256_des3_cra_init,
|
||||
.cra_exit = safexcel_aead_cra_exit,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static int safexcel_aead_sha224_des3_cra_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
safexcel_aead_sha224_cra_init(tfm);
|
||||
ctx->alg = SAFEXCEL_3DES; /* override default */
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des3_ede = {
|
||||
.type = SAFEXCEL_ALG_TYPE_AEAD,
|
||||
.algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_256,
|
||||
.alg.aead = {
|
||||
.setkey = safexcel_aead_setkey,
|
||||
.encrypt = safexcel_aead_encrypt,
|
||||
.decrypt = safexcel_aead_decrypt,
|
||||
.ivsize = DES3_EDE_BLOCK_SIZE,
|
||||
.maxauthsize = SHA224_DIGEST_SIZE,
|
||||
.base = {
|
||||
.cra_name = "authenc(hmac(sha224),cbc(des3_ede))",
|
||||
.cra_driver_name = "safexcel-authenc-hmac-sha224-cbc-des3_ede",
|
||||
.cra_priority = SAFEXCEL_CRA_PRIORITY,
|
||||
.cra_flags = CRYPTO_ALG_ASYNC |
|
||||
CRYPTO_ALG_KERN_DRIVER_ONLY,
|
||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
|
||||
.cra_alignmask = 0,
|
||||
.cra_init = safexcel_aead_sha224_des3_cra_init,
|
||||
.cra_exit = safexcel_aead_cra_exit,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static int safexcel_aead_sha512_des3_cra_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
safexcel_aead_sha512_cra_init(tfm);
|
||||
ctx->alg = SAFEXCEL_3DES; /* override default */
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des3_ede = {
|
||||
.type = SAFEXCEL_ALG_TYPE_AEAD,
|
||||
.algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_512,
|
||||
.alg.aead = {
|
||||
.setkey = safexcel_aead_setkey,
|
||||
.encrypt = safexcel_aead_encrypt,
|
||||
.decrypt = safexcel_aead_decrypt,
|
||||
.ivsize = DES3_EDE_BLOCK_SIZE,
|
||||
.maxauthsize = SHA512_DIGEST_SIZE,
|
||||
.base = {
|
||||
.cra_name = "authenc(hmac(sha512),cbc(des3_ede))",
|
||||
.cra_driver_name = "safexcel-authenc-hmac-sha512-cbc-des3_ede",
|
||||
.cra_priority = SAFEXCEL_CRA_PRIORITY,
|
||||
.cra_flags = CRYPTO_ALG_ASYNC |
|
||||
CRYPTO_ALG_KERN_DRIVER_ONLY,
|
||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
|
||||
.cra_alignmask = 0,
|
||||
.cra_init = safexcel_aead_sha512_des3_cra_init,
|
||||
.cra_exit = safexcel_aead_cra_exit,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static int safexcel_aead_sha384_des3_cra_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
safexcel_aead_sha384_cra_init(tfm);
|
||||
ctx->alg = SAFEXCEL_3DES; /* override default */
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des3_ede = {
|
||||
.type = SAFEXCEL_ALG_TYPE_AEAD,
|
||||
.algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_512,
|
||||
.alg.aead = {
|
||||
.setkey = safexcel_aead_setkey,
|
||||
.encrypt = safexcel_aead_encrypt,
|
||||
.decrypt = safexcel_aead_decrypt,
|
||||
.ivsize = DES3_EDE_BLOCK_SIZE,
|
||||
.maxauthsize = SHA384_DIGEST_SIZE,
|
||||
.base = {
|
||||
.cra_name = "authenc(hmac(sha384),cbc(des3_ede))",
|
||||
.cra_driver_name = "safexcel-authenc-hmac-sha384-cbc-des3_ede",
|
||||
.cra_priority = SAFEXCEL_CRA_PRIORITY,
|
||||
.cra_flags = CRYPTO_ALG_ASYNC |
|
||||
CRYPTO_ALG_KERN_DRIVER_ONLY,
|
||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
|
||||
.cra_alignmask = 0,
|
||||
.cra_init = safexcel_aead_sha384_des3_cra_init,
|
||||
.cra_exit = safexcel_aead_cra_exit,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
static int safexcel_aead_sha1_des_cra_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
|
Loading…
Reference in New Issue