@@ -5487,7 +5487,7 @@ def test_aes_cbc(self):
5487
5487
self .assertEqual (len (dec ), msglen * multiplier )
5488
5488
self .assertEqual (dec , msg * multiplier )
5489
5489
5490
- @support .requires_linux_version (4 , 3 ) # see test_aes_cbc
5490
+ @support .requires_linux_version (4 , 9 ) # see issue29324
5491
5491
def test_aead_aes_gcm (self ):
5492
5492
key = bytes .fromhex ('c939cc13397c1d37de6ae0e1cb7c423c' )
5493
5493
iv = bytes .fromhex ('b3d8cc017cbb89b39e0f67e2' )
@@ -5510,16 +5510,15 @@ def test_aead_aes_gcm(self):
5510
5510
op .sendmsg_afalg (op = socket .ALG_OP_ENCRYPT , iv = iv ,
5511
5511
assoclen = assoclen , flags = socket .MSG_MORE )
5512
5512
op .sendall (assoc , socket .MSG_MORE )
5513
- op .sendall (plain , socket .MSG_MORE )
5514
- op .sendall (b'\x00 ' * taglen )
5513
+ op .sendall (plain )
5515
5514
res = op .recv (assoclen + len (plain ) + taglen )
5516
5515
self .assertEqual (expected_ct , res [assoclen :- taglen ])
5517
5516
self .assertEqual (expected_tag , res [- taglen :])
5518
5517
5519
5518
# now with msg
5520
5519
op , _ = algo .accept ()
5521
5520
with op :
5522
- msg = assoc + plain + b' \x00 ' * taglen
5521
+ msg = assoc + plain
5523
5522
op .sendmsg_afalg ([msg ], op = socket .ALG_OP_ENCRYPT , iv = iv ,
5524
5523
assoclen = assoclen )
5525
5524
res = op .recv (assoclen + len (plain ) + taglen )
@@ -5530,15 +5529,15 @@ def test_aead_aes_gcm(self):
5530
5529
pack_uint32 = struct .Struct ('I' ).pack
5531
5530
op , _ = algo .accept ()
5532
5531
with op :
5533
- msg = assoc + plain + b' \x00 ' * taglen
5532
+ msg = assoc + plain
5534
5533
op .sendmsg (
5535
5534
[msg ],
5536
5535
([socket .SOL_ALG , socket .ALG_SET_OP , pack_uint32 (socket .ALG_OP_ENCRYPT )],
5537
5536
[socket .SOL_ALG , socket .ALG_SET_IV , pack_uint32 (len (iv )) + iv ],
5538
5537
[socket .SOL_ALG , socket .ALG_SET_AEAD_ASSOCLEN , pack_uint32 (assoclen )],
5539
5538
)
5540
5539
)
5541
- res = op .recv (len (msg ))
5540
+ res = op .recv (len (msg ) + taglen )
5542
5541
self .assertEqual (expected_ct , res [assoclen :- taglen ])
5543
5542
self .assertEqual (expected_tag , res [- taglen :])
5544
5543
@@ -5548,8 +5547,8 @@ def test_aead_aes_gcm(self):
5548
5547
msg = assoc + expected_ct + expected_tag
5549
5548
op .sendmsg_afalg ([msg ], op = socket .ALG_OP_DECRYPT , iv = iv ,
5550
5549
assoclen = assoclen )
5551
- res = op .recv (len (msg ))
5552
- self .assertEqual (plain , res [assoclen :- taglen ])
5550
+ res = op .recv (len (msg ) - taglen )
5551
+ self .assertEqual (plain , res [assoclen :])
5553
5552
5554
5553
@support .requires_linux_version (4 , 3 ) # see test_aes_cbc
5555
5554
def test_drbg_pr_sha256 (self ):
0 commit comments