diff options
author | Lee Nipper <lee.nipper@freescale.com> | 2008-07-10 06:29:18 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-07-10 08:35:19 -0400 |
commit | 3952f17ed63434cc2154c3765ff97e1d4adab042 (patch) | |
tree | 938317e6bfb8d4c84ab1553c500e8eefae2508db /drivers/crypto | |
parent | 18e33e6d5cc0495826f5245777cd267732815e01 (diff) |
crypto: talitos - Add support for sha256 and md5 variants
This patch adds support for:
authenc(hmac(sha256),cbc(aes)),
authenc(hmac(sha256),cbc(des3_ede)),
authenc(hmac(md5),cbc(aes)),
authenc(hmac(md5),cbc(des3_ede)).
Some constant usage was changed to use aes, des, and sha include files.
Signed-off-by: Lee Nipper <lee.nipper@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/talitos.c | 111 |
1 files changed, 99 insertions, 12 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 8c270cd7baac..b11943dadefd 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #include <crypto/algapi.h> | 41 | #include <crypto/algapi.h> |
42 | #include <crypto/aes.h> | 42 | #include <crypto/aes.h> |
43 | #include <crypto/des.h> | ||
43 | #include <crypto/sha.h> | 44 | #include <crypto/sha.h> |
44 | #include <crypto/aead.h> | 45 | #include <crypto/aead.h> |
45 | #include <crypto/authenc.h> | 46 | #include <crypto/authenc.h> |
@@ -640,13 +641,9 @@ static void talitos_unregister_rng(struct device *dev) | |||
640 | */ | 641 | */ |
641 | #define TALITOS_CRA_PRIORITY 3000 | 642 | #define TALITOS_CRA_PRIORITY 3000 |
642 | #define TALITOS_MAX_KEY_SIZE 64 | 643 | #define TALITOS_MAX_KEY_SIZE 64 |
643 | #define TALITOS_MAX_AUTH_SIZE 20 | 644 | #define TALITOS_MAX_IV_LENGTH 16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */ |
644 | #define TALITOS_AES_MIN_BLOCK_SIZE 16 | ||
645 | #define TALITOS_3DES_MIN_BLOCK_SIZE 24 | ||
646 | 645 | ||
647 | #define TALITOS_AES_IV_LENGTH 16 | 646 | #define MD5_DIGEST_SIZE 16 |
648 | #define TALITOS_3DES_IV_LENGTH 8 | ||
649 | #define TALITOS_MAX_IV_LENGTH 16 | ||
650 | 647 | ||
651 | struct talitos_ctx { | 648 | struct talitos_ctx { |
652 | struct device *dev; | 649 | struct device *dev; |
@@ -1145,7 +1142,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
1145 | { | 1142 | { |
1146 | .name = "authenc(hmac(sha1),cbc(aes))", | 1143 | .name = "authenc(hmac(sha1),cbc(aes))", |
1147 | .driver_name = "authenc-hmac-sha1-cbc-aes-talitos", | 1144 | .driver_name = "authenc-hmac-sha1-cbc-aes-talitos", |
1148 | .blocksize = TALITOS_AES_MIN_BLOCK_SIZE, | 1145 | .blocksize = AES_BLOCK_SIZE, |
1149 | .aead = { | 1146 | .aead = { |
1150 | .setkey = aead_authenc_setkey, | 1147 | .setkey = aead_authenc_setkey, |
1151 | .setauthsize = aead_authenc_setauthsize, | 1148 | .setauthsize = aead_authenc_setauthsize, |
@@ -1153,8 +1150,8 @@ static struct talitos_alg_template driver_algs[] = { | |||
1153 | .decrypt = aead_authenc_decrypt, | 1150 | .decrypt = aead_authenc_decrypt, |
1154 | .givencrypt = aead_authenc_givencrypt, | 1151 | .givencrypt = aead_authenc_givencrypt, |
1155 | .geniv = "<built-in>", | 1152 | .geniv = "<built-in>", |
1156 | .ivsize = TALITOS_AES_IV_LENGTH, | 1153 | .ivsize = AES_BLOCK_SIZE, |
1157 | .maxauthsize = TALITOS_MAX_AUTH_SIZE, | 1154 | .maxauthsize = SHA1_DIGEST_SIZE, |
1158 | }, | 1155 | }, |
1159 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | | 1156 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | |
1160 | DESC_HDR_SEL0_AESU | | 1157 | DESC_HDR_SEL0_AESU | |
@@ -1167,7 +1164,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
1167 | { | 1164 | { |
1168 | .name = "authenc(hmac(sha1),cbc(des3_ede))", | 1165 | .name = "authenc(hmac(sha1),cbc(des3_ede))", |
1169 | .driver_name = "authenc-hmac-sha1-cbc-3des-talitos", | 1166 | .driver_name = "authenc-hmac-sha1-cbc-3des-talitos", |
1170 | .blocksize = TALITOS_3DES_MIN_BLOCK_SIZE, | 1167 | .blocksize = DES3_EDE_BLOCK_SIZE, |
1171 | .aead = { | 1168 | .aead = { |
1172 | .setkey = aead_authenc_setkey, | 1169 | .setkey = aead_authenc_setkey, |
1173 | .setauthsize = aead_authenc_setauthsize, | 1170 | .setauthsize = aead_authenc_setauthsize, |
@@ -1175,8 +1172,8 @@ static struct talitos_alg_template driver_algs[] = { | |||
1175 | .decrypt = aead_authenc_decrypt, | 1172 | .decrypt = aead_authenc_decrypt, |
1176 | .givencrypt = aead_authenc_givencrypt, | 1173 | .givencrypt = aead_authenc_givencrypt, |
1177 | .geniv = "<built-in>", | 1174 | .geniv = "<built-in>", |
1178 | .ivsize = TALITOS_3DES_IV_LENGTH, | 1175 | .ivsize = DES3_EDE_BLOCK_SIZE, |
1179 | .maxauthsize = TALITOS_MAX_AUTH_SIZE, | 1176 | .maxauthsize = SHA1_DIGEST_SIZE, |
1180 | }, | 1177 | }, |
1181 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | | 1178 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | |
1182 | DESC_HDR_SEL0_DEU | | 1179 | DESC_HDR_SEL0_DEU | |
@@ -1186,6 +1183,96 @@ static struct talitos_alg_template driver_algs[] = { | |||
1186 | DESC_HDR_MODE1_MDEU_INIT | | 1183 | DESC_HDR_MODE1_MDEU_INIT | |
1187 | DESC_HDR_MODE1_MDEU_PAD | | 1184 | DESC_HDR_MODE1_MDEU_PAD | |
1188 | DESC_HDR_MODE1_MDEU_SHA1_HMAC, | 1185 | DESC_HDR_MODE1_MDEU_SHA1_HMAC, |
1186 | }, | ||
1187 | { | ||
1188 | .name = "authenc(hmac(sha256),cbc(aes))", | ||
1189 | .driver_name = "authenc-hmac-sha256-cbc-aes-talitos", | ||
1190 | .blocksize = AES_BLOCK_SIZE, | ||
1191 | .aead = { | ||
1192 | .setkey = aead_authenc_setkey, | ||
1193 | .setauthsize = aead_authenc_setauthsize, | ||
1194 | .encrypt = aead_authenc_encrypt, | ||
1195 | .decrypt = aead_authenc_decrypt, | ||
1196 | .givencrypt = aead_authenc_givencrypt, | ||
1197 | .geniv = "<built-in>", | ||
1198 | .ivsize = AES_BLOCK_SIZE, | ||
1199 | .maxauthsize = SHA256_DIGEST_SIZE, | ||
1200 | }, | ||
1201 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | | ||
1202 | DESC_HDR_SEL0_AESU | | ||
1203 | DESC_HDR_MODE0_AESU_CBC | | ||
1204 | DESC_HDR_SEL1_MDEUA | | ||
1205 | DESC_HDR_MODE1_MDEU_INIT | | ||
1206 | DESC_HDR_MODE1_MDEU_PAD | | ||
1207 | DESC_HDR_MODE1_MDEU_SHA256_HMAC, | ||
1208 | }, | ||
1209 | { | ||
1210 | .name = "authenc(hmac(sha256),cbc(des3_ede))", | ||
1211 | .driver_name = "authenc-hmac-sha256-cbc-3des-talitos", | ||
1212 | .blocksize = DES3_EDE_BLOCK_SIZE, | ||
1213 | .aead = { | ||
1214 | .setkey = aead_authenc_setkey, | ||
1215 | .setauthsize = aead_authenc_setauthsize, | ||
1216 | .encrypt = aead_authenc_encrypt, | ||
1217 | .decrypt = aead_authenc_decrypt, | ||
1218 | .givencrypt = aead_authenc_givencrypt, | ||
1219 | .geniv = "<built-in>", | ||
1220 | .ivsize = DES3_EDE_BLOCK_SIZE, | ||
1221 | .maxauthsize = SHA256_DIGEST_SIZE, | ||
1222 | }, | ||
1223 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | | ||
1224 | DESC_HDR_SEL0_DEU | | ||
1225 | DESC_HDR_MODE0_DEU_CBC | | ||
1226 | DESC_HDR_MODE0_DEU_3DES | | ||
1227 | DESC_HDR_SEL1_MDEUA | | ||
1228 | DESC_HDR_MODE1_MDEU_INIT | | ||
1229 | DESC_HDR_MODE1_MDEU_PAD | | ||
1230 | DESC_HDR_MODE1_MDEU_SHA256_HMAC, | ||
1231 | }, | ||
1232 | { | ||
1233 | .name = "authenc(hmac(md5),cbc(aes))", | ||
1234 | .driver_name = "authenc-hmac-md5-cbc-aes-talitos", | ||
1235 | .blocksize = AES_BLOCK_SIZE, | ||
1236 | .aead = { | ||
1237 | .setkey = aead_authenc_setkey, | ||
1238 | .setauthsize = aead_authenc_setauthsize, | ||
1239 | .encrypt = aead_authenc_encrypt, | ||
1240 | .decrypt = aead_authenc_decrypt, | ||
1241 | .givencrypt = aead_authenc_givencrypt, | ||
1242 | .geniv = "<built-in>", | ||
1243 | .ivsize = AES_BLOCK_SIZE, | ||
1244 | .maxauthsize = MD5_DIGEST_SIZE, | ||
1245 | }, | ||
1246 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | | ||
1247 | DESC_HDR_SEL0_AESU | | ||
1248 | DESC_HDR_MODE0_AESU_CBC | | ||
1249 | DESC_HDR_SEL1_MDEUA | | ||
1250 | DESC_HDR_MODE1_MDEU_INIT | | ||
1251 | DESC_HDR_MODE1_MDEU_PAD | | ||
1252 | DESC_HDR_MODE1_MDEU_MD5_HMAC, | ||
1253 | }, | ||
1254 | { | ||
1255 | .name = "authenc(hmac(md5),cbc(des3_ede))", | ||
1256 | .driver_name = "authenc-hmac-md5-cbc-3des-talitos", | ||
1257 | .blocksize = DES3_EDE_BLOCK_SIZE, | ||
1258 | .aead = { | ||
1259 | .setkey = aead_authenc_setkey, | ||
1260 | .setauthsize = aead_authenc_setauthsize, | ||
1261 | .encrypt = aead_authenc_encrypt, | ||
1262 | .decrypt = aead_authenc_decrypt, | ||
1263 | .givencrypt = aead_authenc_givencrypt, | ||
1264 | .geniv = "<built-in>", | ||
1265 | .ivsize = DES3_EDE_BLOCK_SIZE, | ||
1266 | .maxauthsize = MD5_DIGEST_SIZE, | ||
1267 | }, | ||
1268 | .desc_hdr_template = DESC_HDR_TYPE_IPSEC_ESP | | ||
1269 | DESC_HDR_SEL0_DEU | | ||
1270 | DESC_HDR_MODE0_DEU_CBC | | ||
1271 | DESC_HDR_MODE0_DEU_3DES | | ||
1272 | DESC_HDR_SEL1_MDEUA | | ||
1273 | DESC_HDR_MODE1_MDEU_INIT | | ||
1274 | DESC_HDR_MODE1_MDEU_PAD | | ||
1275 | DESC_HDR_MODE1_MDEU_MD5_HMAC, | ||
1189 | } | 1276 | } |
1190 | }; | 1277 | }; |
1191 | 1278 | ||