0 | module Crypto.Hash.OID
2 | import Crypto.Hash.Interfaces
30 | interface Hash algo => RegisteredHash algo where
32 | header : Vect header_n_byte Bits8
35 | der_digest_n_byte : {algo : _} -> RegisteredHash algo => Nat
36 | der_digest_n_byte = header_n_byte {algo} + digest_nbyte {algo}
39 | hashWithHeader : {algo : _} -> RegisteredHash algo => List Bits8 -> Vect (der_digest_n_byte {algo}) Bits8
40 | hashWithHeader plaintext = header {algo} ++ hash algo plaintext
43 | RegisteredHash Sha1 where
45 | header = [ 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 ]
48 | RegisteredHash Sha256 where
50 | header = [ 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 ]
53 | RegisteredHash Sha384 where
55 | header = [ 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 ]
58 | RegisteredHash Sha512 where
60 | header = [ 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 ]