55 return (cipher->
name() +
"/ECB/" + padder->
name());
61 void ECB_Encryption::write(
const byte input[],
size_t length)
69 void ECB_Encryption::end_msg()
73 secure_vector<byte> padding(cipher->
block_size());
74 padder->
pad(&padding[0], padding.size(), last_block);
83 void ECB_Encryption::buffered_block(
const byte input[],
size_t input_length)
85 const size_t blocks_in_temp = temp.size() / cipher->
block_size();
86 size_t blocks = input_length / cipher->
block_size();
90 size_t to_proc = std::min(blocks, blocks_in_temp);
92 cipher->
encrypt_n(input, &temp[0], to_proc);
101 void ECB_Encryption::buffered_final(
const byte input[],
size_t input_length)
104 buffered_block(input, input_length);
105 else if(input_length != 0)
106 throw Encoding_Error(
name() +
": Did not pad to full blocksize");
152 return (cipher->
name() +
"/ECB/" + padder->
name());
158 void ECB_Decryption::write(
const byte input[],
size_t length)
166 void ECB_Decryption::end_msg()
174 void ECB_Decryption::buffered_block(
const byte input[],
size_t length)
176 const size_t blocks_in_temp = temp.size() / cipher->
block_size();
177 size_t blocks = length / cipher->
block_size();
181 size_t to_proc = std::min(blocks, blocks_in_temp);
183 cipher->
decrypt_n(input, &temp[0], to_proc);
195 void ECB_Decryption::buffered_final(
const byte input[],
size_t length)
197 if(length == 0 || length % cipher->
block_size() != 0)
198 throw Decoding_Error(
name() +
": Ciphertext not multiple of block size");
200 size_t extra_blocks = (length - 1) / cipher->
block_size();
202 buffered_block(input, extra_blocks * cipher->
block_size());
206 cipher->
decrypt(input, &temp[0]);