Java Code Examples for javax.crypto.spec.DESKeySpec#isParityAdjusted()
The following examples show how to use
javax.crypto.spec.DESKeySpec#isParityAdjusted() .
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: EncryptionKey.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 2
Source File: EncryptionKey.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * 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 3
Source File: EncryptionKey.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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 4
Source File: EncryptionKey.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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 5
Source File: EncryptionKey.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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 6
Source File: EncryptionKey.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * 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 7
Source File: EncryptionKey.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 8
Source File: EncryptionKey.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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 9
Source File: EncryptionKey.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * 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 10
Source File: EncryptionKey.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * 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 11
Source File: EncryptionKey.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 12
Source File: EncryptionKey.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 13
Source File: EncryptionKey.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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; } }