1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| | Fix a test failure with recent Linux kernels:
https://bugs.python.org/issue29324
Patch copied from upstream source repository:
https://github.com/python/cpython/commit/9764c151c51480a7ca6042b1ccd69be2620ff360
From 9764c151c51480a7ca6042b1ccd69be2620ff360 Mon Sep 17 00:00:00 2001
From: matejcik <matejcik@gmail.com>
Date: Thu, 16 Feb 2017 14:41:31 +0100
Subject: [PATCH] update test_socket AEAD test for kernel 4.9 and up (#133)
---
Lib/test/test_socket.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index b5c9c0cf21..81f7cf774b 100644
--- Lib/test/test_socket.py
+++ Lib/test/test_socket.py
@@ -5487,7 +5487,7 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
self.assertEqual(len(dec), msglen * multiplier)
self.assertEqual(dec, msg * multiplier)
- @support.requires_linux_version(4, 3) # see test_aes_cbc
+ @support.requires_linux_version(4, 9) # see issue29324
def test_aead_aes_gcm(self):
key = bytes.fromhex('c939cc13397c1d37de6ae0e1cb7c423c')
iv = bytes.fromhex('b3d8cc017cbb89b39e0f67e2')
@@ -5510,8 +5510,7 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
op.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, iv=iv,
assoclen=assoclen, flags=socket.MSG_MORE)
op.sendall(assoc, socket.MSG_MORE)
- op.sendall(plain, socket.MSG_MORE)
- op.sendall(b'\x00' * taglen)
+ op.sendall(plain)
res = op.recv(assoclen + len(plain) + taglen)
self.assertEqual(expected_ct, res[assoclen:-taglen])
self.assertEqual(expected_tag, res[-taglen:])
@@ -5519,7 +5518,7 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
# now with msg
op, _ = algo.accept()
with op:
- msg = assoc + plain + b'\x00' * taglen
+ msg = assoc + plain
op.sendmsg_afalg([msg], op=socket.ALG_OP_ENCRYPT, iv=iv,
assoclen=assoclen)
res = op.recv(assoclen + len(plain) + taglen)
@@ -5530,7 +5529,7 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
pack_uint32 = struct.Struct('I').pack
op, _ = algo.accept()
with op:
- msg = assoc + plain + b'\x00' * taglen
+ msg = assoc + plain
op.sendmsg(
[msg],
([socket.SOL_ALG, socket.ALG_SET_OP, pack_uint32(socket.ALG_OP_ENCRYPT)],
@@ -5538,7 +5537,7 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
[socket.SOL_ALG, socket.ALG_SET_AEAD_ASSOCLEN, pack_uint32(assoclen)],
)
)
- res = op.recv(len(msg))
+ res = op.recv(len(msg) + taglen)
self.assertEqual(expected_ct, res[assoclen:-taglen])
self.assertEqual(expected_tag, res[-taglen:])
@@ -5548,8 +5547,8 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
msg = assoc + expected_ct + expected_tag
op.sendmsg_afalg([msg], op=socket.ALG_OP_DECRYPT, iv=iv,
assoclen=assoclen)
- res = op.recv(len(msg))
- self.assertEqual(plain, res[assoclen:-taglen])
+ res = op.recv(len(msg) - taglen)
+ self.assertEqual(plain, res[assoclen:])
@support.requires_linux_version(4, 3) # see test_aes_cbc
def test_drbg_pr_sha256(self):
--
2.12.0
|