@@ -5469,7 +5469,7 @@ def test_aes_cbc(self):
5469
5469
self .assertEqual (len (dec ), msglen * multiplier )
5470
5470
self .assertEqual (dec , msg * multiplier )
5471
5471
5472
- @support .requires_linux_version (4 , 3 ) # see test_aes_cbc
5472
+ @support .requires_linux_version (4 , 9 ) # see issue29324
5473
5473
def test_aead_aes_gcm (self ):
5474
5474
key = bytes .fromhex ('c939cc13397c1d37de6ae0e1cb7c423c' )
5475
5475
iv = bytes .fromhex ('b3d8cc017cbb89b39e0f67e2' )
@@ -5492,16 +5492,15 @@ def test_aead_aes_gcm(self):
5492
5492
op .sendmsg_afalg (op = socket .ALG_OP_ENCRYPT , iv = iv ,
5493
5493
assoclen = assoclen , flags = socket .MSG_MORE )
5494
5494
op .sendall (assoc , socket .MSG_MORE )
5495
- op .sendall (plain , socket .MSG_MORE )
5496
- op .sendall (b'\x00 ' * taglen )
5495
+ op .sendall (plain )
5497
5496
res = op .recv (assoclen + len (plain ) + taglen )
5498
5497
self .assertEqual (expected_ct , res [assoclen :- taglen ])
5499
5498
self .assertEqual (expected_tag , res [- taglen :])
5500
5499
5501
5500
# now with msg
5502
5501
op , _ = algo .accept ()
5503
5502
with op :
5504
- msg = assoc + plain + b' \x00 ' * taglen
5503
+ msg = assoc + plain
5505
5504
op .sendmsg_afalg ([msg ], op = socket .ALG_OP_ENCRYPT , iv = iv ,
5506
5505
assoclen = assoclen )
5507
5506
res = op .recv (assoclen + len (plain ) + taglen )
@@ -5512,15 +5511,15 @@ def test_aead_aes_gcm(self):
5512
5511
pack_uint32 = struct .Struct ('I' ).pack
5513
5512
op , _ = algo .accept ()
5514
5513
with op :
5515
- msg = assoc + plain + b' \x00 ' * taglen
5514
+ msg = assoc + plain
5516
5515
op .sendmsg (
5517
5516
[msg ],
5518
5517
([socket .SOL_ALG , socket .ALG_SET_OP , pack_uint32 (socket .ALG_OP_ENCRYPT )],
5519
5518
[socket .SOL_ALG , socket .ALG_SET_IV , pack_uint32 (len (iv )) + iv ],
5520
5519
[socket .SOL_ALG , socket .ALG_SET_AEAD_ASSOCLEN , pack_uint32 (assoclen )],
5521
5520
)
5522
5521
)
5523
- res = op .recv (len (msg ))
5522
+ res = op .recv (len (msg ) + taglen )
5524
5523
self .assertEqual (expected_ct , res [assoclen :- taglen ])
5525
5524
self .assertEqual (expected_tag , res [- taglen :])
5526
5525
@@ -5530,8 +5529,8 @@ def test_aead_aes_gcm(self):
5530
5529
msg = assoc + expected_ct + expected_tag
5531
5530
op .sendmsg_afalg ([msg ], op = socket .ALG_OP_DECRYPT , iv = iv ,
5532
5531
assoclen = assoclen )
5533
- res = op .recv (len (msg ))
5534
- self .assertEqual (plain , res [assoclen :- taglen ])
5532
+ res = op .recv (len (msg ) - taglen )
5533
+ self .assertEqual (plain , res [assoclen :])
5535
5534
5536
5535
@support .requires_linux_version (4 , 3 ) # see test_aes_cbc
5537
5536
def test_drbg_pr_sha256 (self ):
0 commit comments