Safety of encryption when knowing part of the content [duplicate]

I want to encrypt a JSON file while exposing its interface (the name of the object fields) in clear text.

Since this exposes part of the content of the file, my guess is that an attacker could use this to hack the encryption key.

Are there encryption methods that can circumvent, or at least be safer for cases like this?

I am mostly convinced that knowing part of the content of an encrypted file can make attacks easier, but I do not know if there is a technical term for such conditions or how to evaluate if some algorithms are safer or not. So far I am specially interested if using aes-192-cbc or gpg would be OK.

• This is known as Known-Plaintext Attack (KPA) and even in the ECB mode, no AES is secure: Is it possible to find the key for AES ECB if I have a list of plaintext and corresponding ciphertext?. One can use the CBC as long as there is no padding oracle attack case and guarantee that nonce is randomly generated. – kelalaka Aug 9 '20 at 11:11
• @kelalaka I think you meant “no, AES is secure”, not “no AES is secure”. But actually, while AES itself is secure, it's only secure to encrypt 128-bit messages. AES-ECB, which allows encrypting multi-block messages is not secure against known-plaintext attacks. For example, if $P_1 \ne P_2$ are two data blocks and the adversary knows that $\mathsf{AES\_ECB\_Enc}(P_1||P_2) = C_1||C_2$, then the adversary knows the decryption of $C_2||C_1$. – Gilles 'SO- stop being evil' Aug 9 '20 at 19:53
• Use a standard protocol instead of rolling your own. – Gilles 'SO- stop being evil' Aug 9 '20 at 19:54
• @Gilles'SO-stopbeingevil' yes it should be "no, AES is secure". Yes, multi-block security is a big issue for ECB. thanks – kelalaka Aug 9 '20 at 19:58
• @Gilles'SO-stopbeingevil' interpreting "hack the encryption key" as actually extracting the key, AES even in ECB mode should be secure in this (laughably weak and in probably every case insufficient) sense. This follows from standard PRP security. – Maeher Aug 10 '20 at 8:55

This security notion is defined as a game between a challenger and the attacker. The challenger chooses a key for the encryption scheme. The attacker can then query any ciphertext of their choice to the challenger and receives an encryption that plaintext. Eventually, the attacker outputs two challenge plaintexts $$m_0,m_1$$, the challenger flips a random bit $$b$$, and gives an encryption of $$m_b$$ to the attacker. The attacker can continue to make queries as above and eventually has to guess which message was encrypted. In an encryption scheme that is IND-CPA secure an efficient attacker can essentially do no better than guessing randomly.