Java Code Examples for javax.crypto.spec.DESKeySpec#isWeak()

The following examples show how to use javax.crypto.spec.DESKeySpec#isWeak() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RsaMd5DesCksumType.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Decrypts keyed checksum.
 * @param enc_cksum the buffer for encrypted checksum.
 * @param key the key.
 * @return the checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
private byte[] decryptKeyedChecksum(byte[] enc_cksum, byte[] key) throws KrbCryptoException {
    //compute modified key
    byte[] new_key = new byte[keySize()];
    System.arraycopy(key, 0, new_key, 0, key.length);
    for (int i = 0; i < new_key.length; i++)
    new_key[i] = (byte)(new_key[i] ^ 0xf0);
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(new_key, 0)) {
            new_key[7] = (byte)(new_key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[new_key.length];

    byte[] cksum = new byte[enc_cksum.length];
    Des.cbc_encrypt(enc_cksum, cksum, new_key, ivec, false);
    return cksum;
}
 
Example 2
Source File: DesMacCksumType.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies keyed checksum.
 * @param data the data.
 * @param size the length of data.
 * @param key the key used to encrypt the checksum.
 * @param checksum the checksum.
 * @return true if verification is successful.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public boolean verifyKeyedChecksum(byte[] data, int size,
    byte[] key, byte[] checksum, int usage) throws KrbCryptoException {
    byte[] cksum = decryptKeyedChecksum(checksum, key);

    byte[] new_data = new byte[size + confounderSize()];
    System.arraycopy(cksum, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //check for weak keys
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[key.length];
    byte[] new_cksum = Des.des_cksum(ivec, new_data, key);
    byte[] orig_cksum = new byte[cksumSize() - confounderSize()];
    System.arraycopy(cksum,  confounderSize(), orig_cksum, 0,
                     cksumSize() - confounderSize());
    return isChecksumEqual(orig_cksum, new_cksum);
}
 
Example 3
Source File: DesMacKCksumType.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calculates keyed checksum.
 * @param data the data used to generate the checksum.
 * @param size length of the data.
 * @param key the key used to encrypt the checksum.
 * @return keyed checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key,
    int usage) throws KrbCryptoException {
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[key.length];
    System.arraycopy(key, 0, ivec, 0, key.length);
    byte[] cksum = Des.des_cksum(ivec, data, key);
    return cksum;
}
 
Example 4
Source File: DesMacCksumType.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies keyed checksum.
 * @param data the data.
 * @param size the length of data.
 * @param key the key used to encrypt the checksum.
 * @param checksum
 * @return true if verification is successful.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public boolean verifyKeyedChecksum(byte[] data, int size,
    byte[] key, byte[] checksum, int usage) throws KrbCryptoException {
    byte[] cksum = decryptKeyedChecksum(checksum, key);

    byte[] new_data = new byte[size + confounderSize()];
    System.arraycopy(cksum, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //check for weak keys
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[key.length];
    byte[] new_cksum = Des.des_cksum(ivec, new_data, key);
    byte[] orig_cksum = new byte[cksumSize() - confounderSize()];
    System.arraycopy(cksum,  confounderSize(), orig_cksum, 0,
                     cksumSize() - confounderSize());
    return isChecksumEqual(orig_cksum, new_cksum);
}
 
Example 5
Source File: DesMacCksumType.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies keyed checksum.
 * @param data the data.
 * @param size the length of data.
 * @param key the key used to encrypt the checksum.
 * @param checksum
 * @return true if verification is successful.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public boolean verifyChecksum(byte[] data, int size,
    byte[] key, byte[] checksum, int usage) throws KrbCryptoException {
    byte[] cksum = decryptKeyedChecksum(checksum, key);

    byte[] new_data = new byte[size + confounderSize()];
    System.arraycopy(cksum, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //check for weak keys
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[key.length];
    byte[] new_cksum = Des.des_cksum(ivec, new_data, key);
    byte[] orig_cksum = new byte[cksumSize() - confounderSize()];
    System.arraycopy(cksum,  confounderSize(), orig_cksum, 0,
                     cksumSize() - confounderSize());
    return isChecksumEqual(orig_cksum, new_cksum);
}
 
Example 6
Source File: DesMacKCksumType.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calculates keyed checksum.
 * @param data the data used to generate the checksum.
 * @param size length of the data.
 * @param key the key used to encrypt the checksum.
 * @return keyed checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key,
    int usage) throws KrbCryptoException {
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[key.length];
    System.arraycopy(key, 0, ivec, 0, key.length);
    byte[] cksum = Des.des_cksum(ivec, data, key);
    return cksum;
}
 
Example 7
Source File: RsaMd5DesCksumType.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Decrypts keyed checksum.
 * @param enc_cksum the buffer for encrypted checksum.
 * @param key the key.
 * @return the checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
private byte[] decryptKeyedChecksum(byte[] enc_cksum, byte[] key) throws KrbCryptoException {
    //compute modified key
    byte[] new_key = new byte[keySize()];
    System.arraycopy(key, 0, new_key, 0, key.length);
    for (int i = 0; i < new_key.length; i++)
    new_key[i] = (byte)(new_key[i] ^ 0xf0);
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(new_key, 0)) {
            new_key[7] = (byte)(new_key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[new_key.length];

    byte[] cksum = new byte[enc_cksum.length];
    Des.cbc_encrypt(enc_cksum, cksum, new_key, ivec, false);
    return cksum;
}
 
Example 8
Source File: DESKeyGenerator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates the DES key.
 *
 * @return the new DES key
 */
protected SecretKey engineGenerateKey() {
    DESKey desKey = null;

    if (this.random == null) {
        this.random = SunJCE.getRandom();
    }

    try {
        byte[] key = new byte[DESKeySpec.DES_KEY_LEN];
        do {
            this.random.nextBytes(key);
            setParityBit(key, 0);
        } while (DESKeySpec.isWeak(key, 0));
        desKey = new DESKey(key);
    } catch (InvalidKeyException e) {
        // this is never thrown
    }

    return desKey;
}
 
Example 9
Source File: DESKeyGenerator.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Generates the DES key.
 *
 * @return the new DES key
 */
protected SecretKey engineGenerateKey() {
    DESKey desKey = null;

    if (this.random == null) {
        this.random = SunJCE.getRandom();
    }

    try {
        byte[] key = new byte[DESKeySpec.DES_KEY_LEN];
        do {
            this.random.nextBytes(key);
            setParityBit(key, 0);
        } while (DESKeySpec.isWeak(key, 0));
        desKey = new DESKey(key);
    } catch (InvalidKeyException e) {
        // this is never thrown
    }

    return desKey;
}
 
Example 10
Source File: CheckWeakKeys.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        boolean failed = false;

        for (int i = 0; i < weakKeys.length; i++) {
            DESKeySpec desSpec = new DESKeySpec(weakKeys[i]);
            if (!DESKeySpec.isWeak(weakKeys[i], 0)) {
                failed = true;
                System.out.println("Entry " + i + " should be weak");
            }
        }

        if (failed) {
            throw new Exception("Failed test!!!");
        }

        System.out.println("Passed test.");
    }
 
Example 11
Source File: DesMacCksumType.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies keyed checksum.
 * @param data the data.
 * @param size the length of data.
 * @param key the key used to encrypt the checksum.
 * @param checksum
 * @return true if verification is successful.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public boolean verifyKeyedChecksum(byte[] data, int size,
    byte[] key, byte[] checksum, int usage) throws KrbCryptoException {
    byte[] cksum = decryptKeyedChecksum(checksum, key);

    byte[] new_data = new byte[size + confounderSize()];
    System.arraycopy(cksum, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //check for weak keys
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[key.length];
    byte[] new_cksum = Des.des_cksum(ivec, new_data, key);
    byte[] orig_cksum = new byte[cksumSize() - confounderSize()];
    System.arraycopy(cksum,  confounderSize(), orig_cksum, 0,
                     cksumSize() - confounderSize());
    return isChecksumEqual(orig_cksum, new_cksum);
}
 
Example 12
Source File: RsaMd5DesCksumType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates keyed checksum.
 * @param data the data used to generate the checksum.
 * @param size length of the data.
 * @param key the key used to encrypt the checksum.
 * @return keyed checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key,
    int usage) throws KrbCryptoException {
    //prepend confounder
    byte[] new_data = new byte[size + confounderSize()];
    byte[] conf = Confounder.bytes(confounderSize());
    System.arraycopy(conf, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //calculate md5 cksum
    byte[] mdc_cksum = calculateChecksum(new_data, new_data.length);
    byte[] cksum = new byte[cksumSize()];
    System.arraycopy(conf, 0, cksum, 0, confounderSize());
    System.arraycopy(mdc_cksum, 0, cksum, confounderSize(),
                     cksumSize() - confounderSize());

    //compute modified key
    byte[] new_key = new byte[keySize()];
    System.arraycopy(key, 0, new_key, 0, key.length);
    for (int i = 0; i < new_key.length; i++)
    new_key[i] = (byte)(new_key[i] ^ 0xf0);
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(new_key, 0)) {
            new_key[7] = (byte)(new_key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[new_key.length];

    //des-cbc encrypt
    byte[] enc_cksum = new byte[cksum.length];
    Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true);
    return enc_cksum;
}
 
Example 13
Source File: Des3DkCrypto.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] keyCorrection(byte[] key) {
    // check for weak key
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    return key;
}
 
Example 14
Source File: RsaMd5DesCksumType.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates keyed checksum.
 * @param data the data used to generate the checksum.
 * @param size length of the data.
 * @param key the key used to encrypt the checksum.
 * @return keyed checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key,
    int usage) throws KrbCryptoException {
    //prepend confounder
    byte[] new_data = new byte[size + confounderSize()];
    byte[] conf = Confounder.bytes(confounderSize());
    System.arraycopy(conf, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //calculate md5 cksum
    byte[] mdc_cksum = calculateChecksum(new_data, new_data.length);
    byte[] cksum = new byte[cksumSize()];
    System.arraycopy(conf, 0, cksum, 0, confounderSize());
    System.arraycopy(mdc_cksum, 0, cksum, confounderSize(),
                     cksumSize() - confounderSize());

    //compute modified key
    byte[] new_key = new byte[keySize()];
    System.arraycopy(key, 0, new_key, 0, key.length);
    for (int i = 0; i < new_key.length; i++)
    new_key[i] = (byte)(new_key[i] ^ 0xf0);
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(new_key, 0)) {
            new_key[7] = (byte)(new_key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[new_key.length];

    //des-cbc encrypt
    byte[] enc_cksum = new byte[cksum.length];
    Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true);
    return enc_cksum;
}
 
Example 15
Source File: Des3DkCrypto.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] keyCorrection(byte[] key) {
    // check for weak key
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    return key;
}
 
Example 16
Source File: Des3DkCrypto.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] keyCorrection(byte[] key) {
    // check for weak key
    try {
        if (DESKeySpec.isWeak(key, 0)) {
            key[7] = (byte)(key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    return key;
}
 
Example 17
Source File: RsaMd5DesCksumType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates keyed checksum.
 * @param data the data used to generate the checksum.
 * @param size length of the data.
 * @param key the key used to encrypt the checksum.
 * @return keyed checksum.
 *
 * @modified by Yanni Zhang, 12/08/99.
 */
public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key,
    int usage) throws KrbCryptoException {
    //prepend confounder
    byte[] new_data = new byte[size + confounderSize()];
    byte[] conf = Confounder.bytes(confounderSize());
    System.arraycopy(conf, 0, new_data, 0, confounderSize());
    System.arraycopy(data, 0, new_data, confounderSize(), size);

    //calculate md5 cksum
    byte[] mdc_cksum = calculateChecksum(new_data, new_data.length);
    byte[] cksum = new byte[cksumSize()];
    System.arraycopy(conf, 0, cksum, 0, confounderSize());
    System.arraycopy(mdc_cksum, 0, cksum, confounderSize(),
                     cksumSize() - confounderSize());

    //compute modified key
    byte[] new_key = new byte[keySize()];
    System.arraycopy(key, 0, new_key, 0, key.length);
    for (int i = 0; i < new_key.length; i++)
    new_key[i] = (byte)(new_key[i] ^ 0xf0);
    //check for weak keys
    try {
        if (DESKeySpec.isWeak(new_key, 0)) {
            new_key[7] = (byte)(new_key[7] ^ 0xF0);
        }
    } catch (InvalidKeyException ex) {
        // swallow, since it should never happen
    }
    byte[] ivec = new byte[new_key.length];

    //des-cbc encrypt
    byte[] enc_cksum = new byte[cksum.length];
    Des.cbc_encrypt(cksum, enc_cksum, new_key, ivec, true);
    return enc_cksum;
}
 
Example 18
Source File: EncryptionKey.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates a sub-sessionkey from a given session key.
 *
 * Used in AcceptSecContextToken and KrbApReq by acceptor- and initiator-
 * side respectively.
 */
public EncryptionKey(EncryptionKey key) throws KrbCryptoException {
    // generate random sub-session key
    keyValue = Confounder.bytes(key.keyValue.length);
    for (int i = 0; i < keyValue.length; i++) {
      keyValue[i] ^= key.keyValue[i];
    }
    keyType = key.keyType;

    // check for key parity and weak keys
    try {
        // check for DES key
        if ((keyType == EncryptedData.ETYPE_DES_CBC_MD5) ||
            (keyType == EncryptedData.ETYPE_DES_CBC_CRC)) {
            // fix DES key parity
            if (!DESKeySpec.isParityAdjusted(keyValue, 0)) {
                keyValue = Des.set_parity(keyValue);
            }
            // check for weak key
            if (DESKeySpec.isWeak(keyValue, 0)) {
                keyValue[7] = (byte)(keyValue[7] ^ 0xF0);
            }
        }
        // check for 3DES key
        if (keyType == EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
            // fix 3DES key parity
            if (!DESedeKeySpec.isParityAdjusted(keyValue, 0)) {
                keyValue = Des3.parityFix(keyValue);
            }
            // check for weak keys
            byte[] oneKey = new byte[8];
            for (int i=0; i<keyValue.length; i+=8) {
                System.arraycopy(keyValue, i, oneKey, 0, 8);
                if (DESKeySpec.isWeak(oneKey, 0)) {
                    keyValue[i+7] = (byte)(keyValue[i+7] ^ 0xF0);
                }
            }
        }
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
Example 19
Source File: EncryptionKey.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates a sub-sessionkey from a given session key.
 *
 * Used in AcceptSecContextToken and KrbApReq by acceptor- and initiator-
 * side respectively.
 */
public EncryptionKey(EncryptionKey key) throws KrbCryptoException {
    // generate random sub-session key
    keyValue = Confounder.bytes(key.keyValue.length);
    for (int i = 0; i < keyValue.length; i++) {
      keyValue[i] ^= key.keyValue[i];
    }
    keyType = key.keyType;

    // check for key parity and weak keys
    try {
        // check for DES key
        if ((keyType == EncryptedData.ETYPE_DES_CBC_MD5) ||
            (keyType == EncryptedData.ETYPE_DES_CBC_CRC)) {
            // fix DES key parity
            if (!DESKeySpec.isParityAdjusted(keyValue, 0)) {
                keyValue = Des.set_parity(keyValue);
            }
            // check for weak key
            if (DESKeySpec.isWeak(keyValue, 0)) {
                keyValue[7] = (byte)(keyValue[7] ^ 0xF0);
            }
        }
        // check for 3DES key
        if (keyType == EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
            // fix 3DES key parity
            if (!DESedeKeySpec.isParityAdjusted(keyValue, 0)) {
                keyValue = Des3.parityFix(keyValue);
            }
            // check for weak keys
            byte[] oneKey = new byte[8];
            for (int i=0; i<keyValue.length; i+=8) {
                System.arraycopy(keyValue, i, oneKey, 0, 8);
                if (DESKeySpec.isWeak(oneKey, 0)) {
                    keyValue[i+7] = (byte)(keyValue[i+7] ^ 0xF0);
                }
            }
        }
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
Example 20
Source File: EncryptionKey.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates a sub-sessionkey from a given session key.
 *
 * Used in AcceptSecContextToken and KrbApReq by acceptor- and initiator-
 * side respectively.
 */
public EncryptionKey(EncryptionKey key) throws KrbCryptoException {
    // generate random sub-session key
    keyValue = Confounder.bytes(key.keyValue.length);
    for (int i = 0; i < keyValue.length; i++) {
      keyValue[i] ^= key.keyValue[i];
    }
    keyType = key.keyType;

    // check for key parity and weak keys
    try {
        // check for DES key
        if ((keyType == EncryptedData.ETYPE_DES_CBC_MD5) ||
            (keyType == EncryptedData.ETYPE_DES_CBC_CRC)) {
            // fix DES key parity
            if (!DESKeySpec.isParityAdjusted(keyValue, 0)) {
                keyValue = Des.set_parity(keyValue);
            }
            // check for weak key
            if (DESKeySpec.isWeak(keyValue, 0)) {
                keyValue[7] = (byte)(keyValue[7] ^ 0xF0);
            }
        }
        // check for 3DES key
        if (keyType == EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
            // fix 3DES key parity
            if (!DESedeKeySpec.isParityAdjusted(keyValue, 0)) {
                keyValue = Des3.parityFix(keyValue);
            }
            // check for weak keys
            byte[] oneKey = new byte[8];
            for (int i=0; i<keyValue.length; i+=8) {
                System.arraycopy(keyValue, i, oneKey, 0, 8);
                if (DESKeySpec.isWeak(oneKey, 0)) {
                    keyValue[i+7] = (byte)(keyValue[i+7] ^ 0xF0);
                }
            }
        }
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}