public int getMaxKeyLength() { return getMinKeyLength(); }
public byte[] decrypt(byte[] cryptedData, int offset, int length, byte[] decryptionKey, long engineBoots, long engineTime, DecryptParams decryptParams) { byte[] initVect = new byte[16]; if (decryptionKey.length != keyBytes) { throw new IllegalArgumentException( "Needed key length is " + keyBytes + ". Got " + decryptionKey.length + "."); } /* Set IV as engine_boots + engine_time + decrypt params */ initVect[0] = (byte) ( (engineBoots >> 24) & 0xFF); initVect[1] = (byte) ( (engineBoots >> 16) & 0xFF); initVect[2] = (byte) ( (engineBoots >> 8) & 0xFF); initVect[3] = (byte) ( (engineBoots) & 0xFF); initVect[4] = (byte) ( (engineTime >> 24) & 0xFF); initVect[5] = (byte) ( (engineTime >> 16) & 0xFF); initVect[6] = (byte) ( (engineTime >> 8) & 0xFF); initVect[7] = (byte) ( (engineTime) & 0xFF); System.arraycopy(decryptParams.array, decryptParams.offset, initVect, 8, 8); if (logger.isDebugEnabled()) { logger.debug("initVect is " + asHex(initVect)); } return doDecrypt(cryptedData, offset, length, decryptionKey, initVect); }
logger.debug("initVect is " + asHex(initVect)); Cipher alg = doInit(encryptionKey, initVect); encryptedData = alg.doFinal(unencryptedData, offset, length); cipherPool.offerCipher(alg); logger.debug("aes encrypt: Data to encrypt " + asHex(unencryptedData)); logger.debug("aes encrypt: used key " + asHex(encryptionKey)); asHex(decryptParams.array)); asHex(encryptedData));
public byte[] decrypt(byte[] cryptedData, int offset, int length, byte[] decryptionKey, long engineBoots, long engineTime, DecryptParams decryptParams) { byte[] initVect = new byte[16]; if (decryptionKey.length != keyBytes) { throw new IllegalArgumentException( "Needed key length is " + keyBytes + ". Got " + decryptionKey.length + "."); } /* Set IV as engine_boots + engine_time + decrypt params */ initVect[0] = (byte) ( (engineBoots >> 24) & 0xFF); initVect[1] = (byte) ( (engineBoots >> 16) & 0xFF); initVect[2] = (byte) ( (engineBoots >> 8) & 0xFF); initVect[3] = (byte) ( (engineBoots) & 0xFF); initVect[4] = (byte) ( (engineTime >> 24) & 0xFF); initVect[5] = (byte) ( (engineTime >> 16) & 0xFF); initVect[6] = (byte) ( (engineTime >> 8) & 0xFF); initVect[7] = (byte) ( (engineTime) & 0xFF); System.arraycopy(decryptParams.array, decryptParams.offset, initVect, 8, 8); if (logger.isDebugEnabled()) { logger.debug("initVect is " + asHex(initVect)); } return doDecrypt(cryptedData, offset, length, decryptionKey, initVect); }
logger.debug("initVect is " + asHex(initVect)); Cipher alg = doInit(encryptionKey, initVect); encryptedData = alg.doFinal(unencryptedData, offset, length); cipherPool.offerCipher(alg); logger.debug("aes encrypt: Data to encrypt " + asHex(unencryptedData)); logger.debug("aes encrypt: used key " + asHex(encryptionKey)); asHex(decryptParams.array)); asHex(encryptedData));
public int getMaxKeyLength() { return getMinKeyLength(); }
public int getMaxKeyLength() { return getMinKeyLength(); }
public byte[] extendShortKey(byte[] shortKey, OctetString password, byte[] engineID, AuthenticationProtocol authProtocol) { // we have to extend the key, currently only the AES draft // defines this algorithm, so this may have to be changed for other // privacy protocols byte[] extKey = new byte[getMinKeyLength()]; int length = shortKey.length; System.arraycopy(shortKey, 0, extKey, 0, length); while (length < extKey.length) { byte[] hash = authProtocol.hash(extKey, 0, length); if (hash == null) { return null; } int bytesToCopy = extKey.length - length; if (bytesToCopy > authProtocol.getDigestLength()) { bytesToCopy = authProtocol.getDigestLength(); } System.arraycopy(hash, 0, extKey, length, bytesToCopy); length += bytesToCopy; } return extKey; }
public byte[] extendShortKey(byte[] shortKey, OctetString password, byte[] engineID, AuthenticationProtocol authProtocol) { // we have to extend the key, currently only the AES draft // defines this algorithm, so this may have to be changed for other // privacy protocols byte[] extKey = new byte[getMinKeyLength()]; int length = shortKey.length; System.arraycopy(shortKey, 0, extKey, 0, length); while (length < extKey.length) { byte[] hash = authProtocol.hash(extKey, 0, length); if (hash == null) { return null; } int bytesToCopy = extKey.length - length; if (bytesToCopy > authProtocol.getDigestLength()) { bytesToCopy = authProtocol.getDigestLength(); } System.arraycopy(hash, 0, extKey, length, bytesToCopy); length += bytesToCopy; } return extKey; }
byte[] extKey = new byte[getMinKeyLength()]; int length = shortKey.length; for (int i=0; i<length; i++) {