Encrypt entire payload or only confidential parts of payload? In cases where a large complex data structure contains elements that are a mix of confidential and not-so-confidential data, what would be the pros &amp; cons of:


encrypting the entire structure with one key; or
encrypting only the parts of the data structure that contain confidential data?
Pros of encrypting entire payload:


That's simplest to code.
Encrypting data may have the side-effect of improving the chances to detect an alteration during transfer of the cryptogram (hence enciphering the whole payload may extend that beneficial side-effect to the whole payload); however that is not the function of encryption, and it must not be assumed that encryption ensures integrity, especially facing malicious changes; see second section.


Cons of encrypting entire payload:


The whole payload becomes unintelligible, possibly hindering functionality; e.g. we could loose access to the identifier of the destination of the data (possibly needed for routing to the appropriate location), when it was produced (forcing transmission of obsolete data), or the index/identifier of the key used for encryption (making decryption a guesswork).
Because of the above, some essential data might need to be duplicated in clear, increasing the size of the data transmitted, thus transmission time and cost.
Encryption time has a component proportional to the amount of data enciphered, thus there is more encryption and decryption work to do.
The attacker has potentially more known plaintext/ciphertext pairs; that is a non-issue with modern ciphers, but used to be a way to attack pre-1970 cryptosystems.
It is much easier to get approval for free circulation across borders of a system using secure encryption that enciphers only specific fields of an application-specific message, than for a secure system designed to encipher arbitrary data; this reality often entirely negates the first stated advantage of enciphering the whole payload.




In many practical cases, a sound security analysis would conclude that the right option is to ensure the integrity of the whole payload, and the confidentiality of part of it. Some modern operating modes, like AES-GCM, have provision for that; the computational savings obtained by not enciphering what needs not are significant (at least when AES is in software).