当前位置:网站首页>Encryption and decryption and the application of OpenSSL
Encryption and decryption and the application of OpenSSL
2022-06-30 21:16:00 【Brother Xing plays with the clouds】
This article mainly introduces briefly ;
One 、 Three ways of data encryption ;
Two 、Openssl Basic application and creation of CA Certificates and certificates ;
One 、 Three ways of data encryption ;
1、 Symmetric encryption ; The encryption and decryption parties use the same algorithm , Cut the data into data blocks and encrypt them step by step , And there is an association between the front and back blocks , It is called a block quantity , Decryption is to get the block quantity for operation , To decrypt .
The commonly used symmetric encryption algorithms are :
DES(56bits), 3DES, AES(128bits), Blowfish
Twofish, IDEA, RC6, CAST5, Serpent
characteristic ; Encryption and decryption use the same password
Divide the original text into fixed size data blocks , Encrypt these data blocks
Fast encryption
shortcoming ; Password transmission , Low security
Too many passwords , Not easy to remember
2、 Public key encryption ( Also known as asymmetric encryption ); The main difference with symmetric encryption algorithm is , The encryption and decryption keys are different , A public ( Public key ), A secret ( Private key ). The key distribution management problem of symmetric encryption algorithm is solved , Improved algorithm security .
Asymmetric algorithms have ;RSA、EIGamal、DSA
characteristic ; The sender encrypts the data with the public key of the receiver , The receiver decrypts with its own private key .
Identity authentication is that the sender encrypts with its own private key , The receiver decrypts the other party's public key to ensure data security .
shortcoming ; Encryption of asymmetric encryption algorithm 、 The efficiency of decryption is relatively low .
3、 One way encryption , Generate feature codes for data according to a certain sum algorithm , It is irreversible .
The algorithms for extracting data signatures are ;MD5, SHA1, SHA512, CRC-32
Message authentication algorithm ;CBC-MAC、HMAC
characteristic ;
Message authentication ; Only used to validate the message itself , Encryption signature is required .
Avalanche effect ; Small changes in input data , Will lead to big changes in the results .
Fixed length output ; No matter how long the input data is , Just use the same one-way encryption algorithm , The length of the output results is the same .
Combine the above three encryption methods : As shown in the figure below ;
The picture above , Combine the three encryption algorithms , Symmetric encryption realizes the confidentiality of data , Public key encryption realizes identity authentication , One way encryption realizes the integrity of data .
Two 、Openssl Basic application and creation of CA Certificates and certificates ;
1)、Openss It's a set for SSL( Secure socket layer )/TLS( Transport layer security ) Protocol encryption tool , It consists of the following three components ;
1、libcrypto; General function encryption library ;
2、libssl; Used to implement SSL/TLS The function of
3、 Multi function command tool
Its function can also generate keys 、 Create a digital certificate 、 Calculate the summary of information 、 Manually encrypt and decrypt data .
2)、 Symmetric encryption and decryption methods ;
Common algorithms are :DES,3DES,AES,Blowfish,Twofish,RC6,CAST5
encryption ; openssl enc -des3 -a -salt -in /etc/issue -out /tmp/issue_cipher [[email protected] ~]# cat /etc/issue No content before encryption CentOS release 6.5 (Final) Kernel \r on an \m [[email protected] ~]# openssl enc -des3 -a -salt -in /etc/issue -out /tmp/issue_cipher enter des-ede3-cbc encryption password: Input password Verifying - enter des-ede3-cbc encryption password: Input again [[email protected] ~]# cd /tmp/ [[email protected] tmp]# ls issue_cipher yum.log [[email protected] tmp]# cat issue_cipher View the encrypted file contents U2FsdGVkX1+A3cLqRI09pTWDT6BhqierBK69evESmUcH9SOHUaA+0nw87hM5sDCT 2/PlBNgiqTMiiKelkoAyBw== Decrypt ;openssl enc -d -des3 -a -salt -in /tmp/issue_cipher -out /mnt/issue [[email protected] ~]# openssl enc -d -des3 -a -salt -in /tmp/issue_cipher -out /mnt/issue enter des-ede3-cbc decryption password: Enter decryption password [[email protected] ~]# cat /mnt/issue Look at the decrypted content CentOS release 6.5 (Final) Kernel \r on an \m User authentication ; Public key encryption , Private key decryption
digital signature ; Private key encryption , Public key decryption
3)、 Certificate format of digital certificate (x509);
Public key and expiration date ;
The holder's personally identifiable information ;
How certificates are used ;
Information about the certification authority ;
verification CA Is your digital signature legal ;
4)、 be based on openssl Generate private CA certificate ;
Experimental environment ;Server,172.16.34.200
Client, 172.16.34.2
1,server Mr. Duan forms a key pair ; [[email protected] CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048) Generating RSA private key, 2048 bit long modulus .....................................................................................................................+++ ......+++ e is 65537 (0x10001) 2、server Complete self signed certificate ;
3、 Create the required files ; [[email protected] CA]# touch index.txt serial crlnumber [[email protected] CA]# ls cacert.pem certs crl crlnumber index.txt newcerts private serial [[email protected] CA]# echo 1 > serial [[email protected] CA]# cat serial 1 [[email protected] CA]# 4、 client Realize certificate application ;
Generate the key on the host , Save to the configuration file directory of the service to which this certificate is applied ; mkdir /etc/httpd/ssl cd /etc/httpd/ssl [[email protected] ssl]# (umask 077; openssl genrsa -out httpd.key 1024) Generating RSA private key, 1024 bit long modulus .++++++ ........++++++ e is 65537 (0x10001) [[email protected] ssl]# ls httpd.key [[email protected] ssl]# 5、 Generate the certificate signing request :
[[email protected] ssl]# openssl req -new -key httpd.key -out httpd.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:BJ Locality Name (eg, city) [Default City]:BJ Organization Name (eg, company) [Default Company Ltd]:Ouyang Organizational Unit Name (eg, section) []:linux Common Name (eg, your name or your server's hostname) []:ca.ouyang.com Email Address []:[email protected] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:RedHat An optional company name []:redhat (Client The information filled in at the end should be consistent with The server Agreement )
6、Clientc The client sends the request file to Server End ;
scp httpd.csr 172.16.34.200:/tmp
7、CA signed Client Certificate application sent ;
openssl ca -in /tmp/httpd.csr -out /tmp/httpd.csr -days 3655
8、 Send the certificate back to the applicant after signing ;
scp httpd.crt 172.16.34.20:/etc/httpd/ssl 9、 Revocation of certificate ; The certificate will be revoked until Server End ;
openssl ca -revoke /tmp/httpd.crt
边栏推荐
- ceshi deces
- The 16th Heilongjiang Provincial Collegiate Programming Contest
- [grade evaluator] how to register a grade evaluator? How many passes?
- Markdown notes concise tutorial
- ICML2022 | 序列决策的效用理论
- 网络营销之四大误解
- Metauniverse may become a new direction of Internet development
- ncat详细介绍(转载)
- Markdown笔记简明教程
- ceshi deces
猜你喜欢

Et la dégradation du modèle de génération de texte? Simctg vous donne la réponse

MySQL高级篇3

文本生成模型退化怎麼辦?SimCTG 告訴你答案

Iclr'22 spotlight | how to measure the amount of information in neural network weights?

Markdown notes concise tutorial

uniapp-富文本编辑器

RP原型资源分享-购物类App

开发技术-使用easyexcel导入文件(简单示例)

Four Misunderstandings of Internet Marketing

开源实习经验分享:openEuler软件包加固测试
随机推荐
Digital currency: far-reaching innovation
ArcGIS构建发布简单路网Network数据服务及Rest调用测试
有趣插件汇总
WebRTC系列-网络传输之本地scoket端口
申请Vector 总线协议彩图壁纸挂画,非常棒哦!
升级kube出现unknown flag: --network-plugin
银行集体下架的智能投顾产品,为何成了“鸡肋”?
物联网僵尸网络Gafgyt家族与物联网设备后门漏洞利用
[untitled]
SQL Server 提取字符串中的纯数字
三个火枪手
[grade evaluator] how to register a grade evaluator? How many passes?
coredns 修改upstream
等级测评是什么意思?工作流程包含哪些?
元宇宙可能成为互联网发展的新方向
Peking University ACM problems 1001:exposition
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的
1.微信小程序页面跳转方法总结;2. navigateTo堆栈到十层不跳转问题
ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?
vncserver: Failed command ‘/etc/X11/Xvnc-session‘: 256!