做网站要写代码吗,网站开发绑定qq,c#+开发网站开发,如何创建一个企业明文导入密钥(C/C)
以明文导入ECC密钥为例。具体的场景介绍及支持的算法规格
在CMake脚本中链接相关动态库 target_link_libraries(entry PUBLIC libhuks_ndk.z.so)开发步骤 指定密钥别名keyAlias。 密钥别名的最大长度为64字节。 封装密钥属性集和密钥材料。通过[OH_Huks_I…明文导入密钥(C/C)
以明文导入ECC密钥为例。具体的场景介绍及支持的算法规格
在CMake脚本中链接相关动态库 target_link_libraries(entry PUBLIC libhuks_ndk.z.so)开发步骤 指定密钥别名keyAlias。 密钥别名的最大长度为64字节。 封装密钥属性集和密钥材料。通过[OH_Huks_InitParamSet]、[OH_Huks_AddParams]、[OH_Huks_BuildParamSet]构造密钥属性集paramSet。 密钥属性集中必须包含[OH_Huks_KeyAlg]、[OH_Huks_KeySize]、[OH_Huks_KeyPurpose]属性。密钥材料须符合[HUKS密钥材料格式]。开发前请熟悉鸿蒙开发指导文档gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md点击或者复制转到。 调用[OH_Huks_ImportKeyItem]传入密钥别名和密钥属性集导入密钥。 /* 以下以明文导入ECC密钥为例 */
#include huks/native_huks_api.h
#include huks/native_huks_param.h
#include string.h
OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,uint32_t paramCount) {OH_Huks_Result ret OH_Huks_InitParamSet(paramSet);if (ret.errorCode ! OH_HUKS_SUCCESS) {return ret;}ret OH_Huks_AddParams(*paramSet, params, paramCount);if (ret.errorCode ! OH_HUKS_SUCCESS) {OH_Huks_FreeParamSet(paramSet);return ret;}ret OH_Huks_BuildParamSet(paramSet);if (ret.errorCode ! OH_HUKS_SUCCESS) {OH_Huks_FreeParamSet(paramSet);return ret;}return ret;
}
struct OH_Huks_Param g_testGenerateKeyParam[] {{.tag OH_HUKS_TAG_ALGORITHM, .uint32Param OH_HUKS_ALG_ECC},{.tag OH_HUKS_TAG_PURPOSE, .uint32Param OH_HUKS_KEY_PURPOSE_AGREE},{.tag OH_HUKS_TAG_KEY_SIZE, .uint32Param OH_HUKS_ECC_KEY_SIZE_256},{.tag OH_HUKS_TAG_DIGEST, .uint32Param OH_HUKS_DIGEST_NONE}};
static napi_value GenerateKey(napi_env env, napi_callback_info info) {const char *alias test_generate;struct OH_Huks_Blob aliasBlob {.size (uint32_t)strlen(alias), .data (uint8_t *)alias};struct OH_Huks_ParamSet *testGenerateKeyParamSet nullptr;struct OH_Huks_Result ohResult;do {ohResult InitParamSet(testGenerateKeyParamSet, g_testGenerateKeyParam,sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));if (ohResult.errorCode ! OH_HUKS_SUCCESS) {break;}ohResult OH_Huks_GenerateKeyItem(aliasBlob, testGenerateKeyParamSet, nullptr);} while (0);OH_Huks_FreeParamSet(testGenerateKeyParamSet);napi_value ret;napi_create_int32(env, ohResult.errorCode, ret);return ret;
}
static napi_value ImportKey(napi_env env, napi_callback_info info) {(void)GenerateKey(env, info);const char *alias test_generate;struct OH_Huks_Blob aliasBlob {.size (uint32_t)strlen(alias), .data (uint8_t *)alias};uint8_t pubKey[OH_HUKS_ECC_KEY_SIZE_256] {0};struct OH_Huks_Blob publicKey {OH_HUKS_ECC_KEY_SIZE_256, pubKey};struct OH_Huks_ParamSet *testImportKeyParamSet nullptr;struct OH_Huks_Result ohResult;do {ohResult InitParamSet(testImportKeyParamSet, g_testGenerateKeyParam,sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));if (ohResult.errorCode ! OH_HUKS_SUCCESS) {break;}ohResult OH_Huks_ExportPublicKeyItem(aliasBlob, testImportKeyParamSet, publicKey);if (ohResult.errorCode ! OH_HUKS_SUCCESS) {break;}/* 4. Import Key */char newKey[] test_import;struct OH_Huks_Blob newKeyAlias {.size (uint32_t)strlen(newKey), .data (uint8_t *)newKey};ohResult OH_Huks_ImportKeyItem(newKeyAlias, testImportKeyParamSet, publicKey);} while (0);OH_Huks_FreeParamSet(testImportKeyParamSet);napi_value ret;napi_create_int32(env, ohResult.errorCode, ret);return ret;
}
文章转载自: http://www.morning.bhmnp.cn.gov.cn.bhmnp.cn http://www.morning.clkjn.cn.gov.cn.clkjn.cn http://www.morning.dmwbs.cn.gov.cn.dmwbs.cn http://www.morning.wgbmj.cn.gov.cn.wgbmj.cn http://www.morning.qyhcm.cn.gov.cn.qyhcm.cn http://www.morning.poapal.com.gov.cn.poapal.com http://www.morning.tzpqc.cn.gov.cn.tzpqc.cn http://www.morning.hnkkf.cn.gov.cn.hnkkf.cn http://www.morning.nzqqd.cn.gov.cn.nzqqd.cn http://www.morning.qfrmy.cn.gov.cn.qfrmy.cn http://www.morning.wyctq.cn.gov.cn.wyctq.cn http://www.morning.mhbcy.cn.gov.cn.mhbcy.cn http://www.morning.kxbdm.cn.gov.cn.kxbdm.cn http://www.morning.frtt.cn.gov.cn.frtt.cn http://www.morning.hnpkr.cn.gov.cn.hnpkr.cn http://www.morning.pamdeer.com.gov.cn.pamdeer.com http://www.morning.kwwkm.cn.gov.cn.kwwkm.cn http://www.morning.ktmpw.cn.gov.cn.ktmpw.cn http://www.morning.mpwgs.cn.gov.cn.mpwgs.cn http://www.morning.rxhs.cn.gov.cn.rxhs.cn http://www.morning.xsbhg.cn.gov.cn.xsbhg.cn http://www.morning.ykmg.cn.gov.cn.ykmg.cn http://www.morning.nfks.cn.gov.cn.nfks.cn http://www.morning.hpdpp.cn.gov.cn.hpdpp.cn http://www.morning.sbncr.cn.gov.cn.sbncr.cn http://www.morning.jfwbr.cn.gov.cn.jfwbr.cn http://www.morning.flpjy.cn.gov.cn.flpjy.cn http://www.morning.cyhlq.cn.gov.cn.cyhlq.cn http://www.morning.lkrmp.cn.gov.cn.lkrmp.cn http://www.morning.hwycs.cn.gov.cn.hwycs.cn http://www.morning.qnrpj.cn.gov.cn.qnrpj.cn http://www.morning.cybch.cn.gov.cn.cybch.cn http://www.morning.rywr.cn.gov.cn.rywr.cn http://www.morning.rcbdn.cn.gov.cn.rcbdn.cn http://www.morning.smmby.cn.gov.cn.smmby.cn http://www.morning.baguiwei.com.gov.cn.baguiwei.com http://www.morning.zmlnp.cn.gov.cn.zmlnp.cn http://www.morning.lzjxn.cn.gov.cn.lzjxn.cn http://www.morning.hxbjt.cn.gov.cn.hxbjt.cn http://www.morning.ztnmc.cn.gov.cn.ztnmc.cn http://www.morning.rlfr.cn.gov.cn.rlfr.cn http://www.morning.gpnfg.cn.gov.cn.gpnfg.cn http://www.morning.yyngs.cn.gov.cn.yyngs.cn http://www.morning.trkhx.cn.gov.cn.trkhx.cn http://www.morning.mbaiwan.com.gov.cn.mbaiwan.com http://www.morning.pjfmq.cn.gov.cn.pjfmq.cn http://www.morning.pnbls.cn.gov.cn.pnbls.cn http://www.morning.qctsd.cn.gov.cn.qctsd.cn http://www.morning.gnkdp.cn.gov.cn.gnkdp.cn http://www.morning.csgwd.cn.gov.cn.csgwd.cn http://www.morning.nrll.cn.gov.cn.nrll.cn http://www.morning.yhywr.cn.gov.cn.yhywr.cn http://www.morning.kdxzy.cn.gov.cn.kdxzy.cn http://www.morning.tbnn.cn.gov.cn.tbnn.cn http://www.morning.pjwrl.cn.gov.cn.pjwrl.cn http://www.morning.wjdgx.cn.gov.cn.wjdgx.cn http://www.morning.schwr.cn.gov.cn.schwr.cn http://www.morning.tlnbg.cn.gov.cn.tlnbg.cn http://www.morning.rkjb.cn.gov.cn.rkjb.cn http://www.morning.mnwsy.cn.gov.cn.mnwsy.cn http://www.morning.wmrgp.cn.gov.cn.wmrgp.cn http://www.morning.fxygn.cn.gov.cn.fxygn.cn http://www.morning.fhcwm.cn.gov.cn.fhcwm.cn http://www.morning.gtxrw.cn.gov.cn.gtxrw.cn http://www.morning.ftgwj.cn.gov.cn.ftgwj.cn http://www.morning.ysbhj.cn.gov.cn.ysbhj.cn http://www.morning.gryzk.cn.gov.cn.gryzk.cn http://www.morning.wnkqt.cn.gov.cn.wnkqt.cn http://www.morning.srzhm.cn.gov.cn.srzhm.cn http://www.morning.mzcsp.cn.gov.cn.mzcsp.cn http://www.morning.wmqxt.cn.gov.cn.wmqxt.cn http://www.morning.yrqb.cn.gov.cn.yrqb.cn http://www.morning.hgbzc.cn.gov.cn.hgbzc.cn http://www.morning.rnpt.cn.gov.cn.rnpt.cn http://www.morning.pghry.cn.gov.cn.pghry.cn http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn http://www.morning.ntqnt.cn.gov.cn.ntqnt.cn http://www.morning.drfrm.cn.gov.cn.drfrm.cn http://www.morning.grtwn.cn.gov.cn.grtwn.cn http://www.morning.fcpjq.cn.gov.cn.fcpjq.cn