LEFT | RIGHT |
(no file at all) | |
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 des implements the Data Encryption Standard (DES) and the | 5 // Package des implements the Data Encryption Standard (DES) and the |
6 // Triple Data Encryption Algorithm (TDEA) as defined | 6 // Triple Data Encryption Algorithm (TDEA) as defined |
7 // in U.S. Federal Information Processing Standards Publication 46-3. | 7 // in U.S. Federal Information Processing Standards Publication 46-3. |
8 package des | 8 package des |
9 | 9 |
10 // Used to perform an initial permutation of a 64-bit input block. | 10 // Used to perform an initial permutation of a 64-bit input block. |
(...skipping 12 matching lines...) Expand all Loading... |
23 // inverse of initialPermutation | 23 // inverse of initialPermutation |
24 var finalPermutation = [64]byte{ | 24 var finalPermutation = [64]byte{ |
25 24, 56, 16, 48, 8, 40, 0, 32, | 25 24, 56, 16, 48, 8, 40, 0, 32, |
26 25, 57, 17, 49, 9, 41, 1, 33, | 26 25, 57, 17, 49, 9, 41, 1, 33, |
27 26, 58, 18, 50, 10, 42, 2, 34, | 27 26, 58, 18, 50, 10, 42, 2, 34, |
28 27, 59, 19, 51, 11, 43, 3, 35, | 28 27, 59, 19, 51, 11, 43, 3, 35, |
29 28, 60, 20, 52, 12, 44, 4, 36, | 29 28, 60, 20, 52, 12, 44, 4, 36, |
30 29, 61, 21, 53, 13, 45, 5, 37, | 30 29, 61, 21, 53, 13, 45, 5, 37, |
31 30, 62, 22, 54, 14, 46, 6, 38, | 31 30, 62, 22, 54, 14, 46, 6, 38, |
32 31, 63, 23, 55, 15, 47, 7, 39, | 32 31, 63, 23, 55, 15, 47, 7, 39, |
33 } | |
34 | |
35 // Used to expand an input block of 32 bits, producing an output block of 48 | |
36 // bits. | |
37 var expansionFunction = [48]byte{ | |
38 0, 31, 30, 29, 28, 27, 28, 27, | |
39 26, 25, 24, 23, 24, 23, 22, 21, | |
40 20, 19, 20, 19, 18, 17, 16, 15, | |
41 16, 15, 14, 13, 12, 11, 12, 11, | |
42 10, 9, 8, 7, 8, 7, 6, 5, | |
43 4, 3, 4, 3, 2, 1, 0, 31, | |
44 } | 33 } |
45 | 34 |
46 // Yields a 32-bit output from a 32-bit input | 35 // Yields a 32-bit output from a 32-bit input |
47 var permutationFunction = [32]byte{ | 36 var permutationFunction = [32]byte{ |
48 16, 25, 12, 11, 3, 20, 4, 15, | 37 16, 25, 12, 11, 3, 20, 4, 15, |
49 31, 17, 9, 6, 27, 14, 1, 22, | 38 31, 17, 9, 6, 27, 14, 1, 22, |
50 30, 24, 8, 18, 0, 5, 29, 23, | 39 30, 24, 8, 18, 0, 5, 29, 23, |
51 13, 19, 2, 26, 10, 21, 28, 7, | 40 13, 19, 2, 26, 10, 21, 28, 7, |
52 } | 41 } |
53 | 42 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 { | 119 { |
131 {13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, | 120 {13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, |
132 {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, | 121 {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, |
133 {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, | 122 {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, |
134 {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}, | 123 {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}, |
135 }, | 124 }, |
136 } | 125 } |
137 | 126 |
138 // Size of left rotation per round in each half of the key schedule | 127 // Size of left rotation per round in each half of the key schedule |
139 var ksRotations = [16]uint8{1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1} | 128 var ksRotations = [16]uint8{1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1} |
LEFT | RIGHT |