Esempio n. 1
0
File: utils.py Progetto: hdknr/jose
def nonce(prefix=''):
    prefix + base64.base64url_encode(struct.pack('!d', time.time()))
Esempio n. 2
0
ServerInfo = '{"Name":"Example","Url":"https://noob.example.com/sendOOB"}'
PeerInfo = '{"Make":"Acme","Type":"None","Serial":"DU-9999","SSID":"Noob1","BSSID":"6c:19:8f:83:c2:80"}'

# SleepTime
SleepTime = 60

################################################################################
############################## CALCULATED  VALUES ##############################
## Load peer and server public keys
PK_peer = PublicKey(bytes.fromhex(PKp))
PK_server = PublicKey(bytes.fromhex(PKs))
#PK2_peer = PublicKey(bytes.fromhex(PKp))
#PK2_server = PublicKey(bytes.fromhex(PKs))

# Peer and server public keys - base64 encoded
PKp_b64 = base64url_encode(bytes.fromhex(PKp)).decode().strip('=')
PKs_b64 = base64url_encode(bytes.fromhex(PKs)).decode().strip('=')
#PKp2_b64 = base64url_encode(bytes.fromhex(PKp2)).decode().strip('=')
#PKs2_b64 = base64url_encode(bytes.fromhex(PKs2)).decode().strip('=')

# Peer and server public keys - jwk formatted
PKp_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}',
                 object_pairs_hook=OrderedDict)
PKs_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}',
                 object_pairs_hook=OrderedDict)
#PKs2_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}', object_pairs_hook=OrderedDict)
#PKp2_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}', object_pairs_hook=OrderedDict)

PKp_full['x'] = PKp_b64
PKs_full['x'] = PKs_b64
#PKs2_full['x'] = PKs2_b64
Esempio n. 3
0
File: utils.py Progetto: hdknr/jose
def long_to_b64(n):
    data = long_to_bytes(n)
    return base64.base64url_encode(data)
Esempio n. 4
0
KeyingMode = 2

# SleepTime
SleepTime = 60


################################################################################
############################## CALCULATED  VALUES ##############################
## Load peer and server public keys
PK_peer = PublicKey(bytes.fromhex(PKp))
PK_server = PublicKey(bytes.fromhex(PKs))
#PK2_peer = PublicKey(bytes.fromhex(PKp))
#PK2_server = PublicKey(bytes.fromhex(PKs))

# Peer and server public keys - base64 encoded
PKp_b64 = base64url_encode(bytes.fromhex(PKp)).decode().strip('=')
PKs_b64 = base64url_encode(bytes.fromhex(PKs)).decode().strip('=')
#PKp2_b64 = base64url_encode(bytes.fromhex(PKp2)).decode().strip('=')
#PKs2_b64 = base64url_encode(bytes.fromhex(PKs2)).decode().strip('=')

# Peer and server public keys - jwk formatted
PKp_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}',
    object_pairs_hook=OrderedDict)
PKs_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}',
    object_pairs_hook=OrderedDict)
# PKs2_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}', \
#     object_pairs_hook=OrderedDict)
# PKp2_full = loads('{"kty":"EC", "crv":"Curve25519", "x":""}', \
#     object_pairs_hook=OrderedDict)

PKp_full['x'] = PKp_b64