Skip to content

Commit

Permalink
Update Sphinx and security
Browse files Browse the repository at this point in the history
  • Loading branch information
T5750 committed Jan 12, 2020
1 parent 3f17000 commit a5958cf
Show file tree
Hide file tree
Showing 51 changed files with 97 additions and 196 deletions.
13 changes: 6 additions & 7 deletions doc/source/security/SSL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SSL/TLS

## Java SSL/TLS 安全通讯协议介绍
### SSL/TLS 协议的介绍
## SSL/TLS 协议的介绍
SSL/TLS 协议(RFC2246 RFC4346)处于 TCP/IP 协议与各种应用层协议之间,为数据通讯提供安全支持。

从协议内部的功能层面上来看,SSL/TLS 协议可分为两层:
Expand All @@ -16,7 +15,7 @@ SSL/TLS 协议(RFC2246 RFC4346)处于 TCP/IP 协议与各种应用层协议

2. SSL/TLS 双向认证,就是双方都会互相认证,也就是两者之间将会交换证书。基本的过程和单向认证完全一样,只是在协商阶段多了几个步骤。在服务器端将协商的结果和服务器端的公钥一起发送给客户端后,会请求客户端的证书,客户端则会将证书发送给服务器端。然后,在客户端给服务器端发送加密数据后,客户端会将私钥生成的数字签名发送给服务器端。而服务器端则会用客户端证书中的公钥来验证数字签名的合法性。建立握手之后过程则和单向通讯完全保持一致。

### SSL/TLS 协议建立通讯的基本流程
## SSL/TLS 协议建立通讯的基本流程
![SSL/TLS 基本流程图](https://www.ibm.com/developerworks/cn/java/j-lo-ssltls/image001.png)

**步骤 1.** ClientHello – 客户端发送所支持的 SSL/TLS 最高协议版本号和所支持的加密算法集合及压缩方法集合等信息给服务器端。
Expand Down Expand Up @@ -49,7 +48,7 @@ SSL/TLS 协议(RFC2246 RFC4346)处于 TCP/IP 协议与各种应用层协议

**步骤 15.** ClosedConnection – 通讯结束后,任何一方发出断开 SSL 连接的消息。

### SSL/TLS 协议概念
## SSL/TLS 协议概念

**Key:** Key 是一个比特(bit)字符串,用来加密解密数据的,就像是一把开锁的钥匙。

Expand All @@ -65,15 +64,15 @@ SSL/TLS 协议(RFC2246 RFC4346)处于 TCP/IP 协议与各种应用层协议

**数字签名(Digital Signature):** 一个消息的加密哈希被创建后,哈希值用发送者的私钥加密,加密的结果就是叫做数字签名。

### JSSE(Java Secure Socket Extension)使用介绍
## JSSE(Java Secure Socket Extension)使用介绍
在 Java SDK 中有一个叫 JSSE(javax.net.ssl)包,这个包中提供了一些类来建立 SSL/TLS 连接。通过这些类,开发者就可以忽略复杂的协议建立流程,较为简单地在网络上建成安全的通讯通道。JSSE 包中主要包括以下一些部分:
- 安全套接字(secure socket)和安全服务器端套接字
- 非阻塞式 SSL/TLS 数据处理引擎(SSLEngine)
- 套接字创建工厂 , 用来产生 SSL 套接字和服务器端套接字
- 套接字上下文 , 用来保存用于创建和数据引擎处理过程中的信息
- 符合 X.509 规范密码匙和安全管理接口

### 安全钥匙与证书的管理工具 Keytool
## 安全钥匙与证书的管理工具 Keytool
1. 进入本地的 java 安装位置的 bin 目录中 cd /java/bin

2. 创建一个客户端 keystore 文件
Expand Down Expand Up @@ -111,4 +110,4 @@ SSL/TLS 协议(RFC2246 RFC4346)处于 TCP/IP 协议与各种应用层协议
## References
- [Java SSL/TLS 安全通讯协议介绍](https://www.ibm.com/developerworks/cn/java/j-lo-ssltls/)
- [SSL/TLS协议运行机制的概述](http://www.ruanyifeng.com/blog/2014/02/ssl_tls.html)
- [图解SSL/TLS协议](http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html)
- [图解SSL/TLS协议](http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html)
21 changes: 8 additions & 13 deletions security/aes/README.md → doc/source/security/aes.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
# AES

## Runtime Environment
- [Java 7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)

## Short & Quick introduction

### Features
## Features
- Symmetric key symmetric block cipher
- 128-bit data, 128/192/256-bit keys
- Stronger and faster than Triple-DES
- Provide full specification and design details
- Software implementable in C and Java

### Operation of AES
![Operation of AES](http://www.wailian.work/images/2018/03/14/OperationofAES.jpg)
## Operation of AES
![Operation of AES](https://www.wailian.work/images/2018/03/14/OperationofAES.jpg)

### Encryption Process
![Encryption Process](http://www.wailian.work/images/2018/03/14/EncryptionProcess.jpg)
## Encryption Process
![Encryption Process](https://www.wailian.work/images/2018/03/14/EncryptionProcess.jpg)

1. Byte Substitution (SubBytes)
1. Shift rows
1. Mix Columns
1. Add round key

### Decryption Process
## Decryption Process
1. Add round key
1. Mix columns
1. Shift rows
1. Byte substitution

## Links
## References
- [Java AES (Advanced Encryption Standard) Algorithm Example](https://howtodoinjava.com/security/java-aes-encryption-example/)
- [Advanced Encryption Standard](http://www.java2s.com/Tutorial/Java/0490__Security/0320__Digital-Signature-Algorithm.htm)
- [Advanced Encryption Standard](https://www.tutorialspoint.com/cryptography/advanced_encryption_standard.htm)
- [Java使用AES加解密](http://blog.csdn.net/elim168/article/details/73456866)
- [Java使用AES加解密](http://blog.csdn.net/elim168/article/details/73456866)
13 changes: 4 additions & 9 deletions security/dsa/README.md → doc/source/security/dsa.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# DSA

## Runtime Environment
- [Java 7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)

## Short & Quick introduction

### DSA
DSA是Schnorr和ElGamal签名算法的变种,被美国NIST作为DSfS(DigitalSignature Standard)。

DSA是基于整数有限域离散对数难题的,其安全性与RSA相比差不多。DSA的一个重要特点是两个素数公开,这样,当使用别人的p和q时,即使不知道私钥,你也能确认它们是否是随机产生的,还是作了手脚。RSA却做不到。
Expand All @@ -20,7 +14,8 @@ SHA256withDSA | ... | 1024 | 同密钥 | BC
SHA384withDSA | ... | 1024 | 同密钥 | BC
SHA512withDSA | ... | 1024 | 同密钥 | BC

### ECDSA
# ECDSA

ECDSA:椭圆曲线数字签名算法

特点:速度快,强度高,签名短。
Expand All @@ -37,8 +32,8 @@ SHA256withECDSA | ... | 256 | 256 | JDK/BC
SHA384withECDSA | ... | 256 | 384 | JDK/BC
SHA512withECDSA | ... | 256 | 512 | JDK/BC

## Links
## References
- [Digital Signature Algorithm](http://www.java2s.com/Tutorial/Java/0490__Security/0320__Digital-Signature-Algorithm.htm)
- [java RSA/DSA/ECDSA实现数字签名](http://blog.csdn.net/caiandyong/article/details/50282889)
- [JAVA 上加密算法的实现用例](https://www.ibm.com/developerworks/cn/java/l-security/)
- [Elliptic Curve Digital Signature Algorithm](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)
- [Elliptic Curve Digital Signature Algorithm](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)
15 changes: 7 additions & 8 deletions doc/source/security/https.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# HTTPS

## Short & Quick introduction
### HTTPS 简介
## HTTPS 简介
超文本传输安全协议(英语:Hypertext Transfer Protocol Secure,缩写:HTTPS,常称为HTTP over TLS,HTTP over SSL或HTTP Secure)是一种网络安全传输协议。

### HTTPS 工作原理
## HTTPS 工作原理
1. 浏览器将自己支持的一套加密规则发送给网站。
1. 网站从中选出一组加密算法与HASH算法,并将自己的身份信息以证书的形式发回给浏览器。证书里面包含了网站地址,加密公钥,以及证书的颁发机构等信息(证书中的私钥只能用于服务器端进行解密,在握手的整个过程中,都用到了证书中的公钥和浏览器发送给服务器的随机密码以及对称加密算法)。
1. 浏览器获得网站证书之后浏览器要做以下工作: 

Expand All @@ -16,20 +15,20 @@
- 使用密码加密一段握手消息,发送给浏览器。
1. 浏览器解密并计算握手消息的HASH,如果与服务端发来的HASH一致,此时握手过程结束,之后所有的通信数据将由之前浏览器生成的随机密码并利用对称加密算法进行加密。

### HTTPS 通信时序图
## HTTPS 通信时序图
![https](https://www.wailian.work/images/2018/03/15/https.png)

### HTTPS协议和HTTP协议的区别
## HTTPS协议和HTTP协议的区别
- https协议需要到ca申请证书,一般免费证书很少,需要交费。
- http是超文本传输协议,信息是明文传输,https 则是具有安全性的ssl加密传输协议。
- http和https使用的是完全不同的连接方式用的端口也不一样,前者是80,后者是443。
- http的连接很简单,是无状态的 。
- HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议, 要比http协议安全。

### SSL 证书
## SSL 证书
SSL证书和我们日常用的身份证类似,是一个支持HTTPS网站的身份证明,SSL证书里面包含了网站的域名,证书有效期,证书的颁发机构以及用于加密传输密码的公钥等信息

### 证书的类型
## 证书的类型
1. SSL证书,用于加密HTTP协议,也就是HTTPS。
1. 代码签名证书,用于签名二进制文件,比如Windows内核驱动,Firefox插件,Java代码签名等等。
1. 客户端证书,用于加密邮件。
Expand Down Expand Up @@ -99,7 +98,7 @@ secure="true" sslProtocol="TLS" />
</security-constraint>
```

将 URL 映射设为 /* ,这样你的整个应用都要求是 HTTPS 访问,而 `transport-guarantee` 标签设置为 `CONFIDENTIAL` 以便使应用支持 SSL。
将 URL 映射设为 `/*` ,这样你的整个应用都要求是 HTTPS 访问,而 `transport-guarantee` 标签设置为 `CONFIDENTIAL` 以便使应用支持 SSL。

如果你希望关闭 SSL ,只需要将 `CONFIDENTIAL` 改为 `NONE` 即可。

Expand Down
3 changes: 3 additions & 0 deletions doc/source/security/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ Security
:maxdepth: 2
:numbered: 0

aes
dsa
rsa
https
SSL
19 changes: 7 additions & 12 deletions security/rsa/README.md → doc/source/security/rsa.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# RSA

## Runtime Environment
- [Java 7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)

## Short & Quick introduction

### Digital Signature
## Digital Signature
- 数字签名:带有密钥(公钥,私钥)的消息摘要算法
私钥用于签名,公钥用于验证。

- 数字签名的作用:验证数据的完整性,认证数据来源,抗否认。
- 常用数字签名算法:RSA,DSA,ECDSA

### RSA
## RSA
RSA是目前最有影响力的公钥加密算法,它能够抵抗到目前为止已知的绝大多数密码攻击,已被ISO推荐为公钥数据加密标准。

算法分类信息:
Expand All @@ -29,14 +24,14 @@ SHA512withRSA | ... | 2048 | 同密钥 | BC
RIPEMD128withRSA | | 2048 | 同密钥 | BC
RIPEMD160withRSA | 同上 | 2048 | 同密钥 | BC

### 序列图
![rsa甲方发送数据](http://www.wailian.work/images/2018/02/08/rsa.jpg)
## 序列图
![rsa甲方发送数据](https://www.wailian.work/images/2018/02/08/rsa.jpg)

![rsa乙方发送数据](http://www.wailian.work/images/2018/02/08/rsa25711.jpg)
![rsa乙方发送数据](https://www.wailian.work/images/2018/02/08/rsa25711.jpg)

## Links
## References
- [java RSA使用](http://www.cnblogs.com/freeman-rain/archive/2012/03/29/2424423.html)
- [RSA algorithm](http://www.java2s.com/Tutorial/Java/0490__Security/0740__RSA-algorithm.htm)
- [java RSA/DSA/ECDSA实现数字签名](http://blog.csdn.net/caiandyong/article/details/50282889)
- [RSA (cryptosystem)](https://en.wikipedia.org/wiki/RSA_(cryptosystem))
- [Java加密技术(四)——非对称加密算法RSA](http://snowolf.iteye.com/blog/381767)
- [Java加密技术(四)——非对称加密算法RSA](http://snowolf.iteye.com/blog/381767)
7 changes: 4 additions & 3 deletions security/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Security

## Contents
- [AES](aes/README.md)
- [DSA](dsa/README.md)
- [RSA](rsa/README.md)
- [AES](../doc/source/security/aes.md)
- [DSA](../doc/source/security/dsa.md)
- [ECDSA](../doc/source/security/dsa.md#ecdsa)
- [RSA](../doc/source/security/rsa.md)
- [HTTPS](../doc/source/security/https.md)
- [SSL/TLS](../doc/source/security/SSL.md)
26 changes: 0 additions & 26 deletions security/aes/pom.xml

This file was deleted.

21 changes: 0 additions & 21 deletions security/dsa/pom.xml

This file was deleted.

23 changes: 17 additions & 6 deletions security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@

<artifactId>security</artifactId>
<packaging>pom</packaging>
<modules>
<module>rsa</module>
<module>dsa</module>
<module>aes</module>
</modules>


<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.54</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
32 changes: 0 additions & 32 deletions security/rsa/pom.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.evangel;
package t5750.security.aes;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*/

package com.evangel;
package t5750.security.aes;

import java.io.FilterOutputStream;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.java2s;
package t5750.security.aes.java2s;

import java.security.Key;
import java.security.Security;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.java2s;
package t5750.security.aes.java2s;

import java.security.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.java2s;
package t5750.security.aes.java2s;

import java.security.Key;
import java.security.Security;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.java2s;
package t5750.security.aes.java2s;

import java.security.*;

Expand Down

0 comments on commit a5958cf

Please sign in to comment.