diff options
-rw-r--r-- | cubehash.rkt | 13 | ||||
-rw-r--r-- | hmac.rkt | 7 | ||||
-rw-r--r-- | salsa-chacha.rkt | 2 | ||||
-rw-r--r-- | threefish.rkt | 1 | ||||
-rw-r--r-- | whirlpool.rkt | 9 |
5 files changed, 27 insertions, 5 deletions
diff --git a/cubehash.rkt b/cubehash.rkt index 9eb8a84..bb87788 100644 --- a/cubehash.rkt +++ b/cubehash.rkt @@ -42,6 +42,19 @@ [cubehash-512x (Bytes -> Exact-Nonnegative-Integer)] #;[cubemac-128 (Bytes Bytes -> Exact-Nonnegative-Integer)]) +(: cubehash (Exact-Nonnegative-Integer Exact-Nonnegative-Integer + Exact-Nonnegative-Integer Exact-Nonnegative-Integer + Exact-Nonnegative-Integer -> + Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-128 (Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-160 (Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-224 (Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-256 (Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-384 (Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-512 (Bytes -> Exact-Nonnegative-Integer)) +(: cubehash-512x (Bytes -> Exact-Nonnegative-Integer)) +#;(: cubemac-128 (Bytes Bytes -> Exact-Nonnegative-Integer)) + (define-type Word Exact-Nonnegative-Integer) (define-type Bit (U Zero One)) @@ -31,6 +31,13 @@ ;; ;; (hmac whirlpool 64 64 #"<secret key>" #"hello") ;; +(: hmac ((Bytes -> Exact-Nonnegative-Integer) + Exact-Nonnegative-Integer + Exact-Nonnegative-Integer + Bytes + Bytes + -> + Exact-Nonnegative-Integer)) (define (hmac hashfn blocksize hashsize key msg) (let ([opad (make-bytes blocksize #x5c)] [ipad (make-bytes blocksize #x36)] diff --git a/salsa-chacha.rkt b/salsa-chacha.rkt index bf7a6ee..9a07820 100644 --- a/salsa-chacha.rkt +++ b/salsa-chacha.rkt @@ -133,7 +133,7 @@ (: times (All (a) ((a -> a) Integer -> (a -> a)))) (define (times fn n) - (for/fold ([acc (inst identity a)]) + (for/fold ([acc : (a -> a) (inst identity a)]) ([i (in-range 0 n)]) (compose fn acc))) diff --git a/threefish.rkt b/threefish.rkt index a9cd8d0..1d49098 100644 --- a/threefish.rkt +++ b/threefish.rkt @@ -20,6 +20,7 @@ (require "util.rkt") (provide: [threefish (Bytes Bytes Bytes (U 'encrypt 'decrypt) -> Bytes)]) +(: threefish (Bytes Bytes Bytes (U 'encrypt 'decrypt) -> Bytes)) (define-type Long Exact-Nonnegative-Integer) diff --git a/whirlpool.rkt b/whirlpool.rkt index 222f9df..636a149 100644 --- a/whirlpool.rkt +++ b/whirlpool.rkt @@ -26,6 +26,7 @@ (require "util.rkt") (provide: [whirlpool (Bytes -> Exact-Nonnegative-Integer)]) +(: whirlpool (Bytes -> Exact-Nonnegative-Integer)) (define-type Matrix Exact-Nonnegative-Integer) @@ -66,8 +67,8 @@ (define: (make-matrix [proc : (Byte Byte -> Byte)]) : Matrix (for*/fold: ([m : Matrix 0]) - ([i : Index (in-range 0 8)] - [j : Index (in-range 0 8)]) + ([i : (U Positive-Fixnum Zero) (in-range 0 8)] + [j : (U Positive-Fixnum Zero) (in-range 0 8)]) (bitwise-ior (proc (assert i byte?) (assert j byte?)) (arithmetic-shift m 8)))) @@ -91,7 +92,7 @@ (define: (reverse-minibox [box : (Vectorof Byte)]) : (Vectorof Byte) (let: ([antibox : (Vectorof Byte) (make-vector 16 0)]) - (for: ([i : Index (in-range 0 16)]) + (for: ([i : (U Positive-Fixnum Zero) (in-range 0 16)]) (vector-set! antibox (vector-ref box i) (assert i byte?))) (vector->immutable-vector antibox))) @@ -143,7 +144,7 @@ (make-matrix (λ (i j) (for/fold: ([sum : Byte 0]) - ([k : Index (in-range 0 8)]) + ([k : (U Positive-Fixnum Zero) (in-range 0 8)]) (let ([k (assert k byte?)]) (gf2^8+ sum (gf2^8* (matrix-ref m i k) |