encryption - OpenSSL - 密码与盐目的

标签 encryption passwords openssl salt

使用 OpenSSL 加密文件时,可以使用 -pass pass:mySillyPassword,其中 mySillyPassword 是用于加密的密码。此外,可以使用盐,其中 -salt -s(十六进制字符串)用于指定盐。

为什么有人要使用密码而不是盐或与盐结合使用?另外,我知道仅使用 -salt 命令会导致 OpenSSL 生成盐。这比用户定义的盐更好吗?如果OpenSSL 随机生成一个salt,那么用户以后如何知道这个salt 是什么来解密文件呢?

最佳答案

在 OpenSSL 中,salt 将被添加到加密数据的前面,这将允许它被解密。 salt的目的是防止字典攻击、彩虹表等,以下来自OpenSSL文档:

Without the -salt option it is possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. The reason for this is that without the salt the same password always generates the same encryption key. When the salt is being used the first eight bytes of the encrypted data are reserved for the salt: it is generated at random when encrypting a file and read from the encrypted file when it is decrypted.



该文档建议盐始终与密码一起使用,除非需要与不支持盐的早期版本兼容。

关于encryption - OpenSSL - 密码与盐目的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17297637/

相关文章:

ssl - 将 OpenSSL 与自定义 channel 结合使用

c# - 如何在本地正确存储密码

C# AES-256 加密

java - 将字节流输出到标准输出

c# - 如何加密密码并将其添加到我的sql数据库?

html - 如何让浏览器识别密码更改?

java - Java 堆转储中的敏感数据

c# - 在 WPF 中同时验证多个控件

c++ - 用于 DHE 交换的 OpenSSL 证书生成

linux - stunnel 和 sshuttle 有什么区别