@@ -945,7 +945,7 @@ static struct skcipher_alg cfbAesAlg = {
945945};
946946static int cfbAesAlg_loaded = 0 ;
947947
948- #endif /* LINUXKM_LKCAPI_REGISTER_AESCBC */
948+ #endif /* LINUXKM_LKCAPI_REGISTER_AESCFB */
949949
950950#if defined(LINUXKM_LKCAPI_REGISTER_AESGCM ) || \
951951 defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 )
@@ -1016,7 +1016,7 @@ static int km_AesGcmSetKey_Rfc4106(struct crypto_aead *tfm, const u8 *in_key,
10161016 if (key_len < 4 )
10171017 return - EINVAL ;
10181018 key_len -= 4 ;
1019- memcpy (ctx -> rfc4106_nonce , in_key + key_len , 4 );
1019+ XMEMCPY (ctx -> rfc4106_nonce , in_key + key_len , 4 );
10201020
10211021 err = wc_AesGcmSetKey (ctx -> aes_encrypt , in_key , key_len );
10221022
@@ -1171,8 +1171,8 @@ static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
11711171 }
11721172 assoclen -= 8 ;
11731173
1174- memcpy (rfc4106_iv , ctx -> rfc4106_nonce , 4 );
1175- memcpy (rfc4106_iv + 4 , walk .iv , 8 );
1174+ XMEMCPY (rfc4106_iv , ctx -> rfc4106_nonce , 4 );
1175+ XMEMCPY (rfc4106_iv + 4 , walk .iv , 8 );
11761176 err = wc_AesGcmInit (aes_copy , NULL /*key*/ , 0 /*keylen*/ , rfc4106_iv ,
11771177 GCM_NONCE_MID_SZ );
11781178 }
@@ -1396,8 +1396,8 @@ static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
13961396 }
13971397 assoclen -= 8 ;
13981398
1399- memcpy (rfc4106_iv , ctx -> rfc4106_nonce , 4 );
1400- memcpy (rfc4106_iv + 4 , sk_walk .iv , 8 );
1399+ XMEMCPY (rfc4106_iv , ctx -> rfc4106_nonce , 4 );
1400+ XMEMCPY (rfc4106_iv + 4 , sk_walk .iv , 8 );
14011401 }
14021402#else
14031403 (void )rfc4106_p ;
@@ -1681,7 +1681,7 @@ static int km_AesCcmSetKey_Rfc4309(struct crypto_aead *tfm, const u8 *in_key,
16811681 if (key_len < 3 )
16821682 return - EINVAL ;
16831683 key_len -= 3 ;
1684- memcpy (ctx -> rfc4309_nonce , in_key + key_len , 3 );
1684+ XMEMCPY (ctx -> rfc4309_nonce , in_key + key_len , 3 );
16851685
16861686 err = wc_AesCcmSetKey (ctx -> aes_encrypt , in_key , key_len );
16871687
@@ -1878,8 +1878,8 @@ static int AesCcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4309_p)
18781878 }
18791879 assoclen -= 8 ;
18801880
1881- memcpy (rfc4309_iv , ctx -> rfc4309_nonce , 3 );
1882- memcpy (rfc4309_iv + 3 , sk_walk .iv , 8 );
1881+ XMEMCPY (rfc4309_iv , ctx -> rfc4309_nonce , 3 );
1882+ XMEMCPY (rfc4309_iv + 3 , sk_walk .iv , 8 );
18831883 nonce = rfc4309_iv ;
18841884 nonceSz = 11 ;
18851885 }
@@ -3125,7 +3125,7 @@ static int linuxkm_test_aescbc(void)
31253125 goto test_cbc_end ;
31263126 }
31273127
3128- memcpy (dec2 , p_vector , sizeof (p_vector ));
3128+ XMEMCPY (dec2 , p_vector , sizeof (p_vector ));
31293129
31303130 tfm = crypto_alloc_skcipher (WOLFKM_AESCBC_NAME , 0 , 0 );
31313131 if (IS_ERR (tfm )) {
@@ -3181,7 +3181,7 @@ static int linuxkm_test_aescbc(void)
31813181 goto test_cbc_end ;
31823182 }
31833183
3184- memset (dec2 , 0 , sizeof (p_vector ));
3184+ XMEMSET (dec2 , 0 , sizeof (p_vector ));
31853185 sg_init_one (& src , enc2 , sizeof (p_vector ));
31863186 sg_init_one (& dst , dec2 , sizeof (p_vector ));
31873187
@@ -3338,7 +3338,7 @@ static int linuxkm_test_aescfb(void)
33383338 goto test_cfb_end ;
33393339 }
33403340
3341- memcpy (dec2 , p_vector , sizeof (p_vector ));
3341+ XMEMCPY (dec2 , p_vector , sizeof (p_vector ));
33423342
33433343 tfm = crypto_alloc_skcipher (WOLFKM_AESCFB_NAME , 0 , 0 );
33443344 if (IS_ERR (tfm )) {
@@ -3385,7 +3385,7 @@ static int linuxkm_test_aescfb(void)
33853385 goto test_cfb_end ;
33863386 }
33873387
3388- memset (dec2 , 0 , sizeof (p_vector ));
3388+ XMEMSET (dec2 , 0 , sizeof (p_vector ));
33893389 sg_init_one (& src , enc2 , sizeof (p_vector ));
33903390 sg_init_one (& dst , dec2 , sizeof (p_vector ));
33913391
@@ -3574,17 +3574,17 @@ static int linuxkm_test_aesgcm(void)
35743574 ret = MEMORY_E ;
35753575 goto test_gcm_end ;
35763576 }
3577- memset (assoc2 , 0 , sizeof (assoc ));
3578- memcpy (assoc2 , assoc , sizeof (assoc ));
3577+ XMEMSET (assoc2 , 0 , sizeof (assoc ));
3578+ XMEMCPY (assoc2 , assoc , sizeof (assoc ));
35793579
35803580 iv = malloc (WC_AES_BLOCK_SIZE );
35813581 if (! iv ) {
35823582 pr_err ("error: malloc failed\n" );
35833583 ret = MEMORY_E ;
35843584 goto test_gcm_end ;
35853585 }
3586- memset (iv , 0 , WC_AES_BLOCK_SIZE );
3587- memcpy (iv , ivstr , GCM_NONCE_MID_SZ );
3586+ XMEMSET (iv , 0 , WC_AES_BLOCK_SIZE );
3587+ XMEMCPY (iv , ivstr , GCM_NONCE_MID_SZ );
35883588
35893589 enc2 = malloc (decryptLen );
35903590 if (! enc2 ) {
@@ -3600,13 +3600,13 @@ static int linuxkm_test_aesgcm(void)
36003600 goto test_gcm_end ;
36013601 }
36023602
3603- memset (enc2 , 0 , decryptLen );
3604- memset (dec2 , 0 , decryptLen );
3605- memcpy (dec2 , p_vector , sizeof (p_vector ));
3603+ XMEMSET (enc2 , 0 , decryptLen );
3604+ XMEMSET (dec2 , 0 , decryptLen );
3605+ XMEMCPY (dec2 , p_vector , sizeof (p_vector ));
36063606
36073607 tfm = crypto_alloc_aead (WOLFKM_AESGCM_NAME , 0 , 0 );
36083608 if (IS_ERR (tfm )) {
3609- pr_err ("error: allocating AES skcipher algorithm %s failed: %ld\n" ,
3609+ pr_err ("error: allocating AES aead algorithm %s failed: %ld\n" ,
36103610 WOLFKM_AESGCM_DRIVER , PTR_ERR (tfm ));
36113611 tfm = NULL ;
36123612 goto test_gcm_end ;
@@ -3632,7 +3632,7 @@ static int linuxkm_test_aesgcm(void)
36323632 if (! req ) {
36333633 ret = - ENOMEM ;
36343634 pr_err ("error: allocating AES aead request %s failed.\n" ,
3635- WOLFKM_AESCBC_DRIVER );
3635+ WOLFKM_AESGCM_DRIVER );
36363636 goto test_gcm_end ;
36373637 }
36383638
@@ -3684,7 +3684,7 @@ static int linuxkm_test_aesgcm(void)
36843684 }
36853685
36863686 /* Now decrypt crypto request. Reverse src and dst. */
3687- memset (dec2 , 0 , decryptLen );
3687+ XMEMSET (dec2 , 0 , decryptLen );
36883688 aead_request_set_ad (req , sizeof (assoc ));
36893689 aead_request_set_crypt (req , dst , src , decryptLen , iv );
36903690
@@ -4253,13 +4253,13 @@ static int aes_xts_128_test(void)
42534253 goto test_xts_end ;
42544254 }
42554255
4256- memcpy (dec2 , p1 , sizeof (p1 ));
4257- memset (enc2 , 0 , sizeof (p1 ));
4256+ XMEMCPY (dec2 , p1 , sizeof (p1 ));
4257+ XMEMSET (enc2 , 0 , sizeof (p1 ));
42584258
42594259 sg_init_one (src , dec2 , sizeof (p1 ));
42604260 sg_init_one (dst , enc2 , sizeof (p1 ));
42614261
4262- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4262+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
42634263 skcipher_request_set_crypt (req , src , dst , sizeof (p1 ), stream .tweak_block );
42644264
42654265 ret = crypto_skcipher_encrypt (req );
@@ -4276,11 +4276,11 @@ static int aes_xts_128_test(void)
42764276 goto test_xts_end ;
42774277 }
42784278
4279- memset (dec2 , 0 , sizeof (p1 ));
4279+ XMEMSET (dec2 , 0 , sizeof (p1 ));
42804280 sg_init_one (src , enc2 , sizeof (p1 ));
42814281 sg_init_one (dst , dec2 , sizeof (p1 ));
42824282
4283- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4283+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
42844284 skcipher_request_set_crypt (req , src , dst , sizeof (p1 ), stream .tweak_block );
42854285
42864286 ret = crypto_skcipher_decrypt (req );
@@ -4297,13 +4297,13 @@ static int aes_xts_128_test(void)
42974297 goto test_xts_end ;
42984298 }
42994299
4300- memcpy (dec2 , pp , sizeof (pp ));
4301- memset (enc2 , 0 , sizeof (pp ));
4300+ XMEMCPY (dec2 , pp , sizeof (pp ));
4301+ XMEMSET (enc2 , 0 , sizeof (pp ));
43024302
43034303 sg_init_one (src , dec2 , sizeof (pp ));
43044304 sg_init_one (dst , enc2 , sizeof (pp ));
43054305
4306- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4306+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
43074307 skcipher_request_set_crypt (req , src , dst , sizeof (pp ), stream .tweak_block );
43084308
43094309 ret = crypto_skcipher_encrypt (req );
@@ -4320,11 +4320,11 @@ static int aes_xts_128_test(void)
43204320 goto test_xts_end ;
43214321 }
43224322
4323- memset (dec2 , 0 , sizeof (pp ));
4323+ XMEMSET (dec2 , 0 , sizeof (pp ));
43244324 sg_init_one (src , enc2 , sizeof (pp ));
43254325 sg_init_one (dst , dec2 , sizeof (pp ));
43264326
4327- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4327+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
43284328 skcipher_request_set_crypt (req , src , dst , sizeof (pp ), stream .tweak_block );
43294329
43304330 ret = crypto_skcipher_decrypt (req );
@@ -4749,13 +4749,13 @@ static int aes_xts_256_test(void)
47494749 goto test_xts_end ;
47504750 }
47514751
4752- memcpy (dec2 , p1 , sizeof (p1 ));
4753- memset (enc2 , 0 , sizeof (p1 ));
4752+ XMEMCPY (dec2 , p1 , sizeof (p1 ));
4753+ XMEMSET (enc2 , 0 , sizeof (p1 ));
47544754
47554755 sg_init_one (src , dec2 , sizeof (p1 ));
47564756 sg_init_one (dst , enc2 , sizeof (p1 ));
47574757
4758- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4758+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
47594759 skcipher_request_set_crypt (req , src , dst , sizeof (p1 ), stream .tweak_block );
47604760
47614761 ret = crypto_skcipher_encrypt (req );
@@ -4772,11 +4772,11 @@ static int aes_xts_256_test(void)
47724772 goto test_xts_end ;
47734773 }
47744774
4775- memset (dec2 , 0 , sizeof (p1 ));
4775+ XMEMSET (dec2 , 0 , sizeof (p1 ));
47764776 sg_init_one (src , enc2 , sizeof (p1 ));
47774777 sg_init_one (dst , dec2 , sizeof (p1 ));
47784778
4779- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4779+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
47804780 skcipher_request_set_crypt (req , src , dst , sizeof (p1 ), stream .tweak_block );
47814781
47824782 ret = crypto_skcipher_decrypt (req );
@@ -4793,13 +4793,13 @@ static int aes_xts_256_test(void)
47934793 goto test_xts_end ;
47944794 }
47954795
4796- memcpy (dec2 , pp , sizeof (pp ));
4797- memset (enc2 , 0 , sizeof (pp ));
4796+ XMEMCPY (dec2 , pp , sizeof (pp ));
4797+ XMEMSET (enc2 , 0 , sizeof (pp ));
47984798
47994799 sg_init_one (src , dec2 , sizeof (pp ));
48004800 sg_init_one (dst , enc2 , sizeof (pp ));
48014801
4802- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4802+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
48034803 skcipher_request_set_crypt (req , src , dst , sizeof (pp ), stream .tweak_block );
48044804
48054805 ret = crypto_skcipher_encrypt (req );
@@ -4816,11 +4816,11 @@ static int aes_xts_256_test(void)
48164816 goto test_xts_end ;
48174817 }
48184818
4819- memset (dec2 , 0 , sizeof (pp ));
4819+ XMEMSET (dec2 , 0 , sizeof (pp ));
48204820 sg_init_one (src , enc2 , sizeof (pp ));
48214821 sg_init_one (dst , dec2 , sizeof (pp ));
48224822
4823- memcpy (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
4823+ XMEMCPY (stream .tweak_block , i1 , sizeof (stream .tweak_block ));
48244824 skcipher_request_set_crypt (req , src , dst , sizeof (pp ), stream .tweak_block );
48254825
48264826 ret = crypto_skcipher_decrypt (req );
0 commit comments