使用AES非对称加密和解密时存储IV [英] Storing IV when using AES asymmetric encryption and decryption

查看:92
本文介绍了使用AES非对称加密和解密时存储IV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看一个C#AES非对称加密和解密示例,不确定是否应将IV存放在安全的地方(也已加密?).或者,我可以将其附加到加密的文本上,以备以后解密时使用.从关于AES的简短阅读中,似乎根本不需要解密,但是我不确定我是否正确,并且 aes.CreateDecryptor(keyBytes,iv)需要它作为参数.

我对所有加密都使用一个密钥.

解决方案

将加密数据作为 IV.Concat(cipherText)传输是相当标准的.将IV放在一边也很标准,例如 PKCS#5 ./p>

IV侧方法与.NET想要处理数据的方式更加匹配,因为分割IV并将其分别传递给IV参数(或属性),然后传递给IV有点烦人.使用密文(或恢复的明文)进行更复杂的切片操作.

但是IV通常以清晰的方式传输.

因此,将其粘合在一起,或将其单独放置一列……更好地适合您的程序和结构.

I'm looking at an C# AES asymmetric encryption and decryption example here and not sure if i should store the IV in a safe place (also encrypted??). Or i can just attach it to the encrypted text for using later when i with to decrypt. From a short reading about AES it seems it's not needed at all for decryption but i'm not sure i got it right and also the aes.CreateDecryptor(keyBytes, iv) need it as parameter.

I use a single key for all encryptions.

解决方案

It's fairly standard to transmit the encrypted data as IV.Concat(cipherText). It's also fairly standard to put the IV off to the side, like in PKCS#5.

The IV-on-the-side approach matches more closely with how .NET wants to process the data, since it's somewhat annoying to slice off the IV to pass it separately to the IV parameter (or property), and then to have a more complicated slicing operation with the ciphertext (or recovered plaintext).

But the IV is usually transmitted in the clear either way.

So, glue it together, or make it a separate column... whatever fits your program and structure better.

这篇关于使用AES非对称加密和解密时存储IV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆