Add Android NDK build doc to README

This commit is contained in:
Zhi Guan
2022-10-07 22:18:59 +08:00
parent 6c169aab65
commit dc58a88588
2 changed files with 47 additions and 11 deletions

View File

@@ -24,6 +24,39 @@ make test
sudo make install
```
### Visual Studio环境编译
在Visual Studio命令提示符下执行
```bash
mkdir build
cd build
cmake .. -G "NMake Makefiles"
nmake
```
### iOS编译
下载 https://github.com/leetal/ios-cmake`ios.toolchain.cmake`文件复制到`build`目录。
```bash
mkdir build; cd build
cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DPLATFORM=OS64
cmake --build . --config Release
```
如果出现“error: Signing for "gmssl" requires a development team.”错误可以用Xcode打开工程文件在Signing配置中设置Development Team。
### Android编译
下载Android NDK执行
```bash
mkdir build; cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23
make
```
## 主要功能
### 密码算法
@@ -68,3 +101,4 @@ GmSSL支持Nginx的适配并提供了Docker实现具体参见[Nginx-with-G
- [ ] Add GCM cipher suites
- [ ] Release official open interfaces
- [ ] **Version 3.2.0 release**

View File

@@ -84,25 +84,27 @@ struct {
int test_hmac(const DIGEST *digest, const char *key_hex, const char *data_hex, const char *hmac_hex)
{
HMAC_CTX ctx;
uint8_t key = malloc(strlen(key_hex)/2); // FIXME: malloc
uint8_t data = malloc(strlen(data_hex)/2);
uint8_t hmac = malloc(strlen(hmac_hex) / 2);
uint8_t *key = (uint8_t *)malloc(strlen(key_hex)/2);
uint8_t *data = (uint8_t *)malloc(strlen(data_hex)/2);
uint8_t *hmac = (uint8_t *)malloc(strlen(hmac_hex) / 2);
size_t keylen, datalen, hmaclen;
uint8_t buf[64];
size_t len;
size_t buflen;
hex_to_bytes(key_hex, strlen(key_hex), key, &len);
hex_to_bytes(data_hex, strlen(data_hex), data, &len);
hex_to_bytes(hmac_hex, strlen(hmac_hex), hmac, &len);
hex_to_bytes(key_hex, strlen(key_hex), key, &keylen);
hex_to_bytes(data_hex, strlen(data_hex), data, &datalen);
hex_to_bytes(hmac_hex, strlen(hmac_hex), hmac, &hmaclen);
hmac_init(&ctx, digest, key, sizeof(key));
hmac_update(&ctx, data, sizeof(data));
hmac_finish(&ctx, buf, &len);
hmac_init(&ctx, digest, key, keylen);
hmac_update(&ctx, data, datalen);
hmac_finish(&ctx, buf, &buflen);
if (len != sizeof(hmac) || memcmp(buf, hmac, sizeof(hmac)) != 0) {
if (buflen != hmaclen || memcmp(buf, hmac, hmaclen) != 0) {
printf("failed\n");
return 0;
}
printf("ok\n");
if (key) free(key);
if (data) free(data);
if (hmac) free(hmac);