@@ -1288,12 +1288,8 @@ static struct skcipher_alg aes_algs[] = {
12881288{
12891289 .base .cra_name = "ecb(aes)" ,
12901290 .base .cra_driver_name = "atmel-ecb-aes" ,
1291- .base .cra_priority = ATMEL_AES_PRIORITY ,
1292- .base .cra_flags = CRYPTO_ALG_ASYNC ,
12931291 .base .cra_blocksize = AES_BLOCK_SIZE ,
12941292 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1295- .base .cra_alignmask = 0xf ,
1296- .base .cra_module = THIS_MODULE ,
12971293
12981294 .init = atmel_aes_init_tfm ,
12991295 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1305,12 +1301,8 @@ static struct skcipher_alg aes_algs[] = {
13051301{
13061302 .base .cra_name = "cbc(aes)" ,
13071303 .base .cra_driver_name = "atmel-cbc-aes" ,
1308- .base .cra_priority = ATMEL_AES_PRIORITY ,
1309- .base .cra_flags = CRYPTO_ALG_ASYNC ,
13101304 .base .cra_blocksize = AES_BLOCK_SIZE ,
13111305 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1312- .base .cra_alignmask = 0xf ,
1313- .base .cra_module = THIS_MODULE ,
13141306
13151307 .init = atmel_aes_init_tfm ,
13161308 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1323,12 +1315,8 @@ static struct skcipher_alg aes_algs[] = {
13231315{
13241316 .base .cra_name = "ofb(aes)" ,
13251317 .base .cra_driver_name = "atmel-ofb-aes" ,
1326- .base .cra_priority = ATMEL_AES_PRIORITY ,
1327- .base .cra_flags = CRYPTO_ALG_ASYNC ,
13281318 .base .cra_blocksize = AES_BLOCK_SIZE ,
13291319 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1330- .base .cra_alignmask = 0xf ,
1331- .base .cra_module = THIS_MODULE ,
13321320
13331321 .init = atmel_aes_init_tfm ,
13341322 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1341,12 +1329,8 @@ static struct skcipher_alg aes_algs[] = {
13411329{
13421330 .base .cra_name = "cfb(aes)" ,
13431331 .base .cra_driver_name = "atmel-cfb-aes" ,
1344- .base .cra_priority = ATMEL_AES_PRIORITY ,
1345- .base .cra_flags = CRYPTO_ALG_ASYNC ,
13461332 .base .cra_blocksize = AES_BLOCK_SIZE ,
13471333 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1348- .base .cra_alignmask = 0xf ,
1349- .base .cra_module = THIS_MODULE ,
13501334
13511335 .init = atmel_aes_init_tfm ,
13521336 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1359,12 +1343,8 @@ static struct skcipher_alg aes_algs[] = {
13591343{
13601344 .base .cra_name = "cfb32(aes)" ,
13611345 .base .cra_driver_name = "atmel-cfb32-aes" ,
1362- .base .cra_priority = ATMEL_AES_PRIORITY ,
1363- .base .cra_flags = CRYPTO_ALG_ASYNC ,
13641346 .base .cra_blocksize = CFB32_BLOCK_SIZE ,
13651347 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1366- .base .cra_alignmask = 0xf ,
1367- .base .cra_module = THIS_MODULE ,
13681348
13691349 .init = atmel_aes_init_tfm ,
13701350 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1377,12 +1357,8 @@ static struct skcipher_alg aes_algs[] = {
13771357{
13781358 .base .cra_name = "cfb16(aes)" ,
13791359 .base .cra_driver_name = "atmel-cfb16-aes" ,
1380- .base .cra_priority = ATMEL_AES_PRIORITY ,
1381- .base .cra_flags = CRYPTO_ALG_ASYNC ,
13821360 .base .cra_blocksize = CFB16_BLOCK_SIZE ,
13831361 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1384- .base .cra_alignmask = 0xf ,
1385- .base .cra_module = THIS_MODULE ,
13861362
13871363 .init = atmel_aes_init_tfm ,
13881364 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1395,12 +1371,8 @@ static struct skcipher_alg aes_algs[] = {
13951371{
13961372 .base .cra_name = "cfb8(aes)" ,
13971373 .base .cra_driver_name = "atmel-cfb8-aes" ,
1398- .base .cra_priority = ATMEL_AES_PRIORITY ,
1399- .base .cra_flags = CRYPTO_ALG_ASYNC ,
14001374 .base .cra_blocksize = CFB8_BLOCK_SIZE ,
14011375 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1402- .base .cra_alignmask = 0xf ,
1403- .base .cra_module = THIS_MODULE ,
14041376
14051377 .init = atmel_aes_init_tfm ,
14061378 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1413,12 +1385,8 @@ static struct skcipher_alg aes_algs[] = {
14131385{
14141386 .base .cra_name = "ctr(aes)" ,
14151387 .base .cra_driver_name = "atmel-ctr-aes" ,
1416- .base .cra_priority = ATMEL_AES_PRIORITY ,
1417- .base .cra_flags = CRYPTO_ALG_ASYNC ,
14181388 .base .cra_blocksize = 1 ,
14191389 .base .cra_ctxsize = sizeof (struct atmel_aes_ctr_ctx ),
1420- .base .cra_alignmask = 0xf ,
1421- .base .cra_module = THIS_MODULE ,
14221390
14231391 .init = atmel_aes_ctr_init_tfm ,
14241392 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1433,12 +1401,8 @@ static struct skcipher_alg aes_algs[] = {
14331401static struct skcipher_alg aes_cfb64_alg = {
14341402 .base .cra_name = "cfb64(aes)" ,
14351403 .base .cra_driver_name = "atmel-cfb64-aes" ,
1436- .base .cra_priority = ATMEL_AES_PRIORITY ,
1437- .base .cra_flags = CRYPTO_ALG_ASYNC ,
14381404 .base .cra_blocksize = CFB64_BLOCK_SIZE ,
14391405 .base .cra_ctxsize = sizeof (struct atmel_aes_ctx ),
1440- .base .cra_alignmask = 0xf ,
1441- .base .cra_module = THIS_MODULE ,
14421406
14431407 .init = atmel_aes_init_tfm ,
14441408 .min_keysize = AES_MIN_KEY_SIZE ,
@@ -1824,12 +1788,8 @@ static struct aead_alg aes_gcm_alg = {
18241788 .base = {
18251789 .cra_name = "gcm(aes)" ,
18261790 .cra_driver_name = "atmel-gcm-aes" ,
1827- .cra_priority = ATMEL_AES_PRIORITY ,
1828- .cra_flags = CRYPTO_ALG_ASYNC ,
18291791 .cra_blocksize = 1 ,
18301792 .cra_ctxsize = sizeof (struct atmel_aes_gcm_ctx ),
1831- .cra_alignmask = 0xf ,
1832- .cra_module = THIS_MODULE ,
18331793 },
18341794};
18351795
@@ -1946,12 +1906,8 @@ static int atmel_aes_xts_init_tfm(struct crypto_skcipher *tfm)
19461906static struct skcipher_alg aes_xts_alg = {
19471907 .base .cra_name = "xts(aes)" ,
19481908 .base .cra_driver_name = "atmel-xts-aes" ,
1949- .base .cra_priority = ATMEL_AES_PRIORITY ,
1950- .base .cra_flags = CRYPTO_ALG_ASYNC ,
19511909 .base .cra_blocksize = AES_BLOCK_SIZE ,
19521910 .base .cra_ctxsize = sizeof (struct atmel_aes_xts_ctx ),
1953- .base .cra_alignmask = 0xf ,
1954- .base .cra_module = THIS_MODULE ,
19551911
19561912 .min_keysize = 2 * AES_MIN_KEY_SIZE ,
19571913 .max_keysize = 2 * AES_MAX_KEY_SIZE ,
@@ -2251,12 +2207,8 @@ static struct aead_alg aes_authenc_algs[] = {
22512207 .base = {
22522208 .cra_name = "authenc(hmac(sha1),cbc(aes))" ,
22532209 .cra_driver_name = "atmel-authenc-hmac-sha1-cbc-aes" ,
2254- .cra_priority = ATMEL_AES_PRIORITY ,
2255- .cra_flags = CRYPTO_ALG_ASYNC ,
22562210 .cra_blocksize = AES_BLOCK_SIZE ,
22572211 .cra_ctxsize = sizeof (struct atmel_aes_authenc_ctx ),
2258- .cra_alignmask = 0xf ,
2259- .cra_module = THIS_MODULE ,
22602212 },
22612213},
22622214{
@@ -2271,12 +2223,8 @@ static struct aead_alg aes_authenc_algs[] = {
22712223 .base = {
22722224 .cra_name = "authenc(hmac(sha224),cbc(aes))" ,
22732225 .cra_driver_name = "atmel-authenc-hmac-sha224-cbc-aes" ,
2274- .cra_priority = ATMEL_AES_PRIORITY ,
2275- .cra_flags = CRYPTO_ALG_ASYNC ,
22762226 .cra_blocksize = AES_BLOCK_SIZE ,
22772227 .cra_ctxsize = sizeof (struct atmel_aes_authenc_ctx ),
2278- .cra_alignmask = 0xf ,
2279- .cra_module = THIS_MODULE ,
22802228 },
22812229},
22822230{
@@ -2291,12 +2239,8 @@ static struct aead_alg aes_authenc_algs[] = {
22912239 .base = {
22922240 .cra_name = "authenc(hmac(sha256),cbc(aes))" ,
22932241 .cra_driver_name = "atmel-authenc-hmac-sha256-cbc-aes" ,
2294- .cra_priority = ATMEL_AES_PRIORITY ,
2295- .cra_flags = CRYPTO_ALG_ASYNC ,
22962242 .cra_blocksize = AES_BLOCK_SIZE ,
22972243 .cra_ctxsize = sizeof (struct atmel_aes_authenc_ctx ),
2298- .cra_alignmask = 0xf ,
2299- .cra_module = THIS_MODULE ,
23002244 },
23012245},
23022246{
@@ -2311,12 +2255,8 @@ static struct aead_alg aes_authenc_algs[] = {
23112255 .base = {
23122256 .cra_name = "authenc(hmac(sha384),cbc(aes))" ,
23132257 .cra_driver_name = "atmel-authenc-hmac-sha384-cbc-aes" ,
2314- .cra_priority = ATMEL_AES_PRIORITY ,
2315- .cra_flags = CRYPTO_ALG_ASYNC ,
23162258 .cra_blocksize = AES_BLOCK_SIZE ,
23172259 .cra_ctxsize = sizeof (struct atmel_aes_authenc_ctx ),
2318- .cra_alignmask = 0xf ,
2319- .cra_module = THIS_MODULE ,
23202260 },
23212261},
23222262{
@@ -2331,12 +2271,8 @@ static struct aead_alg aes_authenc_algs[] = {
23312271 .base = {
23322272 .cra_name = "authenc(hmac(sha512),cbc(aes))" ,
23332273 .cra_driver_name = "atmel-authenc-hmac-sha512-cbc-aes" ,
2334- .cra_priority = ATMEL_AES_PRIORITY ,
2335- .cra_flags = CRYPTO_ALG_ASYNC ,
23362274 .cra_blocksize = AES_BLOCK_SIZE ,
23372275 .cra_ctxsize = sizeof (struct atmel_aes_authenc_ctx ),
2338- .cra_alignmask = 0xf ,
2339- .cra_module = THIS_MODULE ,
23402276 },
23412277},
23422278};
@@ -2452,29 +2388,45 @@ static void atmel_aes_unregister_algs(struct atmel_aes_dev *dd)
24522388 crypto_unregister_skcipher (& aes_algs [i ]);
24532389}
24542390
2391+ static void atmel_aes_crypto_alg_init (struct crypto_alg * alg )
2392+ {
2393+ alg -> cra_flags = CRYPTO_ALG_ASYNC ;
2394+ alg -> cra_alignmask = 0xf ;
2395+ alg -> cra_priority = ATMEL_AES_PRIORITY ;
2396+ alg -> cra_module = THIS_MODULE ;
2397+ }
2398+
24552399static int atmel_aes_register_algs (struct atmel_aes_dev * dd )
24562400{
24572401 int err , i , j ;
24582402
24592403 for (i = 0 ; i < ARRAY_SIZE (aes_algs ); i ++ ) {
2404+ atmel_aes_crypto_alg_init (& aes_algs [i ].base );
2405+
24602406 err = crypto_register_skcipher (& aes_algs [i ]);
24612407 if (err )
24622408 goto err_aes_algs ;
24632409 }
24642410
24652411 if (dd -> caps .has_cfb64 ) {
2412+ atmel_aes_crypto_alg_init (& aes_cfb64_alg .base );
2413+
24662414 err = crypto_register_skcipher (& aes_cfb64_alg );
24672415 if (err )
24682416 goto err_aes_cfb64_alg ;
24692417 }
24702418
24712419 if (dd -> caps .has_gcm ) {
2420+ atmel_aes_crypto_alg_init (& aes_gcm_alg .base );
2421+
24722422 err = crypto_register_aead (& aes_gcm_alg );
24732423 if (err )
24742424 goto err_aes_gcm_alg ;
24752425 }
24762426
24772427 if (dd -> caps .has_xts ) {
2428+ atmel_aes_crypto_alg_init (& aes_xts_alg .base );
2429+
24782430 err = crypto_register_skcipher (& aes_xts_alg );
24792431 if (err )
24802432 goto err_aes_xts_alg ;
@@ -2483,6 +2435,8 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd)
24832435#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )
24842436 if (dd -> caps .has_authenc ) {
24852437 for (i = 0 ; i < ARRAY_SIZE (aes_authenc_algs ); i ++ ) {
2438+ atmel_aes_crypto_alg_init (& aes_authenc_algs [i ].base );
2439+
24862440 err = crypto_register_aead (& aes_authenc_algs [i ]);
24872441 if (err )
24882442 goto err_aes_authenc_alg ;
0 commit comments