dongwo2772 2017-09-28 15:33
浏览 353

golang加密密码块/ AES密钥本身

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?

  • 写回答

1条回答 默认 最新

  • duanli4146 2017-09-28 16:07
    关注

    As Adrian pointed out in the comments, the solution is simpler than I thought. All you need to do is encrypt and store the randKey. Regenerating the aesBlock with decrypted randKey produces the same results.

    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样