| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This version has been further modified by Rich Felker, primary author | 2 * This version has been further modified by Rich Felker, primary author |
| 3 * and maintainer of musl libc, to remove table generation code and | 3 * and maintainer of musl libc, to remove table generation code and |
| 4 * replaced all runtime-generated constant tables with static-initialized | 4 * replaced all runtime-generated constant tables with static-initialized |
| 5 * tables in the binary, in the interest of minimizing non-shareable | 5 * tables in the binary, in the interest of minimizing non-shareable |
| 6 * memory usage and stack size requirements. | 6 * memory usage and stack size requirements. |
| 7 */ | 7 */ |
| 8 /* | 8 /* |
| 9 * This version is derived from the original implementation of FreeSec | 9 * This version is derived from the original implementation of FreeSec |
| 10 * (release 1.1) by David Burren. I've made it reentrant, reduced its memory | 10 * (release 1.1) by David Burren. I've made it reentrant, reduced its memory |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 40 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 40 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 47 * SUCH DAMAGE. | 47 * SUCH DAMAGE. |
| 48 * | 48 * |
| 49 *» $Owl: Owl/packages/glibc/crypt_freesec.c,v 1.6 2010/02/20 14:45:06 solar
Exp $ | 49 *» $Owl: Owl/packages/glibc/crypt_freesec.c,v 1.6 2010/02/20 14:45:06 solar |
| 50 *Exp $ |
| 50 * $Id: crypt.c,v 1.15 1994/09/13 04:58:49 davidb Exp $ | 51 * $Id: crypt.c,v 1.15 1994/09/13 04:58:49 davidb Exp $ |
| 51 * | 52 * |
| 52 * This is an original implementation of the DES and the crypt(3) interfaces | 53 * This is an original implementation of the DES and the crypt(3) interfaces |
| 53 * by David Burren. It has been heavily re-worked by Solar Designer. | 54 * by David Burren. It has been heavily re-worked by Solar Designer. |
| 54 */ | 55 */ |
| 55 | 56 |
| 56 #include <stdint.h> | 57 #include <stdint.h> |
| 57 #include <string.h> | 58 #include <string.h> |
| 58 | 59 |
| 59 struct expanded_key { | 60 struct expanded_key { |
| 60 » uint32_t l[16], r[16]; | 61 uint32_t l[16], r[16]; |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 #define _PASSWORD_EFMT1 '_' | 64 #define _PASSWORD_EFMT1 '_' |
| 64 | 65 |
| 65 static const unsigned char key_shifts[16] = { | 66 static const unsigned char key_shifts[16] = {1, 1, 2, 2, 2, 2, 2, 2, |
| 66 » 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 | 67 1, 2, 2, 2, 2, 2, 2, 1}; |
| 67 }; | |
| 68 | 68 |
| 69 static const uint32_t psbox[8][64] = { | 69 static const uint32_t psbox[8][64] = { |
| 70 { | 70 { |
| 71 0x00808200,0x00000000,0x00008000,0x00808202, | 71 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, |
| 72 0x00808002,0x00008202,0x00000002,0x00008000, | 72 0x00000002, 0x00008000, 0x00000200, 0x00808200, 0x00808202, 0x00000200, |
| 73 0x00000200,0x00808200,0x00808202,0x00000200, | 73 0x00800202, 0x00808002, 0x00800000, 0x00000002, 0x00000202, 0x00800200, |
| 74 0x00800202,0x00808002,0x00800000,0x00000002, | 74 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202, |
| 75 0x00000202,0x00800200,0x00800200,0x00008200, | 75 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, |
| 76 0x00008200,0x00808000,0x00808000,0x00800202, | 76 0x00008202, 0x00800000, 0x00008000, 0x00808202, 0x00000002, 0x00808000, |
| 77 0x00008002,0x00800002,0x00800002,0x00008002, | 77 0x00808200, 0x00800000, 0x00800000, 0x00000200, 0x00808002, 0x00008000, |
| 78 0x00000000,0x00000202,0x00008202,0x00800000, | 78 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202, |
| 79 0x00008000,0x00808202,0x00000002,0x00808000, | 79 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, |
| 80 0x00808200,0x00800000,0x00800000,0x00000200, | 80 0x00008202, 0x00808200, 0x00000202, 0x00800200, 0x00800200, 0x00000000, |
| 81 0x00808002,0x00008000,0x00008200,0x00800002, | 81 0x00008002, 0x00008200, 0x00000000, 0x00808002, |
| 82 0x00000200,0x00000002,0x00800202,0x00008202, | 82 }, |
| 83 0x00808202,0x00008002,0x00808000,0x00800202, | 83 { |
| 84 0x00800002,0x00000202,0x00008202,0x00808200, | 84 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, |
| 85 0x00000202,0x00800200,0x00800200,0x00000000, | 85 0x40080010, 0x40004010, 0x40000010, 0x40084010, 0x40084000, 0x40000000, |
| 86 0x00008002,0x00008200,0x00000000,0x00808002, | 86 0x40004000, 0x00080000, 0x00000010, 0x40080010, 0x00084000, 0x00080010, |
| 87 },{ | 87 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000, |
| 88 0x40084010,0x40004000,0x00004000,0x00084010, | 88 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, |
| 89 0x00080000,0x00000010,0x40080010,0x40004010, | 89 0x40080000, 0x00004010, 0x00000000, 0x00084010, 0x40080010, 0x00080000, |
| 90 0x40000010,0x40084010,0x40084000,0x40000000, | 90 0x40004010, 0x40080000, 0x40084000, 0x00004000, 0x40080000, 0x40004000, |
| 91 0x40004000,0x00080000,0x00000010,0x40080010, | 91 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000, |
| 92 0x00084000,0x00080010,0x40004010,0x00000000, | 92 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, |
| 93 0x40000000,0x00004000,0x00084010,0x40080000, | 93 0x40000010, 0x00080010, 0x00084000, 0x00000000, 0x40004000, 0x00004010, |
| 94 0x00080010,0x40000010,0x00000000,0x00084000, | 94 0x40000000, 0x40080010, 0x40084010, 0x00084000, |
| 95 0x00004010,0x40084000,0x40080000,0x00004010, | 95 }, |
| 96 0x00000000,0x00084010,0x40080010,0x00080000, | 96 { |
| 97 0x40004010,0x40080000,0x40084000,0x00004000, | 97 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, |
| 98 0x40080000,0x40004000,0x00000010,0x40084010, | 98 0x00010104, 0x04000100, 0x00010004, 0x04000004, 0x04000004, 0x00010000, |
| 99 0x00084010,0x00000010,0x00004000,0x40000000, | 99 0x04010104, 0x00010004, 0x04010000, 0x00000104, 0x04000000, 0x00000004, |
| 100 0x00004010,0x40084000,0x00080000,0x40000010, | 100 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104, |
| 101 0x00080010,0x40004010,0x40000010,0x00080010, | 101 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, |
| 102 0x00084000,0x00000000,0x40004000,0x00004010, | 102 0x00000100, 0x04000000, 0x04010100, 0x04000000, 0x00010004, 0x00000104, |
| 103 0x40000000,0x40080010,0x40084010,0x00084000, | 103 0x00010000, 0x04010100, 0x04000100, 0x00000000, 0x00000100, 0x00010004, |
| 104 },{ | 104 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004, |
| 105 0x00000104,0x04010100,0x00000000,0x04010004, | 105 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, |
| 106 0x04000100,0x00000000,0x00010104,0x04000100, | 106 0x00010100, 0x04000004, 0x04010000, 0x04000104, 0x00000104, 0x04010000, |
| 107 0x00010004,0x04000004,0x04000004,0x00010000, | 107 0x00010104, 0x00000004, 0x04010004, 0x00010100, |
| 108 0x04010104,0x00010004,0x04010000,0x00000104, | 108 }, |
| 109 0x04000000,0x00000004,0x04010100,0x00000100, | 109 { |
| 110 0x00010100,0x04010000,0x04010004,0x00010104, | 110 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, |
| 111 0x04000104,0x00010100,0x00010000,0x04000104, | 111 0x80400000, 0x80001000, 0x00000000, 0x00401000, 0x00401000, 0x80401040, |
| 112 0x00000004,0x04010104,0x00000100,0x04000000, | 112 0x80000040, 0x00000000, 0x00400040, 0x80400000, 0x80000000, 0x00001000, |
| 113 0x04010100,0x04000000,0x00010004,0x00000104, | 113 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040, |
| 114 0x00010000,0x04010100,0x04000100,0x00000000, | 114 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, |
| 115 0x00000100,0x00010004,0x04010104,0x04000100, | 115 0x80401040, 0x80000040, 0x00400040, 0x80400000, 0x00401000, 0x80401040, |
| 116 0x04000004,0x00000100,0x00000000,0x04010004, | 116 0x80000040, 0x00000000, 0x00000000, 0x00401000, 0x00001040, 0x00400040, |
| 117 0x04000104,0x00010000,0x04000000,0x04010104, | 117 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040, |
| 118 0x00000004,0x00010104,0x00010100,0x04000004, | 118 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, |
| 119 0x04010000,0x04000104,0x00000104,0x04010000, | 119 0x00401040, 0x80400040, 0x80001000, 0x00001040, 0x00400000, 0x80401000, |
| 120 0x00010104,0x00000004,0x04010004,0x00010100, | 120 0x00000040, 0x00400000, 0x00001000, 0x00401040, |
| 121 },{ | 121 }, |
| 122 0x80401000,0x80001040,0x80001040,0x00000040, | 122 { |
| 123 0x00401040,0x80400040,0x80400000,0x80001000, | 123 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, |
| 124 0x00000000,0x00401000,0x00401000,0x80401040, | 124 0x20000000, 0x01040000, 0x20040080, 0x00040000, 0x01000080, 0x20040080, |
| 125 0x80000040,0x00000000,0x00400040,0x80400000, | 125 0x21000080, 0x21040000, 0x00040080, 0x20000000, 0x01000000, 0x20040000, |
| 126 0x80000000,0x00001000,0x00400000,0x80401000, | 126 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080, |
| 127 0x00000040,0x00400000,0x80001000,0x00001040, | 127 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, |
| 128 0x80400040,0x80000000,0x00001040,0x00400040, | 128 0x21000000, 0x00040080, 0x00040000, 0x21000080, 0x00000080, 0x01000000, |
| 129 0x00001000,0x00401040,0x80401040,0x80000040, | 129 0x20000000, 0x01040000, 0x21000080, 0x20040080, 0x01000080, 0x20000000, |
| 130 0x00400040,0x80400000,0x00401000,0x80401040, | 130 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000, |
| 131 0x80000040,0x00000000,0x00000000,0x00401000, | 131 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, |
| 132 0x00001040,0x00400040,0x80400040,0x80000000, | 132 0x20040000, 0x21000000, 0x00040080, 0x01000080, 0x20000080, 0x00040000, |
| 133 0x80401000,0x80001040,0x80001040,0x00000040, | 133 0x00000000, 0x20040000, 0x01040080, 0x20000080, |
| 134 0x80401040,0x80000040,0x80000000,0x00001000, | 134 }, |
| 135 0x80400000,0x80001000,0x00401040,0x80400040, | 135 { |
| 136 0x80001000,0x00001040,0x00400000,0x80401000, | 136 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, |
| 137 0x00000040,0x00400000,0x00001000,0x00401040, | 137 0x10202008, 0x00200000, 0x10002000, 0x00202008, 0x00200000, 0x10000008, |
| 138 },{ | 138 0x00200008, 0x10002000, 0x10000000, 0x00002008, 0x00000000, 0x00200008, |
| 139 0x00000080,0x01040080,0x01040000,0x21000080, | 139 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008, |
| 140 0x00040000,0x00000080,0x20000000,0x01040000, | 140 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, |
| 141 0x20040080,0x00040000,0x01000080,0x20040080, | 141 0x10202000, 0x10000000, 0x10002000, 0x00000008, 0x10200008, 0x00202000, |
| 142 0x21000080,0x21040000,0x00040080,0x20000000, | 142 0x10202008, 0x00200000, 0x00002008, 0x10000008, 0x00200000, 0x10002000, |
| 143 0x01000000,0x20040000,0x20040000,0x00000000, | 143 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000, |
| 144 0x20000080,0x21040080,0x21040080,0x01000080, | 144 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, |
| 145 0x21040000,0x20000080,0x00000000,0x21000000, | 145 0x10200000, 0x00202008, 0x00002000, 0x00200008, 0x10002008, 0x00000000, |
| 146 0x01040080,0x01000000,0x21000000,0x00040080, | 146 0x10202000, 0x10000000, 0x00200008, 0x10002008, |
| 147 0x00040000,0x21000080,0x00000080,0x01000000, | 147 }, |
| 148 0x20000000,0x01040000,0x21000080,0x20040080, | 148 { |
| 149 0x01000080,0x20000000,0x21040000,0x01040080, | 149 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, |
| 150 0x20040080,0x00000080,0x01000000,0x21040000, | 150 0x00100401, 0x02100400, 0x02100401, 0x00100000, 0x00000000, 0x02000001, |
| 151 0x21040080,0x00040080,0x21000000,0x21040080, | 151 0x00000001, 0x02000000, 0x02100001, 0x00000401, 0x02000400, 0x00100401, |
| 152 0x01040000,0x00000000,0x20040000,0x21000000, | 152 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001, |
| 153 0x00040080,0x01000080,0x20000080,0x00040000, | 153 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, |
| 154 0x00000000,0x20040000,0x01040080,0x20000080, | 154 0x02000000, 0x00100400, 0x02000000, 0x00100400, 0x00100000, 0x02000401, |
| 155 },{ | 155 0x02000401, 0x02100001, 0x02100001, 0x00000001, 0x00100001, 0x02000000, |
| 156 0x10000008,0x10200000,0x00002000,0x10202008, | 156 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400, |
| 157 0x10200000,0x00000008,0x10202008,0x00200000, | 157 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, |
| 158 0x10002000,0x00202008,0x00200000,0x10000008, | 158 0x00000001, 0x02100401, 0x00000000, 0x00100401, 0x02100000, 0x00000400, |
| 159 0x00200008,0x10002000,0x10000000,0x00002008, | 159 0x02000001, 0x02000400, 0x00000400, 0x00100001, |
| 160 0x00000000,0x00200008,0x10002008,0x00002000, | 160 }, |
| 161 0x00202000,0x10002008,0x00000008,0x10200008, | 161 { |
| 162 0x10200008,0x00000000,0x00202008,0x10202000, | 162 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, |
| 163 0x00002008,0x00202000,0x10202000,0x10000000, | 163 0x00000020, 0x08000000, 0x00020020, 0x08020000, 0x08020820, 0x00020800, |
| 164 0x10002000,0x00000008,0x10200008,0x00202000, | 164 0x08020800, 0x00020820, 0x00000800, 0x00000020, 0x08020000, 0x08000020, |
| 165 0x10202008,0x00200000,0x00002008,0x10000008, | 165 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800, |
| 166 0x00200000,0x10002000,0x10000000,0x00002008, | 166 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, |
| 167 0x10000008,0x10202008,0x00202000,0x10200000, | 167 0x00020820, 0x00020000, 0x00020820, 0x00020000, 0x08020800, 0x00000800, |
| 168 0x00202008,0x10202000,0x00000000,0x10200008, | 168 0x00000020, 0x08020020, 0x00000800, 0x00020820, 0x08000800, 0x00000020, |
| 169 0x00000008,0x00002000,0x10200000,0x00202008, | 169 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820, |
| 170 0x00002000,0x00200008,0x10002008,0x00000000, | 170 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, |
| 171 0x10202000,0x10000000,0x00200008,0x10002008, | 171 0x08000820, 0x00000000, 0x08020820, 0x00020800, 0x00020800, 0x00000820, |
| 172 },{ | 172 0x00000820, 0x00020020, 0x08000000, 0x08020800, |
| 173 0x00100000,0x02100001,0x02000401,0x00000000, | 173 }, |
| 174 0x00000400,0x02000401,0x00100401,0x02100400, | |
| 175 0x02100401,0x00100000,0x00000000,0x02000001, | |
| 176 0x00000001,0x02000000,0x02100001,0x00000401, | |
| 177 0x02000400,0x00100401,0x00100001,0x02000400, | |
| 178 0x02000001,0x02100000,0x02100400,0x00100001, | |
| 179 0x02100000,0x00000400,0x00000401,0x02100401, | |
| 180 0x00100400,0x00000001,0x02000000,0x00100400, | |
| 181 0x02000000,0x00100400,0x00100000,0x02000401, | |
| 182 0x02000401,0x02100001,0x02100001,0x00000001, | |
| 183 0x00100001,0x02000000,0x02000400,0x00100000, | |
| 184 0x02100400,0x00000401,0x00100401,0x02100400, | |
| 185 0x00000401,0x02000001,0x02100401,0x02100000, | |
| 186 0x00100400,0x00000000,0x00000001,0x02100401, | |
| 187 0x00000000,0x00100401,0x02100000,0x00000400, | |
| 188 0x02000001,0x02000400,0x00000400,0x00100001, | |
| 189 },{ | |
| 190 0x08000820,0x00000800,0x00020000,0x08020820, | |
| 191 0x08000000,0x08000820,0x00000020,0x08000000, | |
| 192 0x00020020,0x08020000,0x08020820,0x00020800, | |
| 193 0x08020800,0x00020820,0x00000800,0x00000020, | |
| 194 0x08020000,0x08000020,0x08000800,0x00000820, | |
| 195 0x00020800,0x00020020,0x08020020,0x08020800, | |
| 196 0x00000820,0x00000000,0x00000000,0x08020020, | |
| 197 0x08000020,0x08000800,0x00020820,0x00020000, | |
| 198 0x00020820,0x00020000,0x08020800,0x00000800, | |
| 199 0x00000020,0x08020020,0x00000800,0x00020820, | |
| 200 0x08000800,0x00000020,0x08000020,0x08020000, | |
| 201 0x08020020,0x08000000,0x00020000,0x08000820, | |
| 202 0x00000000,0x08020820,0x00020020,0x08000020, | |
| 203 0x08020000,0x08000800,0x08000820,0x00000000, | |
| 204 0x08020820,0x00020800,0x00020800,0x00000820, | |
| 205 0x00000820,0x00020020,0x08000000,0x08020800, | |
| 206 }, | |
| 207 }; | 174 }; |
| 208 static const uint32_t ip_maskl[16][16] = { | 175 static const uint32_t ip_maskl[16][16] = { |
| 209 » { | 176 { |
| 210 » » 0x00000000,0x00010000,0x00000000,0x00010000, | 177 0x00000000, 0x00010000, 0x00000000, 0x00010000, 0x01000000, 0x01010000, |
| 211 » » 0x01000000,0x01010000,0x01000000,0x01010000, | 178 0x01000000, 0x01010000, 0x00000000, 0x00010000, 0x00000000, 0x00010000, |
| 212 » » 0x00000000,0x00010000,0x00000000,0x00010000, | 179 0x01000000, 0x01010000, 0x01000000, 0x01010000, |
| 213 » » 0x01000000,0x01010000,0x01000000,0x01010000, | 180 }, |
| 214 » },{ | 181 { |
| 215 » » 0x00000000,0x00000001,0x00000000,0x00000001, | 182 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000100, 0x00000101, |
| 216 » » 0x00000100,0x00000101,0x00000100,0x00000101, | 183 0x00000100, 0x00000101, 0x00000000, 0x00000001, 0x00000000, 0x00000001, |
| 217 » » 0x00000000,0x00000001,0x00000000,0x00000001, | 184 0x00000100, 0x00000101, 0x00000100, 0x00000101, |
| 218 » » 0x00000100,0x00000101,0x00000100,0x00000101, | 185 }, |
| 219 » },{ | 186 { |
| 220 » » 0x00000000,0x00020000,0x00000000,0x00020000, | 187 0x00000000, 0x00020000, 0x00000000, 0x00020000, 0x02000000, 0x02020000, |
| 221 » » 0x02000000,0x02020000,0x02000000,0x02020000, | 188 0x02000000, 0x02020000, 0x00000000, 0x00020000, 0x00000000, 0x00020000, |
| 222 » » 0x00000000,0x00020000,0x00000000,0x00020000, | 189 0x02000000, 0x02020000, 0x02000000, 0x02020000, |
| 223 » » 0x02000000,0x02020000,0x02000000,0x02020000, | 190 }, |
| 224 » },{ | 191 { |
| 225 » » 0x00000000,0x00000002,0x00000000,0x00000002, | 192 0x00000000, 0x00000002, 0x00000000, 0x00000002, 0x00000200, 0x00000202, |
| 226 » » 0x00000200,0x00000202,0x00000200,0x00000202, | 193 0x00000200, 0x00000202, 0x00000000, 0x00000002, 0x00000000, 0x00000002, |
| 227 » » 0x00000000,0x00000002,0x00000000,0x00000002, | 194 0x00000200, 0x00000202, 0x00000200, 0x00000202, |
| 228 » » 0x00000200,0x00000202,0x00000200,0x00000202, | 195 }, |
| 229 » },{ | 196 { |
| 230 » » 0x00000000,0x00040000,0x00000000,0x00040000, | 197 0x00000000, 0x00040000, 0x00000000, 0x00040000, 0x04000000, 0x04040000, |
| 231 » » 0x04000000,0x04040000,0x04000000,0x04040000, | 198 0x04000000, 0x04040000, 0x00000000, 0x00040000, 0x00000000, 0x00040000, |
| 232 » » 0x00000000,0x00040000,0x00000000,0x00040000, | 199 0x04000000, 0x04040000, 0x04000000, 0x04040000, |
| 233 » » 0x04000000,0x04040000,0x04000000,0x04040000, | 200 }, |
| 234 » },{ | 201 { |
| 235 » » 0x00000000,0x00000004,0x00000000,0x00000004, | 202 0x00000000, 0x00000004, 0x00000000, 0x00000004, 0x00000400, 0x00000404, |
| 236 » » 0x00000400,0x00000404,0x00000400,0x00000404, | 203 0x00000400, 0x00000404, 0x00000000, 0x00000004, 0x00000000, 0x00000004, |
| 237 » » 0x00000000,0x00000004,0x00000000,0x00000004, | 204 0x00000400, 0x00000404, 0x00000400, 0x00000404, |
| 238 » » 0x00000400,0x00000404,0x00000400,0x00000404, | 205 }, |
| 239 » },{ | 206 { |
| 240 » » 0x00000000,0x00080000,0x00000000,0x00080000, | 207 0x00000000, 0x00080000, 0x00000000, 0x00080000, 0x08000000, 0x08080000, |
| 241 » » 0x08000000,0x08080000,0x08000000,0x08080000, | 208 0x08000000, 0x08080000, 0x00000000, 0x00080000, 0x00000000, 0x00080000, |
| 242 » » 0x00000000,0x00080000,0x00000000,0x00080000, | 209 0x08000000, 0x08080000, 0x08000000, 0x08080000, |
| 243 » » 0x08000000,0x08080000,0x08000000,0x08080000, | 210 }, |
| 244 » },{ | 211 { |
| 245 » » 0x00000000,0x00000008,0x00000000,0x00000008, | 212 0x00000000, 0x00000008, 0x00000000, 0x00000008, 0x00000800, 0x00000808, |
| 246 » » 0x00000800,0x00000808,0x00000800,0x00000808, | 213 0x00000800, 0x00000808, 0x00000000, 0x00000008, 0x00000000, 0x00000008, |
| 247 » » 0x00000000,0x00000008,0x00000000,0x00000008, | 214 0x00000800, 0x00000808, 0x00000800, 0x00000808, |
| 248 » » 0x00000800,0x00000808,0x00000800,0x00000808, | 215 }, |
| 249 » },{ | 216 { |
| 250 » » 0x00000000,0x00100000,0x00000000,0x00100000, | 217 0x00000000, 0x00100000, 0x00000000, 0x00100000, 0x10000000, 0x10100000, |
| 251 » » 0x10000000,0x10100000,0x10000000,0x10100000, | 218 0x10000000, 0x10100000, 0x00000000, 0x00100000, 0x00000000, 0x00100000, |
| 252 » » 0x00000000,0x00100000,0x00000000,0x00100000, | 219 0x10000000, 0x10100000, 0x10000000, 0x10100000, |
| 253 » » 0x10000000,0x10100000,0x10000000,0x10100000, | 220 }, |
| 254 » },{ | 221 { |
| 255 » » 0x00000000,0x00000010,0x00000000,0x00000010, | 222 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00001000, 0x00001010, |
| 256 » » 0x00001000,0x00001010,0x00001000,0x00001010, | 223 0x00001000, 0x00001010, 0x00000000, 0x00000010, 0x00000000, 0x00000010, |
| 257 » » 0x00000000,0x00000010,0x00000000,0x00000010, | 224 0x00001000, 0x00001010, 0x00001000, 0x00001010, |
| 258 » » 0x00001000,0x00001010,0x00001000,0x00001010, | 225 }, |
| 259 » },{ | 226 { |
| 260 » » 0x00000000,0x00200000,0x00000000,0x00200000, | 227 0x00000000, 0x00200000, 0x00000000, 0x00200000, 0x20000000, 0x20200000, |
| 261 » » 0x20000000,0x20200000,0x20000000,0x20200000, | 228 0x20000000, 0x20200000, 0x00000000, 0x00200000, 0x00000000, 0x00200000, |
| 262 » » 0x00000000,0x00200000,0x00000000,0x00200000, | 229 0x20000000, 0x20200000, 0x20000000, 0x20200000, |
| 263 » » 0x20000000,0x20200000,0x20000000,0x20200000, | 230 }, |
| 264 » },{ | 231 { |
| 265 » » 0x00000000,0x00000020,0x00000000,0x00000020, | 232 0x00000000, 0x00000020, 0x00000000, 0x00000020, 0x00002000, 0x00002020, |
| 266 » » 0x00002000,0x00002020,0x00002000,0x00002020, | 233 0x00002000, 0x00002020, 0x00000000, 0x00000020, 0x00000000, 0x00000020, |
| 267 » » 0x00000000,0x00000020,0x00000000,0x00000020, | 234 0x00002000, 0x00002020, 0x00002000, 0x00002020, |
| 268 » » 0x00002000,0x00002020,0x00002000,0x00002020, | 235 }, |
| 269 » },{ | 236 { |
| 270 » » 0x00000000,0x00400000,0x00000000,0x00400000, | 237 0x00000000, 0x00400000, 0x00000000, 0x00400000, 0x40000000, 0x40400000, |
| 271 » » 0x40000000,0x40400000,0x40000000,0x40400000, | 238 0x40000000, 0x40400000, 0x00000000, 0x00400000, 0x00000000, 0x00400000, |
| 272 » » 0x00000000,0x00400000,0x00000000,0x00400000, | 239 0x40000000, 0x40400000, 0x40000000, 0x40400000, |
| 273 » » 0x40000000,0x40400000,0x40000000,0x40400000, | 240 }, |
| 274 » },{ | 241 { |
| 275 » » 0x00000000,0x00000040,0x00000000,0x00000040, | 242 0x00000000, 0x00000040, 0x00000000, 0x00000040, 0x00004000, 0x00004040, |
| 276 » » 0x00004000,0x00004040,0x00004000,0x00004040, | 243 0x00004000, 0x00004040, 0x00000000, 0x00000040, 0x00000000, 0x00000040, |
| 277 » » 0x00000000,0x00000040,0x00000000,0x00000040, | 244 0x00004000, 0x00004040, 0x00004000, 0x00004040, |
| 278 » » 0x00004000,0x00004040,0x00004000,0x00004040, | 245 }, |
| 279 » },{ | 246 { |
| 280 » » 0x00000000,0x00800000,0x00000000,0x00800000, | 247 0x00000000, 0x00800000, 0x00000000, 0x00800000, 0x80000000, 0x80800000, |
| 281 » » 0x80000000,0x80800000,0x80000000,0x80800000, | 248 0x80000000, 0x80800000, 0x00000000, 0x00800000, 0x00000000, 0x00800000, |
| 282 » » 0x00000000,0x00800000,0x00000000,0x00800000, | 249 0x80000000, 0x80800000, 0x80000000, 0x80800000, |
| 283 » » 0x80000000,0x80800000,0x80000000,0x80800000, | 250 }, |
| 284 » },{ | 251 { |
| 285 » » 0x00000000,0x00000080,0x00000000,0x00000080, | 252 0x00000000, 0x00000080, 0x00000000, 0x00000080, 0x00008000, 0x00008080, |
| 286 » » 0x00008000,0x00008080,0x00008000,0x00008080, | 253 0x00008000, 0x00008080, 0x00000000, 0x00000080, 0x00000000, 0x00000080, |
| 287 » » 0x00000000,0x00000080,0x00000000,0x00000080, | 254 0x00008000, 0x00008080, 0x00008000, 0x00008080, |
| 288 » » 0x00008000,0x00008080,0x00008000,0x00008080, | 255 }, |
| 289 » }, | |
| 290 }; | 256 }; |
| 291 static const uint32_t ip_maskr[16][16] = { | 257 static const uint32_t ip_maskr[16][16] = { |
| 292 » { | 258 { |
| 293 » » 0x00000000,0x00000000,0x00010000,0x00010000, | 259 0x00000000, 0x00000000, 0x00010000, 0x00010000, 0x00000000, 0x00000000, |
| 294 » » 0x00000000,0x00000000,0x00010000,0x00010000, | 260 0x00010000, 0x00010000, 0x01000000, 0x01000000, 0x01010000, 0x01010000, |
| 295 » » 0x01000000,0x01000000,0x01010000,0x01010000, | 261 0x01000000, 0x01000000, 0x01010000, 0x01010000, |
| 296 » » 0x01000000,0x01000000,0x01010000,0x01010000, | 262 }, |
| 297 » },{ | 263 { |
| 298 » » 0x00000000,0x00000000,0x00000001,0x00000001, | 264 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000000, |
| 299 » » 0x00000000,0x00000000,0x00000001,0x00000001, | 265 0x00000001, 0x00000001, 0x00000100, 0x00000100, 0x00000101, 0x00000101, |
| 300 » » 0x00000100,0x00000100,0x00000101,0x00000101, | 266 0x00000100, 0x00000100, 0x00000101, 0x00000101, |
| 301 » » 0x00000100,0x00000100,0x00000101,0x00000101, | 267 }, |
| 302 » },{ | 268 { |
| 303 » » 0x00000000,0x00000000,0x00020000,0x00020000, | 269 0x00000000, 0x00000000, 0x00020000, 0x00020000, 0x00000000, 0x00000000, |
| 304 » » 0x00000000,0x00000000,0x00020000,0x00020000, | 270 0x00020000, 0x00020000, 0x02000000, 0x02000000, 0x02020000, 0x02020000, |
| 305 » » 0x02000000,0x02000000,0x02020000,0x02020000, | 271 0x02000000, 0x02000000, 0x02020000, 0x02020000, |
| 306 » » 0x02000000,0x02000000,0x02020000,0x02020000, | 272 }, |
| 307 » },{ | 273 { |
| 308 » » 0x00000000,0x00000000,0x00000002,0x00000002, | 274 0x00000000, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000000, |
| 309 » » 0x00000000,0x00000000,0x00000002,0x00000002, | 275 0x00000002, 0x00000002, 0x00000200, 0x00000200, 0x00000202, 0x00000202, |
| 310 » » 0x00000200,0x00000200,0x00000202,0x00000202, | 276 0x00000200, 0x00000200, 0x00000202, 0x00000202, |
| 311 » » 0x00000200,0x00000200,0x00000202,0x00000202, | 277 }, |
| 312 » },{ | 278 { |
| 313 » » 0x00000000,0x00000000,0x00040000,0x00040000, | 279 0x00000000, 0x00000000, 0x00040000, 0x00040000, 0x00000000, 0x00000000, |
| 314 » » 0x00000000,0x00000000,0x00040000,0x00040000, | 280 0x00040000, 0x00040000, 0x04000000, 0x04000000, 0x04040000, 0x04040000, |
| 315 » » 0x04000000,0x04000000,0x04040000,0x04040000, | 281 0x04000000, 0x04000000, 0x04040000, 0x04040000, |
| 316 » » 0x04000000,0x04000000,0x04040000,0x04040000, | 282 }, |
| 317 » },{ | 283 { |
| 318 » » 0x00000000,0x00000000,0x00000004,0x00000004, | 284 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000000, 0x00000000, |
| 319 » » 0x00000000,0x00000000,0x00000004,0x00000004, | 285 0x00000004, 0x00000004, 0x00000400, 0x00000400, 0x00000404, 0x00000404, |
| 320 » » 0x00000400,0x00000400,0x00000404,0x00000404, | 286 0x00000400, 0x00000400, 0x00000404, 0x00000404, |
| 321 » » 0x00000400,0x00000400,0x00000404,0x00000404, | 287 }, |
| 322 » },{ | 288 { |
| 323 » » 0x00000000,0x00000000,0x00080000,0x00080000, | 289 0x00000000, 0x00000000, 0x00080000, 0x00080000, 0x00000000, 0x00000000, |
| 324 » » 0x00000000,0x00000000,0x00080000,0x00080000, | 290 0x00080000, 0x00080000, 0x08000000, 0x08000000, 0x08080000, 0x08080000, |
| 325 » » 0x08000000,0x08000000,0x08080000,0x08080000, | 291 0x08000000, 0x08000000, 0x08080000, 0x08080000, |
| 326 » » 0x08000000,0x08000000,0x08080000,0x08080000, | 292 }, |
| 327 » },{ | 293 { |
| 328 » » 0x00000000,0x00000000,0x00000008,0x00000008, | 294 0x00000000, 0x00000000, 0x00000008, 0x00000008, 0x00000000, 0x00000000, |
| 329 » » 0x00000000,0x00000000,0x00000008,0x00000008, | 295 0x00000008, 0x00000008, 0x00000800, 0x00000800, 0x00000808, 0x00000808, |
| 330 » » 0x00000800,0x00000800,0x00000808,0x00000808, | 296 0x00000800, 0x00000800, 0x00000808, 0x00000808, |
| 331 » » 0x00000800,0x00000800,0x00000808,0x00000808, | 297 }, |
| 332 » },{ | 298 { |
| 333 » » 0x00000000,0x00000000,0x00100000,0x00100000, | 299 0x00000000, 0x00000000, 0x00100000, 0x00100000, 0x00000000, 0x00000000, |
| 334 » » 0x00000000,0x00000000,0x00100000,0x00100000, | 300 0x00100000, 0x00100000, 0x10000000, 0x10000000, 0x10100000, 0x10100000, |
| 335 » » 0x10000000,0x10000000,0x10100000,0x10100000, | 301 0x10000000, 0x10000000, 0x10100000, 0x10100000, |
| 336 » » 0x10000000,0x10000000,0x10100000,0x10100000, | 302 }, |
| 337 » },{ | 303 { |
| 338 » » 0x00000000,0x00000000,0x00000010,0x00000010, | 304 0x00000000, 0x00000000, 0x00000010, 0x00000010, 0x00000000, 0x00000000, |
| 339 » » 0x00000000,0x00000000,0x00000010,0x00000010, | 305 0x00000010, 0x00000010, 0x00001000, 0x00001000, 0x00001010, 0x00001010, |
| 340 » » 0x00001000,0x00001000,0x00001010,0x00001010, | 306 0x00001000, 0x00001000, 0x00001010, 0x00001010, |
| 341 » » 0x00001000,0x00001000,0x00001010,0x00001010, | 307 }, |
| 342 » },{ | 308 { |
| 343 » » 0x00000000,0x00000000,0x00200000,0x00200000, | 309 0x00000000, 0x00000000, 0x00200000, 0x00200000, 0x00000000, 0x00000000, |
| 344 » » 0x00000000,0x00000000,0x00200000,0x00200000, | 310 0x00200000, 0x00200000, 0x20000000, 0x20000000, 0x20200000, 0x20200000, |
| 345 » » 0x20000000,0x20000000,0x20200000,0x20200000, | 311 0x20000000, 0x20000000, 0x20200000, 0x20200000, |
| 346 » » 0x20000000,0x20000000,0x20200000,0x20200000, | 312 }, |
| 347 » },{ | 313 { |
| 348 » » 0x00000000,0x00000000,0x00000020,0x00000020, | 314 0x00000000, 0x00000000, 0x00000020, 0x00000020, 0x00000000, 0x00000000, |
| 349 » » 0x00000000,0x00000000,0x00000020,0x00000020, | 315 0x00000020, 0x00000020, 0x00002000, 0x00002000, 0x00002020, 0x00002020, |
| 350 » » 0x00002000,0x00002000,0x00002020,0x00002020, | 316 0x00002000, 0x00002000, 0x00002020, 0x00002020, |
| 351 » » 0x00002000,0x00002000,0x00002020,0x00002020, | 317 }, |
| 352 » },{ | 318 { |
| 353 » » 0x00000000,0x00000000,0x00400000,0x00400000, | 319 0x00000000, 0x00000000, 0x00400000, 0x00400000, 0x00000000, 0x00000000, |
| 354 » » 0x00000000,0x00000000,0x00400000,0x00400000, | 320 0x00400000, 0x00400000, 0x40000000, 0x40000000, 0x40400000, 0x40400000, |
| 355 » » 0x40000000,0x40000000,0x40400000,0x40400000, | 321 0x40000000, 0x40000000, 0x40400000, 0x40400000, |
| 356 » » 0x40000000,0x40000000,0x40400000,0x40400000, | 322 }, |
| 357 » },{ | 323 { |
| 358 » » 0x00000000,0x00000000,0x00000040,0x00000040, | 324 0x00000000, 0x00000000, 0x00000040, 0x00000040, 0x00000000, 0x00000000, |
| 359 » » 0x00000000,0x00000000,0x00000040,0x00000040, | 325 0x00000040, 0x00000040, 0x00004000, 0x00004000, 0x00004040, 0x00004040, |
| 360 » » 0x00004000,0x00004000,0x00004040,0x00004040, | 326 0x00004000, 0x00004000, 0x00004040, 0x00004040, |
| 361 » » 0x00004000,0x00004000,0x00004040,0x00004040, | 327 }, |
| 362 » },{ | 328 { |
| 363 » » 0x00000000,0x00000000,0x00800000,0x00800000, | 329 0x00000000, 0x00000000, 0x00800000, 0x00800000, 0x00000000, 0x00000000, |
| 364 » » 0x00000000,0x00000000,0x00800000,0x00800000, | 330 0x00800000, 0x00800000, 0x80000000, 0x80000000, 0x80800000, 0x80800000, |
| 365 » » 0x80000000,0x80000000,0x80800000,0x80800000, | 331 0x80000000, 0x80000000, 0x80800000, 0x80800000, |
| 366 » » 0x80000000,0x80000000,0x80800000,0x80800000, | 332 }, |
| 367 » },{ | 333 { |
| 368 » » 0x00000000,0x00000000,0x00000080,0x00000080, | 334 0x00000000, 0x00000000, 0x00000080, 0x00000080, 0x00000000, 0x00000000, |
| 369 » » 0x00000000,0x00000000,0x00000080,0x00000080, | 335 0x00000080, 0x00000080, 0x00008000, 0x00008000, 0x00008080, 0x00008080, |
| 370 » » 0x00008000,0x00008000,0x00008080,0x00008080, | 336 0x00008000, 0x00008000, 0x00008080, 0x00008080, |
| 371 » » 0x00008000,0x00008000,0x00008080,0x00008080, | 337 }, |
| 372 » }, | |
| 373 }; | 338 }; |
| 374 static const uint32_t fp_maskl[8][16] = { | 339 static const uint32_t fp_maskl[8][16] = { |
| 375 » { | 340 { |
| 376 » » 0x00000000,0x40000000,0x00400000,0x40400000, | 341 0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00004000, 0x40004000, |
| 377 » » 0x00004000,0x40004000,0x00404000,0x40404000, | 342 0x00404000, 0x40404000, 0x00000040, 0x40000040, 0x00400040, 0x40400040, |
| 378 » » 0x00000040,0x40000040,0x00400040,0x40400040, | 343 0x00004040, 0x40004040, 0x00404040, 0x40404040, |
| 379 » » 0x00004040,0x40004040,0x00404040,0x40404040, | 344 }, |
| 380 » },{ | 345 { |
| 381 » » 0x00000000,0x10000000,0x00100000,0x10100000, | 346 0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00001000, 0x10001000, |
| 382 » » 0x00001000,0x10001000,0x00101000,0x10101000, | 347 0x00101000, 0x10101000, 0x00000010, 0x10000010, 0x00100010, 0x10100010, |
| 383 » » 0x00000010,0x10000010,0x00100010,0x10100010, | 348 0x00001010, 0x10001010, 0x00101010, 0x10101010, |
| 384 » » 0x00001010,0x10001010,0x00101010,0x10101010, | 349 }, |
| 385 » },{ | 350 { |
| 386 » » 0x00000000,0x04000000,0x00040000,0x04040000, | 351 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000400, 0x04000400, |
| 387 » » 0x00000400,0x04000400,0x00040400,0x04040400, | 352 0x00040400, 0x04040400, 0x00000004, 0x04000004, 0x00040004, 0x04040004, |
| 388 » » 0x00000004,0x04000004,0x00040004,0x04040004, | 353 0x00000404, 0x04000404, 0x00040404, 0x04040404, |
| 389 » » 0x00000404,0x04000404,0x00040404,0x04040404, | 354 }, |
| 390 » },{ | 355 { |
| 391 » » 0x00000000,0x01000000,0x00010000,0x01010000, | 356 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, |
| 392 » » 0x00000100,0x01000100,0x00010100,0x01010100, | 357 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, |
| 393 » » 0x00000001,0x01000001,0x00010001,0x01010001, | 358 0x00000101, 0x01000101, 0x00010101, 0x01010101, |
| 394 » » 0x00000101,0x01000101,0x00010101,0x01010101, | 359 }, |
| 395 » },{ | 360 { |
| 396 » » 0x00000000,0x80000000,0x00800000,0x80800000, | 361 0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00008000, 0x80008000, |
| 397 » » 0x00008000,0x80008000,0x00808000,0x80808000, | 362 0x00808000, 0x80808000, 0x00000080, 0x80000080, 0x00800080, 0x80800080, |
| 398 » » 0x00000080,0x80000080,0x00800080,0x80800080, | 363 0x00008080, 0x80008080, 0x00808080, 0x80808080, |
| 399 » » 0x00008080,0x80008080,0x00808080,0x80808080, | 364 }, |
| 400 » },{ | 365 { |
| 401 » » 0x00000000,0x20000000,0x00200000,0x20200000, | 366 0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00002000, 0x20002000, |
| 402 » » 0x00002000,0x20002000,0x00202000,0x20202000, | 367 0x00202000, 0x20202000, 0x00000020, 0x20000020, 0x00200020, 0x20200020, |
| 403 » » 0x00000020,0x20000020,0x00200020,0x20200020, | 368 0x00002020, 0x20002020, 0x00202020, 0x20202020, |
| 404 » » 0x00002020,0x20002020,0x00202020,0x20202020, | 369 }, |
| 405 » },{ | 370 { |
| 406 » » 0x00000000,0x08000000,0x00080000,0x08080000, | 371 0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00000800, 0x08000800, |
| 407 » » 0x00000800,0x08000800,0x00080800,0x08080800, | 372 0x00080800, 0x08080800, 0x00000008, 0x08000008, 0x00080008, 0x08080008, |
| 408 » » 0x00000008,0x08000008,0x00080008,0x08080008, | 373 0x00000808, 0x08000808, 0x00080808, 0x08080808, |
| 409 » » 0x00000808,0x08000808,0x00080808,0x08080808, | 374 }, |
| 410 » },{ | 375 { |
| 411 » » 0x00000000,0x02000000,0x00020000,0x02020000, | 376 0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00000200, 0x02000200, |
| 412 » » 0x00000200,0x02000200,0x00020200,0x02020200, | 377 0x00020200, 0x02020200, 0x00000002, 0x02000002, 0x00020002, 0x02020002, |
| 413 » » 0x00000002,0x02000002,0x00020002,0x02020002, | 378 0x00000202, 0x02000202, 0x00020202, 0x02020202, |
| 414 » » 0x00000202,0x02000202,0x00020202,0x02020202, | 379 }, |
| 415 » }, | |
| 416 }; | 380 }; |
| 417 static const uint32_t fp_maskr[8][16] = { | 381 static const uint32_t fp_maskr[8][16] = { |
| 418 » { | 382 { |
| 419 » » 0x00000000,0x40000000,0x00400000,0x40400000, | 383 0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00004000, 0x40004000, |
| 420 » » 0x00004000,0x40004000,0x00404000,0x40404000, | 384 0x00404000, 0x40404000, 0x00000040, 0x40000040, 0x00400040, 0x40400040, |
| 421 » » 0x00000040,0x40000040,0x00400040,0x40400040, | 385 0x00004040, 0x40004040, 0x00404040, 0x40404040, |
| 422 » » 0x00004040,0x40004040,0x00404040,0x40404040, | 386 }, |
| 423 » },{ | 387 { |
| 424 » » 0x00000000,0x10000000,0x00100000,0x10100000, | 388 0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00001000, 0x10001000, |
| 425 » » 0x00001000,0x10001000,0x00101000,0x10101000, | 389 0x00101000, 0x10101000, 0x00000010, 0x10000010, 0x00100010, 0x10100010, |
| 426 » » 0x00000010,0x10000010,0x00100010,0x10100010, | 390 0x00001010, 0x10001010, 0x00101010, 0x10101010, |
| 427 » » 0x00001010,0x10001010,0x00101010,0x10101010, | 391 }, |
| 428 » },{ | 392 { |
| 429 » » 0x00000000,0x04000000,0x00040000,0x04040000, | 393 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000400, 0x04000400, |
| 430 » » 0x00000400,0x04000400,0x00040400,0x04040400, | 394 0x00040400, 0x04040400, 0x00000004, 0x04000004, 0x00040004, 0x04040004, |
| 431 » » 0x00000004,0x04000004,0x00040004,0x04040004, | 395 0x00000404, 0x04000404, 0x00040404, 0x04040404, |
| 432 » » 0x00000404,0x04000404,0x00040404,0x04040404, | 396 }, |
| 433 » },{ | 397 { |
| 434 » » 0x00000000,0x01000000,0x00010000,0x01010000, | 398 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, |
| 435 » » 0x00000100,0x01000100,0x00010100,0x01010100, | 399 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, |
| 436 » » 0x00000001,0x01000001,0x00010001,0x01010001, | 400 0x00000101, 0x01000101, 0x00010101, 0x01010101, |
| 437 » » 0x00000101,0x01000101,0x00010101,0x01010101, | 401 }, |
| 438 » },{ | 402 { |
| 439 » » 0x00000000,0x80000000,0x00800000,0x80800000, | 403 0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00008000, 0x80008000, |
| 440 » » 0x00008000,0x80008000,0x00808000,0x80808000, | 404 0x00808000, 0x80808000, 0x00000080, 0x80000080, 0x00800080, 0x80800080, |
| 441 » » 0x00000080,0x80000080,0x00800080,0x80800080, | 405 0x00008080, 0x80008080, 0x00808080, 0x80808080, |
| 442 » » 0x00008080,0x80008080,0x00808080,0x80808080, | 406 }, |
| 443 » },{ | 407 { |
| 444 » » 0x00000000,0x20000000,0x00200000,0x20200000, | 408 0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00002000, 0x20002000, |
| 445 » » 0x00002000,0x20002000,0x00202000,0x20202000, | 409 0x00202000, 0x20202000, 0x00000020, 0x20000020, 0x00200020, 0x20200020, |
| 446 » » 0x00000020,0x20000020,0x00200020,0x20200020, | 410 0x00002020, 0x20002020, 0x00202020, 0x20202020, |
| 447 » » 0x00002020,0x20002020,0x00202020,0x20202020, | 411 }, |
| 448 » },{ | 412 { |
| 449 » » 0x00000000,0x08000000,0x00080000,0x08080000, | 413 0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00000800, 0x08000800, |
| 450 » » 0x00000800,0x08000800,0x00080800,0x08080800, | 414 0x00080800, 0x08080800, 0x00000008, 0x08000008, 0x00080008, 0x08080008, |
| 451 » » 0x00000008,0x08000008,0x00080008,0x08080008, | 415 0x00000808, 0x08000808, 0x00080808, 0x08080808, |
| 452 » » 0x00000808,0x08000808,0x00080808,0x08080808, | 416 }, |
| 453 » },{ | 417 { |
| 454 » » 0x00000000,0x02000000,0x00020000,0x02020000, | 418 0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00000200, 0x02000200, |
| 455 » » 0x00000200,0x02000200,0x00020200,0x02020200, | 419 0x00020200, 0x02020200, 0x00000002, 0x02000002, 0x00020002, 0x02020002, |
| 456 » » 0x00000002,0x02000002,0x00020002,0x02020002, | 420 0x00000202, 0x02000202, 0x00020202, 0x02020202, |
| 457 » » 0x00000202,0x02000202,0x00020202,0x02020202, | 421 }, |
| 458 » }, | |
| 459 }; | 422 }; |
| 460 static const uint32_t key_perm_maskl[8][16] = { | 423 static const uint32_t key_perm_maskl[8][16] = { |
| 461 » { | 424 { |
| 462 » » 0x00000000,0x00000000,0x00000010,0x00000010, | 425 0x00000000, 0x00000000, 0x00000010, 0x00000010, 0x00001000, 0x00001000, |
| 463 » » 0x00001000,0x00001000,0x00001010,0x00001010, | 426 0x00001010, 0x00001010, 0x00100000, 0x00100000, 0x00100010, 0x00100010, |
| 464 » » 0x00100000,0x00100000,0x00100010,0x00100010, | 427 0x00101000, 0x00101000, 0x00101010, 0x00101010, |
| 465 » » 0x00101000,0x00101000,0x00101010,0x00101010, | 428 }, |
| 466 » },{ | 429 { |
| 467 » » 0x00000000,0x00000000,0x00000020,0x00000020, | 430 0x00000000, 0x00000000, 0x00000020, 0x00000020, 0x00002000, 0x00002000, |
| 468 » » 0x00002000,0x00002000,0x00002020,0x00002020, | 431 0x00002020, 0x00002020, 0x00200000, 0x00200000, 0x00200020, 0x00200020, |
| 469 » » 0x00200000,0x00200000,0x00200020,0x00200020, | 432 0x00202000, 0x00202000, 0x00202020, 0x00202020, |
| 470 » » 0x00202000,0x00202000,0x00202020,0x00202020, | 433 }, |
| 471 » },{ | 434 { |
| 472 » » 0x00000000,0x00000000,0x00000040,0x00000040, | 435 0x00000000, 0x00000000, 0x00000040, 0x00000040, 0x00004000, 0x00004000, |
| 473 » » 0x00004000,0x00004000,0x00004040,0x00004040, | 436 0x00004040, 0x00004040, 0x00400000, 0x00400000, 0x00400040, 0x00400040, |
| 474 » » 0x00400000,0x00400000,0x00400040,0x00400040, | 437 0x00404000, 0x00404000, 0x00404040, 0x00404040, |
| 475 » » 0x00404000,0x00404000,0x00404040,0x00404040, | 438 }, |
| 476 » },{ | 439 { |
| 477 » » 0x00000000,0x00000000,0x00000080,0x00000080, | 440 0x00000000, 0x00000000, 0x00000080, 0x00000080, 0x00008000, 0x00008000, |
| 478 » » 0x00008000,0x00008000,0x00008080,0x00008080, | 441 0x00008080, 0x00008080, 0x00800000, 0x00800000, 0x00800080, 0x00800080, |
| 479 » » 0x00800000,0x00800000,0x00800080,0x00800080, | 442 0x00808000, 0x00808000, 0x00808080, 0x00808080, |
| 480 » » 0x00808000,0x00808000,0x00808080,0x00808080, | 443 }, |
| 481 » },{ | 444 { |
| 482 » » 0x00000000,0x00000001,0x00000100,0x00000101, | 445 0x00000000, 0x00000001, 0x00000100, 0x00000101, 0x00010000, 0x00010001, |
| 483 » » 0x00010000,0x00010001,0x00010100,0x00010101, | 446 0x00010100, 0x00010101, 0x01000000, 0x01000001, 0x01000100, 0x01000101, |
| 484 » » 0x01000000,0x01000001,0x01000100,0x01000101, | 447 0x01010000, 0x01010001, 0x01010100, 0x01010101, |
| 485 » » 0x01010000,0x01010001,0x01010100,0x01010101, | 448 }, |
| 486 » },{ | 449 { |
| 487 » » 0x00000000,0x00000002,0x00000200,0x00000202, | 450 0x00000000, 0x00000002, 0x00000200, 0x00000202, 0x00020000, 0x00020002, |
| 488 » » 0x00020000,0x00020002,0x00020200,0x00020202, | 451 0x00020200, 0x00020202, 0x02000000, 0x02000002, 0x02000200, 0x02000202, |
| 489 » » 0x02000000,0x02000002,0x02000200,0x02000202, | 452 0x02020000, 0x02020002, 0x02020200, 0x02020202, |
| 490 » » 0x02020000,0x02020002,0x02020200,0x02020202, | 453 }, |
| 491 » },{ | 454 { |
| 492 » » 0x00000000,0x00000004,0x00000400,0x00000404, | 455 0x00000000, 0x00000004, 0x00000400, 0x00000404, 0x00040000, 0x00040004, |
| 493 » » 0x00040000,0x00040004,0x00040400,0x00040404, | 456 0x00040400, 0x00040404, 0x04000000, 0x04000004, 0x04000400, 0x04000404, |
| 494 » » 0x04000000,0x04000004,0x04000400,0x04000404, | 457 0x04040000, 0x04040004, 0x04040400, 0x04040404, |
| 495 » » 0x04040000,0x04040004,0x04040400,0x04040404, | 458 }, |
| 496 » },{ | 459 { |
| 497 » » 0x00000000,0x00000008,0x00000800,0x00000808, | 460 0x00000000, 0x00000008, 0x00000800, 0x00000808, 0x00080000, 0x00080008, |
| 498 » » 0x00080000,0x00080008,0x00080800,0x00080808, | 461 0x00080800, 0x00080808, 0x08000000, 0x08000008, 0x08000800, 0x08000808, |
| 499 » » 0x08000000,0x08000008,0x08000800,0x08000808, | 462 0x08080000, 0x08080008, 0x08080800, 0x08080808, |
| 500 » » 0x08080000,0x08080008,0x08080800,0x08080808, | 463 }, |
| 501 » }, | |
| 502 }; | 464 }; |
| 503 static const uint32_t key_perm_maskr[12][16] = { | 465 static const uint32_t key_perm_maskr[12][16] = { |
| 504 » { | 466 { |
| 505 » » 0x00000000,0x00000001,0x00000000,0x00000001, | 467 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000001, |
| 506 » » 0x00000000,0x00000001,0x00000000,0x00000001, | 468 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000001, |
| 507 » » 0x00000000,0x00000001,0x00000000,0x00000001, | 469 0x00000000, 0x00000001, 0x00000000, 0x00000001, |
| 508 » » 0x00000000,0x00000001,0x00000000,0x00000001, | 470 }, |
| 509 » },{ | 471 { |
| 510 » » 0x00000000,0x00000000,0x00100000,0x00100000, | 472 0x00000000, 0x00000000, 0x00100000, 0x00100000, 0x00001000, 0x00001000, |
| 511 » » 0x00001000,0x00001000,0x00101000,0x00101000, | 473 0x00101000, 0x00101000, 0x00000010, 0x00000010, 0x00100010, 0x00100010, |
| 512 » » 0x00000010,0x00000010,0x00100010,0x00100010, | 474 0x00001010, 0x00001010, 0x00101010, 0x00101010, |
| 513 » » 0x00001010,0x00001010,0x00101010,0x00101010, | 475 }, |
| 514 » },{ | 476 { |
| 515 » » 0x00000000,0x00000002,0x00000000,0x00000002, | 477 0x00000000, 0x00000002, 0x00000000, 0x00000002, 0x00000000, 0x00000002, |
| 516 » » 0x00000000,0x00000002,0x00000000,0x00000002, | 478 0x00000000, 0x00000002, 0x00000000, 0x00000002, 0x00000000, 0x00000002, |
| 517 » » 0x00000000,0x00000002,0x00000000,0x00000002, | 479 0x00000000, 0x00000002, 0x00000000, 0x00000002, |
| 518 » » 0x00000000,0x00000002,0x00000000,0x00000002, | 480 }, |
| 519 » },{ | 481 { |
| 520 » » 0x00000000,0x00000000,0x00200000,0x00200000, | 482 0x00000000, 0x00000000, 0x00200000, 0x00200000, 0x00002000, 0x00002000, |
| 521 » » 0x00002000,0x00002000,0x00202000,0x00202000, | 483 0x00202000, 0x00202000, 0x00000020, 0x00000020, 0x00200020, 0x00200020, |
| 522 » » 0x00000020,0x00000020,0x00200020,0x00200020, | 484 0x00002020, 0x00002020, 0x00202020, 0x00202020, |
| 523 » » 0x00002020,0x00002020,0x00202020,0x00202020, | 485 }, |
| 524 » },{ | 486 { |
| 525 » » 0x00000000,0x00000004,0x00000000,0x00000004, | 487 0x00000000, 0x00000004, 0x00000000, 0x00000004, 0x00000000, 0x00000004, |
| 526 » » 0x00000000,0x00000004,0x00000000,0x00000004, | 488 0x00000000, 0x00000004, 0x00000000, 0x00000004, 0x00000000, 0x00000004, |
| 527 » » 0x00000000,0x00000004,0x00000000,0x00000004, | 489 0x00000000, 0x00000004, 0x00000000, 0x00000004, |
| 528 » » 0x00000000,0x00000004,0x00000000,0x00000004, | 490 }, |
| 529 » },{ | 491 { |
| 530 » » 0x00000000,0x00000000,0x00400000,0x00400000, | 492 0x00000000, 0x00000000, 0x00400000, 0x00400000, 0x00004000, 0x00004000, |
| 531 » » 0x00004000,0x00004000,0x00404000,0x00404000, | 493 0x00404000, 0x00404000, 0x00000040, 0x00000040, 0x00400040, 0x00400040, |
| 532 » » 0x00000040,0x00000040,0x00400040,0x00400040, | 494 0x00004040, 0x00004040, 0x00404040, 0x00404040, |
| 533 » » 0x00004040,0x00004040,0x00404040,0x00404040, | 495 }, |
| 534 » },{ | 496 { |
| 535 » » 0x00000000,0x00000008,0x00000000,0x00000008, | 497 0x00000000, 0x00000008, 0x00000000, 0x00000008, 0x00000000, 0x00000008, |
| 536 » » 0x00000000,0x00000008,0x00000000,0x00000008, | 498 0x00000000, 0x00000008, 0x00000000, 0x00000008, 0x00000000, 0x00000008, |
| 537 » » 0x00000000,0x00000008,0x00000000,0x00000008, | 499 0x00000000, 0x00000008, 0x00000000, 0x00000008, |
| 538 » » 0x00000000,0x00000008,0x00000000,0x00000008, | 500 }, |
| 539 » },{ | 501 { |
| 540 » » 0x00000000,0x00000000,0x00800000,0x00800000, | 502 0x00000000, 0x00000000, 0x00800000, 0x00800000, 0x00008000, 0x00008000, |
| 541 » » 0x00008000,0x00008000,0x00808000,0x00808000, | 503 0x00808000, 0x00808000, 0x00000080, 0x00000080, 0x00800080, 0x00800080, |
| 542 » » 0x00000080,0x00000080,0x00800080,0x00800080, | 504 0x00008080, 0x00008080, 0x00808080, 0x00808080, |
| 543 » » 0x00008080,0x00008080,0x00808080,0x00808080, | 505 }, |
| 544 » },{ | 506 { |
| 545 » » 0x00000000,0x00000000,0x01000000,0x01000000, | 507 0x00000000, 0x00000000, 0x01000000, 0x01000000, 0x00010000, 0x00010000, |
| 546 » » 0x00010000,0x00010000,0x01010000,0x01010000, | 508 0x01010000, 0x01010000, 0x00000100, 0x00000100, 0x01000100, 0x01000100, |
| 547 » » 0x00000100,0x00000100,0x01000100,0x01000100, | 509 0x00010100, 0x00010100, 0x01010100, 0x01010100, |
| 548 » » 0x00010100,0x00010100,0x01010100,0x01010100, | 510 }, |
| 549 » },{ | 511 { |
| 550 » » 0x00000000,0x00000000,0x02000000,0x02000000, | 512 0x00000000, 0x00000000, 0x02000000, 0x02000000, 0x00020000, 0x00020000, |
| 551 » » 0x00020000,0x00020000,0x02020000,0x02020000, | 513 0x02020000, 0x02020000, 0x00000200, 0x00000200, 0x02000200, 0x02000200, |
| 552 » » 0x00000200,0x00000200,0x02000200,0x02000200, | 514 0x00020200, 0x00020200, 0x02020200, 0x02020200, |
| 553 » » 0x00020200,0x00020200,0x02020200,0x02020200, | 515 }, |
| 554 » },{ | 516 { |
| 555 » » 0x00000000,0x00000000,0x04000000,0x04000000, | 517 0x00000000, 0x00000000, 0x04000000, 0x04000000, 0x00040000, 0x00040000, |
| 556 » » 0x00040000,0x00040000,0x04040000,0x04040000, | 518 0x04040000, 0x04040000, 0x00000400, 0x00000400, 0x04000400, 0x04000400, |
| 557 » » 0x00000400,0x00000400,0x04000400,0x04000400, | 519 0x00040400, 0x00040400, 0x04040400, 0x04040400, |
| 558 » » 0x00040400,0x00040400,0x04040400,0x04040400, | 520 }, |
| 559 » },{ | 521 { |
| 560 » » 0x00000000,0x00000000,0x08000000,0x08000000, | 522 0x00000000, 0x00000000, 0x08000000, 0x08000000, 0x00080000, 0x00080000, |
| 561 » » 0x00080000,0x00080000,0x08080000,0x08080000, | 523 0x08080000, 0x08080000, 0x00000800, 0x00000800, 0x08000800, 0x08000800, |
| 562 » » 0x00000800,0x00000800,0x08000800,0x08000800, | 524 0x00080800, 0x00080800, 0x08080800, 0x08080800, |
| 563 » » 0x00080800,0x00080800,0x08080800,0x08080800, | 525 }, |
| 564 » }, | |
| 565 }; | 526 }; |
| 566 static const uint32_t comp_maskl0[4][8] = { | 527 static const uint32_t comp_maskl0[4][8] = { |
| 567 » { | 528 { |
| 568 » » 0x00000000,0x00020000,0x00000001,0x00020001, | 529 0x00000000, 0x00020000, 0x00000001, 0x00020001, 0x00080000, 0x000a0000, |
| 569 » » 0x00080000,0x000a0000,0x00080001,0x000a0001, | 530 0x00080001, 0x000a0001, |
| 570 » },{ | 531 }, |
| 571 » » 0x00000000,0x00001000,0x00000000,0x00001000, | 532 { |
| 572 » » 0x00000040,0x00001040,0x00000040,0x00001040, | 533 0x00000000, 0x00001000, 0x00000000, 0x00001000, 0x00000040, 0x00001040, |
| 573 » },{ | 534 0x00000040, 0x00001040, |
| 574 » » 0x00000000,0x00400000,0x00000020,0x00400020, | 535 }, |
| 575 » » 0x00008000,0x00408000,0x00008020,0x00408020, | 536 { |
| 576 » },{ | 537 0x00000000, 0x00400000, 0x00000020, 0x00400020, 0x00008000, 0x00408000, |
| 577 » » 0x00000000,0x00100000,0x00000800,0x00100800, | 538 0x00008020, 0x00408020, |
| 578 » » 0x00000000,0x00100000,0x00000800,0x00100800, | 539 }, |
| 579 » }, | 540 { |
| 541 0x00000000, 0x00100000, 0x00000800, 0x00100800, 0x00000000, 0x00100000, |
| 542 0x00000800, 0x00100800, |
| 543 }, |
| 580 }; | 544 }; |
| 581 static const uint32_t comp_maskr0[4][8] = { | 545 static const uint32_t comp_maskr0[4][8] = { |
| 582 » { | 546 { |
| 583 » » 0x00000000,0x00200000,0x00020000,0x00220000, | 547 0x00000000, 0x00200000, 0x00020000, 0x00220000, 0x00000002, 0x00200002, |
| 584 » » 0x00000002,0x00200002,0x00020002,0x00220002, | 548 0x00020002, 0x00220002, |
| 585 » },{ | 549 }, |
| 586 » » 0x00000000,0x00000000,0x00100000,0x00100000, | 550 { |
| 587 » » 0x00000004,0x00000004,0x00100004,0x00100004, | 551 0x00000000, 0x00000000, 0x00100000, 0x00100000, 0x00000004, 0x00000004, |
| 588 » },{ | 552 0x00100004, 0x00100004, |
| 589 » » 0x00000000,0x00004000,0x00000800,0x00004800, | 553 }, |
| 590 » » 0x00000000,0x00004000,0x00000800,0x00004800, | 554 { |
| 591 » },{ | 555 0x00000000, 0x00004000, 0x00000800, 0x00004800, 0x00000000, 0x00004000, |
| 592 » » 0x00000000,0x00400000,0x00008000,0x00408000, | 556 0x00000800, 0x00004800, |
| 593 » » 0x00000008,0x00400008,0x00008008,0x00408008, | 557 }, |
| 594 » }, | 558 { |
| 559 0x00000000, 0x00400000, 0x00008000, 0x00408000, 0x00000008, 0x00400008, |
| 560 0x00008008, 0x00408008, |
| 561 }, |
| 595 }; | 562 }; |
| 596 static const uint32_t comp_maskl1[4][16] = { | 563 static const uint32_t comp_maskl1[4][16] = { |
| 597 » { | 564 { |
| 598 » » 0x00000000,0x00000010,0x00004000,0x00004010, | 565 0x00000000, 0x00000010, 0x00004000, 0x00004010, 0x00040000, 0x00040010, |
| 599 » » 0x00040000,0x00040010,0x00044000,0x00044010, | 566 0x00044000, 0x00044010, 0x00000100, 0x00000110, 0x00004100, 0x00004110, |
| 600 » » 0x00000100,0x00000110,0x00004100,0x00004110, | 567 0x00040100, 0x00040110, 0x00044100, 0x00044110, |
| 601 » » 0x00040100,0x00040110,0x00044100,0x00044110, | 568 }, |
| 602 » },{ | 569 { |
| 603 » » 0x00000000,0x00800000,0x00000002,0x00800002, | 570 0x00000000, 0x00800000, 0x00000002, 0x00800002, 0x00000200, 0x00800200, |
| 604 » » 0x00000200,0x00800200,0x00000202,0x00800202, | 571 0x00000202, 0x00800202, 0x00200000, 0x00a00000, 0x00200002, 0x00a00002, |
| 605 » » 0x00200000,0x00a00000,0x00200002,0x00a00002, | 572 0x00200200, 0x00a00200, 0x00200202, 0x00a00202, |
| 606 » » 0x00200200,0x00a00200,0x00200202,0x00a00202, | 573 }, |
| 607 » },{ | 574 { |
| 608 » » 0x00000000,0x00002000,0x00000004,0x00002004, | 575 0x00000000, 0x00002000, 0x00000004, 0x00002004, 0x00000400, 0x00002400, |
| 609 » » 0x00000400,0x00002400,0x00000404,0x00002404, | 576 0x00000404, 0x00002404, 0x00000000, 0x00002000, 0x00000004, 0x00002004, |
| 610 » » 0x00000000,0x00002000,0x00000004,0x00002004, | 577 0x00000400, 0x00002400, 0x00000404, 0x00002404, |
| 611 » » 0x00000400,0x00002400,0x00000404,0x00002404, | 578 }, |
| 612 » },{ | 579 { |
| 613 » » 0x00000000,0x00010000,0x00000008,0x00010008, | 580 0x00000000, 0x00010000, 0x00000008, 0x00010008, 0x00000080, 0x00010080, |
| 614 » » 0x00000080,0x00010080,0x00000088,0x00010088, | 581 0x00000088, 0x00010088, 0x00000000, 0x00010000, 0x00000008, 0x00010008, |
| 615 » » 0x00000000,0x00010000,0x00000008,0x00010008, | 582 0x00000080, 0x00010080, 0x00000088, 0x00010088, |
| 616 » » 0x00000080,0x00010080,0x00000088,0x00010088, | 583 }, |
| 617 » }, | |
| 618 }; | 584 }; |
| 619 static const uint32_t comp_maskr1[4][16] = { | 585 static const uint32_t comp_maskr1[4][16] = { |
| 620 » { | 586 { |
| 621 » » 0x00000000,0x00000000,0x00000080,0x00000080, | 587 0x00000000, 0x00000000, 0x00000080, 0x00000080, 0x00002000, 0x00002000, |
| 622 » » 0x00002000,0x00002000,0x00002080,0x00002080, | 588 0x00002080, 0x00002080, 0x00000001, 0x00000001, 0x00000081, 0x00000081, |
| 623 » » 0x00000001,0x00000001,0x00000081,0x00000081, | 589 0x00002001, 0x00002001, 0x00002081, 0x00002081, |
| 624 » » 0x00002001,0x00002001,0x00002081,0x00002081, | 590 }, |
| 625 » },{ | 591 { |
| 626 » » 0x00000000,0x00000010,0x00800000,0x00800010, | 592 0x00000000, 0x00000010, 0x00800000, 0x00800010, 0x00010000, 0x00010010, |
| 627 » » 0x00010000,0x00010010,0x00810000,0x00810010, | 593 0x00810000, 0x00810010, 0x00000200, 0x00000210, 0x00800200, 0x00800210, |
| 628 » » 0x00000200,0x00000210,0x00800200,0x00800210, | 594 0x00010200, 0x00010210, 0x00810200, 0x00810210, |
| 629 » » 0x00010200,0x00010210,0x00810200,0x00810210, | 595 }, |
| 630 » },{ | 596 { |
| 631 » » 0x00000000,0x00000400,0x00001000,0x00001400, | 597 0x00000000, 0x00000400, 0x00001000, 0x00001400, 0x00080000, 0x00080400, |
| 632 » » 0x00080000,0x00080400,0x00081000,0x00081400, | 598 0x00081000, 0x00081400, 0x00000020, 0x00000420, 0x00001020, 0x00001420, |
| 633 » » 0x00000020,0x00000420,0x00001020,0x00001420, | 599 0x00080020, 0x00080420, 0x00081020, 0x00081420, |
| 634 » » 0x00080020,0x00080420,0x00081020,0x00081420, | 600 }, |
| 635 » },{ | 601 { |
| 636 » » 0x00000000,0x00000100,0x00040000,0x00040100, | 602 0x00000000, 0x00000100, 0x00040000, 0x00040100, 0x00000000, 0x00000100, |
| 637 » » 0x00000000,0x00000100,0x00040000,0x00040100, | 603 0x00040000, 0x00040100, 0x00000040, 0x00000140, 0x00040040, 0x00040140, |
| 638 » » 0x00000040,0x00000140,0x00040040,0x00040140, | 604 0x00000040, 0x00000140, 0x00040040, 0x00040140, |
| 639 » » 0x00000040,0x00000140,0x00040040,0x00040140, | 605 }, |
| 640 » }, | |
| 641 }; | 606 }; |
| 642 | 607 |
| 643 static const unsigned char ascii64[] = | 608 static const unsigned char ascii64[] = |
| 644 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | 609 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| 645 /* 0000000000111111111122222222223333333333444444444455555555556666 */ | 610 /* 0000000000111111111122222222223333333333444444444455555555556666 */ |
| 646 /* 0123456789012345678901234567890123456789012345678901234567890123 */ | 611 /* 0123456789012345678901234567890123456789012345678901234567890123 */ |
| 647 | 612 |
| 648 /* | 613 /* |
| 649 * We match the behavior of UFC-crypt on systems where "char" is signed by | 614 * We match the behavior of UFC-crypt on systems where "char" is signed by |
| 650 * default (the majority), regardless of char's signedness on our system. | 615 * default (the majority), regardless of char's signedness on our system. |
| 651 */ | 616 */ |
| 652 static uint32_t ascii_to_bin(int ch) | 617 static uint32_t ascii_to_bin(int ch) { |
| 653 { | 618 int sch = (ch < 0x80) ? ch : -(0x100 - ch); |
| 654 » int sch = (ch < 0x80) ? ch : -(0x100 - ch); | 619 int retval; |
| 655 » int retval; | 620 |
| 656 | 621 retval = sch - '.'; |
| 657 » retval = sch - '.'; | 622 if (sch >= 'A') { |
| 658 » if (sch >= 'A') { | 623 retval = sch - ('A' - 12); |
| 659 » » retval = sch - ('A' - 12); | 624 if (sch >= 'a') |
| 660 » » if (sch >= 'a') | 625 retval = sch - ('a' - 38); |
| 661 » » » retval = sch - ('a' - 38); | 626 } |
| 662 » } | 627 retval &= 0x3f; |
| 663 » retval &= 0x3f; | 628 |
| 664 | 629 return retval; |
| 665 » return retval; | |
| 666 } | 630 } |
| 667 | 631 |
| 668 /* | 632 /* |
| 669 * When we choose to "support" invalid salts, nevertheless disallow those | 633 * When we choose to "support" invalid salts, nevertheless disallow those |
| 670 * containing characters that would violate the passwd file format. | 634 * containing characters that would violate the passwd file format. |
| 671 */ | 635 */ |
| 672 static inline int ascii_is_unsafe(unsigned char ch) | 636 static inline int ascii_is_unsafe(unsigned char ch) { |
| 673 { | 637 return !ch || ch == '\n' || ch == ':'; |
| 674 » return !ch || ch == '\n' || ch == ':'; | 638 } |
| 675 } | 639 |
| 676 | 640 static uint32_t setup_salt(uint32_t salt) { |
| 677 static uint32_t setup_salt(uint32_t salt) | 641 uint32_t obit, saltbit, saltbits; |
| 678 { | 642 unsigned int i; |
| 679 » uint32_t obit, saltbit, saltbits; | 643 |
| 680 » unsigned int i; | 644 saltbits = 0; |
| 681 | 645 saltbit = 1; |
| 682 » saltbits = 0; | 646 obit = 0x800000; |
| 683 » saltbit = 1; | 647 for (i = 0; i < 24; i++) { |
| 684 » obit = 0x800000; | 648 if (salt & saltbit) |
| 685 » for (i = 0; i < 24; i++) { | 649 saltbits |= obit; |
| 686 » » if (salt & saltbit) | 650 saltbit <<= 1; |
| 687 » » » saltbits |= obit; | 651 obit >>= 1; |
| 688 » » saltbit <<= 1; | 652 } |
| 689 » » obit >>= 1; | 653 |
| 690 » } | 654 return saltbits; |
| 691 | 655 } |
| 692 » return saltbits; | 656 |
| 693 } | 657 void __des_setkey(const unsigned char* key, struct expanded_key* ekey) { |
| 694 | 658 uint32_t k0, k1, rawkey0, rawkey1; |
| 695 void __des_setkey(const unsigned char *key, struct expanded_key *ekey) | 659 unsigned int shifts, round, i, ibit; |
| 696 { | 660 |
| 697 » uint32_t k0, k1, rawkey0, rawkey1; | 661 rawkey0 = (uint32_t)key[3] | ((uint32_t)key[2] << 8) | |
| 698 » unsigned int shifts, round, i, ibit; | 662 ((uint32_t)key[1] << 16) | ((uint32_t)key[0] << 24); |
| 699 | 663 rawkey1 = (uint32_t)key[7] | ((uint32_t)key[6] << 8) | |
| 700 » rawkey0 = | 664 ((uint32_t)key[5] << 16) | ((uint32_t)key[4] << 24); |
| 701 » (uint32_t)key[3] | | 665 |
| 702 » ((uint32_t)key[2] << 8) | | 666 /* |
| 703 » ((uint32_t)key[1] << 16) | | 667 * Do key permutation and split into two 28-bit subkeys. |
| 704 » ((uint32_t)key[0] << 24); | 668 */ |
| 705 » rawkey1 = | 669 k0 = k1 = 0; |
| 706 » (uint32_t)key[7] | | 670 for (i = 0, ibit = 28; i < 4; i++, ibit -= 4) { |
| 707 » ((uint32_t)key[6] << 8) | | 671 unsigned int j = i << 1; |
| 708 » ((uint32_t)key[5] << 16) | | 672 k0 |= key_perm_maskl[i][(rawkey0 >> ibit) & 0xf] | |
| 709 » ((uint32_t)key[4] << 24); | 673 key_perm_maskl[i + 4][(rawkey1 >> ibit) & 0xf]; |
| 710 | 674 k1 |= key_perm_maskr[j][(rawkey0 >> ibit) & 0xf]; |
| 711 » /* | 675 ibit -= 4; |
| 712 » * Do key permutation and split into two 28-bit subkeys. | 676 k1 |= key_perm_maskr[j + 1][(rawkey0 >> ibit) & 0xf] | |
| 713 » */ | 677 key_perm_maskr[i + 8][(rawkey1 >> ibit) & 0xf]; |
| 714 » k0 = k1 = 0; | 678 } |
| 715 » for (i = 0, ibit = 28; i < 4; i++, ibit -= 4) { | 679 |
| 716 » » unsigned int j = i << 1; | 680 /* |
| 717 » » k0 |= key_perm_maskl[i][(rawkey0 >> ibit) & 0xf] | | 681 * Rotate subkeys and do compression permutation. |
| 718 » » key_perm_maskl[i + 4][(rawkey1 >> ibit) & 0xf]; | 682 */ |
| 719 » » k1 |= key_perm_maskr[j][(rawkey0 >> ibit) & 0xf]; | 683 shifts = 0; |
| 720 » » ibit -= 4; | 684 for (round = 0; round < 16; round++) { |
| 721 » » k1 |= key_perm_maskr[j + 1][(rawkey0 >> ibit) & 0xf] | | 685 uint32_t t0, t1; |
| 722 » » key_perm_maskr[i + 8][(rawkey1 >> ibit) & 0xf]; | 686 uint32_t kl, kr; |
| 723 » } | 687 |
| 724 | 688 shifts += key_shifts[round]; |
| 725 » /* | 689 |
| 726 » * Rotate subkeys and do compression permutation. | 690 t0 = (k0 << shifts) | (k0 >> (28 - shifts)); |
| 727 » */ | 691 t1 = (k1 << shifts) | (k1 >> (28 - shifts)); |
| 728 » shifts = 0; | 692 |
| 729 » for (round = 0; round < 16; round++) { | 693 kl = kr = 0; |
| 730 » » uint32_t t0, t1; | 694 ibit = 25; |
| 731 » » uint32_t kl, kr; | 695 for (i = 0; i < 4; i++) { |
| 732 | 696 kl |= comp_maskl0[i][(t0 >> ibit) & 7]; |
| 733 » » shifts += key_shifts[round]; | 697 kr |= comp_maskr0[i][(t1 >> ibit) & 7]; |
| 734 | 698 ibit -= 4; |
| 735 » » t0 = (k0 << shifts) | (k0 >> (28 - shifts)); | 699 kl |= comp_maskl1[i][(t0 >> ibit) & 0xf]; |
| 736 » » t1 = (k1 << shifts) | (k1 >> (28 - shifts)); | 700 kr |= comp_maskr1[i][(t1 >> ibit) & 0xf]; |
| 737 | 701 ibit -= 3; |
| 738 » » kl = kr = 0; | 702 } |
| 739 » » ibit = 25; | 703 ekey->l[round] = kl; |
| 740 » » for (i = 0; i < 4; i++) { | 704 ekey->r[round] = kr; |
| 741 » » » kl |= comp_maskl0[i][(t0 >> ibit) & 7]; | 705 } |
| 742 » » » kr |= comp_maskr0[i][(t1 >> ibit) & 7]; | |
| 743 » » » ibit -= 4; | |
| 744 » » » kl |= comp_maskl1[i][(t0 >> ibit) & 0xf]; | |
| 745 » » » kr |= comp_maskr1[i][(t1 >> ibit) & 0xf]; | |
| 746 » » » ibit -= 3; | |
| 747 » » } | |
| 748 » » ekey->l[round] = kl; | |
| 749 » » ekey->r[round] = kr; | |
| 750 » } | |
| 751 } | 706 } |
| 752 | 707 |
| 753 /* | 708 /* |
| 754 * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. | 709 * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. |
| 755 */ | 710 */ |
| 756 void __do_des(uint32_t l_in, uint32_t r_in, | 711 void __do_des(uint32_t l_in, |
| 757 uint32_t *l_out, uint32_t *r_out, | 712 uint32_t r_in, |
| 758 uint32_t count, uint32_t saltbits, const struct expanded_key *ekey) | 713 uint32_t* l_out, |
| 759 { | 714 uint32_t* r_out, |
| 760 uint32_t l, r; | 715 uint32_t count, |
| 761 | 716 uint32_t saltbits, |
| 762 /* | 717 const struct expanded_key* ekey) { |
| 763 * Do initial permutation (IP). | 718 uint32_t l, r; |
| 764 */ | 719 |
| 765 l = r = 0; | 720 /* |
| 766 if (l_in | r_in) { | 721 * Do initial permutation (IP). |
| 767 unsigned int i, ibit; | 722 */ |
| 768 for (i = 0, ibit = 28; i < 8; i++, ibit -= 4) { | 723 l = r = 0; |
| 769 l |= ip_maskl[i][(l_in >> ibit) & 0xf] | | 724 if (l_in | r_in) { |
| 770 ip_maskl[i + 8][(r_in >> ibit) & 0xf]; | 725 unsigned int i, ibit; |
| 771 r |= ip_maskr[i][(l_in >> ibit) & 0xf] | | 726 for (i = 0, ibit = 28; i < 8; i++, ibit -= 4) { |
| 772 ip_maskr[i + 8][(r_in >> ibit) & 0xf]; | 727 l |= ip_maskl[i][(l_in >> ibit) & 0xf] | |
| 773 } | 728 ip_maskl[i + 8][(r_in >> ibit) & 0xf]; |
| 774 } | 729 r |= ip_maskr[i][(l_in >> ibit) & 0xf] | |
| 775 | 730 ip_maskr[i + 8][(r_in >> ibit) & 0xf]; |
| 776 while (count--) { | 731 } |
| 777 /* | 732 } |
| 778 * Do each round. | 733 |
| 779 */ | 734 while (count--) { |
| 780 unsigned int round = 16; | 735 /* |
| 781 const uint32_t *kl = ekey->l; | 736 * Do each round. |
| 782 const uint32_t *kr = ekey->r; | 737 */ |
| 783 uint32_t f; | 738 unsigned int round = 16; |
| 784 while (round--) { | 739 const uint32_t* kl = ekey->l; |
| 785 uint32_t r48l, r48r; | 740 const uint32_t* kr = ekey->r; |
| 786 /* | 741 uint32_t f; |
| 787 * Expand R to 48 bits (simulate the E-box). | 742 while (round--) { |
| 788 */ | 743 uint32_t r48l, r48r; |
| 789 r48l = ((r & 0x00000001) << 23) | 744 /* |
| 790 | ((r & 0xf8000000) >> 9) | 745 * Expand R to 48 bits (simulate the E-box). |
| 791 | ((r & 0x1f800000) >> 11) | 746 */ |
| 792 | ((r & 0x01f80000) >> 13) | 747 r48l = ((r & 0x00000001) << 23) | ((r & 0xf8000000) >> 9) | |
| 793 | ((r & 0x001f8000) >> 15); | 748 ((r & 0x1f800000) >> 11) | ((r & 0x01f80000) >> 13) | |
| 794 | 749 ((r & 0x001f8000) >> 15); |
| 795 r48r = ((r & 0x0001f800) << 7) | 750 |
| 796 | ((r & 0x00001f80) << 5) | 751 r48r = ((r & 0x0001f800) << 7) | ((r & 0x00001f80) << 5) | |
| 797 | ((r & 0x000001f8) << 3) | 752 ((r & 0x000001f8) << 3) | ((r & 0x0000001f) << 1) | |
| 798 | ((r & 0x0000001f) << 1) | 753 ((r & 0x80000000) >> 31); |
| 799 | ((r & 0x80000000) >> 31); | 754 /* |
| 800 /* | 755 * Do salting for crypt() and friends, and |
| 801 * Do salting for crypt() and friends, and | 756 * XOR with the permuted key. |
| 802 * XOR with the permuted key. | 757 */ |
| 803 */ | 758 f = (r48l ^ r48r) & saltbits; |
| 804 f = (r48l ^ r48r) & saltbits; | 759 r48l ^= f ^ *kl++; |
| 805 r48l ^= f ^ *kl++; | 760 r48r ^= f ^ *kr++; |
| 806 r48r ^= f ^ *kr++; | 761 /* |
| 807 /* | 762 * Do S-box lookups (which shrink it back to 32 bits) |
| 808 * Do S-box lookups (which shrink it back to 32 bits) | 763 * and do the P-box permutation at the same time. |
| 809 * and do the P-box permutation at the same time. | 764 */ |
| 810 */ | 765 f = psbox[0][r48l >> 18] | psbox[1][(r48l >> 12) & 0x3f] | |
| 811 f = psbox[0][r48l >> 18] | 766 psbox[2][(r48l >> 6) & 0x3f] | psbox[3][r48l & 0x3f] | |
| 812 | psbox[1][(r48l >> 12) & 0x3f] | 767 psbox[4][r48r >> 18] | psbox[5][(r48r >> 12) & 0x3f] | |
| 813 | psbox[2][(r48l >> 6) & 0x3f] | 768 psbox[6][(r48r >> 6) & 0x3f] | psbox[7][r48r & 0x3f]; |
| 814 | psbox[3][r48l & 0x3f] | 769 /* |
| 815 | psbox[4][r48r >> 18] | 770 * Now that we've permuted things, complete f(). |
| 816 | psbox[5][(r48r >> 12) & 0x3f] | 771 */ |
| 817 | psbox[6][(r48r >> 6) & 0x3f] | 772 f ^= l; |
| 818 | psbox[7][r48r & 0x3f]; | 773 l = r; |
| 819 /* | 774 r = f; |
| 820 * Now that we've permuted things, complete f(). | 775 } |
| 821 */ | 776 r = l; |
| 822 f ^= l; | 777 l = f; |
| 823 l = r; | 778 } |
| 824 r = f; | 779 |
| 825 } | 780 /* |
| 826 r = l; | 781 * Do final permutation (inverse of IP). |
| 827 l = f; | 782 */ |
| 828 } | 783 { |
| 829 | 784 unsigned int i, ibit; |
| 830 /* | 785 uint32_t lo, ro; |
| 831 * Do final permutation (inverse of IP). | 786 lo = ro = 0; |
| 832 */ | 787 for (i = 0, ibit = 28; i < 4; i++, ibit -= 4) { |
| 833 { | 788 ro |= fp_maskr[i][(l >> ibit) & 0xf] | fp_maskr[i + 4][(r >> ibit) & 0xf]; |
| 834 unsigned int i, ibit; | 789 ibit -= 4; |
| 835 uint32_t lo, ro; | 790 lo |= fp_maskl[i][(l >> ibit) & 0xf] | fp_maskl[i + 4][(r >> ibit) & 0xf]; |
| 836 lo = ro = 0; | 791 } |
| 837 for (i = 0, ibit = 28; i < 4; i++, ibit -= 4) { | 792 *l_out = lo; |
| 838 ro |= fp_maskr[i][(l >> ibit) & 0xf] | | 793 *r_out = ro; |
| 839 fp_maskr[i + 4][(r >> ibit) & 0xf]; | 794 } |
| 840 ibit -= 4; | 795 } |
| 841 lo |= fp_maskl[i][(l >> ibit) & 0xf] | | 796 |
| 842 fp_maskl[i + 4][(r >> ibit) & 0xf]; | 797 static void des_cipher(const unsigned char* in, |
| 843 } | 798 unsigned char* out, |
| 844 *l_out = lo; | 799 uint32_t count, |
| 845 *r_out = ro; | 800 uint32_t saltbits, |
| 846 } | 801 const struct expanded_key* ekey) { |
| 847 } | 802 uint32_t l_out, r_out, rawl, rawr; |
| 848 | 803 |
| 849 static void des_cipher(const unsigned char *in, unsigned char *out, | 804 rawl = (uint32_t)in[3] | ((uint32_t)in[2] << 8) | ((uint32_t)in[1] << 16) | |
| 850 uint32_t count, uint32_t saltbits, const struct expanded_key *ekey) | 805 ((uint32_t)in[0] << 24); |
| 851 { | 806 rawr = (uint32_t)in[7] | ((uint32_t)in[6] << 8) | ((uint32_t)in[5] << 16) | |
| 852 uint32_t l_out, r_out, rawl, rawr; | 807 ((uint32_t)in[4] << 24); |
| 853 | 808 |
| 854 rawl = | 809 __do_des(rawl, rawr, &l_out, &r_out, count, saltbits, ekey); |
| 855 (uint32_t)in[3] | | 810 |
| 856 ((uint32_t)in[2] << 8) | | 811 out[0] = l_out >> 24; |
| 857 ((uint32_t)in[1] << 16) | | 812 out[1] = l_out >> 16; |
| 858 ((uint32_t)in[0] << 24); | 813 out[2] = l_out >> 8; |
| 859 rawr = | 814 out[3] = l_out; |
| 860 (uint32_t)in[7] | | 815 out[4] = r_out >> 24; |
| 861 ((uint32_t)in[6] << 8) | | 816 out[5] = r_out >> 16; |
| 862 ((uint32_t)in[5] << 16) | | 817 out[6] = r_out >> 8; |
| 863 ((uint32_t)in[4] << 24); | 818 out[7] = r_out; |
| 864 | 819 } |
| 865 __do_des(rawl, rawr, &l_out, &r_out, count, saltbits, ekey); | 820 |
| 866 | 821 static char* _crypt_extended_r_uut(const char* _key, |
| 867 out[0] = l_out >> 24; | 822 const char* _setting, |
| 868 out[1] = l_out >> 16; | 823 char* output) { |
| 869 out[2] = l_out >> 8; | 824 const unsigned char* key = (const unsigned char*)_key; |
| 870 out[3] = l_out; | 825 const unsigned char* setting = (const unsigned char*)_setting; |
| 871 out[4] = r_out >> 24; | 826 struct expanded_key ekey; |
| 872 out[5] = r_out >> 16; | 827 unsigned char keybuf[8]; |
| 873 out[6] = r_out >> 8; | 828 unsigned char *p, *q; |
| 874 out[7] = r_out; | 829 uint32_t count, salt, l, r0, r1; |
| 875 } | 830 unsigned int i; |
| 876 | 831 |
| 877 static char *_crypt_extended_r_uut(const char *_key, const char *_setting, char
*output) | 832 /* |
| 878 { | 833 * Copy the key, shifting each character left by one bit and padding |
| 879 const unsigned char *key = (const unsigned char *)_key; | 834 * with zeroes. |
| 880 const unsigned char *setting = (const unsigned char *)_setting; | 835 */ |
| 881 struct expanded_key ekey; | 836 q = keybuf; |
| 882 unsigned char keybuf[8]; | 837 while (q <= &keybuf[sizeof(keybuf) - 1]) { |
| 883 unsigned char *p, *q; | 838 *q++ = *key << 1; |
| 884 uint32_t count, salt, l, r0, r1; | 839 if (*key) |
| 885 unsigned int i; | 840 key++; |
| 886 | 841 } |
| 887 /* | 842 __des_setkey(keybuf, &ekey); |
| 888 * Copy the key, shifting each character left by one bit and padding | 843 |
| 889 * with zeroes. | 844 if (*setting == _PASSWORD_EFMT1) { |
| 890 */ | 845 /* |
| 891 q = keybuf; | 846 * "new"-style: |
| 892 while (q <= &keybuf[sizeof(keybuf) - 1]) { | 847 * setting - underscore, 4 chars of count, 4 chars of salt |
| 893 *q++ = *key << 1; | 848 * key - unlimited characters |
| 894 if (*key) | 849 */ |
| 895 key++; | 850 for (i = 1, count = 0; i < 5; i++) { |
| 896 } | 851 uint32_t value = ascii_to_bin(setting[i]); |
| 897 __des_setkey(keybuf, &ekey); | 852 if (ascii64[value] != setting[i]) |
| 898 | 853 return NULL; |
| 899 if (*setting == _PASSWORD_EFMT1) { | 854 count |= value << (i - 1) * 6; |
| 900 /* | 855 } |
| 901 * "new"-style: | 856 if (!count) |
| 902 * setting - underscore, 4 chars of count, 4 chars of salt | 857 return NULL; |
| 903 * key - unlimited characters | 858 |
| 904 */ | 859 for (i = 5, salt = 0; i < 9; i++) { |
| 905 for (i = 1, count = 0; i < 5; i++) { | 860 uint32_t value = ascii_to_bin(setting[i]); |
| 906 uint32_t value = ascii_to_bin(setting[i]); | 861 if (ascii64[value] != setting[i]) |
| 907 if (ascii64[value] != setting[i]) | 862 return NULL; |
| 908 return NULL; | 863 salt |= value << (i - 5) * 6; |
| 909 count |= value << (i - 1) * 6; | 864 } |
| 910 } | 865 |
| 911 if (!count) | 866 while (*key) { |
| 912 return NULL; | 867 /* |
| 913 | 868 * Encrypt the key with itself. |
| 914 for (i = 5, salt = 0; i < 9; i++) { | 869 */ |
| 915 uint32_t value = ascii_to_bin(setting[i]); | 870 des_cipher(keybuf, keybuf, 1, 0, &ekey); |
| 916 if (ascii64[value] != setting[i]) | 871 /* |
| 917 return NULL; | 872 * And XOR with the next 8 characters of the key. |
| 918 salt |= value << (i - 5) * 6; | 873 */ |
| 919 } | 874 q = keybuf; |
| 920 | 875 while (q <= &keybuf[sizeof(keybuf) - 1] && *key) |
| 921 while (*key) { | 876 *q++ ^= *key++ << 1; |
| 922 /* | 877 __des_setkey(keybuf, &ekey); |
| 923 * Encrypt the key with itself. | 878 } |
| 924 */ | 879 |
| 925 des_cipher(keybuf, keybuf, 1, 0, &ekey); | 880 memcpy(output, setting, 9); |
| 926 /* | 881 output[9] = '\0'; |
| 927 * And XOR with the next 8 characters of the key. | 882 p = (unsigned char*)output + 9; |
| 928 */ | 883 } else { |
| 929 q = keybuf; | 884 /* |
| 930 while (q <= &keybuf[sizeof(keybuf) - 1] && *key) | 885 * "old"-style: |
| 931 *q++ ^= *key++ << 1; | 886 * setting - 2 chars of salt |
| 932 __des_setkey(keybuf, &ekey); | 887 * key - up to 8 characters |
| 933 } | 888 */ |
| 934 | 889 count = 25; |
| 935 memcpy(output, setting, 9); | 890 |
| 936 output[9] = '\0'; | 891 if (ascii_is_unsafe(setting[0]) || ascii_is_unsafe(setting[1])) |
| 937 p = (unsigned char *)output + 9; | 892 return NULL; |
| 938 } else { | 893 |
| 939 /* | 894 salt = (ascii_to_bin(setting[1]) << 6) | ascii_to_bin(setting[0]); |
| 940 * "old"-style: | 895 |
| 941 * setting - 2 chars of salt | 896 output[0] = setting[0]; |
| 942 * key - up to 8 characters | 897 output[1] = setting[1]; |
| 943 */ | 898 p = (unsigned char*)output + 2; |
| 944 count = 25; | 899 } |
| 945 | 900 |
| 946 if (ascii_is_unsafe(setting[0]) || ascii_is_unsafe(setting[1])) | 901 /* |
| 947 return NULL; | 902 * Do it. |
| 948 | 903 */ |
| 949 salt = (ascii_to_bin(setting[1]) << 6) | 904 __do_des(0, 0, &r0, &r1, count, setup_salt(salt), &ekey); |
| 950 | ascii_to_bin(setting[0]); | 905 |
| 951 | 906 /* |
| 952 output[0] = setting[0]; | 907 * Now encode the result... |
| 953 output[1] = setting[1]; | 908 */ |
| 954 p = (unsigned char *)output + 2; | 909 l = (r0 >> 8); |
| 955 } | 910 *p++ = ascii64[(l >> 18) & 0x3f]; |
| 956 | 911 *p++ = ascii64[(l >> 12) & 0x3f]; |
| 957 /* | 912 *p++ = ascii64[(l >> 6) & 0x3f]; |
| 958 * Do it. | 913 *p++ = ascii64[l & 0x3f]; |
| 959 */ | 914 |
| 960 __do_des(0, 0, &r0, &r1, count, setup_salt(salt), &ekey); | 915 l = (r0 << 16) | ((r1 >> 16) & 0xffff); |
| 961 | 916 *p++ = ascii64[(l >> 18) & 0x3f]; |
| 962 /* | 917 *p++ = ascii64[(l >> 12) & 0x3f]; |
| 963 * Now encode the result... | 918 *p++ = ascii64[(l >> 6) & 0x3f]; |
| 964 */ | 919 *p++ = ascii64[l & 0x3f]; |
| 965 l = (r0 >> 8); | 920 |
| 966 *p++ = ascii64[(l >> 18) & 0x3f]; | 921 l = r1 << 2; |
| 967 *p++ = ascii64[(l >> 12) & 0x3f]; | 922 *p++ = ascii64[(l >> 12) & 0x3f]; |
| 968 *p++ = ascii64[(l >> 6) & 0x3f]; | 923 *p++ = ascii64[(l >> 6) & 0x3f]; |
| 969 *p++ = ascii64[l & 0x3f]; | 924 *p++ = ascii64[l & 0x3f]; |
| 970 | 925 *p = 0; |
| 971 l = (r0 << 16) | ((r1 >> 16) & 0xffff); | 926 |
| 972 *p++ = ascii64[(l >> 18) & 0x3f]; | 927 return output; |
| 973 *p++ = ascii64[(l >> 12) & 0x3f]; | 928 } |
| 974 *p++ = ascii64[(l >> 6) & 0x3f]; | 929 |
| 975 *p++ = ascii64[l & 0x3f]; | 930 char* __crypt_des(const char* key, const char* setting, char* output) { |
| 976 | 931 const char* test_key = |
| 977 l = r1 << 2; | 932 "\x80\xff\x80\x01 " |
| 978 *p++ = ascii64[(l >> 12) & 0x3f]; | 933 "\x7f\x81\x80\x80\x0d\x0a\xff\x7f \x81 test"; |
| 979 *p++ = ascii64[(l >> 6) & 0x3f]; | 934 const char* test_setting = "_0.../9Zz"; |
| 980 *p++ = ascii64[l & 0x3f]; | 935 const char* test_hash = "_0.../9ZzX7iSJNd21sU"; |
| 981 *p = 0; | 936 char test_buf[21]; |
| 982 | 937 char* retval; |
| 983 return output; | 938 const char* p; |
| 984 } | 939 |
| 985 | 940 if (*setting != _PASSWORD_EFMT1) { |
| 986 char *__crypt_des(const char *key, const char *setting, char *output) | 941 test_setting = "\x80x"; |
| 987 { | 942 test_hash = "\x80x22/wK52ZKGA"; |
| 988 const char *test_key = "\x80\xff\x80\x01 " | 943 } |
| 989 "\x7f\x81\x80\x80\x0d\x0a\xff\x7f \x81 test"; | 944 |
| 990 const char *test_setting = "_0.../9Zz"; | 945 /* |
| 991 const char *test_hash = "_0.../9ZzX7iSJNd21sU"; | 946 * Hash the supplied password. |
| 992 char test_buf[21]; | 947 */ |
| 993 char *retval; | 948 retval = _crypt_extended_r_uut(key, setting, output); |
| 994 const char *p; | 949 |
| 995 | 950 /* |
| 996 if (*setting != _PASSWORD_EFMT1) { | 951 * Perform a quick self-test. It is important that we make both calls |
| 997 test_setting = "\x80x"; | 952 * to _crypt_extended_r_uut() from the same scope such that they likely |
| 998 test_hash = "\x80x22/wK52ZKGA"; | 953 * use the same stack locations, which makes the second call overwrite |
| 999 } | 954 * the first call's sensitive data on the stack and makes it more |
| 1000 | 955 * likely that any alignment related issues would be detected. |
| 1001 /* | 956 */ |
| 1002 * Hash the supplied password. | 957 p = _crypt_extended_r_uut(test_key, test_setting, test_buf); |
| 1003 */ | 958 if (p && !strcmp(p, test_hash) && retval) |
| 1004 retval = _crypt_extended_r_uut(key, setting, output); | 959 return retval; |
| 1005 | 960 |
| 1006 /* | 961 return (setting[0] == '*') ? "x" : "*"; |
| 1007 * Perform a quick self-test. It is important that we make both calls | 962 } |
| 1008 * to _crypt_extended_r_uut() from the same scope such that they likely | |
| 1009 * use the same stack locations, which makes the second call overwrite | |
| 1010 * the first call's sensitive data on the stack and makes it more | |
| 1011 * likely that any alignment related issues would be detected. | |
| 1012 */ | |
| 1013 p = _crypt_extended_r_uut(test_key, test_setting, test_buf); | |
| 1014 if (p && !strcmp(p, test_hash) && retval) | |
| 1015 return retval; | |
| 1016 | |
| 1017 return (setting[0]=='*') ? "x" : "*"; | |
| 1018 } | |
| OLD | NEW |