1
;------------------------------------------
4
; TIMA-VDS, Grenoble, France
6
; ACL2 formalization of SHAs
7
; Logic functions (and theorems) needed for all four SHA
8
;------------------------------------------
14
(include-book "bv-op-defthms")
17
;logic functions for SHAs
23
(bv-xor (bv-and x y) (bv-and (bv-not x) z))
27
(implies (and (bvp x) (bvp y) (bvp z))
31
(implies (and (wordp x w) (wordp y w) (wordp z w))
32
(wordp (Ch x y z) w)))
43
(implies (and (bvp x) (bvp y) (bvp z))
44
(bvp (Parity x y z))))
47
(implies (and (wordp x w) (wordp y w) (wordp z w))
48
(wordp (Parity x y z) w)))
54
(bv-xor (bv-and x y) (bv-and x z) (bv-and y z))
58
(implies (and (bvp x) (bvp y) (bvp z))
62
(implies (and (wordp x w) (wordp y w) (wordp z w))
63
(wordp (Maj x y z) w)))
71
(cond ((and (<= 0 i) (<= i 19))
73
((or (and (<= 20 i) (<= i 39)) (and (<= 60 i) (<= i 79)))
75
((and (<= 40 i) (<= i 59))
80
(implies (and (integerp i) (<= 0 i) (wordp x 32) (<= 0 i) (< i 80)
81
(wordp y 32) (wordp z 32))
82
(wordp (Ft i x y z) 32))
83
:hints (("goal" :in-theory (disable ch parity maj) )))
85
(defun sigma-0-256 (x)
87
(bv-xor (rotr 2 x 32) (rotr 13 x 32) (rotr 22 x 32))
91
(defthm wordp-sigma-0-256
93
( wordp (sigma-0-256 x) 32))
94
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl ))))
96
(defun sigma-1-256 (x)
98
(bv-xor (rotr 6 x 32) (rotr 11 x 32) (rotr 25 x 32))
101
(defthm wordp-sigma-1-256
102
(implies (wordp x 32)
103
( wordp (sigma-1-256 x) 32))
104
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl ))))
108
(bv-xor (rotr 7 x 32) (rotr 18 x 32) (shr 3 x 32))
111
(defthm wordp-s-0-256
112
(implies (wordp x 32)
113
( wordp (s-0-256 x) 32))
114
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl shr ))))
118
(bv-xor (rotr 17 x 32) (rotr 19 x 32) (shr 10 x 32))
121
(defthm wordp-s-1-256
122
(implies (wordp x 32)
123
( wordp (s-1-256 x) 32))
124
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl shr ))))
126
(defun sigma-0-512 (x)
128
(bv-xor (rotr 28 x 64) (rotr 34 x 64) (rotr 39 x 64))
131
(defthm wordp-sigma-0-512
132
(implies (wordp x 64)
133
( wordp (sigma-0-512 x) 64))
134
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl ))))
136
(defun sigma-1-512 (x)
138
(bv-xor (rotr 14 x 64) (rotr 18 x 64) (rotr 41 x 64))
141
(defthm wordp-sigma-1-512
142
(implies (wordp x 64)
143
( wordp (sigma-1-512 x) 64))
144
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl ))))
148
(bv-xor (rotr 1 x 64) (rotr 8 x 64) (shr 7 x 64))
151
(defthm wordp-s-0-512
152
(implies (wordp x 64)
153
( wordp (s-0-512 x) 64))
154
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl shr ))))
158
(bv-xor (rotr 19 x 64) (rotr 61 x 64) (shr 6 x 64))
161
(defthm wordp-s-1-512
162
(implies (wordp x 64)
163
( wordp (s-1-512 x) 64))
164
:hints (("goal" :in-theory (disable binary-bv-xor rotr rotr->rotl shr ))))