libnvdimm/of_pmem: Provide a unique name for bus provider
[linux-2.6-block.git] / include / crypto / morus1280_glue.h
CommitLineData
12ea20f6 1/* SPDX-License-Identifier: GPL-2.0-or-later */
56e8e57f
OM
2/*
3 * The MORUS-1280 Authenticated-Encryption Algorithm
4 * Common glue skeleton -- header file
5 *
6 * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com>
7 * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
56e8e57f
OM
8 */
9
10#ifndef _CRYPTO_MORUS1280_GLUE_H
11#define _CRYPTO_MORUS1280_GLUE_H
12
13#include <linux/module.h>
14#include <linux/types.h>
15#include <crypto/algapi.h>
16#include <crypto/aead.h>
17#include <crypto/morus_common.h>
18
19#define MORUS1280_WORD_SIZE 8
20#define MORUS1280_BLOCK_SIZE (MORUS_BLOCK_WORDS * MORUS1280_WORD_SIZE)
21
22struct morus1280_block {
23 u8 bytes[MORUS1280_BLOCK_SIZE];
24};
25
26struct morus1280_glue_ops {
27 void (*init)(void *state, const void *key, const void *iv);
28 void (*ad)(void *state, const void *data, unsigned int length);
29 void (*enc)(void *state, const void *src, void *dst, unsigned int length);
30 void (*dec)(void *state, const void *src, void *dst, unsigned int length);
31 void (*enc_tail)(void *state, const void *src, void *dst, unsigned int length);
32 void (*dec_tail)(void *state, const void *src, void *dst, unsigned int length);
33 void (*final)(void *state, void *tag_xor, u64 assoclen, u64 cryptlen);
34};
35
36struct morus1280_ctx {
37 const struct morus1280_glue_ops *ops;
38 struct morus1280_block key;
39};
40
41void crypto_morus1280_glue_init_ops(struct crypto_aead *aead,
42 const struct morus1280_glue_ops *ops);
43int crypto_morus1280_glue_setkey(struct crypto_aead *aead, const u8 *key,
44 unsigned int keylen);
45int crypto_morus1280_glue_setauthsize(struct crypto_aead *tfm,
46 unsigned int authsize);
47int crypto_morus1280_glue_encrypt(struct aead_request *req);
48int crypto_morus1280_glue_decrypt(struct aead_request *req);
49
e151a8d2 50#define MORUS1280_DECLARE_ALG(id, driver_name, priority) \
56e8e57f
OM
51 static const struct morus1280_glue_ops crypto_morus1280_##id##_ops = {\
52 .init = crypto_morus1280_##id##_init, \
53 .ad = crypto_morus1280_##id##_ad, \
54 .enc = crypto_morus1280_##id##_enc, \
55 .enc_tail = crypto_morus1280_##id##_enc_tail, \
56 .dec = crypto_morus1280_##id##_dec, \
57 .dec_tail = crypto_morus1280_##id##_dec_tail, \
58 .final = crypto_morus1280_##id##_final, \
59 }; \
60 \
61 static int crypto_morus1280_##id##_init_tfm(struct crypto_aead *tfm) \
62 { \
63 crypto_morus1280_glue_init_ops(tfm, &crypto_morus1280_##id##_ops); \
64 return 0; \
65 } \
66 \
67 static void crypto_morus1280_##id##_exit_tfm(struct crypto_aead *tfm) \
68 { \
69 } \
70 \
e151a8d2
EB
71 static struct aead_alg crypto_morus1280_##id##_alg = { \
72 .setkey = crypto_morus1280_glue_setkey, \
73 .setauthsize = crypto_morus1280_glue_setauthsize, \
74 .encrypt = crypto_morus1280_glue_encrypt, \
75 .decrypt = crypto_morus1280_glue_decrypt, \
76 .init = crypto_morus1280_##id##_init_tfm, \
77 .exit = crypto_morus1280_##id##_exit_tfm, \
78 \
79 .ivsize = MORUS_NONCE_SIZE, \
80 .maxauthsize = MORUS_MAX_AUTH_SIZE, \
81 .chunksize = MORUS1280_BLOCK_SIZE, \
82 \
83 .base = { \
84 .cra_flags = CRYPTO_ALG_INTERNAL, \
85 .cra_blocksize = 1, \
86 .cra_ctxsize = sizeof(struct morus1280_ctx), \
87 .cra_alignmask = 0, \
88 .cra_priority = priority, \
56e8e57f 89 \
e151a8d2
EB
90 .cra_name = "__morus1280", \
91 .cra_driver_name = "__"driver_name, \
56e8e57f 92 \
e151a8d2 93 .cra_module = THIS_MODULE, \
56e8e57f
OM
94 } \
95 }
96
97#endif /* _CRYPTO_MORUS1280_GLUE_H */