Executable attachment for the HMAC-SHA-512 interface.
We define a wrapper of the executable definition and attach the wrapper to the constrained function. The wrapper serves to use the fixtypes for byte lists, to fix the inputs accordingly, and to convert the text input to bits as required by the executable definition (while the key is in bytes).
Function:
(defun hmac-sha-512-wrapper (key text) (declare (xargs :guard (and (byte-listp key) (byte-listp text)))) (declare (xargs :guard (and (< (len key) (expt 2 125)) (< (len text) (- (expt 2 125) 128))))) (let ((__function__ 'hmac-sha-512-wrapper)) (declare (ignorable __function__)) (b* ((key (mbe :logic (byte-list-fix key) :exec key)) (text (mbe :logic (byte-list-fix text) :exec text)) (text-bits (bebytes=>bits text))) (hmac::hmac-sha-512 key text-bits))))
Theorem:
(defthm byte-listp-of-hmac-sha-512-wrapper (b* ((result (hmac-sha-512-wrapper key text))) (byte-listp result)) :rule-classes :rewrite)
Theorem:
(defthm len-of-hmac-sha-512-wrapper (equal (len (hmac-sha-512-wrapper key text)) 64))
Theorem:
(defthm hmac-sha-512-wrapper-of-byte-list-fix-key (equal (hmac-sha-512-wrapper (byte-list-fix key) text) (hmac-sha-512-wrapper key text)))
Theorem:
(defthm hmac-sha-512-wrapper-byte-list-equiv-congruence-on-key (implies (byte-list-equiv key key-equiv) (equal (hmac-sha-512-wrapper key text) (hmac-sha-512-wrapper key-equiv text))) :rule-classes :congruence)
Theorem:
(defthm hmac-sha-512-wrapper-of-byte-list-fix-text (equal (hmac-sha-512-wrapper key (byte-list-fix text)) (hmac-sha-512-wrapper key text)))
Theorem:
(defthm hmac-sha-512-wrapper-byte-list-equiv-congruence-on-text (implies (byte-list-equiv text text-equiv) (equal (hmac-sha-512-wrapper key text) (hmac-sha-512-wrapper key text-equiv))) :rule-classes :congruence)