Let say in a simple Java program, Considering all the facts, like security and performance, Which is the best way to follow. I tried searching for a answer but proper answer is not out there.
Which is better: “serialize and then encrypt” or “encrypt and then serialize”?
SealedObject
only claims confidentiality, and that there are several attacks on de-serialization of Java objects possible. I.e. if you use it, make sure that you aren't vulnerable against attackers being able to alter the encrypted objects before you try to unseal them. $\endgroup$SealedObject
you need to perform serialization of theSealedObject
instance if you require a binary representation. This is of course a nicely standardized way of doing things, but it also adds overhead you may want to avoid. Oh, and you can use GCM to seal objects, but I'm not sure this is secure if you serialize / de-serialize theSealedObject
itself (I sure hope this was considered, butSealedObject
only claims confidentiality and the de-serialization ofSealedObject
happens before decryption). $\endgroup$