I'm doing encryption with AES and RSA. Once the encryption stage is complete, I have two pieces of data to transmit.
As this data is byte arrays, I naturally feel like I should be Base64 encoding it.
This data is only ever encrypted and decrypted from my own code, so Base64(RSA(Key)) + "\r\n" + Base64(AES256(message,Key))
"works", but is there a standard I should be using for doing this?
You can use a standardized container format as Oleg has suggested. Well known ones are CMS (derived from PKCS#7) and PGP. XML encryption is also possible, but I would personally try to avoid it unless you are very sure you understand the security of XML encryption. Both Sun and Apache didn't - to name just a few.
As for Base64, you should only base 64 encode anything if you think that your ciphertext is used as text anywhere within the system. If you don't encode it you are very likely to loose data. For crypto, loosing some bytes is about equal to loosing all data. Dont' forget that ciphertext looks like random data, so bytes can have any value, including "fun" values such as 00
, 7F
, space, tab, etc. etc. (and that's just for ASCII).
Note that simply encrypting/decrypting data is often not enough for a transport protocol. You will need to provide integrity/authenticity (e.g. a MAC or HMAC) as well.