digraph "STAP-A -> FU-A" {
node [shape=record];
graph [ splines = line ];
SA [label="{STAP-A Type
| {<f> F |<n> NRI |<t> Type } }
| {<d1> STAP-A Data 1}
| {<dx> STAP-A Data ...}
| {<dn> STAP-A Data N}"
];
FU [label="{<i> N}| {FU-A Indicator | {<f> F |<n> NRI | Type(28) } } | {FU-A Header | {<s> S(1) | E(0) | R(0) | <t> Type } }| {<p> FU-A Payload}"];
FUx [label="{<i> N + ...} | {FU-A Indicator | {<f> F |<n> NRI | Type(28) } } | {FU-A Header | {S(0) | E(0) | R(0) | <t> Type } } | {<p> FU-A Payload}"];
FUn [label="{<i> N + n} | {FU-A Indicator | {<f> F |<n> NRI | Type(28) } } | {FU-A Header | {S(0) |<e> E(1) | R(0) | <t> Type } } | {<p> FU-A Payload}"];
FU:i -> FUx:i;
FUx:i -> FUn:i;
SA:f -> FU:f [color="DodgerBlue" ];
SA:f -> FUx:f [color="DodgerBlue" ];
SA:f -> FUn:f [color="DodgerBlue" ];
SA:n -> FU:n [color="Blue" ];
SA:n -> FUx:n [color="Blue" ];
SA:n -> FUn:n [color="Blue" ];
SA:t -> FU:t [color="Green" ];
SA:t -> FUx:t [color="Green" ];
SA:t -> FUn:t [color="Green" ];
SA:d1 -> FU:p [label="第一段" color="Red" ];
SA:dx -> FUx:p [label="第...段" color="Red" ];
SA:dn -> FUn:p [label="最后一段" color="Red" ];
}
flowchart TB
subgraph key["密钥"]
ASN1["ASN.1"]
CER["CER"]
DER["DER"]
PER["PER"]
XER["XER"]
PEM["PEM"]
symKey["对称密钥
····
如:DES、3DES、AES
————
速度快,但是安全性相对差"]
asymKey["非对称密钥
····
如:RSA、DSA
————
速度慢,但是安全性相对高"]
pubKey["公钥"]
privKey["私钥"]
p1["PKCS #1
····
是专门为 RSA 密钥进行定义的"]
p8["PKCS #8
····
为 RSA 和其它密钥所使用"]
os_rsa["openssl genrsa
-<cipher>
-passout pass:1234
-out server.key 2048
····
生成私钥文件
————
“<cipher>”的可选项参照“man openssl-genrsa”。
它是用来加密密钥自身的。"]
os_rsa_pub["openssl rsa
-in server.key
-pubout -out server.pub.key
····
通过私钥文件生成公钥文件"]
os_key["openssl genpkey
-algorithm RSA
-out privatekey.key
-pass pass:1234
-des-ede3-cbc"]
os_enc_key["openssl aes-256-cbc
-e -pbkdf2 -in input.txt -base64 -md sha256
-K 123 -iv 456 -S 789
> output.txt
····
对称加密(-e)没有所谓的密钥文件,只有类似密钥的东西.
也就是Salt(-S)、IV(-iv)、Key(-K)。
注意:示例使用了123、456、789。真实的密钥要非常复杂。
实际上这么简单的密钥几乎和没有加密是一样的。"]
os_dec_key["openssl aes-256-cbc
-d -pbkdf2 -in output.txt -base64 -md sha256
-K 123 -iv 456 -S 789
> input.txt
····
使用同样的Salt(-S)、IV(-iv)、Key(-K)解密(-d)。"]
os_enc_p2k["openssl aes-256-cbc
-e -pbkdf2 -md sha256 -P
-k 1234
····
OpenSSL提供了一个方法,通过一个密码(-k)
随机生成一组Salt、IV、Key。"]
os_enc_ps["openssl aes-256-cbc
-e -pbkdf2 -in input.txt -base64 -md sha256
-k 1234
> output.txt
····
同样的,也可以直接使用密码加(-e)解(-d)密。"]
end
asymKey --> ASN1
ASN1 --- CER
ASN1 --- DER
ASN1 --- PER
ASN1 --- XER
DER -->|Base64编码| PEM
PEM -->|Base64解码| DER
PEM --> pubKey
pubKey --> p1
pubKey --> p8
PEM --> privKey
privKey --> p1
privKey --> p8
symKey --> os_enc_key
os_enc_key --> os_dec_key
symKey --> os_enc_p2k
os_enc_p2k --> os_enc_ps
p1 --> os_rsa
os_rsa --> os_rsa_pub
p8 --> os_key
style pubKey fill:#f0f8ff,stroke:#00f,stroke-dasharray:3 3,color:#00f
style privKey fill:#f0f8ff,stroke:#00f,stroke-dasharray:3 3,color:#00f
style p1 fill:#f0f8ff,stroke:#00f,stroke-dasharray:3 3,color:#00f
style p8 fill:#f0f8ff,stroke:#00f,stroke-dasharray:3 3,color:#00f
style os_rsa fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00
style os_rsa_pub fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00
style os_key fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00
style os_enc_key fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00
style os_dec_key fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00
style os_enc_p2k fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00
style os_enc_ps fill:#ffc0cb,stroke:#f00,stroke-width:2px,color:#f00