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.
6 package md4 // import "golang.org/x/crypto/md4"
14 crypto.RegisterHash(crypto.MD4, New)
17 // The size of an MD4 checksum in bytes.
20 // The blocksize of MD4 in bytes.
31 // digest represents the partial evaluation of a checksum.
39 func (d *digest) Reset() {
48 // New returns a new hash.Hash computing the MD4 checksum.
49 func New() hash.Hash {
55 func (d *digest) Size() int { return Size }
57 func (d *digest) BlockSize() int { return BlockSize }
59 func (d *digest) Write(p []byte) (nn int, err error) {
67 for i := 0; i < n; i++ {
80 d.nx = copy(d.x[:], p)
85 func (d0 *digest) Sum(in []byte) []byte {
86 // Make a copy of d0, so that caller can keep writing and summing.
90 // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
95 d.Write(tmp[0 : 56-len%64])
97 d.Write(tmp[0 : 64+56-len%64])
102 for i := uint(0); i < 8; i++ {
103 tmp[i] = byte(len >> (8 * i))
111 for _, s := range d.s {
112 in = append(in, byte(s>>0))
113 in = append(in, byte(s>>8))
114 in = append(in, byte(s>>16))
115 in = append(in, byte(s>>24))