Currently I'm saving an array of AES keys into a keychain as JSON, saved as a text file / SQL text column:
{
[
{
encryptedAesKey:RsaEncryptedBytesBase64Encoded==,
signature:RsaSignatureBytesBase64==,
keyId:0,
},
{
encryptedAesKey:RsaEncryptedBytesBase64Encoded==,
signature:RsaSignatureBytesBase64==,
keyId:1,
}
]
signature:HashAboveKeychainThenRsaSignatureBytesBase64==
}
Only the holder of the private key (say Alice) can decrypt the AES keys. Alice also has her own public key, so she can verify the signature before usage. This protects her against Chuck who might disrupt AES decryption of already encrypted data by creating a random AES key, encrypting it with Alice's public key and writing to where the JSON is saved. But chuck can't sign so Alice won't accidentally use bad data.
The above has been working for many many months but CMS/PKCS#7 seems attractive since it already designed for data security and integrity by defining data envelopes (encrypt) and data signatures (signing).
Question: Apart from interoperability what additional benefits would one have by going the CMS/PKCS#7 route?