diff --git a/thirdparty/enchive-3.5/HPKBUILD b/thirdparty/enchive-3.5/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..61f86c57c6c96bb8e65c89d0cee9747f3b1ba197 --- /dev/null +++ b/thirdparty/enchive-3.5/HPKBUILD @@ -0,0 +1,71 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Contributor: wangjialun <2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +pkgname=enchive-3.5 +pkgver=3.5 +pkgrel=0 +pkgdesc="enchive is a tool to encrypt files to yourself for long-term archival. It's a focused, simple alternative to more complex solutions such as GnuPG or encrypted filesystems" +url="https://github.com/skeeto/enchive/tree/3.5" +archs=("armeabi-v7a" "arm64-v8a") +license=("Unlicense license") +depends=() +makedepends=() +source="https://github.com/skeeto/enchive/archive/refs/tags/3.5.zip" + +downloadpackage=true +autounpack=true +buildtools=make + +builddir=enchive-3.5 +packagename=enchive-3.5.zip + +source envset.sh + +prepare() { + cp -rf $builddir $builddir-$ARCH-build + if [ $ARCH == "armeabi-v7a" ];then + setarm32ENV + elif [ $ARCH == "arm64-v8a" ];then + setarm64ENV + else + echo "Not support ${ARCH} yet" + return -1 + fi +} + +build() { + make -j4 -C $builddir-$ARCH-build VERBOSE=1 >> $builddir-$ARCH-build/build.log 2>&1 + ret=$? + return $ret +} + +package() { + cd $builddir-$ARCH-build + make install PREFIX=$LYCIUM_ROOT/usr/$pkgname/$ARCH >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + + +check() { + echo "The test must be on an OpenHarmony device!" +} + + +cleanbuild() { + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build #${PWD}/$packagename +} \ No newline at end of file diff --git a/thirdparty/enchive-3.5/HPKCHECK b/thirdparty/enchive-3.5/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..7d64ba6db8b0c90cf98959b90dc1f7e9daaef364 --- /dev/null +++ b/thirdparty/enchive-3.5/HPKCHECK @@ -0,0 +1,40 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Contributor: wangjialun <2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn> , wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd ${builddir}/${ARCH}-build # 进入到测试目录 + #1.新建名为1.txt文本文件,输入内容:12345。 + #2.执行:./enchive -p ./pubkey.txt -s ./seckey.txt keygen 生成一个密钥对,将公钥存储到当前目录下的pubkey.txt,私钥存储到seckey.txt文件,需要输入密码并二次验证,供解密时确认。 + #3.执行:./enchive -p pubkey.txt archive 1.txt 使用公钥加密 1.txt 文件,生成名为1.txt.enchive加密文件。此时无法查看1.txt.enchive内容 + #4.执行:./enchive -s seckey.txt extract 1.txt.enchive 使用私钥解密1.txt.enchive文件,此时需输入生成密钥对时设置的密码。 + touch 1.txt + echo "12345" > 1.txt + ./enchive -p ./pubkey.txt -s ./seckey.txt keygen >> $logfile 2>&1 + ./enchive -p pubkey.txt archive 1.txt >> $logfile 2>&1 + ./enchive -s seckey.txt extract 1.txt.enchive >> $logfile 2>&1 + res=$? + if [ $res -ne 0 ];then + mkdir ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/ + fi + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/enchive-3.5/README.OpenSource b/thirdparty/enchive-3.5/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..2fe0583c15ead531cb28b8113a29cbe92453948e --- /dev/null +++ b/thirdparty/enchive-3.5/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "enchive-3.5", + "License": " Unlicense license", + "License File": "https://github.com/skeeto/enchive/blob/master/UNLICENSE", + "Version Number": "3.5", + "Owner": "2942375747@qq.com", + "Upstream URL": "https://github.com/skeeto/enchive", + "Description": "enchive is a tool to encrypt files to yourself for long-term archival. It's a focused, simple alternative to more complex solutions such as GnuPG or encrypted filesystems." + } +] \ No newline at end of file diff --git a/thirdparty/enchive-3.5/README_zh.md b/thirdparty/enchive-3.5/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..bd25030862d31f1d7f78f11724534eaad1308639 --- /dev/null +++ b/thirdparty/enchive-3.5/README_zh.md @@ -0,0 +1,9 @@ +# enchive-3.5三方库说明 +## 功能简介 +enchive是一个加密文件的工具。它比GnuPG或其他加密文件系统更简便,可移植性较强。 +## 三方库版本: +- 3.5 +## 使用约束: +- [IDE和SDK版本](../../docs/constraint.md) +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) \ No newline at end of file diff --git a/thirdparty/enchive-3.5/SHA512SUM b/thirdparty/enchive-3.5/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..f803052b8403f7ced29bc6e2e0217746486587d3 --- /dev/null +++ b/thirdparty/enchive-3.5/SHA512SUM @@ -0,0 +1 @@ +a276d4dcb9d9cb3ae290af6812f49b4d268cb860f4a49da34f8491862940da24e6431c5820d7e629d13c76688b974c8cd63375ed0fecd61047b87de4792f9609 enchive-3.5.zip \ No newline at end of file diff --git a/thirdparty/enchive-3.5/docs/hap_integrate.md b/thirdparty/enchive-3.5/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..3a552cfd1ef0c9608ece337039fb540db809d63d --- /dev/null +++ b/thirdparty/enchive-3.5/docs/hap_integrate.md @@ -0,0 +1,79 @@ +# enchive 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/enchive-3.5 #三方库enchive-3.5的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh enchive-3.5 + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + enchive-3.5/arm64-v8a enchive-3.5/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的头文件拷贝到该目录下,将编译生成的三方库以及依赖库全部(动态库名字带版本号和不带版本号的都需要)拷贝到工程的libs目录下。该库未生成头文件及静态/共享库。如下图所示: +   + +  ![thirdparty_install_dir](pic/enchive_install_dir.png) + + +## 测试三方库 +- 编译出可执行的文件,使用原库自带的测试用例来做测试。但本库没有测试用例,改为执行demo验证其功能 [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +- 进入到构建目录下的example目录,运行demo(注意arm64-v8a为构建64位的目录,armeabi-v7a为构建32位的目录)。 + 1.新建名为1.txt文本文件,输入内容:12345。 + 2.执行:./enchive -p ./pubkey.txt -s ./seckey.txt keygen 生成一个密钥对,将公钥存储到当前目录下的pubkey.txt,私钥存储到seckey.txt文件,需要输入密码并二次验证,供解密时确认。 + 3.执行:./enchive -p pubkey.txt archive 1.txt 使用公钥加密 1.txt 文件,生成名为1.txt.enchive加密文件。此时无法查看1.txt.enchive内容 + 4.执行:./enchive -s seckey.txt extract 1.txt.enchive 使用私钥解密1.txt.enchive文件,此时需输入生成密钥对时设置的密码。 + 执行结果如图所示: + +```shell + cd /data/tpc_c_cplusplus/thirdparty/enchive-3.5/enchive-3.5/arm64-v8a-build + touch 1.txt + echo "12345" > 1.txt + ./enchive -p ./pubkey.txt -s ./seckey.txt keygen + ./enchive -p pubkey.txt archive 1.txt + ./enchive -s seckey.txt extract 1.txt.enchive +``` + ![enchive_test](pic/enchive_test.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) \ No newline at end of file diff --git a/thirdparty/enchive-3.5/docs/pic/enchive_install_dir.png b/thirdparty/enchive-3.5/docs/pic/enchive_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..043da43dfec9f03a11aec3df298f07d4a720b993 Binary files /dev/null and b/thirdparty/enchive-3.5/docs/pic/enchive_install_dir.png differ diff --git a/thirdparty/enchive-3.5/docs/pic/enchive_test.png b/thirdparty/enchive-3.5/docs/pic/enchive_test.png new file mode 100644 index 0000000000000000000000000000000000000000..2181753f6448c1ee9033b0302fad5d6b14dec6bb Binary files /dev/null and b/thirdparty/enchive-3.5/docs/pic/enchive_test.png differ