I need to write a Python script to occasionally encrypt some small text files (~10 Kb)
in order to store them in an insecure environment.
Each file will be encrypted via unique symmetric key and AES 256 CTR cipher.
The key and CTR nonce will then be encrypted via RSA key and appended to the
Could you please help to clarify the following security concerns:
I currently use the following code for encryption, basing on Python Cryptodome examples:
key = get_random_bytes(32)
cipher = AES.new(key, AES.MODE_CTR)
encr_data = cipher.encrypt(orig_data)
Is Cryptodome get_random_bytes() secure to be used for AES keys generation?
If not, which one is the better alternative?
In my current script the initial value of CTR counter is set to default value 0. Is it a valid approach?
Or it makes the implementation vulnerable, and some more sophisticated approach should be used
to generate it?
The unencrypted text of each file starts from the same publicly known header which is ~60 bytes.
So, though each file will be encrypted with a unique key, there will be a ~60 bytes known match
between open text and encrypted text. Does it give any chance to decrypt the rest content of the file?