# @file PRF_msg.py (2023-03-16T14:29Z)
# @author David Ireland <www.di-mgt.com.au/contact>
# @copyright 2023 DI Management Services Pty Ltd
# @license Apache-2.0

"""Compute the 16-byte randomizer R using PRF_msg."""

from spx_sha256 import HMAC_SHA256

# Compute the randomizer R of 16 bytes using hex strings
sk_prf='2fd81a25ccb148032dcd739936737f2d'
optrand='33b3c07507e4201748494d832b6ee2a6'
msg= \
'D81C4D8D734FCBFBEADE3D3F8A039FAA2A2C9957E835AD55B22E75BF57BB556AC8'
R = HMAC_SHA256(sk_prf, optrand + msg)
R = R[:32] # Truncate to 16 bytes
print("R =", R)
# R = b77b5397031e67eb585dba86b10b710b