Projet

Général

Profil

0002-python3-struct-packed-C-strings-are-Python-bytes-311.patch

Paul Marillonnet, 18 avril 2019 14:19

Télécharger (1,28 ko)

Voir les différences:

Subject: [PATCH 2/4] python3: struct-packed C strings are Python bytes
 (#31171)

 src/authentic2/crypto.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/authentic2/crypto.py
64 64
def add_padding(msg, block_size):
65 65
    '''Pad message with zero bytes to match block_size'''
66 66
    pad_length = block_size - (len(msg) + 2) % block_size
67
    padded = struct.pack('<h%ds%ds' % (len(msg), pad_length), len(msg), msg, '\0' * pad_length)
67
    padded = struct.pack('<h%ds%ds' % (len(msg), pad_length), len(msg), msg, b'\0' * pad_length)
68 68
    assert len(padded) % block_size == 0
69 69
    return padded
70 70

  
......
113 113

  
114 114
    hmac = prf(key, crypted)[:hmac_size]
115 115

  
116
    raw = struct.pack('<2sBH', 'a2', mode, count) + crypted + hmac
116
    raw = struct.pack('<2sBH', b'a2', mode, count) + crypted + hmac
117 117
    return base64url_encode(raw)
118 118

  
119 119

  
120
-