Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ac01f0

Browse filesBrowse files
authored
update test_socket AEAD test for kernel 4.9 and up (GH-133) (GH-548)
(cherry picked from commit 9764c15)
1 parent 3fce38c commit 4ac01f0
Copy full SHA for 4ac01f0

File tree

1 file changed

+7
-8
lines changed
Filter options

1 file changed

+7
-8
lines changed

‎Lib/test/test_socket.py

Copy file name to clipboardExpand all lines: Lib/test/test_socket.py
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,7 +5479,7 @@ def test_aes_cbc(self):
54795479
self.assertEqual(len(dec), msglen * multiplier)
54805480
self.assertEqual(dec, msg * multiplier)
54815481

5482-
@support.requires_linux_version(4, 3) # see test_aes_cbc
5482+
@support.requires_linux_version(4, 9) # see issue29324
54835483
def test_aead_aes_gcm(self):
54845484
key = bytes.fromhex('c939cc13397c1d37de6ae0e1cb7c423c')
54855485
iv = bytes.fromhex('b3d8cc017cbb89b39e0f67e2')
@@ -5502,16 +5502,15 @@ def test_aead_aes_gcm(self):
55025502
op.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, iv=iv,
55035503
assoclen=assoclen, flags=socket.MSG_MORE)
55045504
op.sendall(assoc, socket.MSG_MORE)
5505-
op.sendall(plain, socket.MSG_MORE)
5506-
op.sendall(b'\x00' * taglen)
5505+
op.sendall(plain)
55075506
res = op.recv(assoclen + len(plain) + taglen)
55085507
self.assertEqual(expected_ct, res[assoclen:-taglen])
55095508
self.assertEqual(expected_tag, res[-taglen:])
55105509

55115510
# now with msg
55125511
op, _ = algo.accept()
55135512
with op:
5514-
msg = assoc + plain + b'\x00' * taglen
5513+
msg = assoc + plain
55155514
op.sendmsg_afalg([msg], op=socket.ALG_OP_ENCRYPT, iv=iv,
55165515
assoclen=assoclen)
55175516
res = op.recv(assoclen + len(plain) + taglen)
@@ -5522,15 +5521,15 @@ def test_aead_aes_gcm(self):
55225521
pack_uint32 = struct.Struct('I').pack
55235522
op, _ = algo.accept()
55245523
with op:
5525-
msg = assoc + plain + b'\x00' * taglen
5524+
msg = assoc + plain
55265525
op.sendmsg(
55275526
[msg],
55285527
([socket.SOL_ALG, socket.ALG_SET_OP, pack_uint32(socket.ALG_OP_ENCRYPT)],
55295528
[socket.SOL_ALG, socket.ALG_SET_IV, pack_uint32(len(iv)) + iv],
55305529
[socket.SOL_ALG, socket.ALG_SET_AEAD_ASSOCLEN, pack_uint32(assoclen)],
55315530
)
55325531
)
5533-
res = op.recv(len(msg))
5532+
res = op.recv(len(msg) + taglen)
55345533
self.assertEqual(expected_ct, res[assoclen:-taglen])
55355534
self.assertEqual(expected_tag, res[-taglen:])
55365535

@@ -5540,8 +5539,8 @@ def test_aead_aes_gcm(self):
55405539
msg = assoc + expected_ct + expected_tag
55415540
op.sendmsg_afalg([msg], op=socket.ALG_OP_DECRYPT, iv=iv,
55425541
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:])
55455544

55465545
@support.requires_linux_version(4, 3) # see test_aes_cbc
55475546
def test_drbg_pr_sha256(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.