Encrypt/decrypt an entire input stream, writing to the given output stream
| 68 | |
| 69 | // Encrypt/decrypt an entire input stream, writing to the given output stream |
| 70 | void Aes_ctr_encryptor::process_stream (std::istream& in, std::ostream& out, const unsigned char* key, const unsigned char* nonce) |
| 71 | { |
| 72 | Aes_ctr_encryptor aes(key, nonce); |
| 73 | |
| 74 | unsigned char buffer[1024]; |
| 75 | while (in) { |
| 76 | in.read(reinterpret_cast<char*>(buffer), sizeof(buffer)); |
| 77 | aes.process(buffer, buffer, in.gcount()); |
| 78 | out.write(reinterpret_cast<char*>(buffer), in.gcount()); |
| 79 | } |
| 80 | } |
| 81 |