powershell - 安全的 openSSL 文件加密

标签 powershell encryption openssl aes

我希望使用 OpenSSL(多个文件)安全地加密千兆字节的数据。

我使用这个命令(openSSL 1.0.2p-i386-win32):

openssl.exe enc -e -aes-256-ctr -in secret.txt -out encrypted.txt -salt -pass pass:AsIDHnd19!&@#@!#lJglG1f31!

我的问题是:
  • 使用什么模式?点击率还是CBC? (点击率是为了速度?)
  • 如何生成随机 IV?例如在 PowerShell 脚本中。 (我使用的是 Pshell v2.0)
  • 我提供的命令是否足够安全?
  • 我可以为每个文件使用相同的盐,以获得更好的加密速度吗?
  • 20-30 字符的真正随 secret 码是否可以弥补密码的不足?
    四?

  • 编辑:

    我下载了一个更新的版本,能够使用 PBKDF2 (openSSL 1.1.1-win32-mingw):
    openssl.exe enc -e -aes-256-ctr -in secret.txt -out encrypted.txt -salt -pass pass:AsIDHnd19!&@#@!#lJglG1f31! -pbkdf2 -p
    

    使用 -p 我可以看到用于加密文件的盐、 key 和 IV。每次我运行 openssl 时,所有 3 个参数都会发生变化,即使在同一个文件上并且使用相同的 channel 也是如此。

    这是否意味着我现在很安全并且 IV 是随机的?

    最佳答案

  • CBC 和 CTR 应该有相同的速度。
  • 如果未指定 IV,则使用 pbkdf2 从您的密码生成。
  • 点击率是 recommended到加拿大广播公司。
  • 不建议使用相同的盐。 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.


  • 四是不缺。如果没有给出,OpenSLL 会为您生成。
  • 关于powershell - 安全的 openSSL 文件加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53005835/

    相关文章:

    android - 在 Android 中将 KeyStore 写入文件时,使用 BouncyCaSTLe PKCS12SafeBagBuilder 或 PKCS12BagAttributeCarrier 更改 PKCS12 安全包属性?

    powershell - 使用 Powershell 哈希表键时如何避免错误匹配

    windows - 在 Powershell 中将多个 Zip 中的特定文件类型提取到一个文件夹

    javascript - CryptoJS AES 解密 PHP openssl_encrypt 中加密的消息

    c++ - 返回函数崩溃 - C++ Openssl

    python - 在Docker上的pip安装上的CERTIFICATE_VERIFY_FAILED

    powershell - PowerShell嵌套函数中的可变作用域

    command-line - Windows事件的“In words”部分

    iphone - 如果使用简单的异或密码需要申请CCATS吗?

    java - IP地址加密