Skip to content

Commit

Permalink
Merge pull request #58 from a-detiste/master
Browse files Browse the repository at this point in the history
finish six removal
  • Loading branch information
cocagne authored Aug 22, 2024
2 parents cc45e01 + 0931971 commit fbdfe9d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
download_url = 'http://pypi.python.org/pypi/srp',
long_description = long_description,
provides = ['srp'],
install_requires = ['six'],
packages = ['srp'],
package_data = {'srp' : ['doc/*.rst', 'doc/*.py']},
license = "MIT",
Expand Down
19 changes: 9 additions & 10 deletions srp/_ctsrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import random
import ctypes
import time
import six


_rfc5054_compat = False
Expand Down Expand Up @@ -55,24 +54,24 @@ def no_username_in_x(enable=True):

_ng_const = (
# 1024-bit
(six.b('''\
(('''\
EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496\
EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8E\
F4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA\
9AFD5138FE8376435B9FC61D2FC0EB06E3'''),
9AFD5138FE8376435B9FC61D2FC0EB06E3''').encode('ascii'),
b"2"),
# 2048
(six.b('''\
(('''\
AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4\
A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF60\
95179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF\
747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B907\
8717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB37861\
60279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DB\
FBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73'''),
FBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73''').encode('ascii'),
b"2"),
# 4096
(six.b('''\
(('''\
FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08\
8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B\
302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9\
Expand All @@ -91,10 +90,10 @@ def no_username_in_x(enable=True):
04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2\
233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127\
D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199\
FFFFFFFFFFFFFFFF'''),
FFFFFFFFFFFFFFFF''').encode('ascii'),
b"5"),
# 8192
(six.b('''\
(('''\
FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08\
8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B\
302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9\
Expand Down Expand Up @@ -131,7 +130,7 @@ def no_username_in_x(enable=True):
0846851DF9AB48195DED7EA1B1D510BD7EE74D73FAF36BC31ECFA268\
359046F4EB879F924009438B481C6CD7889A002ED5EE382BC9190DA6\
FC026E479558E4475677E9AA9E3050E2765694DFC81F56E880B96E71\
60C980DD98EDD3DFFFFFFFFFFFFFFFFF'''),
60C980DD98EDD3DFFFFFFFFFFFFFFFFF''').encode('ascii'),
b'13')
)

Expand Down Expand Up @@ -332,7 +331,7 @@ def HNxorg( hash_class, N, g ):
hN = hash_class( bN.raw ).digest()
hg = hash_class( b''.join([ b'\0'*padding, bg.raw ]) ).digest()

return six.b( ''.join( chr( six.indexbytes(hN, i) ^ six.indexbytes(hg, i) ) for i in range(0,len(hN)) ) )
return ( ''.join( chr( hN[i] ^ hg[i] ) for i in range(0,len(hN)) ) ).encode('latin1')


def get_ngk( hash_class, ng_type, n_hex, g_hex, ctx ):
Expand Down
7 changes: 3 additions & 4 deletions srp/_pysrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import hashlib
import os
import binascii
import six


_rfc5054_compat = False
Expand Down Expand Up @@ -140,7 +139,7 @@ def get_ng( ng_type, n_hex, g_hex ):

def bytes_to_long(s):
n = 0
for b in six.iterbytes(s):
for b in s:
n = (n << 8) | b
return n

Expand All @@ -155,7 +154,7 @@ def long_to_bytes(n):
x = x | (b << off)
off += 8
l.reverse()
return six.b(''.join(l))
return (''.join(l)).encode('latin1')


def get_random( nbytes ):
Expand Down Expand Up @@ -207,7 +206,7 @@ def HNxorg( hash_class, N, g ):
hN = hash_class( bin_N ).digest()
hg = hash_class( b''.join( [b'\0'*padding, bin_g] ) ).digest()

return six.b( ''.join( chr( six.indexbytes(hN, i) ^ six.indexbytes(hg, i) ) for i in range(0,len(hN)) ) )
return ( ''.join( chr( hN[i] ^ hg[i] ) for i in range(0,len(hN)) ) ).encode('latin1')



Expand Down
8 changes: 3 additions & 5 deletions srp/test_srp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import time
import _thread

import six

this_dir = os.path.dirname( os.path.abspath(__file__) )

build_dir = os.path.join( os.path.dirname(this_dir), 'build' )
Expand All @@ -34,14 +32,14 @@


test_g_hex = b"2"
test_n_hex = six.b('''\
AC6BDB41324A9wA9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4\
test_n_hex = ('''\
AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4\
A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF60\
95179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF\
747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B907\
8717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB37861\
60279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DB\
FBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73''')
FBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73''').encode('ascii')


class SRPTests( unittest.TestCase ):
Expand Down

0 comments on commit fbdfe9d

Please sign in to comment.