~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/crypto/md5/md5.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
const BlockSize = 64
22
22
 
23
23
const (
24
 
        _Chunk = 64
25
 
        _Init0 = 0x67452301
26
 
        _Init1 = 0xEFCDAB89
27
 
        _Init2 = 0x98BADCFE
28
 
        _Init3 = 0x10325476
 
24
        chunk = 64
 
25
        init0 = 0x67452301
 
26
        init1 = 0xEFCDAB89
 
27
        init2 = 0x98BADCFE
 
28
        init3 = 0x10325476
29
29
)
30
30
 
31
31
// digest represents the partial evaluation of a checksum.
32
32
type digest struct {
33
33
        s   [4]uint32
34
 
        x   [_Chunk]byte
 
34
        x   [chunk]byte
35
35
        nx  int
36
36
        len uint64
37
37
}
38
38
 
39
39
func (d *digest) Reset() {
40
 
        d.s[0] = _Init0
41
 
        d.s[1] = _Init1
42
 
        d.s[2] = _Init2
43
 
        d.s[3] = _Init3
 
40
        d.s[0] = init0
 
41
        d.s[1] = init1
 
42
        d.s[2] = init2
 
43
        d.s[3] = init3
44
44
        d.nx = 0
45
45
        d.len = 0
46
46
}
61
61
        d.len += uint64(nn)
62
62
        if d.nx > 0 {
63
63
                n := len(p)
64
 
                if n > _Chunk-d.nx {
65
 
                        n = _Chunk - d.nx
 
64
                if n > chunk-d.nx {
 
65
                        n = chunk - d.nx
66
66
                }
67
67
                for i := 0; i < n; i++ {
68
68
                        d.x[d.nx+i] = p[i]
69
69
                }
70
70
                d.nx += n
71
 
                if d.nx == _Chunk {
72
 
                        _Block(d, d.x[0:])
 
71
                if d.nx == chunk {
 
72
                        block(d, d.x[0:chunk])
73
73
                        d.nx = 0
74
74
                }
75
75
                p = p[n:]
76
76
        }
77
 
        n := _Block(d, p)
78
 
        p = p[n:]
 
77
        if len(p) >= chunk {
 
78
                n := len(p) &^ (chunk - 1)
 
79
                block(d, p[:n])
 
80
                p = p[n:]
 
81
        }
79
82
        if len(p) > 0 {
80
83
                d.nx = copy(d.x[:], p)
81
84
        }