File tree Expand file tree Collapse file tree 3 files changed +3
-30
lines changed
Expand file tree Collapse file tree 3 files changed +3
-30
lines changed Original file line number Diff line number Diff line change 88algorithm.'''
99
1010import hmac
11- import math
1211import os
1312from hashlib import sha256
1413
2726)
2827
2928
30- def int_to_bytes (number : int , length : int ) -> bytes :
31- result = number .to_bytes (math .ceil (number .bit_length () / 8 ), 'big' )
32- # Pad with zero bytes if needed.
33- return b'\x00 ' * (length - len (result )) + result
34-
35-
3629DH_PRIME_1024 = int .from_bytes (DH_PRIME_1024_BYTES , 'big' )
3730
3831
@@ -48,7 +41,7 @@ def __init__(self) -> None:
4841 def set_server_public_key (self , server_public_key : int ) -> None :
4942 common_secret_int = pow (server_public_key , self .my_private_key ,
5043 DH_PRIME_1024 )
51- common_secret = int_to_bytes ( common_secret_int , 128 )
44+ common_secret = common_secret_int . to_bytes ( 128 , 'big' )
5245 # HKDF with null salt, empty info and SHA-256 hash
5346 salt = b'\x00 ' * 0x20
5447 pseudo_random_key = hmac .new (salt , common_secret , sha256 ).digest ()
Original file line number Diff line number Diff line change 3535 SS_PATH ,
3636 SS_PREFIX ,
3737)
38- from secretstorage .dhcrypto import Session , int_to_bytes
38+ from secretstorage .dhcrypto import Session
3939from secretstorage .exceptions import (
4040 ItemNotFoundException ,
4141 SecretServiceNotAvailableException ,
@@ -102,7 +102,7 @@ def open_session(connection: DBusConnection) -> Session:
102102 output , result = service .call (
103103 'OpenSession' , 'sv' ,
104104 ALGORITHM_DH ,
105- ('ay' , int_to_bytes ( session .my_public_key , 128 )))
105+ ('ay' , session .my_public_key . to_bytes ( 128 , 'big' )))
106106 except DBusErrorResponse as resp :
107107 if resp .name != DBUS_NOT_SUPPORTED :
108108 raise
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments