@@ -5479,7 +5479,7 @@ def test_aes_cbc(self):
5479
5479
self .assertEqual (len (dec ), msglen * multiplier )
5480
5480
self .assertEqual (dec , msg * multiplier )
5481
5481
5482
- @support .requires_linux_version (4 , 3 ) # see test_aes_cbc
5482
+ @support .requires_linux_version (4 , 9 ) # see issue29324
5483
5483
def test_aead_aes_gcm (self ):
5484
5484
key = bytes .fromhex ('c939cc13397c1d37de6ae0e1cb7c423c' )
5485
5485
iv = bytes .fromhex ('b3d8cc017cbb89b39e0f67e2' )
@@ -5502,16 +5502,15 @@ def test_aead_aes_gcm(self):
5502
5502
op .sendmsg_afalg (op = socket .ALG_OP_ENCRYPT , iv = iv ,
5503
5503
assoclen = assoclen , flags = socket .MSG_MORE )
5504
5504
op .sendall (assoc , socket .MSG_MORE )
5505
- op .sendall (plain , socket .MSG_MORE )
5506
- op .sendall (b'\x00 ' * taglen )
5505
+ op .sendall (plain )
5507
5506
res = op .recv (assoclen + len (plain ) + taglen )
5508
5507
self .assertEqual (expected_ct , res [assoclen :- taglen ])
5509
5508
self .assertEqual (expected_tag , res [- taglen :])
5510
5509
5511
5510
# now with msg
5512
5511
op , _ = algo .accept ()
5513
5512
with op :
5514
- msg = assoc + plain + b' \x00 ' * taglen
5513
+ msg = assoc + plain
5515
5514
op .sendmsg_afalg ([msg ], op = socket .ALG_OP_ENCRYPT , iv = iv ,
5516
5515
assoclen = assoclen )
5517
5516
res = op .recv (assoclen + len (plain ) + taglen )
@@ -5522,15 +5521,15 @@ def test_aead_aes_gcm(self):
5522
5521
pack_uint32 = struct .Struct ('I' ).pack
5523
5522
op , _ = algo .accept ()
5524
5523
with op :
5525
- msg = assoc + plain + b' \x00 ' * taglen
5524
+ msg = assoc + plain
5526
5525
op .sendmsg (
5527
5526
[msg ],
5528
5527
([socket .SOL_ALG , socket .ALG_SET_OP , pack_uint32 (socket .ALG_OP_ENCRYPT )],
5529
5528
[socket .SOL_ALG , socket .ALG_SET_IV , pack_uint32 (len (iv )) + iv ],
5530
5529
[socket .SOL_ALG , socket .ALG_SET_AEAD_ASSOCLEN , pack_uint32 (assoclen )],
5531
5530
)
5532
5531
)
5533
- res = op .recv (len (msg ))
5532
+ res = op .recv (len (msg ) + taglen )
5534
5533
self .assertEqual (expected_ct , res [assoclen :- taglen ])
5535
5534
self .assertEqual (expected_tag , res [- taglen :])
5536
5535
@@ -5540,8 +5539,8 @@ def test_aead_aes_gcm(self):
5540
5539
msg = assoc + expected_ct + expected_tag
5541
5540
op .sendmsg_afalg ([msg ], op = socket .ALG_OP_DECRYPT , iv = iv ,
5542
5541
assoclen = assoclen )
5543
- res = op .recv (len (msg ))
5544
- self .assertEqual (plain , res [assoclen :- taglen ])
5542
+ res = op .recv (len (msg ) - taglen )
5543
+ self .assertEqual (plain , res [assoclen :])
5545
5544
5546
5545
@support .requires_linux_version (4 , 3 ) # see test_aes_cbc
5547
5546
def test_drbg_pr_sha256 (self ):
0 commit comments