Code Monkey home page Code Monkey logo

encryptalgorithm's Introduction

encryptAlgorithm

快速上手

# 制作serverKey.pem和serverCert.cer
```
openssl req -newkey rsa:2048 -nodes -keyout serverKey.pem \
-x509 -days 365 -out serverCert.cer \
-subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=hijk/emailAddress=132456.com"
```
# CentOS环境编译前需要安装开发工具
```
sudo yum groupinstall "Development Tools"
sudo yum install cmake3 openssl-devel
```
# 编译步骤
```
cmake3 .
make
```

命令行编译

# 制作serverKey.pem和serverCert.cer
```
openssl req -newkey rsa:2048 -nodes -keyout serverKey.pem \
-x509 -days 365 -out serverCert.cer \
-subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=server/emailAddress=[email protected]"
```
# 验证
```
在第一个终端窗口运行
openssl s_server -accept 4430 -key serverKey.pem -cert serverCert.cer
在第二个终端窗口制作clientKey.pem和clientCert.cer,然后运行openssl s_client
openssl req -newkey rsa:2048 -nodes -keyout clientKey.pem \
-x509 -days 365 -out clientCert.cer \
-subj "/C=CN/ST=GD/L=GZ/O=abc/OU=defg/CN=client/emailAddress=[email protected]"
openssl s_client -connect 127.0.0.1:4430 -key clientKey.pem -cert clientCert.cer
```

快速上手指南介绍GmSSL的编译、安装和gmssl命令行工具的基本指令。

  1. 下载源代码(zip),解压缩至当前工作目录

    $ unzip GmSSL-master.zip
    
  2. 编译与安装

    Linux平台 (其他平台的安装过程见编译与安装)

    $ ./config no-saf no-sdf no-skf no-sof no-zuc
    $ make
    $ sudo make install
    

    安装之后可以执行gmssl命令行工具检查是否成功

    $ gmssl version
    GmSSL 2.0 - OpenSSL 1.1.0d
    
  3. SM4加密文件

    $ gmssl sms4 -e -in <yourfile> -out <yourfile>.sms4
    enter sms4-cbc encryption password: <your-password>
    Verifying - enter sms4-cbc encryption password: <your-password>
    

    解密

    $ gmssl sms4 -d -in <yourfile>.sms4
    enter sms4-cbc decryption password: <your-password>
    
  4. 生成SM3摘要

    $ gmssl sm3 <yourfile>
    SM3(yourfile)= 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0
    
  5. 生成SM2密钥并签名

    $ gmssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:sm2p256v1 \
                    -out signkey.pem
    $ gmssl pkeyutl -sign -pkeyopt ec_scheme:sm2 -inkey signkey.pem \
                    -in <yourfile> -out <yourfile>.sig
    

    可以将公钥从signkey.pem中导出并发发布给验证签名的一方

    $ gmssl pkey -pubout -in signkey.pem -out vrfykey.pem
    $ gmssl pkeyutl -verify -pkeyopt ec_scheme:sm2 -pubin -inkey vrfykey.pem \
                    -in <yourfile> -sigfile <yourfile>.sig
    
  6. 生成SM2私钥及证书请求

    $ gmssl ecparam -genkey -name sm2p256v1 -text -out user.key
    $ gmssl req -new -key user.key -out user.req
    

    查看证书请求内容:

    $ gmssl req -in user.req -noout -text -subject
    

encryptalgorithm's People

Contributors

matrixbillli avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

liuzhenxin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.