135
135
#define regk_crypto_ext 0x00000001
136
136
#define regk_crypto_hmac_sha1 0x00000007
137
137
#define regk_crypto_hmac_sha256 0x00000009
138
- #define regk_crypto_hmac_sha512 0x0000000d
139
138
#define regk_crypto_init 0x00000000
140
139
#define regk_crypto_key_128 0x00000000
141
140
#define regk_crypto_key_192 0x00000001
142
141
#define regk_crypto_key_256 0x00000002
143
142
#define regk_crypto_null 0x00000000
144
143
#define regk_crypto_sha1 0x00000006
145
144
#define regk_crypto_sha256 0x00000008
146
- #define regk_crypto_sha512 0x0000000c
147
145
148
146
/* DMA descriptor structures */
149
147
struct pdma_descr_ctrl {
@@ -188,7 +186,6 @@ struct pdma_stat_descr {
188
186
/* Hash modes (including HMAC variants) */
189
187
#define ARTPEC6_CRYPTO_HASH_SHA1 1
190
188
#define ARTPEC6_CRYPTO_HASH_SHA256 2
191
- #define ARTPEC6_CRYPTO_HASH_SHA512 4
192
189
193
190
/* Crypto modes */
194
191
#define ARTPEC6_CRYPTO_CIPHER_AES_ECB 1
@@ -288,11 +285,11 @@ struct artpec6_crypto_req_common {
288
285
};
289
286
290
287
struct artpec6_hash_request_context {
291
- char partial_buffer [SHA512_BLOCK_SIZE ];
292
- char partial_buffer_out [SHA512_BLOCK_SIZE ];
293
- char key_buffer [SHA512_BLOCK_SIZE ];
294
- char pad_buffer [SHA512_BLOCK_SIZE + 32 ];
295
- unsigned char digeststate [SHA512_DIGEST_SIZE ];
288
+ char partial_buffer [SHA256_BLOCK_SIZE ];
289
+ char partial_buffer_out [SHA256_BLOCK_SIZE ];
290
+ char key_buffer [SHA256_BLOCK_SIZE ];
291
+ char pad_buffer [SHA256_BLOCK_SIZE + 32 ];
292
+ unsigned char digeststate [SHA256_DIGEST_SIZE ];
296
293
size_t partial_bytes ;
297
294
u64 digcnt ;
298
295
u32 key_md ;
@@ -302,16 +299,16 @@ struct artpec6_hash_request_context {
302
299
};
303
300
304
301
struct artpec6_hash_export_state {
305
- char partial_buffer [SHA512_BLOCK_SIZE ];
306
- unsigned char digeststate [SHA512_DIGEST_SIZE ];
302
+ char partial_buffer [SHA256_BLOCK_SIZE ];
303
+ unsigned char digeststate [SHA256_DIGEST_SIZE ];
307
304
size_t partial_bytes ;
308
305
u64 digcnt ;
309
306
int oper ;
310
307
unsigned int hash_flags ;
311
308
};
312
309
313
310
struct artpec6_hashalg_context {
314
- char hmac_key [SHA512_BLOCK_SIZE ];
311
+ char hmac_key [SHA256_BLOCK_SIZE ];
315
312
size_t hmac_key_length ;
316
313
struct crypto_shash * child_hash ;
317
314
};
@@ -2252,10 +2249,6 @@ artpec6_crypto_init_hash(struct ahash_request *req, u8 type, int hmac)
2252
2249
case ARTPEC6_CRYPTO_HASH_SHA256 :
2253
2250
oper = hmac ? regk_crypto_hmac_sha256 : regk_crypto_sha256 ;
2254
2251
break ;
2255
- case ARTPEC6_CRYPTO_HASH_SHA512 :
2256
- oper = hmac ? regk_crypto_hmac_sha512 : regk_crypto_sha512 ;
2257
- break ;
2258
-
2259
2252
default :
2260
2253
pr_err ("%s: Unsupported hash type 0x%x\n" , MODULE_NAME , type );
2261
2254
return - EINVAL ;
@@ -2351,31 +2344,11 @@ static int artpec6_crypto_sha256_digest(struct ahash_request *req)
2351
2344
return artpec6_crypto_prepare_submit_hash (req );
2352
2345
}
2353
2346
2354
- static int artpec6_crypto_sha512_init (struct ahash_request * req )
2355
- {
2356
- return artpec6_crypto_init_hash (req , ARTPEC6_CRYPTO_HASH_SHA512 , 0 );
2357
- }
2358
-
2359
- static int artpec6_crypto_sha512_digest (struct ahash_request * req )
2360
- {
2361
- struct artpec6_hash_request_context * req_ctx = ahash_request_ctx (req );
2362
-
2363
- artpec6_crypto_init_hash (req , ARTPEC6_CRYPTO_HASH_SHA512 , 0 );
2364
- req_ctx -> hash_flags |= HASH_FLAG_UPDATE | HASH_FLAG_FINALIZE ;
2365
-
2366
- return artpec6_crypto_prepare_submit_hash (req );
2367
- }
2368
-
2369
2347
static int artpec6_crypto_hmac_sha256_init (struct ahash_request * req )
2370
2348
{
2371
2349
return artpec6_crypto_init_hash (req , ARTPEC6_CRYPTO_HASH_SHA256 , 1 );
2372
2350
}
2373
2351
2374
- static int artpec6_crypto_hmac_sha512_init (struct ahash_request * req )
2375
- {
2376
- return artpec6_crypto_init_hash (req , ARTPEC6_CRYPTO_HASH_SHA512 , 1 );
2377
- }
2378
-
2379
2352
static int artpec6_crypto_hmac_sha256_digest (struct ahash_request * req )
2380
2353
{
2381
2354
struct artpec6_hash_request_context * req_ctx = ahash_request_ctx (req );
@@ -2386,16 +2359,6 @@ static int artpec6_crypto_hmac_sha256_digest(struct ahash_request *req)
2386
2359
return artpec6_crypto_prepare_submit_hash (req );
2387
2360
}
2388
2361
2389
- static int artpec6_crypto_hmac_sha512_digest (struct ahash_request * req )
2390
- {
2391
- struct artpec6_hash_request_context * req_ctx = ahash_request_ctx (req );
2392
-
2393
- artpec6_crypto_init_hash (req , ARTPEC6_CRYPTO_HASH_SHA512 , 1 );
2394
- req_ctx -> hash_flags |= HASH_FLAG_UPDATE | HASH_FLAG_FINALIZE ;
2395
-
2396
- return artpec6_crypto_prepare_submit_hash (req );
2397
- }
2398
-
2399
2362
static int artpec6_crypto_ahash_init_common (struct crypto_tfm * tfm ,
2400
2363
const char * base_hash_name )
2401
2364
{
@@ -2430,11 +2393,6 @@ static int artpec6_crypto_ahash_init_hmac_sha256(struct crypto_tfm *tfm)
2430
2393
return artpec6_crypto_ahash_init_common (tfm , "sha256" );
2431
2394
}
2432
2395
2433
- static int artpec6_crypto_ahash_init_hmac_sha512 (struct crypto_tfm * tfm )
2434
- {
2435
- return artpec6_crypto_ahash_init_common (tfm , "sha512" );
2436
- }
2437
-
2438
2396
static void artpec6_crypto_ahash_exit (struct crypto_tfm * tfm )
2439
2397
{
2440
2398
struct artpec6_hashalg_context * tfm_ctx = crypto_tfm_ctx (tfm );
@@ -2705,56 +2663,6 @@ static struct ahash_alg hash_algos[] = {
2705
2663
},
2706
2664
};
2707
2665
2708
- static struct ahash_alg artpec7_hash_algos [] = {
2709
- /* SHA-512 */
2710
- {
2711
- .init = artpec6_crypto_sha512_init ,
2712
- .update = artpec6_crypto_hash_update ,
2713
- .final = artpec6_crypto_hash_final ,
2714
- .digest = artpec6_crypto_sha512_digest ,
2715
- .import = artpec6_crypto_hash_import ,
2716
- .export = artpec6_crypto_hash_export ,
2717
- .halg .digestsize = SHA512_DIGEST_SIZE ,
2718
- .halg .statesize = sizeof (struct artpec6_hash_export_state ),
2719
- .halg .base = {
2720
- .cra_name = "sha512" ,
2721
- .cra_driver_name = "artpec-sha512" ,
2722
- .cra_priority = 300 ,
2723
- .cra_flags = CRYPTO_ALG_ASYNC ,
2724
- .cra_blocksize = SHA512_BLOCK_SIZE ,
2725
- .cra_ctxsize = sizeof (struct artpec6_hashalg_context ),
2726
- .cra_alignmask = 3 ,
2727
- .cra_module = THIS_MODULE ,
2728
- .cra_init = artpec6_crypto_ahash_init ,
2729
- .cra_exit = artpec6_crypto_ahash_exit ,
2730
- }
2731
- },
2732
- /* HMAC SHA-512 */
2733
- {
2734
- .init = artpec6_crypto_hmac_sha512_init ,
2735
- .update = artpec6_crypto_hash_update ,
2736
- .final = artpec6_crypto_hash_final ,
2737
- .digest = artpec6_crypto_hmac_sha512_digest ,
2738
- .import = artpec6_crypto_hash_import ,
2739
- .export = artpec6_crypto_hash_export ,
2740
- .setkey = artpec6_crypto_hash_set_key ,
2741
- .halg .digestsize = SHA512_DIGEST_SIZE ,
2742
- .halg .statesize = sizeof (struct artpec6_hash_export_state ),
2743
- .halg .base = {
2744
- .cra_name = "hmac(sha512)" ,
2745
- .cra_driver_name = "artpec-hmac-sha512" ,
2746
- .cra_priority = 300 ,
2747
- .cra_flags = CRYPTO_ALG_ASYNC ,
2748
- .cra_blocksize = SHA512_BLOCK_SIZE ,
2749
- .cra_ctxsize = sizeof (struct artpec6_hashalg_context ),
2750
- .cra_alignmask = 3 ,
2751
- .cra_module = THIS_MODULE ,
2752
- .cra_init = artpec6_crypto_ahash_init_hmac_sha512 ,
2753
- .cra_exit = artpec6_crypto_ahash_exit ,
2754
- }
2755
- },
2756
- };
2757
-
2758
2666
/* Crypto */
2759
2667
static struct skcipher_alg crypto_algos [] = {
2760
2668
/* AES - ECB */
@@ -2992,19 +2900,10 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
2992
2900
goto disable_hw ;
2993
2901
}
2994
2902
2995
- if (variant != ARTPEC6_CRYPTO ) {
2996
- err = crypto_register_ahashes (artpec7_hash_algos ,
2997
- ARRAY_SIZE (artpec7_hash_algos ));
2998
- if (err ) {
2999
- dev_err (dev , "Failed to register ahashes\n" );
3000
- goto unregister_ahashes ;
3001
- }
3002
- }
3003
-
3004
2903
err = crypto_register_skciphers (crypto_algos , ARRAY_SIZE (crypto_algos ));
3005
2904
if (err ) {
3006
2905
dev_err (dev , "Failed to register ciphers\n" );
3007
- goto unregister_a7_ahashes ;
2906
+ goto unregister_ahashes ;
3008
2907
}
3009
2908
3010
2909
err = crypto_register_aeads (aead_algos , ARRAY_SIZE (aead_algos ));
@@ -3017,10 +2916,6 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
3017
2916
3018
2917
unregister_algs :
3019
2918
crypto_unregister_skciphers (crypto_algos , ARRAY_SIZE (crypto_algos ));
3020
- unregister_a7_ahashes :
3021
- if (variant != ARTPEC6_CRYPTO )
3022
- crypto_unregister_ahashes (artpec7_hash_algos ,
3023
- ARRAY_SIZE (artpec7_hash_algos ));
3024
2919
unregister_ahashes :
3025
2920
crypto_unregister_ahashes (hash_algos , ARRAY_SIZE (hash_algos ));
3026
2921
disable_hw :
@@ -3036,9 +2931,6 @@ static int artpec6_crypto_remove(struct platform_device *pdev)
3036
2931
int irq = platform_get_irq (pdev , 0 );
3037
2932
3038
2933
crypto_unregister_ahashes (hash_algos , ARRAY_SIZE (hash_algos ));
3039
- if (ac -> variant != ARTPEC6_CRYPTO )
3040
- crypto_unregister_ahashes (artpec7_hash_algos ,
3041
- ARRAY_SIZE (artpec7_hash_algos ));
3042
2934
crypto_unregister_skciphers (crypto_algos , ARRAY_SIZE (crypto_algos ));
3043
2935
crypto_unregister_aeads (aead_algos , ARRAY_SIZE (aead_algos ));
3044
2936
0 commit comments