#include "lib4.h" #include "lib3.h" #include "lib2.h" #include "lib.h" /** * encrypt always with the same key, same nonce? * **/ int aes_ctr_edit(char *ciphertext, int ciphertext_length, int offset, char *newtext) { // do not allow greater ciphertexts if((strlen(newtext)+offset) > ciphertext_length) return 1; // insert newtext at offset and reencrpyt char *plaintext = malloc(ciphertext_length); aes_ctr(ciphertext, ciphertext_length, plaintext, key, nonce); memcpy(&plaintext[offset], newtext, strlen(newtext)); aes_ctr(plaintext, ciphertext_length, ciphertext, key, nonce); return 0; }