Skip to content

Commit 8ac0d68

Browse files
committed
update README
1 parent baf6f64 commit 8ac0d68

File tree

2 files changed

+53
-26
lines changed

2 files changed

+53
-26
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# zcrypto
2+
3+
**English** | [**中文**](./README.zh.md)
4+
25
a minimal crypto lib for limited environment like MCU.
36

4-
*features*:
7+
## features
58
* base64
69
* hash
710
* SM3
@@ -18,23 +21,20 @@ a minimal crypto lib for limited environment like MCU.
1821
* OFB
1922
* asymmetric key encryption
2023
* RSA(2048)
24+
* RSA-OAEP(2048)
2125

2226
## block cipher
23-
* crypto algorithm:
24-
* AES(128, 192, 256)
25-
* SM4
26-
* operation mode:
27-
* ECB
28-
* CBC
29-
* CFB
30-
* OFB
3127

32-
api has two styles:
33-
* `aes_{keylen}_{mode}_{en/de}crypt` / `sm4_{mode}_{en/de}crypt`
34-
* `aes_{en/de}crypt(aes_ctx_t*, ...)` / `sm4_{en/de}crypt(sm4_ctx_t*, ...)`
28+
do encryption or decryption in once function call.
29+
* `aes_{keylen}_{mode}_{en/de}crypt`
30+
* `sm4_{mode}_{en/de}crypt`
31+
32+
or use context:
33+
* `aes_{en/de}crypt(aes_ctx_t*, ...)`
34+
* `sm4_{en/de}crypt(sm4_ctx_t*, ...)`
3535

36-
the first style api do **only once** encryption or decryption. but for the second style api,
37-
you can call `{aes/sm4}_{en/de}crypt` multiple times and to encryption(decryption) for stream data.
36+
you can call `{aes/sm4}_{en/de}crypt` multiple times
37+
to encrypt or decrypt for stream data.
3838

3939
for both two style apis, you should do the padding yourself, and make sure the input data length
4040
**exactly** multiple of the block size (aka 16bytes).

README.zh.md

+39-12
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,54 @@
11
# zcrypto
2+
3+
**中文** | [**English**](./README.md)
4+
25
一个为受限环境(比如STM32)写的加密相关操作的库。
36

4-
*支持功能*:
7+
## 支持功能:
58
* base64
6-
* hash
9+
* 散列函数
710
* SM3
811
* MD5
912
* SHA1
1013
* SHA256
11-
* block cipher algorithm
14+
* 分组密码算法
1215
* AES(128, 192, 256)
1316
* SM4
14-
* block cipher mode
17+
* 分组密码模式
1518
* ECB
1619
* CBC
1720
* CFB
1821
* OFB
19-
* asymmetric key encryption
22+
* 非对称加密算法
2023
* RSA(2048)
24+
* RSA-OAEP(2048)
2125

2226
## 分组密码
2327

24-
支持:AES(192、169,256), SM4,模式支持ECB,CBC,CFB,OFB。
25-
支持两种风格的API。一种是:`aes_{keylen}_{mode}_{en/de}crypt``sm4_{mode}_{en/de}crypt`,这是做一次性加密(解密)的。
26-
另一种是`aes_{en/de}crypt(aes_ctx_t*, ...)``sm4_{en/de}crypt(sm4_ctx_t*, ...)`,这种可以调用多次,
27-
对流数据进行加密(解密)。具体使用请看`test/test_{aes/sm4}.c`
28+
使用单一加解密函数:
29+
* `aes_{keylen}_{mode}_{en/de}crypt`
30+
* `sm4_{mode}_{en/de}crypt`
31+
32+
或者使用多次调用的函数:
33+
* `aes_{en/de}crypt(aes_ctx_t*, ...)`
34+
* `sm4_{en/de}crypt(sm4_ctx_t*, ...)`
35+
36+
可以多次调用`{aes/sm4}_{en/de}crypt`,方便用于流式数据的加解密。
37+
38+
具体使用请看`test/test_{aes/sm4}.c`
2839

2940
## HASH算法
3041

31-
支持SM3,MD5,SHA1,SHA256。使用`{alg}_init`初始化,使用`{alg}_update`更新数据,使用`{alg}_[hex]digest`输出hash值。
32-
可以在任意时候调用`{alg}_[hex]digest`获取当前数据的hash值。但是需要保证结果的空间足够存hash值。具体使用请看`test/test_hash.c`
42+
支持SM3,MD5,SHA1,SHA256。
43+
44+
使用方法:
45+
* 使用`{alg}_init`初始化
46+
* 使用`{alg}_update`更新数据
47+
* 使用`{alg}_[hex]digest`输出hash值。
48+
49+
可以在任意时候调用`{alg}_[hex]digest`获取当前数据的hash值。但是需要保证结果的空间足够存hash值。
50+
51+
具体使用请看`test/test_hash.c`
3352

3453
## 非对称密钥算法
3554

@@ -40,4 +59,12 @@
4059
使用`./test/rsa_naive_test.py | ./build/test_rsa.elf`进行测试。
4160

4261
使用`rsa_pub_oaep_encrypt`进行`RSAES-OAEP`运算,请参考[RFC8017](https://tools.ietf.org/html/rfc8017#section-7.1)
43-
具体使用请看`test/test_oaep.c`。 使用`./test/rsa_oaep_test.py gen | ./build/test_oaep.elf | ./test/rsa_oaep_test.py verify`进行测试。
62+
63+
具体使用请看`test/test_oaep.c`
64+
65+
测试:
66+
```
67+
./test/rsa_oaep_test.py gen |
68+
./build/test_oaep.elf |
69+
./test/rsa_oaep_test.py verify
70+
```

0 commit comments

Comments
 (0)