Dec 5

[译]OpenSSL Command-Line HOWTO 不指定

linuxing , 12:10 , 网络服务 » 安全相关 , 评论(0) , 引用(0) , 阅读(63644) , Via 本站原创 | |
   OpenSSL是使用非常广泛的 SSL 的开源实现。由于其中实现了为SSL 所用的各种加密算法,因此OpenSSL也是被广泛使用的加密函数库。SSL/TLS 协议位于 TCP 协议和应用层协议之间,为传输双方提供认证、加密和完整性保护等安全服务。SSL作为一个协议框架,通信双方可以选用合适的对称算法、公钥算法、MAC 算法等密码算法实现安全服务。在Linux环境中,除可以使用OpenSSL提供的各种加密函数库外,还能利用其应用程序实现许多重要的功能。以下内容翻译自:OpenSSL Command-Line HOWTO

一、系统环境
以红旗DC Server 5.0 for x86 SP2环境为例,自带版本为:
引用
# rpm -qa|grep openssl
openssl-0.9.7a-43.14
openssl-perl-0.9.7a-43.14
openssl-devel-0.9.7a-43.14
openssl096b-0.9.6b-22.46

二、介绍
1、如何知道我的OpenSSL运行版本
引用
# openssl version
OpenSSL 0.9.7a Feb 19 2003

-a参数可以获得更详细的信息:
引用
# openssl version -a
OpenSSL 0.9.7a Feb 19 2003
built on: Tue Oct 31 02:10:29 EST 2006
platform: linux-elf
options:  bn(64,32) md2(int) rc4(idx,int) des(ptr,risc1,16,long) blowfish(idx)
compiler: gcc -fPIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -DOPENSSL_NO_ASM -DOPENSSL_NO_IDEA -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_EC -I/usr/kerberos/include -DL_ENDIAN -DTERMIO -Wall -O2 -g -march=i386 -mcpu=i686 -Wa,--noexecstack
OPENSSLDIR: "/usr/share/ssl"
engines:  dynamic cswift chil atalla nuron ubsec aep ibmca sureware 4758cca

2、获取可用的命令列表
OpenSSL提供三个内置的选项命令组,而通过提供一个错误的参数,可以获得其帮助信息。(例如help、或-h)
引用
# openssl -h
openssl:Error: '-h' is an invalid command.

Standard commands
asn1parse      ca             ciphers        crl            crl2pkcs7
dgst           dh             dhparam        dsa            dsaparam
enc            engine         errstr         gendh          gendsa
genrsa         nseq           ocsp           passwd         pkcs12
pkcs7          pkcs8          rand           req            rsa
rsautl         s_client       s_server       s_time         sess_id
smime          speed          spkac          verify         version
x509

Message Digest commands (see the `dgst' command for more details)
md2            md4            md5            rmd160         sha
sha1

Cipher commands (see the `enc' command for more details)
aes-128-cbc    aes-128-ecb    aes-192-cbc    aes-192-ecb    aes-256-cbc
aes-256-ecb    base64         bf             bf-cbc         bf-cfb
bf-ecb         bf-ofb         cast           cast-cbc       cast5-cbc
cast5-cfb      cast5-ecb      cast5-ofb      des            des-cbc
des-cfb        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           rc2            rc2-40-cbc
rc2-64-cbc     rc2-cbc        rc2-cfb        rc2-ecb        rc2-ofb
rc4            rc4-40

也可以获取某个命令组可用的参数:
引用
# openssl dgst -h
unknown option '-h'
options are
-c              to output the digest with separating colons
-d              to output debug info
-hex            output as hex dump
-binary         output in binary form
-sign   file    sign digest using private key in file
-verify file    verify a signature using public key in file
-prverify file  verify a signature using private key in file
-keyform arg    key file format (PEM or ENGINE)
-signature file signature to verify
-binary         output in binary form
-engine e       use engine e, possibly a hardware device.
-md5 to use the md5 message digest algorithm (default)
-md4 to use the md4 message digest algorithm
-md2 to use the md2 message digest algorithm
-sha1 to use the sha1 message digest algorithm
-sha to use the sha message digest algorithm
-mdc2 to use the mdc2 message digest algorithm
-ripemd160 to use the ripemd160 message digest algorithm

3、如何获取可用的密码(ciphers)列表
引用
# 显示所有可用的密码(ciphers)列表
openssl ciphers -v
# 仅显示TLSv1版本的密码
openssl ciphers -v -tls1
# 仅显示密钥大于128bit的高强度密码方式
openssl ciphers -v 'HIGH'
# 仅显示使用AES运算法则的高强度密码方式
openssl ciphers -v 'AES+HIGH'

三、性能测试
OpenSSL提供内置的性能测试组件,其通过speed选项,可以测试在一段时间内可以执行的操作数量,而不是测试固定数量操作的时间,这能确保即使是慢的系统,也不会花费过长的时间。
1、如何进行性能测试
引用
# 执行一个完整的性能测试
openssl speed
# 仅进行rsa的速度测试
openssl speed rsa
# 在一个SMP系统中,进行2路的rsa速度测试
openssl speed rsa -multi 2

2、如何测试远程连接的性能
使用s_time运行你测试远程连接的性能(30sec):
openssl s_time -connect remote.host:443

除了简单的测试外,s_time也允许进行指定的测试项目:
引用
# 使用新的session接收远程的test.html页面
openssl s_time -connect remote.host:443 -www /test.html -new
# 类似的,仅使用SSL v3版本和高强度的加密
openssl s_time \
 -connect remote.host:443 -www /test.html -new \
 -ssl3 -cipher HIGH
# 对比多个加密规则在10秒内连接的性能情况
IFS=":"
for c in $(openssl ciphers -ssl3 RSA); do
 echo $c
 openssl s_time -connect remote.host:443 \
   -www / -new -time 10 -cipher $c 2>&1 | \
   grep bytes
 echo
done

如果你并没有SSL支持的Web服务器可以使用,你可以用s_server选项模拟:
引用
# 主机一,建立服务端(默认使用4433端口)
openssl s_server -cert mycert.pem -www
# 主机二,通过s_time连接到指定的4433端口进行测试
openssl s_time -connect myhost:4433 -www / -new -ssl3
内文分页: [1] [2] [3] [4]
Tags: , , ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]