I'm using an AES key of type cipher.Block
generated by using crypto/aes
package with below func:
aesBlock, err := aes.NewCipher(randKey)
I'm using this to encrypt a particular set of data but afterward I want to encrypt aesBlock
itself with a Public Key, so that I can store and later decrypt with the asymmetric Private Key. However, I'm having a tough time finding the best way to encrypt aesBlock
. Obviously this needs to be reversible so that I can use it to decrypt the previously mentioned data.
The func EncryptOAEP from crypto/aes
seems like a good fit, as it takes a *PublicKey
, however the msg
parameter is of type []byte
and my AES key is of type cipher.Block
. Not sure a direct conversion is possible or even a good idea.
Any ideas?