linux - 使用 openssl 时如何隐藏 key 、salt 和 iv,使其不出现在进程标题中?

标签 linux security openssl aes

当使用 openssl 加密/解密数据和 AES 密码时,我的命令将如下所示:

openssl enc -aes-256-cbc -in message_file -K 42AB7FCE7BFEEE03E16719044916CBD475F6D000F230D213FF0F4775EF8D46F5 -iv D5C21AC249B26A1FBA376E8CFCDC4E1A -S 2C6A1B8EAACA302D -e -out message_file.enc

这会将 key、iv 和 salt 放在我的进程标题中,在 top/ps 中可见。有没有一种方法可以在不泄露此信息的情况下使用 openssl(或者如果没有,则使用其他替代方法)对文件进行 AES 加密?我没有看到从文件中获取这些字符串的选项。

最佳答案

RSA 加密:

http://bsdsupport.org/q-how-do-i-use-openssl-to-encrypt-files/

openssl rsautl -encrypt -pubin -inkey public.key -in plaintext.txt -out encrypted.txt

AES 加密:

基于openssl enc -h的结果

openssl enc -aes-128-cbc -in foo -out foo.enc -kfile passwordfile

这是 openssl enc -h 的结果。注意-kfile的说明

root@bt:/tmp# openssl enc -h
unknown option '-h'
options are
-in <file>     input file
-out <file>    output file
-pass <arg>    pass phrase source
-e             encrypt
-d             decrypt
-a/-base64     base64 encode/decode, depending on encryption flag
-k             passphrase is the next argument
-kfile         passphrase is the first line of the file argument
-md            the next argument is the md to use to create a key
                 from a passphrase.  One of md2, md5, sha or sha1
-K/-iv         key/iv in hex is the next argument
-[pP]          print the iv/key (then exit if -P)
-bufsize <n>   buffer size
-engine e      use engine e, possibly a hardware device.
Cipher Types
-aes-128-cbc               -aes-128-cfb               -aes-128-cfb1             
-aes-128-cfb8              -aes-128-ecb               -aes-128-ofb              
-aes-192-cbc               -aes-192-cfb               -aes-192-cfb1             
-aes-192-cfb8              -aes-192-ecb               -aes-192-ofb              
-aes-256-cbc               -aes-256-cfb               -aes-256-cfb1             
-aes-256-cfb8              -aes-256-ecb               -aes-256-ofb              
-aes128                    -aes192                    -aes256                   
-bf                        -bf-cbc                    -bf-cfb                   
-bf-ecb                    -bf-ofb                    -blowfish                 
-cast                      -cast-cbc                  -cast5-cbc                
-cast5-cfb                 -cast5-ecb                 -cast5-ofb                
-des                       -des-cbc                   -des-cfb                  
-des-cfb1                  -des-cfb8                  -des-ecb                  
-des-ede                   -des-ede-cbc               -des-ede-cfb              
-des-ede-ofb               -des-ede3                  -des-ede3-cbc             
-des-ede3-cfb              -des-ede3-ofb              -des-ofb                  
-des3                      -desx                      -desx-cbc                 
-rc2                       -rc2-40-cbc                -rc2-64-cbc               
-rc2-cbc                   -rc2-cfb                   -rc2-ecb                  
-rc2-ofb                   -rc4                       -rc4-40           

关于linux - 使用 openssl 时如何隐藏 key 、salt 和 iv,使其不出现在进程标题中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16028710/

相关文章:

linux - openssl输出文件权限

linux - 如何在 crontab 中快速禁用单个作业

php - 如何防止 &lt;meta http-equiv ="refresh"> 攻击?

php - 使用 openssl sha1 -sign 和 PHP 的 openssl_sign 时,CloudFront 签名 URL 的签名不同

linux - 将 h264 转换为原始 RGB 时 gstreamer 颜色错误

c - Linux 内核中的 nr_cpu_ids 与 NR_CPUS

java - 通过浏览器注入(inject) header

c# - ASP.NET MVC 4 如何使用自定义 membershipprovider 和 roleprovider 实现 Oauth

c++ - SSL 握手产生 BIO 错误

java - RSA_verify 中预期的数据类型是什么,无法验证从 Java 生成的签名