Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P38789
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Vgutierrez
on Nov 9 2022, 10:18 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
Traffic
Referenced Files
F35729797: raw-paste-data.txt
Nov 9 2022, 10:18 AM
2022-11-09 10:18:14 (UTC+0)
Subscribers
None
#!/usr/bin/python3.9
import
datetime
# requires python3-nacl
import
nacl.encoding
from
nacl.hash
import
blake2b
,
siphash24
,
SIPHASH_KEYBYTES
master_key
=
bytes
.
fromhex
(
'e7e1ce2f97d3b8c6a83096ff5a68566549fa5de00731e001b1e623865060a725ed99c68790a3a8e09e3f631bc5fc704bedb4b6604aa8d06d5609147b34d6dc4e'
)
subkey_id
=
str
(
datetime
.
date
.
today
())
.
encode
()
context
=
b
'diffpriv'
# from https://libsodium.gitbook.io/doc/key_derivation
# BLAKE2B-subkeylen(key=key, message={}, salt=subkey_id || {0}, personal=ctx || {0})
derived
=
blake2b
(
b
''
,
key
=
master_key
,
salt
=
subkey_id
,
person
=
context
,
encoder
=
nacl
.
encoding
.
RawEncoder
)
key
=
derived
[:
SIPHASH_KEYBYTES
]
print
(
f
"[*] key to be used with SipHash24: {key.hex()}"
)
msg
=
b
'message to be hashed'
h
=
siphash24
(
msg
,
key
)
print
(
f
"[*] siphash24({msg}, {key.hex()}) = {h.hex()}"
)
Event Timeline
Vgutierrez
created this paste.
Nov 9 2022, 10:18 AM
2022-11-09 10:18:14 (UTC+0)
Log In to Comment