Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Core
Tor
Commits
6babd3d9
Commit
6babd3d9
authored
Sep 18, 2017
by
Nick Mathewson
🐻
Browse files
Merge branch 'maint-0.3.1' into release-0.3.1
parents
9d35ddf1
63ae9ea3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/hs_ntor_ref.py
View file @
6babd3d9
...
...
@@ -83,11 +83,11 @@ from ntor_ref import hash_nil
from
ntor_ref
import
PrivateKey
# String constants used in this protocol
PROTOID
=
"tor-hs-ntor-curve25519-sha3-256-1"
T_HSENC
=
PROTOID
+
":hs_key_extract"
T_HSVERIFY
=
PROTOID
+
":hs_verify"
T_HSMAC
=
PROTOID
+
":hs_mac"
M_HSEXPAND
=
PROTOID
+
":hs_key_expand"
PROTOID
=
b
"tor-hs-ntor-curve25519-sha3-256-1"
T_HSENC
=
PROTOID
+
b
":hs_key_extract"
T_HSVERIFY
=
PROTOID
+
b
":hs_verify"
T_HSMAC
=
PROTOID
+
b
":hs_mac"
M_HSEXPAND
=
PROTOID
+
b
":hs_key_expand"
INTRO_SECRET_LEN
=
161
REND_SECRET_LEN
=
225
...
...
@@ -191,7 +191,7 @@ def service_part1(intro_auth_pubkey_str, client_enc_pubkey, intro_enc_privkey, i
ntor_key_seed
=
mac
(
rend_secret_hs_input
,
T_HSENC
)
verify
=
mac
(
rend_secret_hs_input
,
T_HSVERIFY
)
auth_input
=
verify
+
intro_auth_pubkey_str
+
intro_enc_pubkey
.
serialize
()
+
service_ephemeral_pubkey
.
serialize
()
+
client_enc_pubkey
.
serialize
()
+
PROTOID
+
"Server"
auth_input
=
verify
+
intro_auth_pubkey_str
+
intro_enc_pubkey
.
serialize
()
+
service_ephemeral_pubkey
.
serialize
()
+
client_enc_pubkey
.
serialize
()
+
PROTOID
+
b
"Server"
assert
(
len
(
auth_input
)
==
AUTH_INPUT_LEN
)
auth_input_mac
=
mac
(
auth_input
,
T_HSMAC
)
...
...
@@ -218,7 +218,7 @@ def client_part2(intro_auth_pubkey_str, client_ephemeral_enc_pubkey, client_ephe
ntor_key_seed
=
mac
(
rend_secret_hs_input
,
T_HSENC
)
verify
=
mac
(
rend_secret_hs_input
,
T_HSVERIFY
)
auth_input
=
verify
+
intro_auth_pubkey_str
+
intro_enc_pubkey
.
serialize
()
+
service_ephemeral_rend_pubkey
.
serialize
()
+
client_ephemeral_enc_pubkey
.
serialize
()
+
PROTOID
+
"Server"
auth_input
=
verify
+
intro_auth_pubkey_str
+
intro_enc_pubkey
.
serialize
()
+
service_ephemeral_rend_pubkey
.
serialize
()
+
client_ephemeral_enc_pubkey
.
serialize
()
+
PROTOID
+
b
"Server"
assert
(
len
(
auth_input
)
==
AUTH_INPUT_LEN
)
auth_input_mac
=
mac
(
auth_input
,
T_HSMAC
)
...
...
@@ -294,7 +294,7 @@ def do_pure_python_ntor_test():
assert
(
client_ntor_key_seed
==
service_ntor_key_seed
)
assert
(
client_auth_input_mac
==
service_auth_input_mac
)
print
"DONE: python dance [%s]"
%
repr
(
client_auth_input_mac
)
print
(
"DONE: python dance [%s]"
%
repr
(
client_auth_input_mac
)
)
# Perform a pure little-t-tor integration test.
def
do_little_t_tor_ntor_test
():
...
...
@@ -334,7 +334,7 @@ def do_little_t_tor_ntor_test():
assert
(
client_ntor_key_seed
==
service_ntor_key_seed
)
assert
(
client_ntor_auth_mac
==
service_ntor_auth_mac
)
print
"DONE: tor dance [%s]"
%
repr
(
client_ntor_auth_mac
)
print
(
"DONE: tor dance [%s]"
%
repr
(
client_ntor_auth_mac
)
)
"""
Do mixed test as follows:
...
...
@@ -379,7 +379,7 @@ def do_first_mixed_test():
assert
(
client_auth_input_mac
==
service_ntor_auth_mac
)
assert
(
client_ntor_key_seed
==
service_ntor_key_seed
)
print
"DONE: 1st mixed dance [%s]"
%
repr
(
client_auth_input_mac
)
print
(
"DONE: 1st mixed dance [%s]"
%
repr
(
client_auth_input_mac
)
)
"""
Do mixed test as follows:
...
...
@@ -413,7 +413,7 @@ def do_second_mixed_test():
assert
(
client_ntor_key_seed
==
service_ntor_key_seed
)
assert
(
client_ntor_auth_mac
==
service_ntor_auth_mac
)
print
"DONE: 2nd mixed dance [%s]"
%
repr
(
client_ntor_auth_mac
)
print
(
"DONE: 2nd mixed dance [%s]"
%
repr
(
client_ntor_auth_mac
)
)
def
do_mixed_tests
():
do_first_mixed_test
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment