public EncryptionKey(EncryptionKey key) throws KrbCryptoException {
  keyValue=Confounder.bytes(key.keyValue.length);
  for (int i=0; i < keyValue.length; i++) {
    keyValue[i]^=key.keyValue[i];
  }
  keyType=key.keyType;
  try {
    if ((keyType == EncryptedData.ETYPE_DES_CBC_MD5) || (keyType == EncryptedData.ETYPE_DES_CBC_CRC)) {
      if (!DESKeySpec.isParityAdjusted(keyValue,0)) {
        keyValue=Des.set_parity(keyValue);
      }
      if (DESKeySpec.isWeak(keyValue,0)) {
        keyValue[7]=(byte)(keyValue[7] ^ 0xF0);
      }
    }
    if (keyType == EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
      if (!DESedeKeySpec.isParityAdjusted(keyValue,0)) {
        keyValue=Des3.parityFix(keyValue);
      }
      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;
  }
}

public EncryptionKey ( EncryptionKey key ) throws KrbCryptoException { keyValue = Confounder . bytes ( key . keyValue . length ) ; for ( int i = 0 ; i < keyValue . length ; i ++ ) { keyValue [ i ] ^= key . keyValue [ i ] ; } keyType = key . keyType ; try { if ( ( keyType == EncryptedData . ETYPE_DES_CBC_MD5 ) || ( keyType == EncryptedData . ETYPE_DES_CBC_CRC ) ) { if ( ! DESKeySpec . isParityAdjusted ( keyValue , 0 ) ) { keyValue = Des . set_parity ( keyValue ) ; } if ( DESKeySpec . isWeak ( keyValue , 0 ) ) { keyValue [ 7 ] = ( byte ) ( keyValue [ 7 ] ^ 0xF0 ) ; } } if ( keyType == EncryptedData . ETYPE_DES3_CBC_HMAC_SHA1_KD ) { if ( ! DESedeKeySpec . isParityAdjusted ( keyValue , 0 ) ) { keyValue = Des3 . parityFix ( keyValue ) ; } 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 ; } }
generates a sub - sessionkey from a given session key . used in acceptseccontexttoken and krbapreq by acceptor - and initiator - side respectively .
