3.openssl speed和openssl rand

(1).openssl speed

测试加密算法的性能。

支持的算法有:

openssl speed [md2] [mdc2] [md5] [hmac] [sha1] [rmd160] [idea-cbc] [rc2-cbc] [rc5-cbc] [bf-cbc] [des-cbc] [des-ede3] [rc4] [rsa512] [rsa1024] [rsa2048] [rsa4096] [dsa512] [dsa1024] [dsa2048] [idea] [rc2] [des] [rsa] [blowfish]

为什么没有base64算法呢?

测试速度好几秒一个指标,很慢。如果不指定参数将测试所有支持的算法,所以会花很久时间,我的虚拟机上花了十多分钟才测试完所有的算法性能。

例如测试下,dsa512、rsa512和rsa2048加密速度如何。

[[email protected] tmp]# openssl speed dsa512 rsa512 rsa2048
Doing 512 bit private rsa‘s for 10s: 107496 512 bit private RSA‘s in 9.99s
Doing 512 bit public rsa‘s for 10s: 1425095 512 bit public RSA‘s in 10.00s
Doing 2048 bit private rsa‘s for 10s: 4623 2048 bit private RSA‘s in 9.99s
Doing 2048 bit public rsa‘s for 10s: 153395 2048 bit public RSA‘s in 9.99s
Doing 512 bit sign dsa‘s for 10s: 102089 512 bit DSA signs in 10.00s
Doing 512 bit verify dsa‘s for 10s: 121654 512 bit DSA verify in 9.99s
                  sign    verify    sign/s verify/s
rsa  512 bits 0.000093s 0.000007s  10760.4 142509.5
rsa 2048 bits 0.002161s 0.000065s    462.8  15354.9
                  sign    verify    sign/s verify/s
dsa  512 bits 0.000098s 0.000082s  10208.9  12177.6

在10秒时间内,rsa512的私钥处理107496单位,而rsa2048仅处理4623单位,慢了20多倍。

再看签名性能,dsa算法只支持签名不支持加密,而rsa支持加密也支持签名。从上面的结果中可以看到rsa512的签名速度为每秒10760.4,而dsa512的速度为10208.9,速度相差不大。

(2).openssl rand

生成伪随机数。

openssl rand [-out file] [-rand file(s)] [-base64] [-hex] num

-base64和-hex分别是生成不同编码格式的随机数。

示例:

[[email protected] tmp]# openssl rand -base64 30;openssl rand -hex 30;openssl rand 30
azTkjzvILtI1ODqREGHgcOnzxTz6SmVUuQUjWXiP
4a64f49084d1fc97085acba1c88b963537511cebf0f4d20e8407ff82df26
z28?Z[[email protected] tmp]#

可以看到,不指定-base64或-hex时生成的随机数是乱码随机数(其实是2进制),且没有\n符号。

时间: 2024-07-28 22:18:41

3.openssl speed和openssl rand的相关文章

Openssl speed命令

一.简介 speed命令用于测试库的性能 二.语法 openssl speed [md2] [mdc2] [md5] [hmac] [sha1] [sha256] [sha512] [whirlpool] [rmd160] [idea-cbc] [seed-cbc] [rc2-cbc] [rc5-cbc] [bf-cbc] [des-cbc] [des-ede3] [aes-128-cbc] [aes-192-cbc] [aes-256-cbc] [aes-128-ige] [aes-192-i

php开启openssl的方法,openssl安装

php开启openssl的方法,openssl安装 2014年10月10日 8312次浏览 什么是openssl? 关于openssl,我说的不如百度百科齐全,还是看看百度百科的解释吧!http://baike.baidu.com/view/300712.htm php开启openssl的方法,大多数情况下openssl是没有开启的,要想启用需要进行下简单的设置: windows下开启方法: 1: 首先检查php.ini中:extension=php_openssl.dll是否存在, 如果存在的

修复OpenSSL漏洞 升级OpenSSL版本 nginx静态编译ssl模块

背景 OpenSSL全称为Secure Socket Layer,是Netscape所研发,利用数据加密(Encryption)作技术保障在Internet上数据传输的安全.可确保数据在网络上的传输不会被窃听及截取. 当然,OpenSSL是一个强大的密码库,我们在使用SSL协议的时候不一定非得采用OpenSSL,不过目前基本上都是用的OpenSSL,因为它更安全,使用起来也更简单. 通常出现的OpenSSL的漏洞需要升级版本解决 查看openssl版本 openssl version 进入存放源

(12) OpenSSL主配置文件openssl.cnf

1.man config 该帮助文档说明了openssl.cnf以及一些其他辅助配置文件的规范.格式及读取方式.后文中的所有解释除非特别指明,都将以openssl.cnf为例. [[email protected] ~]# whatis config Config (3pm) - access Perl configuration information config (5ssl) - OpenSSL CONF library configuration files Config::Extens

6.openssl rsautl和openssl pkeyutl

rsautl是rsa的工具,相当于rsa.dgst的部分功能集合.可用于签名.验证.加密和解密文件.非对称密钥的密钥是随机生成的,因此不需要也无法指定salt参与加密. pkeyutl是非对称加密的通用工具,大体上和rsautl的用法差不多,这里只解释rsautl. [[email protected] tmp]# man rsautl NAME rsautl - RSA utility SYNOPSIS openssl rsautl [-in file] [-out file] [-inkey

【openssl】利用openssl完成X509证书和PFX证书之间的互转

利用openssl完成X509证书和PFX证书之间的互转 # OpenSSL的下载与安装: 1.下载地址: 官方网址—— https://www.openssl.org/source/ OpenSSL for Windows —— http://gnuwin32.sourceforge.net/packages/openssl.htm 2.安装:此处已OpenSSL for Windows为例 * 点击openssl-0.9.8h-1-setup.exe 进行安装: * 添加环境变量:path

openssl version 查看openssl 版本出现openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory,怎么办

查看openssl版本, 解决办法: ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1 ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1 原文地址:https://www.cnblogs.com/peteremperor/p/9994108.html

openssl大纲

1.加密和SSL机制:http://www.cnblogs.com/f-ck-need-u/p/6089523.html 2.openssl命令总指挥:http://www.cnblogs.com/f-ck-need-u/p/6089703.html 3.openssl genrsa:http://www.cnblogs.com/f-ck-need-u/p/6089730.html 4.openssl rsa:http://www.cnblogs.com/f-ck-need-u/p/608979

再谈加密-RSA非对称加密的理解和使用

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption