Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
99d1f362
Commit
99d1f362
authored
Jan 03, 2016
by
Alexander Korolkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename some functions in uacrypto and add comments
parent
4f41b4eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
opcua/security_policies.py
opcua/security_policies.py
+3
-2
opcua/uacrypto.py
opcua/uacrypto.py
+7
-6
No files found.
opcua/security_policies.py
View file @
99d1f362
...
...
@@ -249,7 +249,7 @@ class SignerAesCbc(Signer):
return
uacrypto
.
sha1_size
()
def
signature
(
self
,
data
):
return
uacrypto
.
h
ash_hmac
(
self
.
key
,
data
)
return
uacrypto
.
h
mac_sha1
(
self
.
key
,
data
)
class
VerifierAesCbc
(
Verifier
):
...
...
@@ -261,7 +261,7 @@ class VerifierAesCbc(Verifier):
return
uacrypto
.
sha1_size
()
def
verify
(
self
,
data
,
signature
):
expected
=
uacrypto
.
h
ash_hmac
(
self
.
key
,
data
)
expected
=
uacrypto
.
h
mac_sha1
(
self
.
key
,
data
)
if
signature
!=
expected
:
raise
uacrypto
.
InvalidSignature
...
...
@@ -403,6 +403,7 @@ class SecurityPolicyBasic256(SecurityPolicy):
self
.
client_certificate
=
uacrypto
.
der_from_x509
(
client_cert
)
def
make_symmetric_key
(
self
,
nonce1
,
nonce2
):
# specs part 6, 6.7.5
key_sizes
=
(
self
.
signature_key_size
,
self
.
symmetric_key_size
,
16
)
(
sigkey
,
key
,
init_vec
)
=
uacrypto
.
p_sha1
(
nonce2
,
nonce1
,
key_sizes
)
...
...
opcua/uacrypto.py
View file @
99d1f362
...
...
@@ -129,7 +129,7 @@ def cipher_decrypt(cipher, data):
return
decryptor
.
update
(
data
)
+
decryptor
.
finalize
()
def
h
ash_hmac
(
key
,
message
):
def
h
mac_sha1
(
key
,
message
):
hasher
=
hmac
.
HMAC
(
key
,
hashes
.
SHA1
(),
backend
=
default_backend
())
hasher
.
update
(
message
)
return
hasher
.
finalize
()
...
...
@@ -139,9 +139,10 @@ def sha1_size():
return
hashes
.
SHA1
.
digest_size
def
p_sha1
(
key
,
body
,
sizes
=
()):
def
p_sha1
(
secret
,
seed
,
sizes
=
()):
"""
Derive one or more keys from key and body.
Derive one or more keys from secret and seed.
(See specs part 6, 6.7.5 and RFC 2246 - TLS v1.0)
Lengths of keys will match sizes argument
"""
full_size
=
0
...
...
@@ -149,10 +150,10 @@ def p_sha1(key, body, sizes=()):
full_size
+=
size
result
=
b''
accum
=
body
accum
=
seed
while
len
(
result
)
<
full_size
:
accum
=
h
ash_hmac
(
key
,
accum
)
result
+=
h
ash_hmac
(
key
,
accum
+
body
)
accum
=
h
mac_sha1
(
secret
,
accum
)
result
+=
h
mac_sha1
(
secret
,
accum
+
seed
)
parts
=
[]
for
size
in
sizes
:
...
...
Write
Preview
Markdown
is supported
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