jdk/src/share/classes/com/sun/crypto/provider/DESCrypt.java
author valeriep
Tue, 08 May 2012 17:57:48 -0700
changeset 12685 8a448b5b9006
parent 10336 0bb1999251f8
permissions -rw-r--r--
4963723: Implement SHA-224 Summary: Add support for SHA-224, SHA224withRSA, SHA224withECDSA, HmacSHA224 and OAEPwithSHA-224AndMGF1Padding. Reviewed-by: vinnie
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.crypto.provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.InvalidKeyException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This is the internal DES class responsible for encryption and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * decryption of a byte array of size <code>DES_BLOCK_SIZE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @author Gigi Ankeny
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author Jan Luehe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @see DESConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @see DESCipher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
class DESCrypt extends SymmetricCipher implements DESConstants {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static final int s0p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        0x00410100, 0x00010000, 0x40400000, 0x40410100, 0x00400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        0x40010100, 0x40010000, 0x40400000, 0x40010100, 0x00410100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        0x00410000, 0x40000100, 0x40400100, 0x00400000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        0x40010000, 0x00010000, 0x40000000, 0x00400100, 0x00010100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        0x40410100, 0x00410000, 0x40000100, 0x00400100, 0x40000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        0x00000100, 0x00010100, 0x40410000, 0x00000100, 0x40400100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        0x40410000, 0x00000000, 0x00000000, 0x40410100, 0x00400100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        0x40010000, 0x00410100, 0x00010000, 0x40000100, 0x00400100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        0x40410000, 0x00000100, 0x00010100, 0x40400000, 0x40010100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        0x40000000, 0x40400000, 0x00410000, 0x40410100, 0x00010100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        0x00410000, 0x40400100, 0x00400000, 0x40000100, 0x40010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        0x00000000, 0x00010000, 0x00400000, 0x40400100, 0x00410100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        0x40000000, 0x40410000, 0x00000100, 0x40010100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static final int s1p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        0x08021002, 0x00000000, 0x00021000, 0x08020000, 0x08000002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        0x00001002, 0x08001000, 0x00021000, 0x00001000, 0x08020002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        0x00000002, 0x08001000, 0x00020002, 0x08021000, 0x08020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        0x00000002, 0x00020000, 0x08001002, 0x08020002, 0x00001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        0x00021002, 0x08000000, 0x00000000, 0x00020002, 0x08001002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        0x00021002, 0x08021000, 0x08000002, 0x08000000, 0x00020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        0x00001002, 0x08021002, 0x00020002, 0x08021000, 0x08001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        0x00021002, 0x08021002, 0x00020002, 0x08000002, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        0x08000000, 0x00001002, 0x00020000, 0x08020002, 0x00001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        0x08000000, 0x00021002, 0x08001002, 0x08021000, 0x00001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        0x00000000, 0x08000002, 0x00000002, 0x08021002, 0x00021000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        0x08020000, 0x08020002, 0x00020000, 0x00001002, 0x08001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        0x08001002, 0x00000002, 0x08020000, 0x00021000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private static final int s2p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        0x20800000, 0x00808020, 0x00000020, 0x20800020, 0x20008000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        0x00800000, 0x20800020, 0x00008020, 0x00800020, 0x00008000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        0x00808000, 0x20000000, 0x20808020, 0x20000020, 0x20000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        0x20808000, 0x00000000, 0x20008000, 0x00808020, 0x00000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        0x20000020, 0x20808020, 0x00008000, 0x20800000, 0x20808000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        0x00800020, 0x20008020, 0x00808000, 0x00008020, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        0x00800000, 0x20008020, 0x00808020, 0x00000020, 0x20000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        0x00008000, 0x20000020, 0x20008000, 0x00808000, 0x20800020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        0x00000000, 0x00808020, 0x00008020, 0x20808000, 0x20008000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        0x00800000, 0x20808020, 0x20000000, 0x20008020, 0x20800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        0x00800000, 0x20808020, 0x00008000, 0x00800020, 0x20800020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        0x00008020, 0x00800020, 0x00000000, 0x20808000, 0x20000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        0x20800000, 0x20008020, 0x00000020, 0x00808000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static final int s3p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        0x00080201, 0x02000200, 0x00000001, 0x02080201, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        0x02080000, 0x02000201, 0x00080001, 0x02080200, 0x02000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        0x02000000, 0x00000201, 0x02000001, 0x00080201, 0x00080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        0x02000000, 0x02080001, 0x00080200, 0x00000200, 0x00000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        0x00080200, 0x02000201, 0x02080000, 0x00000200, 0x00000201,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        0x00000000, 0x00080001, 0x02080200, 0x02000200, 0x02080001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        0x02080201, 0x00080000, 0x02080001, 0x00000201, 0x00080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        0x02000001, 0x00080200, 0x02000200, 0x00000001, 0x02080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        0x02000201, 0x00000000, 0x00000200, 0x00080001, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        0x02080001, 0x02080200, 0x00000200, 0x02000000, 0x02080201,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        0x00080201, 0x00080000, 0x02080201, 0x00000001, 0x02000200,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        0x00080201, 0x00080001, 0x00080200, 0x02080000, 0x02000201,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        0x00000201, 0x02000000, 0x02000001, 0x02080200,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private static final int s4p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        0x01000000, 0x00002000, 0x00000080, 0x01002084, 0x01002004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        0x01000080, 0x00002084, 0x01002000, 0x00002000, 0x00000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        0x01000004, 0x00002080, 0x01000084, 0x01002004, 0x01002080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        0x00000000, 0x00002080, 0x01000000, 0x00002004, 0x00000084,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        0x01000080, 0x00002084, 0x00000000, 0x01000004, 0x00000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        0x01000084, 0x01002084, 0x00002004, 0x01002000, 0x00000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        0x00000084, 0x01002080, 0x01002080, 0x01000084, 0x00002004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        0x01002000, 0x00002000, 0x00000004, 0x01000004, 0x01000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        0x01000000, 0x00002080, 0x01002084, 0x00000000, 0x00002084,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        0x01000000, 0x00000080, 0x00002004, 0x01000084, 0x00000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        0x00000000, 0x01002084, 0x01002004, 0x01002080, 0x00000084,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        0x00002000, 0x00002080, 0x01002004, 0x01000080, 0x00000084,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        0x00000004, 0x00002084, 0x01002000, 0x01000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private static final int s5p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        0x10000008, 0x00040008, 0x00000000, 0x10040400, 0x00040008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        0x00000400, 0x10000408, 0x00040000, 0x00000408, 0x10040408,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        0x00040400, 0x10000000, 0x10000400, 0x10000008, 0x10040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        0x00040408, 0x00040000, 0x10000408, 0x10040008, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        0x00000400, 0x00000008, 0x10040400, 0x10040008, 0x10040408,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        0x10040000, 0x10000000, 0x00000408, 0x00000008, 0x00040400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        0x00040408, 0x10000400, 0x00000408, 0x10000000, 0x10000400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        0x00040408, 0x10040400, 0x00040008, 0x00000000, 0x10000400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        0x10000000, 0x00000400, 0x10040008, 0x00040000, 0x00040008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        0x10040408, 0x00040400, 0x00000008, 0x10040408, 0x00040400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        0x00040000, 0x10000408, 0x10000008, 0x10040000, 0x00040408,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        0x00000000, 0x00000400, 0x10000008, 0x10000408, 0x10040400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        0x10040000, 0x00000408, 0x00000008, 0x10040008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static final int s6p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        0x00000800, 0x00000040, 0x00200040, 0x80200000, 0x80200840,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        0x80000800, 0x00000840, 0x00000000, 0x00200000, 0x80200040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        0x80000040, 0x00200800, 0x80000000, 0x00200840, 0x00200800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        0x80000040, 0x80200040, 0x00000800, 0x80000800, 0x80200840,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        0x00000000, 0x00200040, 0x80200000, 0x00000840, 0x80200800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        0x80000840, 0x00200840, 0x80000000, 0x80000840, 0x80200800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        0x00000040, 0x00200000, 0x80000840, 0x00200800, 0x80200800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        0x80000040, 0x00000800, 0x00000040, 0x00200000, 0x80200800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        0x80200040, 0x80000840, 0x00000840, 0x00000000, 0x00000040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        0x80200000, 0x80000000, 0x00200040, 0x00000000, 0x80200040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        0x00200040, 0x00000840, 0x80000040, 0x00000800, 0x80200840,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        0x00200000, 0x00200840, 0x80000000, 0x80000800, 0x80200840,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        0x80200000, 0x00200840, 0x00200800, 0x80000800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    private static final int s7p[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        0x04100010, 0x04104000, 0x00004010, 0x00000000, 0x04004000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        0x00100010, 0x04100000, 0x04104010, 0x00000010, 0x04000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        0x00104000, 0x00004010, 0x00104010, 0x04004010, 0x04000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        0x04100000, 0x00004000, 0x00104010, 0x00100010, 0x04004000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        0x04104010, 0x04000010, 0x00000000, 0x00104000, 0x04000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        0x00100000, 0x04004010, 0x04100010, 0x00100000, 0x00004000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        0x04104000, 0x00000010, 0x00100000, 0x00004000, 0x04000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        0x04104010, 0x00004010, 0x04000000, 0x00000000, 0x00104000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        0x04100010, 0x04004010, 0x04004000, 0x00100010, 0x04104000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        0x00000010, 0x00100010, 0x04004000, 0x04104010, 0x00100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        0x04100000, 0x04000010, 0x00104000, 0x00004010, 0x04004010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        0x04100000, 0x00000010, 0x04104000, 0x00104010, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        0x04000000, 0x04100010, 0x00004000, 0x00104010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    private static final int permRight0[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00004000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        0x40004000, 0x00404000, 0x40404000, 0x00000040, 0x40000040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        0x00400040, 0x40400040, 0x00004040, 0x40004040, 0x00404040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        0x40404040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    private static final int permLeft1[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00004000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        0x40004000, 0x00404000, 0x40404000, 0x00000040, 0x40000040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        0x00400040, 0x40400040, 0x00004040, 0x40004040, 0x00404040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        0x40404040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    private static final int permRight2[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        0x10001000, 0x00101000, 0x10101000, 0x00000010, 0x10000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        0x00100010, 0x10100010, 0x00001010, 0x10001010, 0x00101010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        0x10101010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    private static final int permLeft3[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        0x10001000, 0x00101000, 0x10101000, 0x00000010, 0x10000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        0x00100010, 0x10100010, 0x00001010, 0x10001010, 0x00101010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        0x10101010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private static final int permRight4[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        0x04000400, 0x00040400, 0x04040400, 0x00000004, 0x04000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        0x00040004, 0x04040004, 0x00000404, 0x04000404, 0x00040404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        0x04040404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    private static final int permLeft5[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        0x04000400, 0x00040400, 0x04040400, 0x00000004, 0x04000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        0x00040004, 0x04040004, 0x00000404, 0x04000404, 0x00040404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        0x04040404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    private static final int permRight6[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        0x01000100, 0x00010100, 0x01010100, 0x00000001, 0x01000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        0x00010001, 0x01010001, 0x00000101, 0x01000101, 0x00010101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        0x01010101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    private static final int permLeft7[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        0x01000100, 0x00010100, 0x01010100, 0x00000001, 0x01000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        0x00010001, 0x01010001, 0x00000101, 0x01000101, 0x00010101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        0x01010101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    private static final int permRight8[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00008000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        0x80008000, 0x00808000, 0x80808000, 0x00000080, 0x80000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        0x00800080, 0x80800080, 0x00008080, 0x80008080, 0x00808080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        0x80808080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private static final int permLeft9[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00008000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        0x80008000, 0x00808000, 0x80808000, 0x00000080, 0x80000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        0x00800080, 0x80800080, 0x00008080, 0x80008080, 0x00808080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        0x80808080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    private static final int permRightA[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00002000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        0x20002000, 0x00202000, 0x20202000, 0x00000020, 0x20000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        0x00200020, 0x20200020, 0x00002020, 0x20002020, 0x00202020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        0x20202020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    private static final int permLeftB[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00002000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        0x20002000, 0x00202000, 0x20202000, 0x00000020, 0x20000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        0x00200020, 0x20200020, 0x00002020, 0x20002020, 0x00202020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        0x20202020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    private static final int permRightC[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00000800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        0x08000800, 0x00080800, 0x08080800, 0x00000008, 0x08000008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        0x00080008, 0x08080008, 0x00000808, 0x08000808, 0x00080808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        0x08080808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    private static final int permLeftD[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00000800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        0x08000800, 0x00080800, 0x08080800, 0x00000008, 0x08000008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        0x00080008, 0x08080008, 0x00000808, 0x08000808, 0x00080808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        0x08080808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    private static final int permRightE[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00000200,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        0x02000200, 0x00020200, 0x02020200, 0x00000002, 0x02000002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        0x00020002, 0x02020002, 0x00000202, 0x02000202, 0x00020202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        0x02020202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    private static final int permLeftF[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00000200,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        0x02000200, 0x00020200, 0x02020200, 0x00000002, 0x02000002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        0x00020002, 0x02020002, 0x00000202, 0x02000202, 0x00020202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        0x02020202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *        Initial Permutation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    private static final int initPermLeft0[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
       0x00000000, 0x00008000, 0x00000000, 0x00008000, 0x00000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
       0x00008080, 0x00000080, 0x00008080, 0x00000000, 0x00008000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
       0x00000000, 0x00008000, 0x00000080, 0x00008080, 0x00000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
       0x00008080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    private static final int initPermRight0[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
       0x00000000, 0x00000000, 0x00008000, 0x00008000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
       0x00000000, 0x00008000, 0x00008000, 0x00000080, 0x00000080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
       0x00008080, 0x00008080, 0x00000080, 0x00000080, 0x00008080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
       0x00008080,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    private static final int initPermLeft1[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
       0x00000000, 0x80000000, 0x00000000, 0x80000000, 0x00800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
       0x80800000, 0x00800000, 0x80800000, 0x00000000, 0x80000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
       0x00000000, 0x80000000, 0x00800000, 0x80800000, 0x00800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
       0x80800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    private static final int initPermRight1[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
       0x00000000, 0x00000000, 0x80000000, 0x80000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
       0x00000000, 0x80000000, 0x80000000, 0x00800000, 0x00800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
       0x80800000, 0x80800000, 0x00800000, 0x00800000, 0x80800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
       0x80800000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    private static final int initPermLeft2[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
       0x00000000, 0x00004000, 0x00000000, 0x00004000, 0x00000040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
       0x00004040, 0x00000040, 0x00004040, 0x00000000, 0x00004000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
       0x00000000, 0x00004000, 0x00000040, 0x00004040, 0x00000040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
       0x00004040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    private static final int initPermRight2[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
       0x00000000, 0x00000000, 0x00004000, 0x00004000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
       0x00000000, 0x00004000, 0x00004000, 0x00000040, 0x00000040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
       0x00004040, 0x00004040, 0x00000040, 0x00000040, 0x00004040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
       0x00004040,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    private static final int initPermLeft3[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
       0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
       0x40400000, 0x00400000, 0x40400000, 0x00000000, 0x40000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
       0x00000000, 0x40000000, 0x00400000, 0x40400000, 0x00400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
       0x40400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    private static final int initPermRight3[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
       0x00000000, 0x00000000, 0x40000000, 0x40000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
       0x00000000, 0x40000000, 0x40000000, 0x00400000, 0x00400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
       0x40400000, 0x40400000, 0x00400000, 0x00400000, 0x40400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
       0x40400000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    private static final int initPermLeft4[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
       0x00000000, 0x00002000, 0x00000000, 0x00002000, 0x00000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
       0x00002020, 0x00000020, 0x00002020, 0x00000000, 0x00002000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
       0x00000000, 0x00002000, 0x00000020, 0x00002020, 0x00000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
       0x00002020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    private static final int initPermRight4[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
       0x00000000, 0x00000000, 0x00002000, 0x00002000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
       0x00000000, 0x00002000, 0x00002000, 0x00000020, 0x00000020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
       0x00002020, 0x00002020, 0x00000020, 0x00000020, 0x00002020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
       0x00002020,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    private static final int initPermLeft5[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
       0x00000000, 0x20000000, 0x00000000, 0x20000000, 0x00200000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
       0x20200000, 0x00200000, 0x20200000, 0x00000000, 0x20000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
       0x00000000, 0x20000000, 0x00200000, 0x20200000, 0x00200000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
       0x20200000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    private static final int initPermRight5[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
       0x00000000, 0x00000000, 0x20000000, 0x20000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
       0x00000000, 0x20000000, 0x20000000, 0x00200000, 0x00200000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
       0x20200000, 0x20200000, 0x00200000, 0x00200000, 0x20200000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
       0x20200000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    private static final int initPermLeft6[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
       0x00000000, 0x00001000, 0x00000000, 0x00001000, 0x00000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
       0x00001010, 0x00000010, 0x00001010, 0x00000000, 0x00001000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
       0x00000000, 0x00001000, 0x00000010, 0x00001010, 0x00000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
       0x00001010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    private static final int initPermRight6[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
       0x00000000, 0x00000000, 0x00001000, 0x00001000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
       0x00000000, 0x00001000, 0x00001000, 0x00000010, 0x00000010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
       0x00001010, 0x00001010, 0x00000010, 0x00000010, 0x00001010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
       0x00001010,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    private static final int initPermLeft7[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
       0x00000000, 0x10000000, 0x00000000, 0x10000000, 0x00100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
       0x10100000, 0x00100000, 0x10100000, 0x00000000, 0x10000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
       0x00000000, 0x10000000, 0x00100000, 0x10100000, 0x00100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
       0x10100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    private static final int initPermRight7[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
       0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
       0x00000000, 0x10000000, 0x10000000, 0x00100000, 0x00100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
       0x10100000, 0x10100000, 0x00100000, 0x00100000, 0x10100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
       0x10100000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    private static final int initPermLeft8[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
       0x00000000, 0x00000800, 0x00000000, 0x00000800, 0x00000008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
       0x00000808, 0x00000008, 0x00000808, 0x00000000, 0x00000800,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
       0x00000000, 0x00000800, 0x00000008, 0x00000808, 0x00000008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
       0x00000808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    private static final int initPermRight8[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
       0x00000000, 0x00000000, 0x00000800, 0x00000800, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
       0x00000000, 0x00000800, 0x00000800, 0x00000008, 0x00000008,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
       0x00000808, 0x00000808, 0x00000008, 0x00000008, 0x00000808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
       0x00000808,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    private static final int initPermLeft9[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
       0x00000000, 0x08000000, 0x00000000, 0x08000000, 0x00080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
       0x08080000, 0x00080000, 0x08080000, 0x00000000, 0x08000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
       0x00000000, 0x08000000, 0x00080000, 0x08080000, 0x00080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
       0x08080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    private static final int initPermRight9[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
       0x00000000, 0x00000000, 0x08000000, 0x08000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
       0x00000000, 0x08000000, 0x08000000, 0x00080000, 0x00080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
       0x08080000, 0x08080000, 0x00080000, 0x00080000, 0x08080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
       0x08080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    private static final int initPermLeftA[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
       0x00000000, 0x00000400, 0x00000000, 0x00000400, 0x00000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
       0x00000404, 0x00000004, 0x00000404, 0x00000000, 0x00000400,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
       0x00000000, 0x00000400, 0x00000004, 0x00000404, 0x00000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
       0x00000404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    private static final int initPermRightA[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
       0x00000000, 0x00000000, 0x00000400, 0x00000400, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
       0x00000000, 0x00000400, 0x00000400, 0x00000004, 0x00000004,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
       0x00000404, 0x00000404, 0x00000004, 0x00000004, 0x00000404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
       0x00000404,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    private static final int initPermLeftB[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
       0x00000000, 0x04000000, 0x00000000, 0x04000000, 0x00040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
       0x04040000, 0x00040000, 0x04040000, 0x00000000, 0x04000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
       0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
       0x04040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    private static final int initPermRightB[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
       0x00000000, 0x00000000, 0x04000000, 0x04000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
       0x00000000, 0x04000000, 0x04000000, 0x00040000, 0x00040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
       0x04040000, 0x04040000, 0x00040000, 0x00040000, 0x04040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
       0x04040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    private static final int initPermLeftC[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
       0x00000000, 0x00000200, 0x00000000, 0x00000200, 0x00000002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
       0x00000202, 0x00000002, 0x00000202, 0x00000000, 0x00000200,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
       0x00000000, 0x00000200, 0x00000002, 0x00000202, 0x00000002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
       0x00000202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    private static final int initPermRightC[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
       0x00000000, 0x00000000, 0x00000200, 0x00000200, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
       0x00000000, 0x00000200, 0x00000200, 0x00000002, 0x00000002,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
       0x00000202, 0x00000202, 0x00000002, 0x00000002, 0x00000202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
       0x00000202,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    private static final int initPermLeftD[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
       0x00000000, 0x02000000, 0x00000000, 0x02000000, 0x00020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
       0x02020000, 0x00020000, 0x02020000, 0x00000000, 0x02000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
       0x00000000, 0x02000000, 0x00020000, 0x02020000, 0x00020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
       0x02020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    private static final int initPermRightD[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
       0x00000000, 0x00000000, 0x02000000, 0x02000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
       0x00000000, 0x02000000, 0x02000000, 0x00020000, 0x00020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
       0x02020000, 0x02020000, 0x00020000, 0x00020000, 0x02020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
       0x02020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    private static final int initPermLeftE[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
       0x00000000, 0x00000100, 0x00000000, 0x00000100, 0x00000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
       0x00000101, 0x00000001, 0x00000101, 0x00000000, 0x00000100,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
       0x00000000, 0x00000100, 0x00000001, 0x00000101, 0x00000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
       0x00000101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    private static final int initPermRightE[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
       0x00000000, 0x00000000, 0x00000100, 0x00000100, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
       0x00000000, 0x00000100, 0x00000100, 0x00000001, 0x00000001,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
       0x00000101, 0x00000101, 0x00000001, 0x00000001, 0x00000101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
       0x00000101,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    private static final int initPermLeftF[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
       0x00000000, 0x01000000, 0x00000000, 0x01000000, 0x00010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
       0x01010000, 0x00010000, 0x01010000, 0x00000000, 0x01000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
       0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
       0x01010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    private static final int initPermRightF[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
       0x00000000, 0x00000000, 0x01000000, 0x01000000, 0x00000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
       0x00000000, 0x01000000, 0x01000000, 0x00010000, 0x00010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
       0x01010000, 0x01010000, 0x00010000, 0x00010000, 0x01010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
       0x01010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * the encryption key array after expansion and permutation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    byte[] expandedKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * Are we encrypting or decrypting?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    boolean decrypting = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * Returns this cipher's block size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * @return this cipher's block size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    int getBlockSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        return DES_BLOCK_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    void init(boolean decrypting, String algorithm, byte[] rawKey)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        this.decrypting = decrypting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        if (!algorithm.equalsIgnoreCase("DES")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            throw new InvalidKeyException("Wrong algorithm: DES required");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        if (rawKey.length != DES_BLOCK_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            throw new InvalidKeyException("Wrong key size");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        expandKey(rawKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * Performs encryption operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * <p>The input plain text <code>plain</code>, starting at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * <code>plainOffset</code> and ending at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * <code>(plainOffset + len - 1)</code>, is encrypted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * The result is stored in <code>cipher</code>, starting at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * <code>cipherOffset</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * <p>The subclass that implements Cipher should ensure that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * <code>init</code> has been called before this method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @param plain the buffer with the input data to be encrypted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @param plainOffset the offset in <code>plain</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @param plainLen the length of the input data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @param cipher the buffer for the result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @param cipherOffset the offset in <code>cipher</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @exception IllegalBlockSizeException if the input length is different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * from the cipher's block size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    void encryptBlock(byte[] plain, int plainOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                 byte[] cipher, int cipherOffset)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        cipherBlock(plain, plainOffset, cipher, cipherOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * Performs decryption operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * <p>The input cipher text <code>cipher</code>, starting at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * <code>cipherOffset</code> and ending at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * <code>(cipherOffset + len - 1)</code>, is decrypted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * The result is stored in <code>plain</code>, starting at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * <code>plainOffset</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * <p>The subclass that implements Cipher should ensure that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * <code>init</code> has been called before this method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @param cipher the buffer with the input data to be decrypted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @param cipherOffset the offset in <code>cipherOffset</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * @param cipherLen the length of the input data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * @param plain the buffer for the result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * @param plainOffset the offset in <code>plain</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * @exception IllegalBlockSizeException if the input length is different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * from the cipher's block size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    void decryptBlock(byte[] cipher, int cipherOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                 byte[] plain, int plainOffset)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        cipherBlock(cipher, cipherOffset, plain, plainOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    void cipherBlock(byte[] in, int inOffset, byte[] out, int outOffset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        byte key[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        int temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        int i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        int left, right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        left = initialPermutationLeft(in, inOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        right = initialPermutationRight(in, inOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        key = expandedKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        if (decrypting) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            offset = 16 - DES_BLOCK_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            j = 128 - DES_BLOCK_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            offset = 0 - DES_BLOCK_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            j = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        for (i = 0; i < 16; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            // make the first and last bit adjacent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            // move the first bit to the last
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            temp = (right << 1) | ((right >> 31) & 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            // mangler function:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            // every 6 bit is fed into the sbox, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            // produces 4-bit output
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   625
            left ^= s0p[(temp & 0x3f) ^ key[j+0]]
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   626
                ^ s1p[((temp >>  4) & 0x3f) ^ key[j+1]]
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   627
                ^ s2p[((temp >>  8) & 0x3f) ^ key[j+2]]
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   628
                ^ s3p[((temp >> 12) & 0x3f) ^ key[j+3]]
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   629
                ^ s4p[((temp >> 16) & 0x3f) ^ key[j+4]]
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   630
                ^ s5p[((temp >> 20) & 0x3f) ^ key[j+5]]
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   631
                ^ s6p[((temp >> 24) & 0x3f) ^ key[j+6]];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            // make the last sbox input the last bit from right[0]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            temp = ((right & 1) << 5) | ((right >> 27) & 0x1f);
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   635
            left ^= s7p[temp ^ key[j+7]];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            temp = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            left = right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            right = temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            j -= offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        temp = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        left = right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        right = temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        perm(left, right, out, outOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    private static void perm(int left, int right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                             byte out[], int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        int low, high, temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        temp = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        high = permRight0[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        low  = permLeft1[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        high |= permRight2[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        low  |= permLeft3[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        high |= permRight4[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        low  |= permLeft5[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        high |= permRight6[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        low  |= permLeft7[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        temp = right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        high |= permRight8[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        low  |= permLeft9[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        high |= permRightA[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        low  |= permLeftB[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        high |= permRightC[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        low  |= permLeftD[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        high |= permRightE[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        temp >>= 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        low  |= permLeftF[temp & 0x0000000f];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        out[offset + 0] = (byte)low;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        out[offset + 1] = (byte)(low >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        out[offset + 2] = (byte)(low >> 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        out[offset + 3] = (byte)(low >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        out[offset + 4] = (byte)high;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        out[offset + 5] = (byte)(high >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        out[offset + 6] = (byte)(high >> 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        out[offset + 7] = (byte)(high >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    private static int initialPermutationLeft(byte block[], int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        int l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        l  = initPermLeft1[block[offset] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        l |= initPermLeft0[(block[offset] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        l |= initPermLeft3[block[offset + 1] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        l |= initPermLeft2[(block[offset + 1] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        l |= initPermLeft5[block[offset + 2] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        l |= initPermLeft4[(block[offset + 2] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        l |= initPermLeft7[block[offset + 3] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        l |= initPermLeft6[(block[offset + 3] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        l |= initPermLeft9[block[offset + 4] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        l |= initPermLeft8[(block[offset + 4] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        l |= initPermLeftB[block[offset + 5] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        l |= initPermLeftA[(block[offset + 5] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        l |= initPermLeftD[block[offset + 6] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        l |= initPermLeftC[(block[offset + 6] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        l |= initPermLeftF[block[offset + 7] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        l |= initPermLeftE[(block[offset + 7] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        return l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    private static int initialPermutationRight(byte block[], int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        int l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        l  = initPermRight1[block[offset] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        l |= initPermRight0[(block[offset] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        l |= initPermRight3[block[offset + 1] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        l |= initPermRight2[(block[offset + 1] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        l |= initPermRight5[block[offset + 2] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        l |= initPermRight4[(block[offset + 2] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        l |= initPermRight7[block[offset + 3] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        l |= initPermRight6[(block[offset + 3] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        l |= initPermRight9[block[offset + 4] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        l |= initPermRight8[(block[offset + 4] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        l |= initPermRightB[block[offset + 5] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        l |= initPermRightA[(block[offset + 5] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        l |= initPermRightD[block[offset + 6] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        l |= initPermRightC[(block[offset + 6] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        l |= initPermRightF[block[offset + 7] & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        l |= initPermRightE[(block[offset + 7] >> 4) & 0xf];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        return l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    void expandKey(byte key[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        int octet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        byte ek[] = new byte[128];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        octet = key[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            ek[  3] |=  2; ek[  9] |=  8; ek[ 18] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            ek[ 27] |= 32; ek[ 33] |=  2; ek[ 42] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            ek[ 48] |=  8; ek[ 65] |= 16; ek[ 74] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            ek[ 80] |=  2; ek[ 89] |=  4; ek[ 99] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            ek[104] |=  4; ek[122] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            ek[  1] |=  4; ek[  8] |=  1; ek[ 18] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            ek[ 25] |= 32; ek[ 34] |= 32; ek[ 41] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            ek[ 50] |=  8; ek[ 59] |= 32; ek[ 64] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            ek[ 75] |=  4; ek[ 90] |=  1; ek[ 97] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            ek[106] |=  2; ek[112] |=  2; ek[123] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            ek[  2] |=  1; ek[ 19] |=  8; ek[ 35] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            ek[ 40] |=  1; ek[ 50] |=  4; ek[ 57] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            ek[ 75] |=  2; ek[ 80] |= 32; ek[ 89] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            ek[ 96] |= 16; ek[107] |=  4; ek[120] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            ek[  4] |= 32; ek[ 20] |=  2; ek[ 31] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            ek[ 37] |= 32; ek[ 47] |=  1; ek[ 54] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            ek[ 63] |=  2; ek[ 68] |=  1; ek[ 78] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            ek[ 84] |=  8; ek[101] |= 16; ek[108] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            ek[119] |= 16; ek[126] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            ek[  5] |=  4; ek[ 15] |=  4; ek[ 21] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            ek[ 31] |=  1; ek[ 38] |=  1; ek[ 47] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            ek[ 53] |=  2; ek[ 68] |=  8; ek[ 85] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            ek[ 92] |=  4; ek[103] |= 16; ek[108] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            ek[118] |= 32; ek[124] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            ek[ 15] |=  2; ek[ 21] |=  2; ek[ 39] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            ek[ 46] |= 16; ek[ 55] |= 32; ek[ 61] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            ek[ 71] |= 16; ek[ 76] |= 32; ek[ 86] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            ek[ 93] |=  4; ek[102] |=  2; ek[108] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            ek[117] |=  8; ek[126] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            ek[ 14] |= 16; ek[ 23] |= 32; ek[ 29] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            ek[ 38] |=  8; ek[ 52] |=  2; ek[ 63] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            ek[ 70] |=  2; ek[ 76] |= 16; ek[ 85] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            ek[100] |=  1; ek[110] |=  4; ek[116] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
            ek[127] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        octet = key[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            ek[  1] |=  8; ek[  8] |= 32; ek[ 17] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            ek[ 24] |= 16; ek[ 35] |=  4; ek[ 50] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            ek[ 57] |= 16; ek[ 67] |=  8; ek[ 83] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            ek[ 88] |=  1; ek[ 98] |=  4; ek[105] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            ek[114] |= 32; ek[123] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            ek[  0] |=  1; ek[ 11] |= 16; ek[ 16] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            ek[ 35] |=  2; ek[ 40] |= 32; ek[ 49] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            ek[ 56] |= 16; ek[ 65] |=  2; ek[ 74] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            ek[ 80] |=  8; ek[ 99] |=  8; ek[115] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            ek[121] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            ek[  9] |= 16; ek[ 18] |=  2; ek[ 24] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            ek[ 33] |=  4; ek[ 43] |= 16; ek[ 48] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            ek[ 66] |= 32; ek[ 73] |=  8; ek[ 82] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            ek[ 91] |= 32; ek[ 97] |=  2; ek[106] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            ek[112] |=  8; ek[122] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            ek[ 14] |= 32; ek[ 21] |=  4; ek[ 30] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            ek[ 36] |= 16; ek[ 45] |=  8; ek[ 60] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            ek[ 69] |=  2; ek[ 87] |=  8; ek[ 94] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            ek[103] |= 32; ek[109] |=  1; ek[118] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            ek[124] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            ek[  7] |=  4; ek[ 14] |=  2; ek[ 20] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            ek[ 29] |=  8; ek[ 44] |=  1; ek[ 54] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            ek[ 60] |=  8; ek[ 71] |=  8; ek[ 78] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            ek[ 87] |= 32; ek[ 93] |=  1; ek[102] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            ek[116] |=  2; ek[125] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            ek[  7] |=  2; ek[ 12] |=  1; ek[ 22] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            ek[ 28] |=  8; ek[ 45] |= 16; ek[ 52] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            ek[ 63] |= 16; ek[ 70] |=  8; ek[ 84] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            ek[ 95] |=  4; ek[101] |= 32; ek[111] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            ek[118] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            ek[  6] |= 16; ek[ 13] |= 16; ek[ 20] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            ek[ 31] |= 16; ek[ 36] |= 32; ek[ 46] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            ek[ 53] |=  4; ek[ 62] |=  2; ek[ 69] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            ek[ 79] |=  1; ek[ 86] |=  1; ek[ 95] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            ek[101] |=  2; ek[119] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        octet = key[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            ek[  0] |= 32; ek[ 10] |=  8; ek[ 19] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            ek[ 25] |=  2; ek[ 34] |= 16; ek[ 40] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            ek[ 59] |=  8; ek[ 66] |=  2; ek[ 72] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            ek[ 81] |=  4; ek[ 91] |= 16; ek[ 96] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            ek[115] |=  2; ek[121] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            ek[  3] |= 16; ek[ 10] |=  4; ek[ 17] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            ek[ 26] |= 32; ek[ 33] |=  8; ek[ 42] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            ek[ 51] |= 32; ek[ 57] |=  2; ek[ 67] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            ek[ 82] |=  1; ek[ 89] |= 16; ek[ 98] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            ek[104] |=  2; ek[113] |=  4; ek[120] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            ek[  1] |= 16; ek[ 11] |=  8; ek[ 27] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            ek[ 32] |=  1; ek[ 42] |=  4; ek[ 49] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            ek[ 58] |= 32; ek[ 67] |=  2; ek[ 72] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
            ek[ 81] |=  1; ek[ 88] |= 16; ek[ 99] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            ek[114] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            ek[  6] |= 32; ek[ 12] |=  2; ek[ 23] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            ek[ 29] |= 32; ek[ 39] |=  1; ek[ 46] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            ek[ 55] |=  2; ek[ 61] |=  2; ek[ 70] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            ek[ 76] |=  8; ek[ 93] |= 16; ek[100] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
            ek[111] |= 16; ek[116] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            ek[  6] |=  2; ek[ 13] |= 32; ek[ 23] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            ek[ 30] |=  1; ek[ 39] |=  2; ek[ 45] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            ek[ 63] |=  8; ek[ 77] |= 16; ek[ 84] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            ek[ 95] |= 16; ek[100] |= 32; ek[110] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            ek[117] |=  4; ek[127] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            ek[  4] |=  1; ek[ 13] |=  2; ek[ 31] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            ek[ 38] |= 16; ek[ 47] |= 32; ek[ 53] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            ek[ 62] |=  8; ek[ 68] |= 32; ek[ 78] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            ek[ 85] |=  4; ek[ 94] |=  2; ek[100] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            ek[109] |=  8; ek[127] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            ek[  5] |= 16; ek[ 15] |= 32; ek[ 21] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            ek[ 30] |=  8; ek[ 44] |=  2; ek[ 55] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            ek[ 61] |= 32; ek[ 68] |= 16; ek[ 77] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            ek[ 92] |=  1; ek[102] |=  4; ek[108] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            ek[126] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        octet = key[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            ek[  2] |=  8; ek[  9] |=  1; ek[ 16] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            ek[ 27] |=  4; ek[ 42] |=  1; ek[ 49] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            ek[ 58] |=  2; ek[ 75] |=  1; ek[ 80] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            ek[ 90] |=  4; ek[ 97] |= 32; ek[106] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            ek[113] |=  8; ek[120] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            ek[  2] |=  4; ek[  8] |=  4; ek[ 27] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            ek[ 32] |= 32; ek[ 41] |=  1; ek[ 48] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            ek[ 59] |=  4; ek[ 66] |= 16; ek[ 72] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            ek[ 91] |=  8; ek[107] |=  1; ek[112] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            ek[123] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            ek[  3] |=  8; ek[ 10] |=  2; ek[ 16] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            ek[ 25] |=  4; ek[ 35] |= 16; ek[ 40] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
            ek[ 59] |=  2; ek[ 65] |=  8; ek[ 74] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            ek[ 83] |= 32; ek[ 89] |=  2; ek[ 98] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            ek[104] |=  8; ek[121] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            ek[  4] |=  2; ek[ 13] |=  4; ek[ 22] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            ek[ 28] |= 16; ek[ 37] |=  8; ek[ 52] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            ek[ 62] |=  4; ek[ 79] |=  8; ek[ 86] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            ek[ 95] |= 32; ek[101] |=  1; ek[110] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            ek[126] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            ek[  5] |= 32; ek[ 12] |= 16; ek[ 21] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            ek[ 36] |=  1; ek[ 46] |=  4; ek[ 52] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            ek[ 70] |= 16; ek[ 79] |= 32; ek[ 85] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            ek[ 94] |=  8; ek[108] |=  2; ek[119] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            ek[126] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            ek[  5] |=  2; ek[ 14] |=  4; ek[ 20] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            ek[ 37] |= 16; ek[ 44] |=  4; ek[ 55] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            ek[ 60] |= 32; ek[ 76] |=  2; ek[ 87] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
            ek[ 93] |= 32; ek[103] |=  1; ek[110] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            ek[119] |=  2; ek[124] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            ek[  7] |= 32; ek[ 12] |=  4; ek[ 23] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            ek[ 28] |= 32; ek[ 38] |= 32; ek[ 45] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            ek[ 54] |=  2; ek[ 60] |= 16; ek[ 71] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            ek[ 78] |=  1; ek[ 87] |=  2; ek[ 93] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            ek[111] |=  8; ek[118] |= 16; ek[125] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        octet = key[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
            ek[  1] |=  1; ek[ 11] |= 32; ek[ 17] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            ek[ 26] |= 16; ek[ 32] |=  8; ek[ 51] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            ek[ 64] |=  2; ek[ 73] |=  4; ek[ 83] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            ek[ 88] |=  4; ek[107] |=  2; ek[112] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            ek[122] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
            ek[  0] |=  4; ek[  9] |= 32; ek[ 18] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            ek[ 25] |=  8; ek[ 34] |=  8; ek[ 43] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            ek[ 49] |=  2; ek[ 58] |= 16; ek[ 74] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            ek[ 81] |= 16; ek[ 90] |=  2; ek[ 96] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            ek[105] |=  4; ek[115] |= 16; ek[122] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            ek[  2] |=  2; ek[ 19] |=  1; ek[ 24] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            ek[ 34] |=  4; ek[ 41] |= 32; ek[ 50] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            ek[ 57] |=  8; ek[ 64] |= 32; ek[ 73] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            ek[ 80] |= 16; ek[ 91] |=  4; ek[106] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            ek[113] |= 16; ek[123] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            ek[  3] |=  4; ek[ 10] |= 16; ek[ 16] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            ek[ 35] |=  8; ek[ 51] |=  1; ek[ 56] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            ek[ 67] |= 16; ek[ 72] |=  4; ek[ 91] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            ek[ 96] |= 32; ek[105] |=  1; ek[112] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            ek[121] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            ek[  4] |= 16; ek[ 15] |=  1; ek[ 22] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
            ek[ 31] |=  2; ek[ 37] |=  2; ek[ 55] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            ek[ 62] |= 16; ek[ 69] |= 16; ek[ 76] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            ek[ 87] |= 16; ek[ 92] |= 32; ek[102] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            ek[109] |=  4; ek[118] |=  2; ek[125] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
            ek[  6] |=  4; ek[ 23] |=  8; ek[ 30] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
            ek[ 39] |= 32; ek[ 45] |=  1; ek[ 54] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            ek[ 70] |= 32; ek[ 77] |=  4; ek[ 86] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            ek[ 92] |= 16; ek[101] |=  8; ek[116] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            ek[125] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
            ek[  4] |=  4; ek[ 13] |=  1; ek[ 22] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
            ek[ 36] |=  2; ek[ 47] |=  4; ek[ 53] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            ek[ 63] |=  1; ek[ 69] |=  8; ek[ 84] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            ek[ 94] |=  4; ek[100] |=  8; ek[117] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            ek[127] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        octet = key[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            ek[  3] |= 32; ek[  8] |= 16; ek[ 19] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            ek[ 34] |=  1; ek[ 41] |= 16; ek[ 50] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
            ek[ 56] |=  2; ek[ 67] |=  1; ek[ 72] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            ek[ 82] |=  4; ek[ 89] |= 32; ek[ 98] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
            ek[105] |=  8; ek[114] |=  8; ek[121] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            ek[  1] |= 32; ek[ 19] |=  2; ek[ 24] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            ek[ 33] |=  1; ek[ 40] |= 16; ek[ 51] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            ek[ 64] |=  8; ek[ 83] |=  8; ek[ 99] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            ek[104] |=  1; ek[114] |=  4; ek[120] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            ek[  8] |=  2; ek[ 17] |=  4; ek[ 27] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            ek[ 32] |=  4; ek[ 51] |=  2; ek[ 56] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            ek[ 66] |=  8; ek[ 75] |= 32; ek[ 81] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            ek[ 90] |= 16; ek[ 96] |=  8; ek[115] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            ek[122] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            ek[  2] |= 16; ek[ 18] |=  1; ek[ 25] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            ek[ 34] |=  2; ek[ 40] |=  2; ek[ 49] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            ek[ 59] |= 16; ek[ 66] |=  4; ek[ 73] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            ek[ 82] |= 32; ek[ 89] |=  8; ek[ 98] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            ek[107] |= 32; ek[113] |=  2; ek[123] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            ek[  7] |=  1; ek[ 13] |=  8; ek[ 28] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            ek[ 38] |=  4; ek[ 44] |=  8; ek[ 61] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            ek[ 71] |= 32; ek[ 77] |=  1; ek[ 86] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            ek[100] |=  2; ek[111] |=  4; ek[117] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            ek[124] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            ek[ 12] |=  8; ek[ 29] |= 16; ek[ 36] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            ek[ 47] |= 16; ek[ 52] |= 32; ek[ 62] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            ek[ 68] |=  2; ek[ 79] |=  4; ek[ 85] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            ek[ 95] |=  1; ek[102] |=  1; ek[111] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
            ek[117] |=  2; ek[126] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            ek[  5] |=  1; ek[ 15] |= 16; ek[ 20] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
            ek[ 30] |= 32; ek[ 37] |=  4; ek[ 46] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
            ek[ 52] |= 16; ek[ 61] |=  8; ek[ 70] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
            ek[ 79] |=  2; ek[ 85] |=  2; ek[103] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
            ek[110] |= 16; ek[119] |= 32; ek[124] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        octet = key[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
            ek[  0] |= 16; ek[  9] |=  2; ek[ 18] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            ek[ 24] |=  8; ek[ 43] |=  8; ek[ 59] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            ek[ 65] |=  4; ek[ 75] |= 16; ek[ 80] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            ek[ 99] |=  2; ek[104] |= 32; ek[113] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            ek[123] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            ek[ 10] |= 32; ek[ 17] |=  8; ek[ 26] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
            ek[ 35] |= 32; ek[ 41] |=  2; ek[ 50] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            ek[ 56] |=  8; ek[ 66] |=  1; ek[ 73] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            ek[ 82] |=  2; ek[ 88] |=  2; ek[ 97] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            ek[107] |= 16; ek[112] |=  4; ek[121] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            ek[  0] |=  2; ek[ 11] |=  1; ek[ 16] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            ek[ 26] |=  4; ek[ 33] |= 32; ek[ 42] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            ek[ 49] |=  8; ek[ 58] |=  8; ek[ 65] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
            ek[ 72] |= 16; ek[ 83] |=  4; ek[ 98] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            ek[105] |= 16; ek[114] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            ek[  8] |=  8; ek[ 27] |=  8; ek[ 43] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
            ek[ 48] |=  1; ek[ 58] |=  4; ek[ 64] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
            ek[ 83] |=  2; ek[ 88] |= 32; ek[ 97] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            ek[104] |= 16; ek[115] |=  4; ek[122] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
            ek[  5] |=  8; ek[ 14] |=  1; ek[ 23] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            ek[ 29] |=  2; ek[ 47] |=  8; ek[ 54] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            ek[ 63] |= 32; ek[ 68] |=  4; ek[ 79] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            ek[ 84] |= 32; ek[ 94] |= 32; ek[101] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
            ek[110] |=  2; ek[116] |= 16; ek[127] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            ek[  4] |=  8; ek[ 15] |=  8; ek[ 22] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            ek[ 31] |= 32; ek[ 37] |=  1; ek[ 46] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            ek[ 60] |=  2; ek[ 69] |=  4; ek[ 78] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            ek[ 84] |= 16; ek[ 93] |=  8; ek[108] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
            ek[118] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            ek[  7] |= 16; ek[ 14] |=  8; ek[ 28] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            ek[ 39] |=  4; ek[ 45] |= 32; ek[ 55] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            ek[ 62] |=  1; ek[ 76] |=  1; ek[ 86] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            ek[ 92] |=  8; ek[109] |= 16; ek[116] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
            ek[125] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        octet = key[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        if ((octet & 0x80) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            ek[  1] |=  2; ek[ 11] |=  4; ek[ 26] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            ek[ 33] |= 16; ek[ 42] |=  2; ek[ 48] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
            ek[ 57] |=  4; ek[ 64] |=  1; ek[ 74] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
            ek[ 81] |= 32; ek[ 90] |= 32; ek[ 97] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
            ek[106] |=  8; ek[115] |= 32; ek[120] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        if ((octet & 0x40) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
            ek[  2] |= 32; ek[ 11] |=  2; ek[ 16] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            ek[ 25] |=  1; ek[ 32] |= 16; ek[ 43] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            ek[ 58] |=  1; ek[ 75] |=  8; ek[ 91] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            ek[ 96] |=  1; ek[106] |=  4; ek[113] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        if ((octet & 0x20) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            ek[  3] |=  1; ek[  9] |=  4; ek[ 19] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            ek[ 24] |=  4; ek[ 43] |=  2; ek[ 48] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            ek[ 57] |=  1; ek[ 67] |= 32; ek[ 73] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
            ek[ 82] |= 16; ek[ 88] |=  8; ek[107] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            ek[120] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        if ((octet & 0x10) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            ek[  0] |=  8; ek[ 10] |=  1; ek[ 17] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            ek[ 26] |=  2; ek[ 32] |=  2; ek[ 41] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
            ek[ 51] |= 16; ek[ 56] |=  4; ek[ 65] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            ek[ 74] |= 32; ek[ 81] |=  8; ek[ 90] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            ek[ 99] |= 32; ek[105] |=  2; ek[114] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        if ((octet & 0x8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
            ek[  6] |=  1; ek[ 20] |=  1; ek[ 30] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
            ek[ 36] |=  8; ek[ 53] |= 16; ek[ 60] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
            ek[ 69] |=  1; ek[ 78] |=  8; ek[ 92] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            ek[103] |=  4; ek[109] |= 32; ek[119] |=  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            ek[125] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        if ((octet & 0x4) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
            ek[  7] |=  8; ek[ 21] |= 16; ek[ 28] |=  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
            ek[ 39] |= 16; ek[ 44] |= 32; ek[ 54] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
            ek[ 61] |=  4; ek[ 71] |=  4; ek[ 77] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
            ek[ 87] |=  1; ek[ 94] |=  1; ek[103] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            ek[109] |=  2; ek[124] |=  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        if ((octet & 0x2) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
            ek[  6] |=  8; ek[ 12] |= 32; ek[ 22] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
            ek[ 29] |=  4; ek[ 38] |=  2; ek[ 44] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
            ek[ 53] |=  8; ek[ 71] |=  2; ek[ 77] |=  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
            ek[ 95] |=  8; ek[102] |= 16; ek[111] |= 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            ek[117] |=  1; ek[127] |= 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        expandedKey = ek;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
}