// ECB mode encryption private int EcbEncrypt(byte[] input, int inputOffset, int inputCount, byte[] output, int outputOffset) { if (inputCount < cipherBytes) { return(0); } GetBytes(input, inputOffset, block, cipherBytes); cipher.Encrypt(block, block); PutBytes(block, output, outputOffset, cipherBytes); return(cipherBytes); }
// ECB mode encryption int EcbEncrypt(byte[] input, int inputOffset, int inputCount, byte[] output, int outputOffset) { if (inputCount >= _cipherBytes) { GetBytes(input, inputOffset, _block, _cipherBytes); _cipher.Encrypt(_block, _block); PutBytes(_block, output, outputOffset, _cipherBytes); return(_cipherBytes); } return(0); }
private void ProcessBlock(int bytes) { // Set the key to the current state cipher.SetKey(state); // Update tweak UbiParameters.BitsProcessed += (ulong)bytes; cipher.SetTweak(UbiParameters.Tweak); // Encrypt block cipher.Encrypt(cipherInput, state); // Feed-forward input with state for (int i = 0; i < cipherInput.Length; i++) { state[i] ^= cipherInput[i]; } }