protected AEADBlockCipher createAEADBlockCipher_AES_CCM() { return new CCMBlockCipher(createAESEngine()); }
protected AEADBlockCipher createAEADBlockCipher_AES_CCM() { return new CCMBlockCipher(createAESEngine()); }
public CCM() { super(new CCMBlockCipher(new AESEngine()), false, 16); } }
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; } }
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; }
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; }
cipher = new AEADGenericBlockCipher(new CCMBlockCipher(baseEngine));
cipher = new AEADGenericBlockCipher(new CCMBlockCipher(baseEngine));
cipher = new AEADGenericBlockCipher(new CCMBlockCipher(baseEngine));