1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Package md4 implements the MD4 hash algorithm as defined in RFC 1320.
15 crypto.RegisterHash(crypto.MD4, New)
18 // The size of an MD4 checksum in bytes.
29 // digest represents the partial evaluation of a checksum.
37 func (d *digest) Reset() {
46 // New returns a new hash.Hash computing the MD4 checksum.
47 func New() hash.Hash {
53 func (d *digest) Size() int { return Size }
55 func (d *digest) Write(p []byte) (nn int, err os.Error) {
63 for i := 0; i < n; i++ {
76 d.nx = copy(d.x[:], p)
81 func (d0 *digest) Sum() []byte {
82 // Make a copy of d0, so that caller can keep writing and summing.
86 // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
91 d.Write(tmp[0 : 56-len%64])
93 d.Write(tmp[0 : 64+56-len%64])
98 for i := uint(0); i < 8; i++ {
99 tmp[i] = byte(len >> (8 * i))
107 p := make([]byte, 16)
109 for _, s := range d.s {
110 p[j+0] = byte(s >> 0)
111 p[j+1] = byte(s >> 8)
112 p[j+2] = byte(s >> 16)
113 p[j+3] = byte(s >> 24)