OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package cast5 implements CAST5, as defined in RFC 2144. CAST5 is a common | 5 // Package cast5 implements CAST5, as defined in RFC 2144. CAST5 is a common |
6 // OpenPGP cipher. | 6 // OpenPGP cipher. |
7 package cast5 | 7 package cast5 |
8 | 8 |
9 import ( | 9 import ( |
10 "os" | 10 "os" |
11 ) | 11 ) |
12 | 12 |
13 const BlockSize = 8 | 13 const BlockSize = 8 |
14 const KeySize = 16 | 14 const KeySize = 16 |
15 | 15 |
16 type Cipher struct { | 16 type Cipher struct { |
17 masking [16]uint32 | 17 masking [16]uint32 |
18 rotate [16]uint8 | 18 rotate [16]uint8 |
19 } | 19 } |
20 | 20 |
21 func NewCipher(key []byte) (c *Cipher, err os.Error) { | 21 func NewCipher(key []byte) (c *Cipher, err os.Error) { |
22 if len(key) != KeySize { | 22 if len(key) != KeySize { |
23 » » return nil, os.ErrorString("CAST5: keys must be 16 bytes") | 23 » » return nil, os.NewError("CAST5: keys must be 16 bytes") |
24 } | 24 } |
25 | 25 |
26 c = new(Cipher) | 26 c = new(Cipher) |
27 c.keySchedule(key) | 27 c.keySchedule(key) |
28 return | 28 return |
29 } | 29 } |
30 | 30 |
31 func (c *Cipher) BlockSize() int { | 31 func (c *Cipher) BlockSize() int { |
32 return BlockSize | 32 return BlockSize |
33 } | 33 } |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 0x730edebc, 0x5b643113, 0x94917e4f, 0x503c2fba, 0x646f1282, 0x75
23d24a, 0xe0779695, 0xf9c17a8f, | 527 0x730edebc, 0x5b643113, 0x94917e4f, 0x503c2fba, 0x646f1282, 0x75
23d24a, 0xe0779695, 0xf9c17a8f, |
528 0x7a5b2121, 0xd187b896, 0x29263a4d, 0xba510cdf, 0x81f47c9f, 0xad
1163ed, 0xea7b5965, 0x1a00726e, | 528 0x7a5b2121, 0xd187b896, 0x29263a4d, 0xba510cdf, 0x81f47c9f, 0xad
1163ed, 0xea7b5965, 0x1a00726e, |
529 0x11403092, 0x00da6d77, 0x4a0cdd61, 0xad1f4603, 0x605bdfb0, 0x9e
edc364, 0x22ebe6a8, 0xcee7d28a, | 529 0x11403092, 0x00da6d77, 0x4a0cdd61, 0xad1f4603, 0x605bdfb0, 0x9e
edc364, 0x22ebe6a8, 0xcee7d28a, |
530 0xa0e736a0, 0x5564a6b9, 0x10853209, 0xc7eb8f37, 0x2de705ca, 0x89
51570f, 0xdf09822b, 0xbd691a6c, | 530 0xa0e736a0, 0x5564a6b9, 0x10853209, 0xc7eb8f37, 0x2de705ca, 0x89
51570f, 0xdf09822b, 0xbd691a6c, |
531 0xaa12e4f2, 0x87451c0f, 0xe0f6a27a, 0x3ada4819, 0x4cf1764f, 0x0d
771c2b, 0x67cdb156, 0x350d8384, | 531 0xaa12e4f2, 0x87451c0f, 0xe0f6a27a, 0x3ada4819, 0x4cf1764f, 0x0d
771c2b, 0x67cdb156, 0x350d8384, |
532 0x5938fa0f, 0x42399ef3, 0x36997b07, 0x0e84093d, 0x4aa93e61, 0x83
60d87b, 0x1fa98b0c, 0x1149382c, | 532 0x5938fa0f, 0x42399ef3, 0x36997b07, 0x0e84093d, 0x4aa93e61, 0x83
60d87b, 0x1fa98b0c, 0x1149382c, |
533 0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d
2059d1, 0xa466bb1e, 0xf8da0a82, | 533 0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d
2059d1, 0xa466bb1e, 0xf8da0a82, |
534 0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xea
ee6801, 0x8db2a283, 0xea8bf59e, | 534 0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xea
ee6801, 0x8db2a283, 0xea8bf59e, |
535 }, | 535 }, |
536 } | 536 } |
OLD | NEW |