public FrameCodec(EncryptionHandshake.Secrets secrets) { this.mac = secrets.mac; BlockCipher cipher; enc = new SICBlockCipher(cipher = new AESEngine()); enc.init(true, new ParametersWithIV(new KeyParameter(secrets.aes), new byte[cipher.getBlockSize()])); dec = new SICBlockCipher(cipher = new AESEngine()); dec.init(false, new ParametersWithIV(new KeyParameter(secrets.aes), new byte[cipher.getBlockSize()])); egressMac = secrets.egressMac; ingressMac = secrets.ingressMac; }
/** * return the blocksize for the underlying cipher. * * @return the blocksize for the underlying cipher. */ public int getBlockSize() { return cipher.getBlockSize(); }
/** * create a standard MAC based on a CBC block cipher. This will produce an * authentication code half the length of the block size of the cipher. * * @param cipher the cipher to be used as the basis of the MAC generation. */ public CBCBlockCipherMac( BlockCipher cipher) { this(cipher, (cipher.getBlockSize() * 8) / 2, null); }
/** * return the block size we are operating at. * * @return the block size we are operating at (in bytes). */ public int getBlockSize() { return cipher.getBlockSize(); }
/** * Create a buffered block cipher with, or without, padding. * * @param cipher the underlying block cipher this buffering object wraps. */ public PaddedBlockCipher( BlockCipher cipher) { this.cipher = cipher; buf = new byte[cipher.getBlockSize()]; bufOff = 0; }
/** * create a Retail-MAC based on a CBC block cipher. This will produce an * authentication code of the length of the block size of the cipher. * * @param cipher the cipher to be used as the basis of the MAC generation. This must * be DESEngine. */ public ISO9797Alg3Mac( BlockCipher cipher) { this(cipher, cipher.getBlockSize() * 8, null); }
/** * create a standard MAC based on a CFB block cipher. This will produce an * authentication code half the length of the block size of the cipher, with * the CFB mode set to 8 bits. * * @param cipher the cipher to be used as the basis of the MAC generation. */ public CFBBlockCipherMac( BlockCipher cipher) { this(cipher, 8, (cipher.getBlockSize() * 8) / 2, null); }
/** * return the blocksize for the underlying cipher. * * @return the blocksize for the underlying cipher. */ public int getBlockSize() { return cipher.getBlockSize(); }
/** * create a standard MAC based on a CBC block cipher. This will produce an * authentication code half the length of the block size of the cipher. * * @param cipher the cipher to be used as the basis of the MAC generation. */ public CBCBlockCipherMac( BlockCipher cipher) { this(cipher, (cipher.getBlockSize() * 8) / 2, null); }
/** * return the block size of the underlying cipher. * * @return the block size of the underlying cipher. */ public int getBlockSize() { return cipher.getBlockSize(); }
/** * return the block size we are operating at. * * @return the block size we are operating at (in bytes). */ public int getBlockSize() { return cipher.getBlockSize(); }
/** * create a standard MAC based on a CBC block cipher (64 or 128 bit block). * This will produce an authentication code the length of the block size * of the cipher. * * @param cipher the cipher to be used as the basis of the MAC generation. */ public CMac(BlockCipher cipher) { this(cipher, cipher.getBlockSize() * 8); }
/** * create a standard MAC based on a block cipher. This will produce an * authentication code half the length of the block size of the cipher. * * @param cipher the cipher to be used as the basis of the MAC generation. * @deprecated use CBCBlockCipherMac */ public BlockCipherMac( BlockCipher cipher) { this(cipher, (cipher.getBlockSize() * 8) / 2); }
/** * Constructs a Poly1305 MAC, using a 128 bit block cipher. */ public Poly1305(final BlockCipher cipher) { if (cipher.getBlockSize() != BLOCK_SIZE) { throw new IllegalArgumentException("Poly1305 requires a 128 bit block cipher."); } this.cipher = cipher; }
/** * Reseed the RNG. */ void reseed() { V = entropySource.getEntropy(); if (V.length != engine.getBlockSize()) { throw new IllegalStateException("Insufficient entropy returned"); } reseedCounter = 1; }
public GCFBBlockCipher(BlockCipher engine) { super(engine); this.cfbEngine = new CFBBlockCipher(engine, engine.getBlockSize() * 8); }
public int doFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) { int blockSize = cipher.getBlockSize(); for (int i = 0; i < inputLength; i += blockSize) { cipher.processBlock(input, inputOffset + i, output, outputOffset + i); } return inputLength; }
protected BaseBlockCipher( AEADBlockCipher engine) { this.baseEngine = engine.getUnderlyingCipher(); this.ivLength = baseEngine.getBlockSize(); this.cipher = new AEADGenericBlockCipher(engine); }
private void CTR_DRBG_Instantiate_algorithm(byte[] entropy, byte[] nonce, byte[] personalisationString) { byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalisationString); byte[] seed = Block_Cipher_df(seedMaterial, _seedLength); int outlen = _engine.getBlockSize(); _Key = new byte[(_keySizeInBits + 7) / 8]; _V = new byte[outlen]; // _Key & _V are modified by this call CTR_DRBG_Update(seed, _Key, _V); _reseedCounter = 1; }
public static BufferedBlockCipher createSymmetricKeyWrapper(boolean forEncryption, BlockCipher engine, byte[] key, byte[] iv) { BufferedBlockCipher c = new BufferedBlockCipher(new CFBBlockCipher(engine, engine.getBlockSize() * 8)); c.init(forEncryption, new ParametersWithIV(new KeyParameter(key), iv)); return c; }