t om sh a form alization · 2003-07-03 · sh a form alization t om a diana and borrione dominique...

29
VDS 1 © Diana Toma SHA Formalization TOMA Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO

Upload: others

Post on 20-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S1

© D

iana Tom

a

SHA

Formalization

TOM

A D

iana and BORRIO

NE D

ominique

TIMA

Laboratory - VD

S Group,

Grenoble, France

AC

L2 Workshop 2003 Boulder,C

O

Page 2: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S2

© D

iana Tom

a

Project in progress

•D

esign of a chip for secure transmissions

•O

ur participation:–

Validation of the hash block

VH

DL

File

Textu

al D

escriptio

n

Sym

bo

lic S

imu

lation

AC

L2 F

orm

alization

an

d V

erification

Fu

nctio

nal

verification

with

AC

L2

Page 3: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S3

© D

iana Tom

a

Project in progress

•D

esign of a chip for secure transmissions

•O

ur participation:–

Validation of the hash block

VH

DL

File

Textu

al D

escriptio

n

Sym

bo

lic S

imu

lation

AC

L2 F

orm

alization

an

d V

erification

Fu

nctio

nal

verification

with

AC

L2

Page 4: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S4

© D

iana Tom

a

Hash functions

•A

mong the m

ost widespread cryptographic prim

itives•

Used in :

–digital signature schem

es together with public key

cryptographic systems

–secret-key M

essage Authentication Codes (M

ACs)

used in security protocols–

fast encryption–

Password storage and verification

–Com

puter virus detection

Page 5: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S5

© D

iana Tom

a

SHA

Properties

2256

51264

1024<2

128SH

A-512

2192

38464

1024<2

128SH

A-384

2128

25632

512<2

64SH

A-256

280

16032

512<2

64SH

A-1

SecurityM

essagedigest size

Word

sizeBlocksize

Message

sizeA

lgorithm

•Process a m

essage to produce a condensed representationcalled m

essage digest

•O

ne way hash functions

•A

ny change to the message w

ill result in a differentm

essage digest

Page 6: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S6

© D

iana Tom

a

SHA

Properties

2256

51264

1024<2

128SH

A-512

2192

38464

1024<2

128SH

A-384

2128

25632

512<2

64SH

A-256

280

16032

512<2

64SH

A-1

SecurityM

essagedigest size

Word

sizeBlocksize

Message

sizeA

lgorithm

•Process a m

essage to produce a condensed representationcalled m

essage digest

•O

ne way hash functions

•A

ny change to the message w

ill result in a differentm

essage digest

Page 7: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S7

© D

iana Tom

a

SHA

Properties

2256

51264

1024<2

128SH

A-512

2192

38464

1024<2

128SH

A-384

2128

25632

512<2

64SH

A-256

280

16032

512<2

64SH

A-1

SecurityM

essagedigest size

Word

sizeBlocksize

Message

sizeA

lgorithm

•Process a m

essage to produce a condensed representationcalled m

essage digest

•O

ne way hash functions

•A

ny change to the message w

ill result in a differentm

essage digest

Page 8: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S8

© D

iana Tom

a

Textual description

•Bit, w

ord (a w-bit string),

•Integer represented as w

ord•

Operations on w

ords:–

Logical operations: and, or, xor, not–

Addition m

odulo 2w

–Right shift, circular right shift, circular left shift

•Logical functions on w

ords•

Constants

The big endian convention is used when expressing w

ords.•

A book on bit vectors represented as lists w

ith operationson w

-bit words, w

as created.

Page 9: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S9

© D

iana Tom

a

SHA

Algorithm

Pad

din

g

dig

est

Messag

e M

Parsin

g

M1

M2

MK

dig

estd

igest

…In

itialH

ashV

alue

H1

H2

H3

HK

HK

+1

Fin

al Dig

est

Preprocesing

Step

Page 10: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S10

© D

iana Tom

a

Padding

•Extends M

to a multiple of 512 bits

•Padded m

esssage is:–

Append bit 1 to the end of m

essage M–

Append k bits 0, s.t.

(len+1+k) m

od 512 = 448–

Append the 64-bit binary representation of len

(len is length of M)

•Exam

ple the 8-bit ASCII m

essage “!abc!”

ab

c

42364

01100001 01100010 01100011 1 00…00 00…011000

Page 11: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S11

© D

iana Tom

a

Padding

Two cases:

-on one block : previous exam

ple-

on several blocks

or

M0len…

last block

M0len

last two blocks

M

first block

Page 12: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S12

© D

iana Tom

a

Padding Formalization

(defun padding (M) (if (and (bvp M) (< (len M) (expt 2 64))) (if (<= (mod (1+ (len M)) 512) 448) (append M (list 1) (make-list (- 448 (mod (1+ (len M)) 512))

:initial-element 0) (bv-to-n (int-bv-big-endian (len M)) 64)) (append M (list 1) (make-list (- 960 (mod (1+ (len M)) 512))

:initial-element 0) (bv-to-n (int-bv-big-endian (len M)) 64))) nil))

•bvp (m

) recognizes a bit vector•

bv-to-n (m,i) forces the bit-vector m

to the length i•

int-bv-big-endian (i) transforms the integer i into the corresponding bit

vector, with the m

ost significant bit on the leftmost-bit position

Page 13: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S13

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp

(padding m)))

(defthm len-padding-mod (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (mod (len (padding M)) 512) 0)))(defthm len-padding>=512 (implies (and (bvp M) (< (len M) (expt 2 64))) (<= 512 (len (padding M)))))(defthm last64-padding=

len (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (bv-int-big-endian (nthcdr (- (len (padding M)) 64) (padding M))) (len M))))(defthm first-padding=message (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (firstn (len M) (padding M)) M)))(defthm end-message-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (segment (1+ (len M)) (- (len (padding M)) 64) (padding M)) (make-list (- (len (padding m)) (+ 65 (len M))) :initial-element 0))))

The padded m

essage is a bit vector

Page 14: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S14

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp (padding m)))

(defthm len-padding-m

od

(implies (and

(bvp M)

(< (len

M) (expt

2 64)))

(equal (mod (len (padding M)) 512) 0)))

(defthm len-padding>=512 (implies (and (bvp M) (< (len M) (expt 2 64))) (<= 512 (len (padding M)))))(defthm last64-padding=

len (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (bv-int-big-endian (nthcdr (- (len (padding M)) 64) (padding M))) (len M))))(defthm first-padding=message (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (firstn (len M) (padding M)) M)))(defthm end-message-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (segment (1+ (len M)) (- (len (padding M)) 64) (padding M)) (make-list (- (len (padding m)) (+ 65 (len M))) :initial-element 0))))

The length of

the padded message

is a multiple of 512

Page 15: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S15

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp (padding m)))(defthm len-padding-mod (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (mod (len (padding M)) 512) 0)))

(defthm len-padding>=512

(implies (and

(bvp M)

(< (len

M) (expt

2 64)))

(<= 512 (len (padding M)))))

(defthm last64-padding=len

(implies (and (bvp M) (< (len M) (expt 2 64))) (equal (bv-int-big-endian (nthcdr (- (len (padding M)) 64) (padding M))) (len M))))(defthm first-padding=message (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (firstn (len M) (padding M)) M)))(defthm end-message-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (segment (1+ (len M)) (- (len (padding M)) 64) (padding M)) (make-list (- (len (padding m)) (+ 65 (len M))) :initial-element 0))))

The length of

the padded message

is greater or equal to 512

Page 16: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S16

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp (padding m)))(defthm len-padding-mod (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (mod (len (padding M)) 512) 0)))(defthm len-padding>=512 (implies (and (bvp M) (< (len M) (expt 2 64))) (<= 512 (len (padding M)))))

(defthm last64-padding=len

(implies (and

(bvp M)

(< (len

M) (expt

2 64)))

(equal (bv-int-big-endian (nthcdr (-

(len (padding M)) 64)(padding

M)))

(len M))))

(defthm first-padding=message (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (firstn (len M) (padding M)) M)))(defthm end-message-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (segment (1+ (len M)) (- (len (padding M)) 64) (padding M)) (make-list (- (len (padding m)) (+ 65 (len M))) :initial-element 0))))

The last 64 bits of the padded m

essage represent the length of M

Page 17: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S17

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp (padding m)))(defthm len-padding-mod (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (mod (len (padding M)) 512) 0)))(defthm len-padding>=512 (implies (and (bvp M) (< (len M) (expt 2 64))) (<= 512 (len (padding M)))))(defthm last64-padding=

len (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (bv-int-big-endian (nthcdr (- (len (padding M)) 64) (padding M))) (len M))))

(defthm first-padding=message

(implies (and

(bvp M)

(< (len

M) (expt

2 64)))

(equal (firstn (len M) (padding M)) M)))

(defthm end-message-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding (implies (

and (bvp M) (< (len M) (expt 2 64)))

(equal (segment (1+ (len M)) (- (len (padding M)) 64) (padding M)) (make-list (- (len (padding m)) (+ 65 (len M))) :initial-element 0))))

The first len (M

) bits of the padded m

essage represent the initial m

essage

Page 18: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S18

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp (padding m)))(defthm len-padding-mod (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (mod (len (padding M)) 512) 0)))(defthm len-padding>=512 (implies (and (bvp M) (< (len M) (expt 2 64))) (<= 512 (len (padding M)))))(defthm last64-padding=

len (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (bv-int-big-endian (nthcdr (- (len (padding M)) 64) (padding M))) (len M))))(defthm first-padding=message (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (firstn (len M) (padding M)) M)))

(defthm end-message-padding

(implies (and

(bvp M)

(< (len

M) (expt

2 64)))

(equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding

(implies (and (bvp M) (< (len M) (expt 2 64))) (equal (segment (1+ (len M)) (- (len (padding M)) 64) (padding M)) (make-list (- (len (padding m)) (+ 65 (len M))) :initial-element 0))))

The next bit after M

in the padded m

essage marks

the end of the messsage

Page 19: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S19

© D

iana Tom

a

Padding Verification

(defthm bvp-padding (bvp (padding m)))(defthm len-padding-mod (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (mod (len (padding M)) 512) 0)))(defthm len-padding>=512 (implies (and (bvp M) (< (len M) (expt 2 64))) (<= 512 (len (padding M)))))(defthm last64-padding=

len (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (bv-int-big-endian (nthcdr (- (len (padding M)) 64) (padding M))) (len M))))(defthm first-padding=message (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (firstn (len M) (padding M)) M)))(defthm end-message-padding (implies (and (bvp M) (< (len M) (expt 2 64))) (equal (nth (len M) (padding M)) 1)))

(defthm 0-fill-padding

(implies (and

(bvp M)

(< (len

M) (expt

2 64)))

(equal (segment (1+ (len M)) (- (len (padding M)) 64)

(padding M))

(make-list (- (len (padding m)) (+ 65 (len M)))

:initial-element 0))))

The bits betw

een the end-of-the-m

essage bit and the last 64 bits are all 0

Page 20: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S20

© D

iana Tom

a

Parsing

•Splits the padded m

essage into N-bit blocks

(512 for SHA

-1 and SHA

-256; 1024 for the others) (defun

parsing (l

n)

(if (and

(integerp n) (<=

0 n)

(true-listp l))

(if (or (endp l) (zp n)) nil

(cons (firstn n l) (parsing (nthcdr n l) n))))

nil))

ACL2!>(parsing ‘(1 2 3

4 5

6 7

8 9)

4)((1 2

3 4) (5 6

7 8) (9))

(defun el-of-eq-len (l)

(if

(true-listp l)

(if (or (endp l) (endp (cdr l))

(and (equal (len (car l)) (len (cadr l)))

(el-of-eq-len (cdr l))))

nil))

Page 21: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S21

© D

iana Tom

a

Parsing Verification

(defthm parsing-right-len

(implies (and

(true-listp l) (integerp n)

(< 0

n)

(equal (mod (len l) n) 0))

(el-of-eq-len (parsing l n))))

(defthm len-parsing (implies (and (true-listp l) (integerp n) (< 0 n) (equal (mod (len l) n) 0)) (equal (len (parsing l n)) (/ (len l) n))))(defthm wvp-parsing (implies (and (bvp m) (integerp n) (< 0 n) (equal (mod (len m) n) 0)) (wvp (parsing m n) n)))(defthm wvp-parsing-padding (implies (and (bvp M) (< (len M) (expt 2 64))) (wvp (parsing (padding M) 512) 512)))

wvp (m

,n) recognizes a vector of words, each of length n If len (l) is a m

ultiple of n, the result is a list L

of blocks of equal length …

Page 22: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S22

© D

iana Tom

a

Parsing Verification

(defthm parsing-right-len (implies (and (true-listp l) (integerp n) (< 0 n) (equal (mod (len l) n) 0)) (el-of-eq-len (parsing l n))))

(defthm len-parsing

(implies (and

(true-listp l) (integerp n)

(< 0

n)

(equal (mod (len l) n) 0))

(equal (len (parsing l n)) (/ (len l) n))))

(defthm wvp-parsing (implies (and (bvp m) (integerp n) (< 0 n) (equal (mod (len m) n) 0)) (wvp (parsing m n) n)))(defthm wvp-parsing-padding (implies (and (bvp M) (< (len M) (expt 2 64))) (wvp (parsing (padding M) 512) 512)))

wvp (m

,n) recognizes a vector of words, each of length n …

where the length of L

is the result of

dividing len (l) to n

Page 23: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S23

© D

iana Tom

a

Parsing Verification

(defthm parsing-right-len (implies (and (true-listp l) (integerp n) (< 0 n) (equal (mod (len l) n) 0)) (el-of-eq-len (parsing l n))))(defthm len-parsing (implies (and (true-listp l) (integerp n) (< 0 n) (equal (mod (len l) n) 0)) (equal (len (parsing l n)) (/ (len l) n))))

(defthm wvp-parsing

(implies (and (bvp m)

(integerp n) (<

0 n)

(equal (mod (len m) n) 0))

(wvp (parsing m n) n)))

(defthm wvp-parsing-padding (implies (and (bvp M) (< (len M) (expt 2 64))) (wvp (parsing (padding M) 512) 512)))

wvp (m

,n) recognizes a vector of words, each of length n If a bit vector m

is parsed, the result is a vector of w

ords, each of length n

Page 24: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S24

© D

iana Tom

a

Parsing Verification

(defthm parsing-right-len (implies (and (true-listp l) (integerp n) (< 0 n) (equal (mod (len l) n) 0)) (el-of-eq-len (parsing l n))))(defthm len-parsing (implies (and (true-listp l) (integerp n) (< 0 n) (equal (mod (len l) n) 0)) (equal (len (parsing l n)) (/ (len l) n))))(defthm wvp-parsing (implies (and (bvp m) (integerp n) (< 0 n) (equal (mod (len m) n) 0)) (wvp (parsing m n) n)))

(defthm wvp-parsing-padding

(implies (and

(bvp M)

(< (len

M) (expt 2

64)))

(wvp (parsing (padding M) 512) 512)))

wvp (m

,n) recognizes a vector of words, each of length n A

fter parsing the padded m

essage, the result is a vector of w

ords, each of 512 bits.

Page 25: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S25

© D

iana Tom

a

Message digest

•For each block M

i of 512 bits1. Parse M

i in 16 words W

i 0, Wi 1,…

, Wi 15, each of 32 bits and com

puteW

i j=ROTL

1(Wi j-3⊕

Wi j-8⊕

Wi j-14⊕

Wi j-16), 16<=j<80

(defun prepare (M-i) (if (wordp M-i 512) (prepare-ac 16 (parsing M-i 32)) nil))

(defun prepare-ac (j M-i)

(declare (xargs :measure (acl2-count (- 80 j)))) (if (and (integerp j) (<= 16 j) (wvp M-i 32)) (cond ((<= 80 j) M-i) ((<= j 79) (prepare-ac (1+ j) (append M-i (list (rotl 1 (bv-xor (nth (- j 3) M-i) (nth (- j 8) M-i) (nth (- j 14) M-i) (nth (- j 16) M-i)) 32)))))) nil))

2. Initialize the working variables w

ith intermediate hash value

(for M1 - initial hash value)

Page 26: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S26

© D

iana Tom

a

Message digest

•For each block M

i of 512 bits3. A

pply eighty times the digest step

(defun digest-one-block (hash-values M-i-ext) (if (and (wvp hash-values 32) (equal (len hash-values) 5) (wvp M-i-ext 32) (equal (len M-i-ext) 80)) (digest-one-block-ac 0 hash-values M-i-ext) nil))

(defun digest-one-block-ac (j working-variables M-i-ext)(declare (xargs :measure (acl2-count (- 80 j)))) (if (and (wvp working-variables 32) (equal (len working-variables ) 5) (integerp j) (<= 0 j) (wvp M-i-ext 32) (equal (len M-i-ext) 80)) (if (<= 80 j) working-variables (digest-one-block-ac (+ 1 j) (list (temp j working-variables M-i-ext) (nth 0 working-variables) (rotl 30 (nth 1 working-variables) 32) (nth 2 working-variables) (nth 3 working-variables)) M-i-ext)) nil))

4. Compute the interm

ediate hash values

Page 27: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S27

© D

iana Tom

a

Message digest

•The interm

ediate hash value of the block Mi is the input hash value of

the block Mi+1

•The result of applying step one to four to all K

message blocks

represents the message digest of m

essage M.

(defun sha-1 (M) (if (and (bvp M) (< (len M) (expt 2 64))) (digest (parsing (padding M) 512) (h-1)) nil))

(defun digest (M hash-values) (if (and (wvp M 512) (wvp hash-values 32) (equal (len hash-values) 5)) (if (endp M) hash-values (digest (cdr M) (intermediate-hash hash-values (digest-one-block hash-values (prepare (car M)))))) nil))

(defthm wvp-sha-1 (implies (and (bvp M) (< (len M) (expt 2 64))) (and (wvp (sha-1 M) 32) (equal (len (sha-1 M)) 5))))

Page 28: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S28

© D

iana Tom

a

Conclusion

•Form

alization of SHA

algorithms and verification of safety theorem

s•

Num

eric execution on the tests provided in the standard document

•D

evelopment of a book for bit vectors represented as lists w

ith highorder bits on the left, closer to the V

HD

L bit vectors representation.Future W

ork•

Prove equivalence between list representation and IH

S book•

Prove correctness of SHA

implem

entation

VH

DL

File

Textu

al D

escriptio

n

Sym

bo

lic S

imu

lation

AC

L2 F

orm

alization

and

Verificatio

n

Fu

nctio

nal

verification

with

AC

L2

Done

To do

Page 29: T OM SH A Form alization · 2003-07-03 · SH A Form alization T OM A Diana and BORRIONE Dominique TIMA Laboratory - VDS Group, Grenoble, France ACL2 Workshop 2003 Boulder,CO. VDS

VD

S29

© D

iana Tom

a