Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 2 | /* |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 3 | * Shared descriptors for aead, skcipher algorithms |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 4 | * |
| 5 | * Copyright 2016 NXP |
| 6 | */ |
| 7 | |
| 8 | #ifndef _CAAMALG_DESC_H_ |
| 9 | #define _CAAMALG_DESC_H_ |
| 10 | |
| 11 | /* length of descriptors text */ |
| 12 | #define DESC_AEAD_BASE (4 * CAAM_CMD_SZ) |
| 13 | #define DESC_AEAD_ENC_LEN (DESC_AEAD_BASE + 11 * CAAM_CMD_SZ) |
| 14 | #define DESC_AEAD_DEC_LEN (DESC_AEAD_BASE + 15 * CAAM_CMD_SZ) |
Horia Geantă | 48f89d2 | 2019-07-30 08:48:33 +0300 | [diff] [blame] | 15 | #define DESC_AEAD_GIVENC_LEN (DESC_AEAD_ENC_LEN + 8 * CAAM_CMD_SZ) |
Horia Geantă | b189817 | 2017-03-17 12:06:02 +0200 | [diff] [blame] | 16 | #define DESC_QI_AEAD_ENC_LEN (DESC_AEAD_ENC_LEN + 3 * CAAM_CMD_SZ) |
| 17 | #define DESC_QI_AEAD_DEC_LEN (DESC_AEAD_DEC_LEN + 3 * CAAM_CMD_SZ) |
| 18 | #define DESC_QI_AEAD_GIVENC_LEN (DESC_AEAD_GIVENC_LEN + 3 * CAAM_CMD_SZ) |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 19 | |
| 20 | /* Note: Nonce is counted in cdata.keylen */ |
| 21 | #define DESC_AEAD_CTR_RFC3686_LEN (4 * CAAM_CMD_SZ) |
| 22 | |
| 23 | #define DESC_AEAD_NULL_BASE (3 * CAAM_CMD_SZ) |
| 24 | #define DESC_AEAD_NULL_ENC_LEN (DESC_AEAD_NULL_BASE + 11 * CAAM_CMD_SZ) |
| 25 | #define DESC_AEAD_NULL_DEC_LEN (DESC_AEAD_NULL_BASE + 13 * CAAM_CMD_SZ) |
| 26 | |
| 27 | #define DESC_GCM_BASE (3 * CAAM_CMD_SZ) |
| 28 | #define DESC_GCM_ENC_LEN (DESC_GCM_BASE + 16 * CAAM_CMD_SZ) |
| 29 | #define DESC_GCM_DEC_LEN (DESC_GCM_BASE + 12 * CAAM_CMD_SZ) |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 30 | #define DESC_QI_GCM_ENC_LEN (DESC_GCM_ENC_LEN + 6 * CAAM_CMD_SZ) |
| 31 | #define DESC_QI_GCM_DEC_LEN (DESC_GCM_DEC_LEN + 3 * CAAM_CMD_SZ) |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 32 | |
| 33 | #define DESC_RFC4106_BASE (3 * CAAM_CMD_SZ) |
Iuliana Prodan | d28a43e | 2019-07-31 16:08:09 +0300 | [diff] [blame] | 34 | #define DESC_RFC4106_ENC_LEN (DESC_RFC4106_BASE + 16 * CAAM_CMD_SZ) |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 35 | #define DESC_RFC4106_DEC_LEN (DESC_RFC4106_BASE + 13 * CAAM_CMD_SZ) |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 36 | #define DESC_QI_RFC4106_ENC_LEN (DESC_RFC4106_ENC_LEN + 5 * CAAM_CMD_SZ) |
| 37 | #define DESC_QI_RFC4106_DEC_LEN (DESC_RFC4106_DEC_LEN + 5 * CAAM_CMD_SZ) |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 38 | |
| 39 | #define DESC_RFC4543_BASE (3 * CAAM_CMD_SZ) |
| 40 | #define DESC_RFC4543_ENC_LEN (DESC_RFC4543_BASE + 11 * CAAM_CMD_SZ) |
| 41 | #define DESC_RFC4543_DEC_LEN (DESC_RFC4543_BASE + 12 * CAAM_CMD_SZ) |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 42 | #define DESC_QI_RFC4543_ENC_LEN (DESC_RFC4543_ENC_LEN + 4 * CAAM_CMD_SZ) |
| 43 | #define DESC_QI_RFC4543_DEC_LEN (DESC_RFC4543_DEC_LEN + 4 * CAAM_CMD_SZ) |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 44 | |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 45 | #define DESC_SKCIPHER_BASE (3 * CAAM_CMD_SZ) |
| 46 | #define DESC_SKCIPHER_ENC_LEN (DESC_SKCIPHER_BASE + \ |
Horia Geantă | 334d37c | 2019-06-10 16:30:59 +0300 | [diff] [blame] | 47 | 21 * CAAM_CMD_SZ) |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 48 | #define DESC_SKCIPHER_DEC_LEN (DESC_SKCIPHER_BASE + \ |
Horia Geantă | 334d37c | 2019-06-10 16:30:59 +0300 | [diff] [blame] | 49 | 16 * CAAM_CMD_SZ) |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 50 | |
| 51 | void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata, |
Horia Geantă | 7e0880b | 2017-12-19 12:16:07 +0200 | [diff] [blame] | 52 | unsigned int icvsize, int era); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 53 | |
| 54 | void cnstr_shdsc_aead_null_decap(u32 * const desc, struct alginfo *adata, |
Horia Geantă | 7e0880b | 2017-12-19 12:16:07 +0200 | [diff] [blame] | 55 | unsigned int icvsize, int era); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 56 | |
| 57 | void cnstr_shdsc_aead_encap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | b189817 | 2017-03-17 12:06:02 +0200 | [diff] [blame] | 58 | struct alginfo *adata, unsigned int ivsize, |
| 59 | unsigned int icvsize, const bool is_rfc3686, |
| 60 | u32 *nonce, const u32 ctx1_iv_off, |
Horia Geantă | 7e0880b | 2017-12-19 12:16:07 +0200 | [diff] [blame] | 61 | const bool is_qi, int era); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 62 | |
| 63 | void cnstr_shdsc_aead_decap(u32 * const desc, struct alginfo *cdata, |
| 64 | struct alginfo *adata, unsigned int ivsize, |
| 65 | unsigned int icvsize, const bool geniv, |
| 66 | const bool is_rfc3686, u32 *nonce, |
Horia Geantă | 7e0880b | 2017-12-19 12:16:07 +0200 | [diff] [blame] | 67 | const u32 ctx1_iv_off, const bool is_qi, int era); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 68 | |
| 69 | void cnstr_shdsc_aead_givencap(u32 * const desc, struct alginfo *cdata, |
| 70 | struct alginfo *adata, unsigned int ivsize, |
| 71 | unsigned int icvsize, const bool is_rfc3686, |
Horia Geantă | b189817 | 2017-03-17 12:06:02 +0200 | [diff] [blame] | 72 | u32 *nonce, const u32 ctx1_iv_off, |
Horia Geantă | 7e0880b | 2017-12-19 12:16:07 +0200 | [diff] [blame] | 73 | const bool is_qi, int era); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 74 | |
| 75 | void cnstr_shdsc_gcm_encap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 76 | unsigned int ivsize, unsigned int icvsize, |
| 77 | const bool is_qi); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 78 | |
| 79 | void cnstr_shdsc_gcm_decap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 80 | unsigned int ivsize, unsigned int icvsize, |
| 81 | const bool is_qi); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 82 | |
| 83 | void cnstr_shdsc_rfc4106_encap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 84 | unsigned int ivsize, unsigned int icvsize, |
| 85 | const bool is_qi); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 86 | |
| 87 | void cnstr_shdsc_rfc4106_decap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 88 | unsigned int ivsize, unsigned int icvsize, |
| 89 | const bool is_qi); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 90 | |
| 91 | void cnstr_shdsc_rfc4543_encap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 92 | unsigned int ivsize, unsigned int icvsize, |
| 93 | const bool is_qi); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 94 | |
| 95 | void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata, |
Horia Geantă | 87ec3a0 | 2018-01-29 10:38:36 +0200 | [diff] [blame] | 96 | unsigned int ivsize, unsigned int icvsize, |
| 97 | const bool is_qi); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 98 | |
Horia Geantă | d6bbd4e | 2018-11-08 15:36:30 +0200 | [diff] [blame] | 99 | void cnstr_shdsc_chachapoly(u32 * const desc, struct alginfo *cdata, |
| 100 | struct alginfo *adata, unsigned int ivsize, |
Horia Geantă | c10a533 | 2018-11-08 15:36:31 +0200 | [diff] [blame] | 101 | unsigned int icvsize, const bool encap, |
| 102 | const bool is_qi); |
Horia Geantă | d6bbd4e | 2018-11-08 15:36:30 +0200 | [diff] [blame] | 103 | |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 104 | void cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata, |
| 105 | unsigned int ivsize, const bool is_rfc3686, |
| 106 | const u32 ctx1_iv_off); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 107 | |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 108 | void cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata, |
| 109 | unsigned int ivsize, const bool is_rfc3686, |
| 110 | const u32 ctx1_iv_off); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 111 | |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 112 | void cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 113 | |
Horia Geantă | 9dbe307 | 2018-08-06 15:44:00 +0300 | [diff] [blame] | 114 | void cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata); |
Horia Geantă | 8cea7b6 | 2016-11-22 15:44:09 +0200 | [diff] [blame] | 115 | |
| 116 | #endif /* _CAAMALG_DESC_H_ */ |