|
7 | 7 | from .KDF import _HKDF_extract, _HKDF_expand
|
8 | 8 | from .DH import key_agreement, import_x25519_public_key, import_x448_public_key
|
9 | 9 | from Crypto.Util.strxor import strxor
|
10 |
| -from Crypto.Util.number import long_to_bytes |
11 | 10 | from Crypto.PublicKey import ECC
|
12 | 11 | from Crypto.PublicKey.ECC import EccKey
|
13 | 12 | from Crypto.Hash import SHA256, SHA384, SHA512
|
@@ -254,7 +253,7 @@ def _key_schedule(self,
|
254 | 253 | suite_id,
|
255 | 254 | self._hashmod)
|
256 | 255 |
|
257 |
| - key_schedule_context = self._mode.to_bytes() + psk_id_hash + info_hash |
| 256 | + key_schedule_context = self._mode.to_bytes(1, 'big') + psk_id_hash + info_hash |
258 | 257 |
|
259 | 258 | secret = labeled_extract(shared_secret,
|
260 | 259 | b'secret',
|
@@ -286,7 +285,7 @@ def _key_schedule(self,
|
286 | 285 | return key, base_nonce, exporter_secret
|
287 | 286 |
|
288 | 287 | def _new_cipher(self):
|
289 |
| - nonce = strxor(self._base_nonce, long_to_bytes(self._sequence, self._Nn)) |
| 288 | + nonce = strxor(self._base_nonce, self._sequence.to_bytes(self._Nn, 'big')) |
290 | 289 | if self._aead_id in (AEAD.AES128_GCM, AEAD.AES256_GCM):
|
291 | 290 | cipher = AES.new(self._key, AES.MODE_GCM, nonce=nonce, mac_len=self._Nt)
|
292 | 291 | elif self._aead_id == AEAD.CHACHA20_POLY1305:
|
|
0 commit comments