public void init(byte[] nonce, int macSize, byte[] additionalData) { cipher.init(isEncrypting, new AEADParameters(key, macSize * 8, nonce, additionalData)); }
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { this.forEncryption = forEncryption; if (params instanceof AEADParameters) { AEADParameters param = (AEADParameters)params; nonce = param.getNonce(); associatedText = param.getAssociatedText(); macSize = param.getMacSize() / 8; keyParam = param.getKey(); } else if (params instanceof ParametersWithIV) { ParametersWithIV param = (ParametersWithIV)params; nonce = param.getIV(); associatedText = null; macSize = macBlock.length / 2; keyParam = param.getParameters(); } else { throw new IllegalArgumentException("invalid parameters passed to CCM"); } }
engineParams.init(new GCMParameters(aeadParams.getNonce(), aeadParams.getMacSize() / 8).getEncoded());
protected byte[] engineGetIV() { if (aeadParams != null) { return aeadParams.getNonce(); } return (ivParam != null) ? ivParam.getIV() : null; }
if (parameters.getMacSize() > MAX_MAC_BIT_LENGTH || parameters.getMacSize() < MIN_MAC_BIT_LENGTH || parameters.getMacSize() % 8 != 0) nonce = parameters.getNonce(); macSize = parameters.getMacSize() / BITS_IN_BYTE; initialAssociatedText = parameters.getAssociatedText(); cipherParameters = parameters.getKey();
/** * Initialises the GMAC - requires a {@link ParametersWithIV} providing a {@link KeyParameter} * and a nonce. */ public void init(final CipherParameters params) throws IllegalArgumentException { if (params instanceof ParametersWithIV) { final ParametersWithIV param = (ParametersWithIV)params; final byte[] iv = param.getIV(); final KeyParameter keyParam = (KeyParameter)param.getParameters(); // GCM is always operated in encrypt mode to calculate MAC cipher.init(true, new AEADParameters(keyParam, macSizeBits, iv)); } else { throw new IllegalArgumentException("KGMAC requires ParametersWithIV"); } }
nonce = param.getNonce(); initialAssociatedText = param.getAssociatedText(); macSize = param.getMacSize() / 8; cipherParameters = param.getKey();
/** * Initialises the GMAC - requires a {@link ParametersWithIV} providing a {@link KeyParameter} * and a nonce. */ public void init(final CipherParameters params) throws IllegalArgumentException { if (params instanceof ParametersWithIV) { final ParametersWithIV param = (ParametersWithIV)params; final byte[] iv = param.getIV(); final KeyParameter keyParam = (KeyParameter)param.getParameters(); // GCM is always operated in encrypt mode to calculate MAC cipher.init(true, new AEADParameters(keyParam, macSizeBits, iv)); } else { throw new IllegalArgumentException("GMAC requires ParametersWithIV"); } }
byte[] iv = param.getNonce(); int diff = this.iv.length - iv.length; Arrays.fill(this.iv, (byte)0); System.arraycopy(iv, 0, this.iv, diff, iv.length); initialAssociatedText = param.getAssociatedText(); int macSizeBits = param.getMacSize(); if (macSizeBits < MIN_MAC_BITS || macSizeBits > engine.getBlockSize() * BITS_IN_BYTE || macSizeBits % BITS_IN_BYTE != 0) engineParam = param.getKey();
Log.e(TAG, "key: " + getKey()); Log.e(TAG, "nonce: " + Utilities.byteArrayToHexString(nonce)); AEADParameters params = new AEADParameters(new KeyParameter(getKey()), mac_len, nonce, null); eax.init(true, params); //TODO switch true to false here to implement a decryption method, apply it to microdumps/megadumps
nonce = param.getNonce(); initialAssociatedText = param.getAssociatedText(); macSize = param.getMacSize() / 8; keyParam = param.getKey();
Log.e(TAG, "key: " + getKey()); Log.e(TAG, "nonce: " + Utilities.byteArrayToHexString(nonce)); AEADParameters params = new AEADParameters(new KeyParameter(getKey()), mac_len, nonce, null); eax.init(false, params); //TODO switch true to false here to implement a decryption method, apply it to microdumps/megadumps
N = aeadParameters.getNonce(); initialAssociatedText = aeadParameters.getAssociatedText(); int macSizeBits = aeadParameters.getMacSize(); if (macSizeBits < 64 || macSizeBits > 128 || macSizeBits % 8 != 0) keyParameter = aeadParameters.getKey();
public static byte[] encryptCCM(final byte[] data, final byte[] key, final byte[] nonce) { final byte[] ccm = new byte[25 + 8]; final ByteBuffer buffer = ByteBuffer.allocate(ccm.length + 8); CCMBlockCipher ccmBlockCipher = new CCMBlockCipher(new AESEngine()); AEADParameters aeadParameters = new AEADParameters(new KeyParameter(key), 64, nonce); ccmBlockCipher.init(true, aeadParameters); ccmBlockCipher.processBytes(data, 0, data.length, ccm, data.length); try { ccmBlockCipher.doFinal(ccm, 0); } catch (InvalidCipherTextException e) { e.printStackTrace(); } return ccm; }
nonce = param.getNonce(); initialAssociatedText = param.getAssociatedText(); int macSizeBits = param.getMacSize(); if ((macSizeBits < 96 || macSizeBits > 128 || macSizeBits % 8 != 0) && macSizeBits != 32 && macSizeBits != 64) keyParam = param.getKey();
public static byte[] encryptCCM(final byte[] data, final byte[] key, final byte[] nonce, final int micSize) { final byte[] ccm = new byte[data.length + micSize]; final CCMBlockCipher ccmBlockCipher = new CCMBlockCipher(new AESEngine()); final AEADParameters aeadParameters = new AEADParameters(new KeyParameter(key), micSize * 8, nonce); ccmBlockCipher.init(true, aeadParameters); ccmBlockCipher.processBytes(data, 0, data.length, ccm, data.length); try { ccmBlockCipher.doFinal(ccm, 0); return ccm; } catch (InvalidCipherTextException e) { Log.e(TAG, "Error wile encrypting: " + e.getMessage()); return null; } }
nonce = param.getNonce(); A = param.getAssociatedText(); int macSizeBits = param.getMacSize(); if (macSizeBits < 96 || macSizeBits > 128 || macSizeBits % 8 != 0) keyParam = param.getKey();
public static byte[] decryptCCM(final byte[] data, final byte[] key, final byte[] nonce, final int micSize) throws InvalidCipherTextException { final byte[] ccm = new byte[data.length - micSize]; final CCMBlockCipher ccmBlockCipher = new CCMBlockCipher(new AESEngine()); final AEADParameters aeadParameters = new AEADParameters(new KeyParameter(key), micSize * 8, nonce); ccmBlockCipher.init(false, aeadParameters); ccmBlockCipher.processBytes(data, 0, data.length, ccm, 0); ccmBlockCipher.doFinal(ccm, 0); return ccm; }
nonce = param.getNonce(); associatedText = param.getAssociatedText(); macSize = param.getMacSize() / 8; keyParam = param.getKey();
AEADParameters parameters = new AEADParameters(null, 8 * macSize, nonce, additionalData);