@@ -803,10 +803,7 @@ static int rfc4106_init(struct crypto_aead *aead)
803
803
return PTR_ERR (cryptd_tfm );
804
804
805
805
* ctx = cryptd_tfm ;
806
- crypto_aead_set_reqsize (
807
- aead ,
808
- sizeof (struct aead_request ) +
809
- crypto_aead_reqsize (& cryptd_tfm -> base ));
806
+ crypto_aead_set_reqsize (aead , crypto_aead_reqsize (& cryptd_tfm -> base ));
810
807
return 0 ;
811
808
}
812
809
@@ -955,8 +952,8 @@ static int helper_rfc4106_encrypt(struct aead_request *req)
955
952
956
953
/* Assuming we are supporting rfc4106 64-bit extended */
957
954
/* sequence numbers We need to have the AAD length equal */
958
- /* to 8 or 12 bytes */
959
- if (unlikely (req -> assoclen != 8 && req -> assoclen != 12 ))
955
+ /* to 16 or 20 bytes */
956
+ if (unlikely (req -> assoclen != 16 && req -> assoclen != 20 ))
960
957
return - EINVAL ;
961
958
962
959
/* IV below built */
@@ -992,9 +989,9 @@ static int helper_rfc4106_encrypt(struct aead_request *req)
992
989
}
993
990
994
991
kernel_fpu_begin ();
995
- aesni_gcm_enc_tfm (aes_ctx , dst , src , ( unsigned long ) req -> cryptlen , iv ,
996
- ctx -> hash_subkey , assoc , ( unsigned long ) req -> assoclen , dst
997
- + (( unsigned long ) req -> cryptlen ) , auth_tag_len );
992
+ aesni_gcm_enc_tfm (aes_ctx , dst , src , req -> cryptlen , iv ,
993
+ ctx -> hash_subkey , assoc , req -> assoclen - 8 ,
994
+ dst + req -> cryptlen , auth_tag_len );
998
995
kernel_fpu_end ();
999
996
1000
997
/* The authTag (aka the Integrity Check Value) needs to be written
@@ -1033,12 +1030,12 @@ static int helper_rfc4106_decrypt(struct aead_request *req)
1033
1030
struct scatter_walk dst_sg_walk ;
1034
1031
unsigned int i ;
1035
1032
1036
- if (unlikely (req -> assoclen != 8 && req -> assoclen != 12 ))
1033
+ if (unlikely (req -> assoclen != 16 && req -> assoclen != 20 ))
1037
1034
return - EINVAL ;
1038
1035
1039
1036
/* Assuming we are supporting rfc4106 64-bit extended */
1040
1037
/* sequence numbers We need to have the AAD length */
1041
- /* equal to 8 or 12 bytes */
1038
+ /* equal to 16 or 20 bytes */
1042
1039
1043
1040
tempCipherLen = (unsigned long )(req -> cryptlen - auth_tag_len );
1044
1041
/* IV below built */
@@ -1075,8 +1072,8 @@ static int helper_rfc4106_decrypt(struct aead_request *req)
1075
1072
1076
1073
kernel_fpu_begin ();
1077
1074
aesni_gcm_dec_tfm (aes_ctx , dst , src , tempCipherLen , iv ,
1078
- ctx -> hash_subkey , assoc , ( unsigned long ) req -> assoclen ,
1079
- authTag , auth_tag_len );
1075
+ ctx -> hash_subkey , assoc , req -> assoclen - 8 ,
1076
+ authTag , auth_tag_len );
1080
1077
kernel_fpu_end ();
1081
1078
1082
1079
/* Compare generated tag with passed in tag. */
@@ -1105,39 +1102,25 @@ static int rfc4106_encrypt(struct aead_request *req)
1105
1102
struct crypto_aead * tfm = crypto_aead_reqtfm (req );
1106
1103
struct cryptd_aead * * ctx = crypto_aead_ctx (tfm );
1107
1104
struct cryptd_aead * cryptd_tfm = * ctx ;
1108
- struct aead_request * subreq = aead_request_ctx (req );
1109
1105
1110
- aead_request_set_tfm (subreq , irq_fpu_usable () ?
1111
- cryptd_aead_child (cryptd_tfm ) :
1112
- & cryptd_tfm -> base );
1106
+ aead_request_set_tfm (req , irq_fpu_usable () ?
1107
+ cryptd_aead_child (cryptd_tfm ) :
1108
+ & cryptd_tfm -> base );
1113
1109
1114
- aead_request_set_callback (subreq , req -> base .flags ,
1115
- req -> base .complete , req -> base .data );
1116
- aead_request_set_crypt (subreq , req -> src , req -> dst ,
1117
- req -> cryptlen , req -> iv );
1118
- aead_request_set_ad (subreq , req -> assoclen );
1119
-
1120
- return crypto_aead_encrypt (subreq );
1110
+ return crypto_aead_encrypt (req );
1121
1111
}
1122
1112
1123
1113
static int rfc4106_decrypt (struct aead_request * req )
1124
1114
{
1125
1115
struct crypto_aead * tfm = crypto_aead_reqtfm (req );
1126
1116
struct cryptd_aead * * ctx = crypto_aead_ctx (tfm );
1127
1117
struct cryptd_aead * cryptd_tfm = * ctx ;
1128
- struct aead_request * subreq = aead_request_ctx (req );
1129
-
1130
- aead_request_set_tfm (subreq , irq_fpu_usable () ?
1131
- cryptd_aead_child (cryptd_tfm ) :
1132
- & cryptd_tfm -> base );
1133
1118
1134
- aead_request_set_callback (subreq , req -> base .flags ,
1135
- req -> base .complete , req -> base .data );
1136
- aead_request_set_crypt (subreq , req -> src , req -> dst ,
1137
- req -> cryptlen , req -> iv );
1138
- aead_request_set_ad (subreq , req -> assoclen );
1119
+ aead_request_set_tfm (req , irq_fpu_usable () ?
1120
+ cryptd_aead_child (cryptd_tfm ) :
1121
+ & cryptd_tfm -> base );
1139
1122
1140
- return crypto_aead_decrypt (subreq );
1123
+ return crypto_aead_decrypt (req );
1141
1124
}
1142
1125
#endif
1143
1126
@@ -1454,7 +1437,8 @@ static struct aead_alg aesni_aead_algs[] = { {
1454
1437
.cra_name = "rfc4106(gcm(aes))" ,
1455
1438
.cra_driver_name = "rfc4106-gcm-aesni" ,
1456
1439
.cra_priority = 400 ,
1457
- .cra_flags = CRYPTO_ALG_ASYNC ,
1440
+ .cra_flags = CRYPTO_ALG_ASYNC |
1441
+ CRYPTO_ALG_AEAD_NEW ,
1458
1442
.cra_blocksize = 1 ,
1459
1443
.cra_ctxsize = sizeof (struct cryptd_aead * ),
1460
1444
.cra_module = THIS_MODULE ,
0 commit comments