Merged
Fix the bugs in dupCtx and the comment error #483
OoohuiAdd on Aug 20, 2025
Fix the bugs in dupCtx and the comment error #483
Merged
Total: 19 files changed+122-99
| @@ -1114,7 +1114,8 @@ | |||
| 1114 | "crypto/ecdsa/include", | 1114 | "crypto/ecdsa/include", |
| 1115 | "crypto/sm2/include", | 1115 | "crypto/sm2/include", |
| 1116 | "crypto/curve25519/include", | 1116 | "crypto/curve25519/include", |
| 1117 | - "crypto/provider/include" | 1117 | + "crypto/provider/include", |
| 1118 | + "crypto/provider/src/mgr" | ||
| 1118 | ] | 1119 | ] |
| 1119 | }, | 1120 | }, |
| 1120 | "util": { | 1121 | "util": { |
| @@ -34,6 +34,7 @@ | |||
| 34 | #include "crypt_curve25519.h" | 34 | #include "crypt_curve25519.h" |
| 35 | #endif | 35 | #endif |
| 36 | #include "eal_pkey.h" | 36 | #include "eal_pkey.h" |
| 37 | +#include "crypt_provider_local.h" | ||
| 37 | #include "crypt_errno.h" | 38 | #include "crypt_errno.h" |
| 38 | #include "bsl_sal.h" | 39 | #include "bsl_sal.h" |
| 39 | #include "bsl_obj.h" | 40 | #include "bsl_obj.h" |
| @@ -228,7 +229,8 @@ EXIT: | |||
| 228 | int32_t DECODER_##keyType##PrvKeyDer2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ | 229 | int32_t DECODER_##keyType##PrvKeyDer2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ |
| 229 | { \ | 230 | { \ |
| 230 | DECODER_CHECK_PARAMS(ctx, inParam, outParam); \ | 231 | DECODER_CHECK_PARAMS(ctx, inParam, outParam); \ |
| 231 | - ret = parseFunc(asn1Encode.data, asn1Encode.dataLen, NULL, (keyStructName **)&key); \ | 232 | + ret = parseFunc(decoderCtx->provMgrCtx->libCtx, asn1Encode.data, asn1Encode.dataLen, NULL, \ |
| 233 | + (keyStructName **)&key); \ | ||
| 232 | if (ret != CRYPT_SUCCESS) { \ | 234 | if (ret != CRYPT_SUCCESS) { \ |
| 233 | BSL_ERR_PUSH_ERROR(ret); \ | 235 | BSL_ERR_PUSH_ERROR(ret); \ |
| 234 | return ret; \ | 236 | return ret; \ |
| @@ -240,7 +242,8 @@ int32_t DECODER_##keyType##PrvKeyDer2KeyDecode(void *ctx, const BSL_Param *inPar | |||
| 240 | int32_t DECODER_##keyType##PubKeyDer2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ | 242 | int32_t DECODER_##keyType##PubKeyDer2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ |
| 241 | { \ | 243 | { \ |
| 242 | DECODER_CHECK_PARAMS(ctx, inParam, outParam); \ | 244 | DECODER_CHECK_PARAMS(ctx, inParam, outParam); \ |
| 243 | - ret = parseFunc(asn1Encode.data, asn1Encode.dataLen, NULL, (keyStructName **)&key, BSL_CID_UNKNOWN); \ | 245 | + ret = parseFunc(decoderCtx->provMgrCtx->libCtx, asn1Encode.data, asn1Encode.dataLen, NULL, \ |
| 246 | + (keyStructName **)&key, BSL_CID_UNKNOWN); \ | ||
| 244 | if (ret != CRYPT_SUCCESS) { \ | 247 | if (ret != CRYPT_SUCCESS) { \ |
| 245 | BSL_ERR_PUSH_ERROR(ret); \ | 248 | BSL_ERR_PUSH_ERROR(ret); \ |
| 246 | return ret; \ | 249 | return ret; \ |
| @@ -252,7 +255,8 @@ int32_t DECODER_##keyType##PubKeyDer2KeyDecode(void *ctx, const BSL_Param *inPar | |||
| 252 | int32_t DECODER_##keyType##SubPubKeyDer2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ | 255 | int32_t DECODER_##keyType##SubPubKeyDer2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ |
| 253 | { \ | 256 | { \ |
| 254 | DECODER_CHECK_PARAMS(ctx, inParam, outParam) \ | 257 | DECODER_CHECK_PARAMS(ctx, inParam, outParam) \ |
| 255 | - ret = parseFunc(asn1Encode.data, asn1Encode.dataLen, (keyStructName **)&key, true); \ | 258 | + ret = parseFunc(decoderCtx->provMgrCtx->libCtx, asn1Encode.data, asn1Encode.dataLen, \ |
| 259 | + (keyStructName **)&key, true); \ | ||
| 256 | if (ret != CRYPT_SUCCESS) { \ | 260 | if (ret != CRYPT_SUCCESS) { \ |
| 257 | BSL_ERR_PUSH_ERROR(ret); \ | 261 | BSL_ERR_PUSH_ERROR(ret); \ |
| 258 | return ret; \ | 262 | return ret; \ |
| @@ -265,7 +269,8 @@ int32_t DECODER_##keyType##SubPubKeyWithOutSeqDer2KeyDecode(void *ctx, const BSL | |||
| 265 | BSL_Param **outParam) \ | 269 | BSL_Param **outParam) \ |
| 266 | { \ | 270 | { \ |
| 267 | DECODER_CHECK_PARAMS(ctx, inParam, outParam) \ | 271 | DECODER_CHECK_PARAMS(ctx, inParam, outParam) \ |
| 268 | - ret = parseFunc(asn1Encode.data, asn1Encode.dataLen, (keyStructName **)&key, false); \ | 272 | + ret = parseFunc(decoderCtx->provMgrCtx->libCtx, asn1Encode.data, asn1Encode.dataLen, (keyStructName **)&key, \ |
| 273 | + false); \ | ||
| 269 | if (ret != CRYPT_SUCCESS) { \ | 274 | if (ret != CRYPT_SUCCESS) { \ |
| 270 | BSL_ERR_PUSH_ERROR(ret); \ | 275 | BSL_ERR_PUSH_ERROR(ret); \ |
| 271 | return ret; \ | 276 | return ret; \ |
| @@ -277,7 +282,7 @@ int32_t DECODER_##keyType##SubPubKeyWithOutSeqDer2KeyDecode(void *ctx, const BSL | |||
| 277 | int32_t DECODER_##keyType##Pkcs8Der2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ | 282 | int32_t DECODER_##keyType##Pkcs8Der2KeyDecode(void *ctx, const BSL_Param *inParam, BSL_Param **outParam) \ |
| 278 | { \ | 283 | { \ |
| 279 | DECODER_CHECK_PARAMS(ctx, inParam, outParam) \ | 284 | DECODER_CHECK_PARAMS(ctx, inParam, outParam) \ |
| 280 | - ret = parseFunc(asn1Encode.data, asn1Encode.dataLen, (keyStructName **)&key); \ | 285 | + ret = parseFunc(decoderCtx->provMgrCtx->libCtx, asn1Encode.data, asn1Encode.dataLen, (keyStructName **)&key); \ |
| 281 | if (ret != CRYPT_SUCCESS) { \ | 286 | if (ret != CRYPT_SUCCESS) { \ |
| 282 | BSL_ERR_PUSH_ERROR(ret); \ | 287 | BSL_ERR_PUSH_ERROR(ret); \ |
| 283 | return ret; \ | 288 | return ret; \ |
| @@ -102,13 +102,13 @@ static int32_t ParsePrikeyAsn1Info(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buf | |||
| 102 | 102 | ||
| 103 | #ifdef HITLS_CRYPTO_ECDSA | 103 | #ifdef HITLS_CRYPTO_ECDSA |
| 104 | // ecdh is not considered, and it will be improved in the future | 104 | // ecdh is not considered, and it will be improved in the future |
| 105 | -static int32_t EccKeyNew(BSL_ASN1_Buffer *ecParamOid, void **ecKey) | 105 | +static int32_t EccKeyNew(void *libCtx, BSL_ASN1_Buffer *ecParamOid, void **ecKey) |
| 106 | { | 106 | { |
| 107 | int32_t paraId = GetParaId(ecParamOid->buff, ecParamOid->len); | 107 | int32_t paraId = GetParaId(ecParamOid->buff, ecParamOid->len); |
| 108 | if (!IsEcdsaEcParaId(paraId)) { | 108 | if (!IsEcdsaEcParaId(paraId)) { |
| 109 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 109 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 110 | } | 110 | } |
| 111 | - CRYPT_ECDSA_Ctx *key = CRYPT_ECDSA_NewCtx(); | 111 | + CRYPT_ECDSA_Ctx *key = CRYPT_ECDSA_NewCtxEx(libCtx); |
| 112 | if (key == NULL) { | 112 | if (key == NULL) { |
| 113 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | 113 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); |
| 114 | return CRYPT_MEM_ALLOC_FAIL; | 114 | return CRYPT_MEM_ALLOC_FAIL; |
| @@ -124,7 +124,7 @@ static int32_t EccKeyNew(BSL_ASN1_Buffer *ecParamOid, void **ecKey) | |||
| 124 | return CRYPT_SUCCESS; | 124 | return CRYPT_SUCCESS; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | -int32_t CRYPT_ECC_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, void **pubKey, bool isComplete) | 127 | +int32_t CRYPT_ECC_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, void **pubKey, bool isComplete) |
| 128 | { | 128 | { |
| 129 | if (buff == NULL || buffLen == 0 || pubKey == NULL) { | 129 | if (buff == NULL || buffLen == 0 || pubKey == NULL) { |
| 130 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); | 130 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); |
| @@ -141,7 +141,7 @@ int32_t CRYPT_ECC_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, void * | |||
| 141 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 141 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 142 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 142 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 143 | } | 143 | } |
| 144 | - ret = EccKeyNew(&subPubkeyInfo.keyParam, &pctx); | 144 | + ret = EccKeyNew(libCtx, &subPubkeyInfo.keyParam, &pctx); |
| 145 | if (ret != CRYPT_SUCCESS) { | 145 | if (ret != CRYPT_SUCCESS) { |
| 146 | BSL_ERR_PUSH_ERROR(ret); | 146 | BSL_ERR_PUSH_ERROR(ret); |
| 147 | return ret; | 147 | return ret; |
| @@ -161,7 +161,7 @@ int32_t CRYPT_ECC_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, void * | |||
| 161 | return ret; | 161 | return ret; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | -int32_t CRYPT_ECC_ParsePrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, | 164 | +int32_t CRYPT_ECC_ParsePrikeyAsn1Buff(void *libCtx, uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, |
| 165 | void **ecPriKey) | 165 | void **ecPriKey) |
| 166 | { | 166 | { |
| 167 | if (buffer == NULL || bufferLen == 0 || ecPriKey == NULL) { | 167 | if (buffer == NULL || bufferLen == 0 || ecPriKey == NULL) { |
| @@ -176,7 +176,7 @@ int32_t CRYPT_ECC_ParsePrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, BSL_A | |||
| 176 | return ret; | 176 | return ret; |
| 177 | } | 177 | } |
| 178 | void *pctx = NULL; | 178 | void *pctx = NULL; |
| 179 | - ret = EccKeyNew(&eccPrvInfo.param, &pctx); | 179 | + ret = EccKeyNew(libCtx, &eccPrvInfo.param, &pctx); |
| 180 | if (ret != CRYPT_SUCCESS) { | 180 | if (ret != CRYPT_SUCCESS) { |
| 181 | BSL_ERR_PUSH_ERROR(ret); | 181 | BSL_ERR_PUSH_ERROR(ret); |
| 182 | return ret; | 182 | return ret; |
| @@ -207,7 +207,7 @@ ERR: | |||
| 207 | return ret; | 207 | return ret; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | -int32_t CRYPT_ECC_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, void **ecdsaPriKey) | 210 | +int32_t CRYPT_ECC_ParsePkcs8Key(void *libCtx, uint8_t *buff, uint32_t buffLen, void **ecdsaPriKey) |
| 211 | { | 211 | { |
| 212 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; | 212 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; |
| 213 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buff, buffLen, NULL, &pk8PrikeyInfo); | 213 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buff, buffLen, NULL, &pk8PrikeyInfo); |
| @@ -219,8 +219,8 @@ int32_t CRYPT_ECC_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, void **ecdsaPri | |||
| 219 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 219 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 220 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 220 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 221 | } | 221 | } |
| 222 | - ret = CRYPT_ECC_ParsePrikeyAsn1Buff(pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, &pk8PrikeyInfo.keyParam, | 222 | + ret = CRYPT_ECC_ParsePrikeyAsn1Buff(libCtx, pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, |
| 223 | - ecdsaPriKey); | 223 | + &pk8PrikeyInfo.keyParam, ecdsaPriKey); |
| 224 | if (ret != CRYPT_SUCCESS) { | 224 | if (ret != CRYPT_SUCCESS) { |
| 225 | BSL_ERR_PUSH_ERROR(ret); | 225 | BSL_ERR_PUSH_ERROR(ret); |
| 226 | } | 226 | } |
| @@ -228,14 +228,14 @@ int32_t CRYPT_ECC_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, void **ecdsaPri | |||
| 228 | } | 228 | } |
| 229 | #endif // HITLS_CRYPTO_ECDSA | 229 | #endif // HITLS_CRYPTO_ECDSA |
| 230 | #ifdef HITLS_CRYPTO_SM2 | 230 | #ifdef HITLS_CRYPTO_SM2 |
| 231 | -static int32_t Sm2KeyNew(BSL_ASN1_Buffer *ecParamOid, CRYPT_SM2_Ctx **ecKey) | 231 | +static int32_t Sm2KeyNew(void *libCtx, BSL_ASN1_Buffer *ecParamOid, CRYPT_SM2_Ctx **ecKey) |
| 232 | { | 232 | { |
| 233 | CRYPT_SM2_Ctx *key = NULL; | 233 | CRYPT_SM2_Ctx *key = NULL; |
| 234 | int32_t paraId = GetParaId(ecParamOid->buff, ecParamOid->len); | 234 | int32_t paraId = GetParaId(ecParamOid->buff, ecParamOid->len); |
| 235 | if (paraId != CRYPT_ECC_SM2) { | 235 | if (paraId != CRYPT_ECC_SM2) { |
| 236 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 236 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 237 | } | 237 | } |
| 238 | - key = CRYPT_SM2_NewCtx(); | 238 | + key = CRYPT_SM2_NewCtxEx(libCtx); |
| 239 | if (key == NULL) { | 239 | if (key == NULL) { |
| 240 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | 240 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); |
| 241 | return CRYPT_MEM_ALLOC_FAIL; | 241 | return CRYPT_MEM_ALLOC_FAIL; |
| @@ -244,7 +244,8 @@ static int32_t Sm2KeyNew(BSL_ASN1_Buffer *ecParamOid, CRYPT_SM2_Ctx **ecKey) | |||
| 244 | return CRYPT_SUCCESS; | 244 | return CRYPT_SUCCESS; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | -int32_t CRYPT_SM2_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **pubKey, bool isComplete) | 247 | +int32_t CRYPT_SM2_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **pubKey, |
| 248 | + bool isComplete) | ||
| 248 | { | 249 | { |
| 249 | if (buff == NULL || buffLen == 0 || pubKey == NULL) { | 250 | if (buff == NULL || buffLen == 0 || pubKey == NULL) { |
| 250 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); | 251 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); |
| @@ -261,7 +262,7 @@ int32_t CRYPT_SM2_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_ | |||
| 261 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 262 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 262 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 263 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 263 | } | 264 | } |
| 264 | - ret = Sm2KeyNew(&subPubkeyInfo.keyParam, &pctx); | 265 | + ret = Sm2KeyNew(libCtx, &subPubkeyInfo.keyParam, &pctx); |
| 265 | if (ret != CRYPT_SUCCESS) { | 266 | if (ret != CRYPT_SUCCESS) { |
| 266 | BSL_ERR_PUSH_ERROR(ret); | 267 | BSL_ERR_PUSH_ERROR(ret); |
| 267 | return ret; | 268 | return ret; |
| @@ -281,7 +282,7 @@ int32_t CRYPT_SM2_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_ | |||
| 281 | return ret; | 282 | return ret; |
| 282 | } | 283 | } |
| 283 | 284 | ||
| 284 | -int32_t CRYPT_SM2_ParsePrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, | 285 | +int32_t CRYPT_SM2_ParsePrikeyAsn1Buff(void *libCtx, uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, |
| 285 | CRYPT_SM2_Ctx **sm2PriKey) | 286 | CRYPT_SM2_Ctx **sm2PriKey) |
| 286 | { | 287 | { |
| 287 | CRYPT_DECODE_EccPrikeyInfo eccPrvInfo = {0}; | 288 | CRYPT_DECODE_EccPrikeyInfo eccPrvInfo = {0}; |
| @@ -291,7 +292,7 @@ int32_t CRYPT_SM2_ParsePrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, BSL_A | |||
| 291 | return ret; | 292 | return ret; |
| 292 | } | 293 | } |
| 293 | CRYPT_SM2_Ctx *pctx = NULL; | 294 | CRYPT_SM2_Ctx *pctx = NULL; |
| 294 | - ret = Sm2KeyNew(&eccPrvInfo.param, &pctx); | 295 | + ret = Sm2KeyNew(libCtx, &eccPrvInfo.param, &pctx); |
| 295 | if (ret != CRYPT_SUCCESS) { | 296 | if (ret != CRYPT_SUCCESS) { |
| 296 | BSL_ERR_PUSH_ERROR(ret); | 297 | BSL_ERR_PUSH_ERROR(ret); |
| 297 | return ret; | 298 | return ret; |
| @@ -322,7 +323,7 @@ ERR: | |||
| 322 | return ret; | 323 | return ret; |
| 323 | } | 324 | } |
| 324 | 325 | ||
| 325 | -int32_t CRYPT_SM2_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **sm2PriKey) | 326 | +int32_t CRYPT_SM2_ParsePkcs8Key(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **sm2PriKey) |
| 326 | { | 327 | { |
| 327 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; | 328 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; |
| 328 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buff, buffLen, NULL, &pk8PrikeyInfo); | 329 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buff, buffLen, NULL, &pk8PrikeyInfo); |
| @@ -334,8 +335,8 @@ int32_t CRYPT_SM2_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx * | |||
| 334 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 335 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 335 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 336 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 336 | } | 337 | } |
| 337 | - ret = CRYPT_SM2_ParsePrikeyAsn1Buff(pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, &pk8PrikeyInfo.keyParam, | 338 | + ret = CRYPT_SM2_ParsePrikeyAsn1Buff(libCtx, pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, |
| 338 | - sm2PriKey); | 339 | + &pk8PrikeyInfo.keyParam, sm2PriKey); |
| 339 | if (ret != CRYPT_SUCCESS) { | 340 | if (ret != CRYPT_SUCCESS) { |
| 340 | BSL_ERR_PUSH_ERROR(ret); | 341 | BSL_ERR_PUSH_ERROR(ret); |
| 341 | } | 342 | } |
| @@ -344,7 +345,8 @@ int32_t CRYPT_SM2_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx * | |||
| 344 | #endif // HITLS_CRYPTO_SM2 | 345 | #endif // HITLS_CRYPTO_SM2 |
| 345 | 346 | ||
| 346 | #ifdef HITLS_CRYPTO_ED25519 | 347 | #ifdef HITLS_CRYPTO_ED25519 |
| 347 | -static int32_t ParseEd25519PrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, CRYPT_CURVE25519_Ctx **ed25519PriKey) | 348 | +static int32_t ParseEd25519PrikeyAsn1Buff(void *libCtx, uint8_t *buffer, uint32_t bufferLen, |
| 349 | + CRYPT_CURVE25519_Ctx **ed25519PriKey) | ||
| 348 | { | 350 | { |
| 349 | uint8_t *tmpBuff = buffer; | 351 | uint8_t *tmpBuff = buffer; |
| 350 | uint32_t tmpBuffLen = bufferLen; | 352 | uint32_t tmpBuffLen = bufferLen; |
| @@ -355,7 +357,7 @@ static int32_t ParseEd25519PrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, C | |||
| 355 | return ret; | 357 | return ret; |
| 356 | } | 358 | } |
| 357 | 359 | ||
| 358 | - CRYPT_CURVE25519_Ctx *pctx = CRYPT_ED25519_NewCtx(); | 360 | + CRYPT_CURVE25519_Ctx *pctx = CRYPT_ED25519_NewCtxEx(libCtx); |
| 359 | if (pctx == NULL) { | 361 | if (pctx == NULL) { |
| 360 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | 362 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); |
| 361 | return CRYPT_MEM_ALLOC_FAIL; | 363 | return CRYPT_MEM_ALLOC_FAIL; |
| @@ -374,7 +376,8 @@ static int32_t ParseEd25519PrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, C | |||
| 374 | return CRYPT_SUCCESS; | 376 | return CRYPT_SUCCESS; |
| 375 | } | 377 | } |
| 376 | 378 | ||
| 377 | -int32_t CRYPT_ED25519_ParsePkcs8Key(uint8_t *buffer, uint32_t bufferLen, CRYPT_CURVE25519_Ctx **ed25519PriKey) | 379 | +int32_t CRYPT_ED25519_ParsePkcs8Key(void *libCtx, uint8_t *buffer, uint32_t bufferLen, |
| 380 | + CRYPT_CURVE25519_Ctx **ed25519PriKey) | ||
| 378 | { | 381 | { |
| 379 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; | 382 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; |
| 380 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buffer, bufferLen, NULL, &pk8PrikeyInfo); | 383 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buffer, bufferLen, NULL, &pk8PrikeyInfo); |
| @@ -386,11 +389,11 @@ int32_t CRYPT_ED25519_ParsePkcs8Key(uint8_t *buffer, uint32_t bufferLen, CRYPT_C | |||
| 386 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 389 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 387 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 390 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 388 | } | 391 | } |
| 389 | - return ParseEd25519PrikeyAsn1Buff(pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, ed25519PriKey); | 392 | + return ParseEd25519PrikeyAsn1Buff(libCtx, pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, ed25519PriKey); |
| 390 | } | 393 | } |
| 391 | 394 | ||
| 392 | -int32_t CRYPT_ED25519_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_CURVE25519_Ctx **pubKey, | 395 | +int32_t CRYPT_ED25519_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, |
| 393 | - bool isComplete) | 396 | + CRYPT_CURVE25519_Ctx **pubKey, bool isComplete) |
| 394 | { | 397 | { |
| 395 | if (buff == NULL || buffLen == 0 || pubKey == NULL) { | 398 | if (buff == NULL || buffLen == 0 || pubKey == NULL) { |
| 396 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); | 399 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); |
| @@ -406,7 +409,7 @@ int32_t CRYPT_ED25519_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CR | |||
| 406 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 409 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 407 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 410 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 408 | } | 411 | } |
| 409 | - CRYPT_CURVE25519_Ctx *pctx = CRYPT_ED25519_NewCtx(); | 412 | + CRYPT_CURVE25519_Ctx *pctx = CRYPT_ED25519_NewCtxEx(libCtx); |
| 410 | if (pctx == NULL) { | 413 | if (pctx == NULL) { |
| 411 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | 414 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); |
| 412 | return CRYPT_MEM_ALLOC_FAIL; | 415 | return CRYPT_MEM_ALLOC_FAIL; |
| @@ -423,7 +426,6 @@ int32_t CRYPT_ED25519_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CR | |||
| 423 | } | 426 | } |
| 424 | *pubKey = pctx; | 427 | *pubKey = pctx; |
| 425 | return ret; | 428 | return ret; |
| 426 | - | ||
| 427 | } | 429 | } |
| 428 | #endif // HITLS_CRYPTO_ED25519 | 430 | #endif // HITLS_CRYPTO_ED25519 |
| 429 | #endif // HITLS_CRYPTO_KEY_DECODE | 431 | #endif // HITLS_CRYPTO_KEY_DECODE |
| @@ -106,10 +106,10 @@ static int32_t ProcRsaPssParam(BSL_ASN1_Buffer *rsaPssParam, CRYPT_RSA_Ctx *rsaP | |||
| 106 | return CRYPT_RSA_Ctrl(rsaPriKey, CRYPT_CTRL_SET_RSA_EMSA_PSS, param, 0); | 106 | return CRYPT_RSA_Ctrl(rsaPriKey, CRYPT_CTRL_SET_RSA_EMSA_PSS, param, 0); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | -static int32_t DecodeRsaPrikeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *rsaPssParam, BslCid cid, | 109 | +static int32_t DecodeRsaPrikeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *rsaPssParam, |
| 110 | - CRYPT_RSA_Ctx **rsaPriKey) | 110 | + BslCid cid, CRYPT_RSA_Ctx **rsaPriKey) |
| 111 | { | 111 | { |
| 112 | - CRYPT_RSA_Ctx *pctx = CRYPT_RSA_NewCtx(); | 112 | + CRYPT_RSA_Ctx *pctx = CRYPT_RSA_NewCtxEx(libCtx); |
| 113 | if (pctx == NULL) { | 113 | if (pctx == NULL) { |
| 114 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | 114 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); |
| 115 | return CRYPT_MEM_ALLOC_FAIL; | 115 | return CRYPT_MEM_ALLOC_FAIL; |
| @@ -135,13 +135,13 @@ static int32_t DecodeRsaPrikeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1 | |||
| 135 | return ret; | 135 | return ret; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | -int32_t CRYPT_RSA_ParsePrikeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *rsaPssParam, | 138 | +int32_t CRYPT_RSA_ParsePrikeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *rsaPssParam, |
| 139 | CRYPT_RSA_Ctx **rsaPriKey) | 139 | CRYPT_RSA_Ctx **rsaPriKey) |
| 140 | { | 140 | { |
| 141 | - return DecodeRsaPrikeyAsn1Buff(buff, buffLen, rsaPssParam, BSL_CID_UNKNOWN, rsaPriKey); | 141 | + return DecodeRsaPrikeyAsn1Buff(libCtx, buff, buffLen, rsaPssParam, BSL_CID_UNKNOWN, rsaPriKey); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | -int32_t CRYPT_RSA_ParsePubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *param, | 144 | +int32_t CRYPT_RSA_ParsePubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *param, |
| 145 | CRYPT_RSA_Ctx **rsaPubKey, BslCid cid) | 145 | CRYPT_RSA_Ctx **rsaPubKey, BslCid cid) |
| 146 | { | 146 | { |
| 147 | // decode n and e | 147 | // decode n and e |
| @@ -151,7 +151,7 @@ int32_t CRYPT_RSA_ParsePubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_ | |||
| 151 | return ret; | 151 | return ret; |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | - CRYPT_RSA_Ctx *pctx = CRYPT_RSA_NewCtx(); | 154 | + CRYPT_RSA_Ctx *pctx = CRYPT_RSA_NewCtxEx(libCtx); |
| 155 | if (pctx == NULL) { | 155 | if (pctx == NULL) { |
| 156 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); | 156 | BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL); |
| 157 | return CRYPT_MEM_ALLOC_FAIL; | 157 | return CRYPT_MEM_ALLOC_FAIL; |
| @@ -180,7 +180,8 @@ int32_t CRYPT_RSA_ParsePubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_ | |||
| 180 | return ret; | 180 | return ret; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | -int32_t CRYPT_RSA_ParseSubPubkeyAsn1Buff( uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **pubKey, bool isComplete) | 183 | +int32_t CRYPT_RSA_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **pubKey, |
| 184 | + bool isComplete) | ||
| 184 | { | 185 | { |
| 185 | if (pubKey == NULL) { | 186 | if (pubKey == NULL) { |
| 186 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); | 187 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); |
| @@ -198,8 +199,8 @@ int32_t CRYPT_RSA_ParseSubPubkeyAsn1Buff( uint8_t *buff, uint32_t buffLen, CRYPT | |||
| 198 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 199 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | - ret = CRYPT_RSA_ParsePubkeyAsn1Buff(subPubkeyInfo.pubKey.buff, subPubkeyInfo.pubKey.len, &subPubkeyInfo.keyParam, | 202 | + ret = CRYPT_RSA_ParsePubkeyAsn1Buff(libCtx, subPubkeyInfo.pubKey.buff, subPubkeyInfo.pubKey.len, |
| 202 | - &pctx, subPubkeyInfo.keyType); | 203 | + &subPubkeyInfo.keyParam, &pctx, subPubkeyInfo.keyType); |
| 203 | if (ret != CRYPT_SUCCESS) { | 204 | if (ret != CRYPT_SUCCESS) { |
| 204 | BSL_ERR_PUSH_ERROR(ret); | 205 | BSL_ERR_PUSH_ERROR(ret); |
| 205 | return ret; | 206 | return ret; |
| @@ -209,7 +210,7 @@ int32_t CRYPT_RSA_ParseSubPubkeyAsn1Buff( uint8_t *buff, uint32_t buffLen, CRYPT | |||
| 209 | return ret; | 210 | return ret; |
| 210 | } | 211 | } |
| 211 | 212 | ||
| 212 | -int32_t CRYPT_RSA_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **rsaPriKey) | 213 | +int32_t CRYPT_RSA_ParsePkcs8Key(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **rsaPriKey) |
| 213 | { | 214 | { |
| 214 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; | 215 | CRYPT_ENCODE_DECODE_Pk8PrikeyInfo pk8PrikeyInfo = {0}; |
| 215 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buff, buffLen, NULL, &pk8PrikeyInfo); | 216 | int32_t ret = CRYPT_DECODE_Pkcs8Info(buff, buffLen, NULL, &pk8PrikeyInfo); |
| @@ -221,8 +222,8 @@ int32_t CRYPT_RSA_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx * | |||
| 221 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); | 222 | BSL_ERR_PUSH_ERROR(CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH); |
| 222 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; | 223 | return CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH; |
| 223 | } | 224 | } |
| 224 | - ret = DecodeRsaPrikeyAsn1Buff(pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, &pk8PrikeyInfo.keyParam, | 225 | + ret = DecodeRsaPrikeyAsn1Buff(libCtx, pk8PrikeyInfo.pkeyRawKey, pk8PrikeyInfo.pkeyRawKeyLen, |
| 225 | - pk8PrikeyInfo.keyType, rsaPriKey); | 226 | + &pk8PrikeyInfo.keyParam, pk8PrikeyInfo.keyType, rsaPriKey); |
| 226 | if (ret != CRYPT_SUCCESS) { | 227 | if (ret != CRYPT_SUCCESS) { |
| 227 | BSL_ERR_PUSH_ERROR(ret); | 228 | BSL_ERR_PUSH_ERROR(ret); |
| 228 | } | 229 | } |
| @@ -137,36 +137,39 @@ int32_t CRYPT_DECODE_RsaPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1 | |||
| 137 | 137 | ||
| 138 | int32_t CRYPT_DECODE_RsaPrikeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *asn1, uint32_t asn1Num); | 138 | int32_t CRYPT_DECODE_RsaPrikeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *asn1, uint32_t asn1Num); |
| 139 | 139 | ||
| 140 | -int32_t CRYPT_RSA_ParsePubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *param, | 140 | +int32_t CRYPT_RSA_ParsePubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *param, |
| 141 | CRYPT_RSA_Ctx **rsaPubKey, BslCid cid); | 141 | CRYPT_RSA_Ctx **rsaPubKey, BslCid cid); |
| 142 | -int32_t CRYPT_RSA_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **rsaPriKey); | 142 | +int32_t CRYPT_RSA_ParsePkcs8Key(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **rsaPriKey); |
| 143 | 143 | ||
| 144 | -int32_t CRYPT_RSA_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **pubKey, bool isComplete); | 144 | +int32_t CRYPT_RSA_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_RSA_Ctx **pubKey, |
| 145 | + bool isComplete); | ||
| 145 | 146 | ||
| 146 | -int32_t CRYPT_RSA_ParsePrikeyAsn1Buff(uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *rsaPssParam, | 147 | +int32_t CRYPT_RSA_ParsePrikeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, BSL_ASN1_Buffer *rsaPssParam, |
| 147 | CRYPT_RSA_Ctx **rsaPriKey); | 148 | CRYPT_RSA_Ctx **rsaPriKey); |
| 148 | #endif | 149 | #endif |
| 149 | 150 | ||
| 150 | #if defined(HITLS_CRYPTO_ECDSA) || defined(HITLS_CRYPTO_ECDH) | 151 | #if defined(HITLS_CRYPTO_ECDSA) || defined(HITLS_CRYPTO_ECDH) |
| 151 | -int32_t CRYPT_ECC_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, void **pubKey, bool isComplete); | 152 | +int32_t CRYPT_ECC_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, void **pubKey, bool isComplete); |
| 152 | 153 | ||
| 153 | -int32_t CRYPT_ECC_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, void **ecdsaPriKey); | 154 | +int32_t CRYPT_ECC_ParsePkcs8Key(void *libCtx, uint8_t *buff, uint32_t buffLen, void **ecdsaPriKey); |
| 154 | 155 | ||
| 155 | -int32_t CRYPT_ECC_ParsePrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, | 156 | +int32_t CRYPT_ECC_ParsePrikeyAsn1Buff(void *libCtx, uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, |
| 156 | void **ecPriKey); | 157 | void **ecPriKey); |
| 157 | #endif | 158 | #endif |
| 158 | 159 | ||
| 159 | #ifdef HITLS_CRYPTO_SM2 | 160 | #ifdef HITLS_CRYPTO_SM2 |
| 160 | -int32_t CRYPT_SM2_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **pubKey, bool isComplete); | 161 | +int32_t CRYPT_SM2_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **pubKey, |
| 161 | -int32_t CRYPT_SM2_ParsePrikeyAsn1Buff(uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, | 162 | + bool isComplete); |
| 163 | +int32_t CRYPT_SM2_ParsePrikeyAsn1Buff(void *libCtx, uint8_t *buffer, uint32_t bufferLen, BSL_ASN1_Buffer *pk8AlgoParam, | ||
| 162 | CRYPT_SM2_Ctx **sm2PriKey); | 164 | CRYPT_SM2_Ctx **sm2PriKey); |
| 163 | -int32_t CRYPT_SM2_ParsePkcs8Key(uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **sm2PriKey); | 165 | +int32_t CRYPT_SM2_ParsePkcs8Key(void *libCtx, uint8_t *buff, uint32_t buffLen, CRYPT_SM2_Ctx **sm2PriKey); |
| 164 | #endif | 166 | #endif |
| 165 | 167 | ||
| 166 | #ifdef HITLS_CRYPTO_ED25519 | 168 | #ifdef HITLS_CRYPTO_ED25519 |
| 167 | -int32_t CRYPT_ED25519_ParsePkcs8Key(uint8_t *buffer, uint32_t bufferLen, CRYPT_CURVE25519_Ctx **ed25519PriKey); | 169 | +int32_t CRYPT_ED25519_ParsePkcs8Key(void *libCtx, uint8_t *buffer, uint32_t bufferLen, |
| 168 | -int32_t CRYPT_ED25519_ParseSubPubkeyAsn1Buff(uint8_t *buff, uint32_t buffLen, CRYPT_CURVE25519_Ctx **pubKey, | 170 | + CRYPT_CURVE25519_Ctx **ed25519PriKey); |
| 169 | - bool isComplete); | 171 | +int32_t CRYPT_ED25519_ParseSubPubkeyAsn1Buff(void *libCtx, uint8_t *buff, uint32_t buffLen, |
| 172 | + CRYPT_CURVE25519_Ctx **pubKey, bool isComplete); | ||
| 170 | #endif | 173 | #endif |
| 171 | 174 | ||
| 172 | #endif | 175 | #endif |
| @@ -342,6 +342,7 @@ CRYPT_DH_Ctx *CRYPT_DH_DupCtx(CRYPT_DH_Ctx *ctx) | |||
| 342 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->y, ctx->y, BN_Dup(ctx->y), CRYPT_MEM_ALLOC_FAIL); | 342 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->y, ctx->y, BN_Dup(ctx->y), CRYPT_MEM_ALLOC_FAIL); |
| 343 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, ctx->para, ParaDup(ctx->para), CRYPT_MEM_ALLOC_FAIL); | 343 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, ctx->para, ParaDup(ctx->para), CRYPT_MEM_ALLOC_FAIL); |
| 344 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); | 344 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); |
| 345 | + newKeyCtx->libCtx = ctx->libCtx; | ||
| 345 | return newKeyCtx; | 346 | return newKeyCtx; |
| 346 | 347 | ||
| 347 | ERR: | 348 | ERR: |
| @@ -364,6 +364,7 @@ CRYPT_DSA_Ctx *CRYPT_DSA_DupCtx(CRYPT_DSA_Ctx *dsaCtx) | |||
| 364 | GOTO_ERR_IF_SRC_NOT_NULL(dsaNewCtx->y, dsaCtx->y, BN_Dup(dsaCtx->y), CRYPT_MEM_ALLOC_FAIL); | 364 | GOTO_ERR_IF_SRC_NOT_NULL(dsaNewCtx->y, dsaCtx->y, BN_Dup(dsaCtx->y), CRYPT_MEM_ALLOC_FAIL); |
| 365 | GOTO_ERR_IF_SRC_NOT_NULL(dsaNewCtx->para, dsaCtx->para, ParaDup(dsaCtx->para), CRYPT_MEM_ALLOC_FAIL); | 365 | GOTO_ERR_IF_SRC_NOT_NULL(dsaNewCtx->para, dsaCtx->para, ParaDup(dsaCtx->para), CRYPT_MEM_ALLOC_FAIL); |
| 366 | BSL_SAL_ReferencesInit(&(dsaNewCtx->references)); | 366 | BSL_SAL_ReferencesInit(&(dsaNewCtx->references)); |
| 367 | + dsaNewCtx->libCtx = dsaCtx->libCtx; | ||
| 367 | return dsaNewCtx; | 368 | return dsaNewCtx; |
| 368 | 369 | ||
| 369 | ERR: | 370 | ERR: |
| @@ -253,7 +253,11 @@ ECC_Para *ECC_DupPara(const ECC_Para *para) | |||
| 253 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); | 253 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); |
| 254 | return NULL; | 254 | return NULL; |
| 255 | } | 255 | } |
| 256 | - return ECC_NewPara(para->id); | 256 | + ECC_Para *newPara = ECC_NewPara(para->id); |
| 257 | + if (newPara != NULL) { | ||
| 258 | + newPara->libCtx = para->libCtx; | ||
| 259 | + } | ||
| 260 | + return newPara; | ||
| 257 | } | 261 | } |
| 258 | 262 | ||
| 259 | uint32_t ECC_ParaBits(const ECC_Para *para) | 263 | uint32_t ECC_ParaBits(const ECC_Para *para) |
| @@ -73,6 +73,7 @@ ECC_Pkey *ECC_DupCtx(ECC_Pkey *ctx) | |||
| 73 | GOTO_ERR_IF_SRC_NOT_NULL(newCtx->pubkey, ctx->pubkey, ECC_DupPoint(ctx->pubkey), CRYPT_MEM_ALLOC_FAIL); | 73 | GOTO_ERR_IF_SRC_NOT_NULL(newCtx->pubkey, ctx->pubkey, ECC_DupPoint(ctx->pubkey), CRYPT_MEM_ALLOC_FAIL); |
| 74 | 74 | ||
| 75 | GOTO_ERR_IF_SRC_NOT_NULL(newCtx->para, ctx->para, ECC_DupPara(ctx->para), CRYPT_MEM_ALLOC_FAIL); | 75 | GOTO_ERR_IF_SRC_NOT_NULL(newCtx->para, ctx->para, ECC_DupPara(ctx->para), CRYPT_MEM_ALLOC_FAIL); |
| 76 | + newCtx->libCtx = ctx->libCtx; | ||
| 76 | return newCtx; | 77 | return newCtx; |
| 77 | 78 | ||
| 78 | ERR: | 79 | ERR: |
| @@ -130,6 +130,7 @@ CRYPT_ELGAMAL_Ctx *CRYPT_ELGAMAL_DupCtx(CRYPT_ELGAMAL_Ctx *keyCtx) | |||
| 130 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->pubKey, keyCtx->pubKey, ElGamalPubKeyDupCtx(keyCtx->pubKey), | 130 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->pubKey, keyCtx->pubKey, ElGamalPubKeyDupCtx(keyCtx->pubKey), |
| 131 | CRYPT_MEM_ALLOC_FAIL); | 131 | CRYPT_MEM_ALLOC_FAIL); |
| 132 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, keyCtx->para, ElGamalParaDupCtx(keyCtx->para), CRYPT_MEM_ALLOC_FAIL); | 132 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, keyCtx->para, ElGamalParaDupCtx(keyCtx->para), CRYPT_MEM_ALLOC_FAIL); |
| 133 | + newKeyCtx->libCtx = keyCtx->libCtx; | ||
| 133 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); | 134 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); |
| 134 | 135 | ||
| 135 | return newKeyCtx; | 136 | return newKeyCtx; |
| @@ -115,6 +115,7 @@ CRYPT_ML_DSA_Ctx *CRYPT_ML_DSA_DupCtx(CRYPT_ML_DSA_Ctx *ctx) | |||
| 115 | newCtx->isMuMsg = ctx->isMuMsg; | 115 | newCtx->isMuMsg = ctx->isMuMsg; |
| 116 | newCtx->deterministicSignFlag = ctx->deterministicSignFlag; | 116 | newCtx->deterministicSignFlag = ctx->deterministicSignFlag; |
| 117 | newCtx->needPreHash = ctx->needPreHash; | 117 | newCtx->needPreHash = ctx->needPreHash; |
| 118 | + newCtx->libCtx = ctx->libCtx; | ||
| 118 | return newCtx; | 119 | return newCtx; |
| 119 | ERR: | 120 | ERR: |
| 120 | CRYPT_ML_DSA_FreeCtx(newCtx); | 121 | CRYPT_ML_DSA_FreeCtx(newCtx); |
| @@ -137,6 +137,7 @@ CRYPT_ML_KEM_Ctx *CRYPT_ML_KEM_DupCtx(CRYPT_ML_KEM_Ctx *ctx) | |||
| 137 | } | 137 | } |
| 138 | newCtx->dkLen = ctx->dkLen; | 138 | newCtx->dkLen = ctx->dkLen; |
| 139 | } | 139 | } |
| 140 | + newCtx->libCtx = ctx->libCtx; | ||
| 140 | return newCtx; | 141 | return newCtx; |
| 141 | } | 142 | } |
| 142 | 143 | ||
| @@ -132,6 +132,7 @@ CRYPT_PAILLIER_Ctx *CRYPT_PAILLIER_DupCtx(CRYPT_PAILLIER_Ctx *keyCtx) | |||
| 132 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->prvKey, keyCtx->prvKey, PaillierPrvKeyDupCtx(keyCtx->prvKey), CRYPT_MEM_ALLOC_FAIL); | 132 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->prvKey, keyCtx->prvKey, PaillierPrvKeyDupCtx(keyCtx->prvKey), CRYPT_MEM_ALLOC_FAIL); |
| 133 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->pubKey, keyCtx->pubKey, PaillierPubKeyDupCtx(keyCtx->pubKey), CRYPT_MEM_ALLOC_FAIL); | 133 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->pubKey, keyCtx->pubKey, PaillierPubKeyDupCtx(keyCtx->pubKey), CRYPT_MEM_ALLOC_FAIL); |
| 134 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, keyCtx->para, PaillierParaDupCtx(keyCtx->para), CRYPT_MEM_ALLOC_FAIL); | 134 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, keyCtx->para, PaillierParaDupCtx(keyCtx->para), CRYPT_MEM_ALLOC_FAIL); |
| 135 | + newKeyCtx->libCtx = keyCtx->libCtx; | ||
| 135 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); | 136 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); |
| 136 | return newKeyCtx; | 137 | return newKeyCtx; |
| 137 | 138 | ||
| @@ -191,6 +191,7 @@ CRYPT_RSA_Ctx *CRYPT_RSA_DupCtx(CRYPT_RSA_Ctx *keyCtx) | |||
| 191 | } | 191 | } |
| 192 | #endif | 192 | #endif |
| 193 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, keyCtx->para, RSAParaDupCtx(keyCtx->para), CRYPT_MEM_ALLOC_FAIL); | 193 | GOTO_ERR_IF_SRC_NOT_NULL(newKeyCtx->para, keyCtx->para, RSAParaDupCtx(keyCtx->para), CRYPT_MEM_ALLOC_FAIL); |
| 194 | + newKeyCtx->libCtx = keyCtx->libCtx; | ||
| 194 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); | 195 | BSL_SAL_ReferencesInit(&(newKeyCtx->references)); |
| 195 | return newKeyCtx; | 196 | return newKeyCtx; |
| 196 | 197 | ||
| @@ -110,8 +110,8 @@ int32_t HITLS_X509_CertCtrl(HITLS_X509_Cert *cert, int32_t cmd, void *val, uint3 | |||
| 110 | * @ingroup pki | 110 | * @ingroup pki |
| 111 | * @brief Parse the CERT in the buffer. | 111 | * @brief Parse the CERT in the buffer. |
| 112 | * @par Description: Parse the CERT in the buffer. | 112 | * @par Description: Parse the CERT in the buffer. |
| 113 | - * If the encoding is successful, the memory for the crl is requested from within the function, | 113 | + * If the parsing is successful, the memory for the cert is requested from within the function, |
| 114 | - * and the user needs to free it after using it. When the parameter is BSL_FORMAT_PEM and | 114 | + * and the user needs to free it after use. When the parameter is BSL_FORMAT_PEM and |
| 115 | * BSL_FORMAT_UNKNOWN, the buff of encode needs to end with '\0' | 115 | * BSL_FORMAT_UNKNOWN, the buff of encode needs to end with '\0' |
| 116 | * @attention None | 116 | * @attention None |
| 117 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. | 117 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. |
| @@ -144,8 +144,8 @@ int32_t HITLS_X509_ProviderCertParseBuff(HITLS_PKI_LibCtx *libCtx, const char *a | |||
| 144 | * @ingroup pki | 144 | * @ingroup pki |
| 145 | * @brief Parse the CERT in the file. | 145 | * @brief Parse the CERT in the file. |
| 146 | * @par Description: Parse the CERT in the file. | 146 | * @par Description: Parse the CERT in the file. |
| 147 | - * If the encoding is successful, the memory for the crl is requested from within the function, | 147 | + * If the parsing is successful, the memory for the cert is requested from within the function, |
| 148 | - * and the user needs to free it after using it. | 148 | + * and the user needs to free it after use. |
| 149 | * @attention None | 149 | * @attention None |
| 150 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. | 150 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. |
| 151 | * @param path [IN] CERT file path. | 151 | * @param path [IN] CERT file path. |
| @@ -164,7 +164,7 @@ int32_t HITLS_X509_CertParseFile(int32_t format, const char *path, HITLS_X509_Ce | |||
| 164 | * | 164 | * |
| 165 | * @param libCtx [IN] Library context from CRYPT_EAL_LibCtx | 165 | * @param libCtx [IN] Library context from CRYPT_EAL_LibCtx |
| 166 | * @param attrName [IN] Provider attribute name for capability matching | 166 | * @param attrName [IN] Provider attribute name for capability matching |
| 167 | - * @param format [IN] Encoding format: PEM/ASN1/NULL | 167 | + * @param format [IN] Encoding format: "PEM"/"ASN1"/NULL |
| 168 | * @param path [IN] Certificate file path | 168 | * @param path [IN] Certificate file path |
| 169 | * @param cert [OUT] Parsed certificate object | 169 | * @param cert [OUT] Parsed certificate object |
| 170 | * @return #HITLS_PKI_SUCCESS, success. | 170 | * @return #HITLS_PKI_SUCCESS, success. |
| @@ -177,12 +177,12 @@ int32_t HITLS_X509_ProviderCertParseFile(HITLS_PKI_LibCtx *libCtx, const char *a | |||
| 177 | * @ingroup pki | 177 | * @ingroup pki |
| 178 | * @brief Parse the CERTs in the file. | 178 | * @brief Parse the CERTs in the file. |
| 179 | * @par Description: Parse multiple CERTs in the file. | 179 | * @par Description: Parse multiple CERTs in the file. |
| 180 | - * If the encoding is successful, the memory for the certlist is requested from within the function, | 180 | + * If the parsing is successful, the memory for the certlist is requested from within the function, |
| 181 | - * and the user needs to free it after using it. | 181 | + * and the user needs to free it after use. |
| 182 | * @attention None | 182 | * @attention None |
| 183 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. | 183 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. |
| 184 | - * @param path [IN] CRL file path. | 184 | + * @param path [IN] Certificate file path. |
| 185 | - * @param crllist [OUT] CRL list after parse. | 185 | + * @param certlist [OUT] Certificate list after parse. |
| 186 | * @return #HITLS_PKI_SUCCESS, success. | 186 | * @return #HITLS_PKI_SUCCESS, success. |
| 187 | * Error codes can be found in hitls_pki_errno.h | 187 | * Error codes can be found in hitls_pki_errno.h |
| 188 | */ | 188 | */ |
| @@ -197,7 +197,7 @@ int32_t HITLS_X509_CertParseBundleFile(int32_t format, const char *path, HITLS_X | |||
| 197 | * | 197 | * |
| 198 | * @param libCtx [IN] Library context from CRYPT_EAL_LibCtx | 198 | * @param libCtx [IN] Library context from CRYPT_EAL_LibCtx |
| 199 | * @param attrName [IN] Provider attribute name for capability matching | 199 | * @param attrName [IN] Provider attribute name for capability matching |
| 200 | - * @param format [IN] Encoding format: PEM/ASN1/NULL | 200 | + * @param format [IN] Encoding format: "PEM"/"ASN1"/NULL |
| 201 | * @param path [IN] Certificate bundle file path | 201 | * @param path [IN] Certificate bundle file path |
| 202 | * @param certlist [OUT] List of parsed certificate objects | 202 | * @param certlist [OUT] List of parsed certificate objects |
| 203 | * @return #HITLS_PKI_SUCCESS, success. | 203 | * @return #HITLS_PKI_SUCCESS, success. |
| @@ -65,12 +65,11 @@ int32_t HITLS_X509_CrlCtrl(HITLS_X509_Crl *crl, int32_t cmd, void *val, uint32_t | |||
| 65 | * @ingroup pki | 65 | * @ingroup pki |
| 66 | * @brief Parse the CRL in the buffer. | 66 | * @brief Parse the CRL in the buffer. |
| 67 | * @par Description: Parse the CRL in the buffer. | 67 | * @par Description: Parse the CRL in the buffer. |
| 68 | - * If the encoding is successful, the memory for the crl is requested from within the function, | 68 | + * If the parsing is successful, the memory for the crl is requested from within the function, |
| 69 | - * and the user needs to free it after using it. When the parameter is BSL_FORMAT_PEM and | 69 | + * and the user needs to free it after use. When the parameter is BSL_FORMAT_PEM and |
| 70 | * BSL_FORMAT_UNKNOWN, the buff of encode needs to end with '\0' | 70 | * BSL_FORMAT_UNKNOWN, the buff of encode needs to end with '\0' |
| 71 | * @attention None | 71 | * @attention None |
| 72 | - * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/ | 72 | + * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. |
| 73 | - * BSL_FORMAT_UNKNOWN. | ||
| 74 | * @param encode [IN] CRL data. | 73 | * @param encode [IN] CRL data. |
| 75 | * @param crl [OUT] CRL after parse. | 74 | * @param crl [OUT] CRL after parse. |
| 76 | * @return Error code | 75 | * @return Error code |
| @@ -81,11 +80,10 @@ int32_t HITLS_X509_CrlParseBuff(int32_t format, const BSL_Buffer *encode, HITLS_ | |||
| 81 | * @ingroup pki | 80 | * @ingroup pki |
| 82 | * @brief Parse the CRL in the file. | 81 | * @brief Parse the CRL in the file. |
| 83 | * @par Description: Parse the CRL in the file. | 82 | * @par Description: Parse the CRL in the file. |
| 84 | - * If the encoding is successful, the memory for the crl is requested from within the function, | 83 | + * If the parsing is successful, the memory for the crl is requested from within the function, |
| 85 | - * and the user needs to free it after using it. | 84 | + * and the user needs to free it after use. |
| 86 | * @attention None | 85 | * @attention None |
| 87 | - * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/ | 86 | + * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. |
| 88 | - * BSL_FORMAT_UNKNOWN. | ||
| 89 | * @param path [IN] CRL file path. | 87 | * @param path [IN] CRL file path. |
| 90 | * @param crl [OUT] CRL after parse. | 88 | * @param crl [OUT] CRL after parse. |
| 91 | * @return Error code | 89 | * @return Error code |
| @@ -96,8 +94,8 @@ int32_t HITLS_X509_CrlParseFile(int32_t format, const char *path, HITLS_X509_Crl | |||
| 96 | * @ingroup pki | 94 | * @ingroup pki |
| 97 | * @brief Parse the CRLs in the file. | 95 | * @brief Parse the CRLs in the file. |
| 98 | * @par Description: Parse multiple CRLs in the file. | 96 | * @par Description: Parse multiple CRLs in the file. |
| 99 | - * If the encoding is successful, the memory for the crllist is requested from within the function, | 97 | + * If the parsing is successful, the memory for the crllist is requested from within the function, |
| 100 | - * and the user needs to free it after using it. | 98 | + * and the user needs to free it after use. |
| 101 | * @attention None | 99 | * @attention None |
| 102 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/ | 100 | * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1/ |
| 103 | * BSL_FORMAT_UNKNOWN. | 101 | * BSL_FORMAT_UNKNOWN. |
| @@ -112,7 +110,7 @@ int32_t HITLS_X509_CrlParseBundleFile(int32_t format, const char *path, HITLS_X5 | |||
| 112 | * @brief Generate a CRL and encode it. | 110 | * @brief Generate a CRL and encode it. |
| 113 | * @par Description: This function encodes the CRL into the specified format. | 111 | * @par Description: This function encodes the CRL into the specified format. |
| 114 | * If the encoding is successful, the memory for the encode data is requested from within the function, | 112 | * If the encoding is successful, the memory for the encode data is requested from within the function, |
| 115 | - * and the user needs to free it after using it. | 113 | + * and the user needs to free it after use. |
| 116 | * | 114 | * |
| 117 | * @attention This function is used after parsing the crl or after signing. | 115 | * @attention This function is used after parsing the crl or after signing. |
| 118 | * | 116 | * |
| @@ -129,7 +127,7 @@ int32_t HITLS_X509_CrlGenBuff(int32_t format, HITLS_X509_Crl *crl, BSL_Buffer *b | |||
| 129 | * @brief Generate a CRL and encode it to specific file. | 127 | * @brief Generate a CRL and encode it to specific file. |
| 130 | * @par Description: This function encodes the CRL into the specified format. | 128 | * @par Description: This function encodes the CRL into the specified format. |
| 131 | * If the encoding is successful, the memory for the encode data is requested from within the function, | 129 | * If the encoding is successful, the memory for the encode data is requested from within the function, |
| 132 | - * and the user needs to free it after using it. | 130 | + * and the user needs to free it after use. |
| 133 | * | 131 | * |
| 134 | * @attention This function is used after parsing the crl or after signing. | 132 | * @attention This function is used after parsing the crl or after signing. |
| 135 | * | 133 | * |
| @@ -195,13 +193,13 @@ void HITLS_X509_CrlEntryFree(HITLS_X509_CrlEntry *entry); | |||
| 195 | 193 | ||
| 196 | /** | 194 | /** |
| 197 | * @ingroup pki | 195 | * @ingroup pki |
| 198 | - * @brief Generate a CRL and encode it to specific file. | 196 | + * @brief Control interface for CRL entry. |
| 199 | - * @par Description: This function encodes the CRL into the specified format. | 197 | + * @par Description: This function provides control interface for CRL entry operations. |
| 200 | - * If the encoding is successful, the memory for the encode data is requested from within the function, | ||
| 201 | - * and the user needs to free it after using it. | ||
| 202 | * @attention None | 198 | * @attention None |
| 203 | - * @param pubkey [IN] pubkey. | 199 | + * @param revoked [IN] CRL entry to control. |
| 204 | - * @param crl [IN] CRL info. | 200 | + * @param cmd [IN] Control command. |
| 201 | + * @param val [IN/OUT] Control value. | ||
| 202 | + * @param valLen [IN] Length of control value. | ||
| 205 | * @return Error code | 203 | * @return Error code |
| 206 | */ | 204 | */ |
| 207 | int32_t HITLS_X509_CrlEntryCtrl(HITLS_X509_CrlEntry *revoked, int32_t cmd, void *val, uint32_t valLen); | 205 | int32_t HITLS_X509_CrlEntryCtrl(HITLS_X509_CrlEntry *revoked, int32_t cmd, void *val, uint32_t valLen); |
| @@ -46,7 +46,7 @@ void HITLS_X509_CsrFree(HITLS_X509_Csr *csr); | |||
| 46 | * @ingroup pki | 46 | * @ingroup pki |
| 47 | * @brief Sign a CSR (Certificate Signing Request). | 47 | * @brief Sign a CSR (Certificate Signing Request). |
| 48 | * | 48 | * |
| 49 | -* @attention 1. This function can only be used when generating a new csr. | 49 | + * @attention 1. This function can only be used when generating a new csr. |
| 50 | * 2. You need to first call interfaces HITLS_X509_CsrCtrl and HITLS_X509_AttrCtrl to set csr information. | 50 | * 2. You need to first call interfaces HITLS_X509_CsrCtrl and HITLS_X509_AttrCtrl to set csr information. |
| 51 | * | 51 | * |
| 52 | * @param mdId [IN] The message digest algorithm ID. | 52 | * @param mdId [IN] The message digest algorithm ID. |
| @@ -65,7 +65,7 @@ int32_t HITLS_X509_CsrSign(int32_t mdId, const CRYPT_EAL_PkeyCtx *prvKey, const | |||
| 65 | * | 65 | * |
| 66 | * @attention This function is used after parsing the csr or after signing. | 66 | * @attention This function is used after parsing the csr or after signing. |
| 67 | * | 67 | * |
| 68 | - * @param format [IN] The format of the generated csr. | 68 | + * @param format [IN] The format of the generated csr: BSL_FORMAT_ASN1/BSL_FORMAT_PEM |
| 69 | * @param csr [IN] The csr context | 69 | * @param csr [IN] The csr context |
| 70 | * @param buff [OUT] The buffer of the generated csr. | 70 | * @param buff [OUT] The buffer of the generated csr. |
| 71 | * @retval #HITLS_PKI_SUCCESS, success. | 71 | * @retval #HITLS_PKI_SUCCESS, success. |
| @@ -79,7 +79,7 @@ int32_t HITLS_X509_CsrGenBuff(int32_t format, HITLS_X509_Csr *csr, BSL_Buffer *b | |||
| 79 | * | 79 | * |
| 80 | * @attention This function is used after parsing the csr or after signing. | 80 | * @attention This function is used after parsing the csr or after signing. |
| 81 | * | 81 | * |
| 82 | - * @param format [IN] The format of the generated csr. | 82 | + * @param format [IN] The format of the generated csr: BSL_FORMAT_ASN1/BSL_FORMAT_PEM |
| 83 | * @param csr [IN] The csr context | 83 | * @param csr [IN] The csr context |
| 84 | * @param path [IN] The path of the generated csr. | 84 | * @param path [IN] The path of the generated csr. |
| 85 | * @retval #HITLS_PKI_SUCCESS, success. | 85 | * @retval #HITLS_PKI_SUCCESS, success. |
| @@ -129,7 +129,7 @@ int32_t HITLS_X509_CsrParseFile(int32_t format, const char *path, HITLS_X509_Csr | |||
| 129 | * @ingroup pki | 129 | * @ingroup pki |
| 130 | * @brief Csr verify function | 130 | * @brief Csr verify function |
| 131 | * | 131 | * |
| 132 | - * @param csr [OUT] The csr context | 132 | + * @param csr [IN] The csr context |
| 133 | * @retval #HITLS_PKI_SUCCESS, success. | 133 | * @retval #HITLS_PKI_SUCCESS, success. |
| 134 | * Error codes can be found in hitls_pki_errno.h | 134 | * Error codes can be found in hitls_pki_errno.h |
| 135 | */ | 135 | */ |
| @@ -81,7 +81,7 @@ void HITLS_PKCS12_BagFree(HITLS_PKCS12_Bag *bag); | |||
| 81 | * @param bag [IN] bag context. | 81 | * @param bag [IN] bag context. |
| 82 | * @param cmd [IN] HITLS_PKCS12_XXX | 82 | * @param cmd [IN] HITLS_PKCS12_XXX |
| 83 | * @param val [IN/OUT] input and output value | 83 | * @param val [IN/OUT] input and output value |
| 84 | - * @param valLen [In] value length | 84 | + * @param valType [In] value type or length |
| 85 | * @retval #HITLS_PKI_SUCCESS, success. | 85 | * @retval #HITLS_PKI_SUCCESS, success. |
| 86 | * Error codes can be found in hitls_pki_errno.h | 86 | * Error codes can be found in hitls_pki_errno.h |
| 87 | */ | 87 | */ |
| @@ -114,7 +114,7 @@ int32_t HITLS_PKCS12_Ctrl(HITLS_PKCS12 *p12, int32_t cmd, void *val, uint32_t va | |||
| 114 | * BSL_FORMAT_PEM and BSL_FORMAT_UNKNOWN, the buff of encode needs to end with '\0' | 114 | * BSL_FORMAT_PEM and BSL_FORMAT_UNKNOWN, the buff of encode needs to end with '\0' |
| 115 | * | 115 | * |
| 116 | * @attention Only support to parse p12 buffer in key-integrity and key-privacy protection mode. | 116 | * @attention Only support to parse p12 buffer in key-integrity and key-privacy protection mode. |
| 117 | - * @param format [IN] Decoding format: BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. | 117 | + * @param format [IN] Decoding format: BSL_FORMAT_ASN. |
| 118 | * @param encode [IN] encode data | 118 | * @param encode [IN] encode data |
| 119 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. | 119 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. |
| 120 | * @param p12 [OUT] the p12 struct. | 120 | * @param p12 [OUT] the p12 struct. |
| @@ -133,7 +133,7 @@ int32_t HITLS_PKCS12_ParseBuff(int32_t format, const BSL_Buffer *encode, const H | |||
| 133 | * @attention Only support to parse p12 buffer in key-integrity and key-privacy protection mode. | 133 | * @attention Only support to parse p12 buffer in key-integrity and key-privacy protection mode. |
| 134 | * @param libCtx [IN] lib context | 134 | * @param libCtx [IN] lib context |
| 135 | * @param attrName [IN] attribute name | 135 | * @param attrName [IN] attribute name |
| 136 | - * @param format [IN] Encoding format: PEM/ASN1/NULL | 136 | + * @param format [IN] Encoding format: "ASN1" |
| 137 | * @param encode [IN] encode data | 137 | * @param encode [IN] encode data |
| 138 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. | 138 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. |
| 139 | * @param p12 [OUT] the p12 struct. | 139 | * @param p12 [OUT] the p12 struct. |
| @@ -148,7 +148,7 @@ int32_t HITLS_PKCS12_ProviderParseBuff(HITLS_PKI_LibCtx *libCtx, const char *att | |||
| 148 | * @par Description: parse p12 file, and set the p12 struct. | 148 | * @par Description: parse p12 file, and set the p12 struct. |
| 149 | * | 149 | * |
| 150 | * @attention Only support to parse p12 files in key-integrity and key-privacy protection mode. | 150 | * @attention Only support to parse p12 files in key-integrity and key-privacy protection mode. |
| 151 | - * @param format [IN] Encoding format: BSL_FORMAT_PEM/BSL_FORMAT_ASN1 | 151 | + * @param format [IN] Encoding format: BSL_FORMAT_ASN1 |
| 152 | * @param path [IN] p12 file path. | 152 | * @param path [IN] p12 file path. |
| 153 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. | 153 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. |
| 154 | * @param p12 [OUT] the p12 struct. | 154 | * @param p12 [OUT] the p12 struct. |
| @@ -167,7 +167,7 @@ int32_t HITLS_PKCS12_ParseFile(int32_t format, const char *path, const HITLS_PKC | |||
| 167 | * @attention Only support to parse p12 files in key-integrity and key-privacy protection mode. | 167 | * @attention Only support to parse p12 files in key-integrity and key-privacy protection mode. |
| 168 | * @param libCtx [IN] lib context | 168 | * @param libCtx [IN] lib context |
| 169 | * @param attrName [IN] attribute name | 169 | * @param attrName [IN] attribute name |
| 170 | - * @param format [IN] Encoding format: PEM/ASN1/NULL | 170 | + * @param format [IN] Encoding format: "ASN1" |
| 171 | * @param path [IN] p12 file path. | 171 | * @param path [IN] p12 file path. |
| 172 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. | 172 | * @param pwdParam [IN] include MAC-pwd, enc-pwd, they can be different. |
| 173 | * @param p12 [OUT] the p12 struct. | 173 | * @param p12 [OUT] the p12 struct. |
| @@ -183,7 +183,7 @@ int32_t HITLS_PKCS12_ProviderParseFile(HITLS_PKI_LibCtx *libCtx, const char *att | |||
| 183 | * @par Description: gen p12 buffer. | 183 | * @par Description: gen p12 buffer. |
| 184 | * | 184 | * |
| 185 | * @attention Generate a p12 buffer based on the existing information. | 185 | * @attention Generate a p12 buffer based on the existing information. |
| 186 | - * @param format [IN] Encoding format: BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. | 186 | + * @param format [IN] Encoding format: BSL_FORMAT_ASN1. |
| 187 | * @param p12 [IN] p12 struct, including entityCert, CA-cert, prvkey, and so on. | 187 | * @param p12 [IN] p12 struct, including entityCert, CA-cert, prvkey, and so on. |
| 188 | * @param encodeParam [IN] encode data | 188 | * @param encodeParam [IN] encode data |
| 189 | * @param isNeedMac [IN] Identifies whether macData is required. | 189 | * @param isNeedMac [IN] Identifies whether macData is required. |
| @@ -199,7 +199,7 @@ int32_t HITLS_PKCS12_GenBuff(int32_t format, HITLS_PKCS12 *p12, const HITLS_PKCS | |||
| 199 | * @par Description: Generate p12 to store in file | 199 | * @par Description: Generate p12 to store in file |
| 200 | * | 200 | * |
| 201 | * @attention Generate a .p12 file based on the existing information. | 201 | * @attention Generate a .p12 file based on the existing information. |
| 202 | - * @param format [IN] Encoding format: BSL_FORMAT_ASN1/BSL_FORMAT_UNKNOWN. | 202 | + * @param format [IN] Encoding format: BSL_FORMAT_ASN1. |
| 203 | * @param p12 [IN] p12 struct, including entityCert, CA-cert, prvkey, and so on. | 203 | * @param p12 [IN] p12 struct, including entityCert, CA-cert, prvkey, and so on. |
| 204 | * @param encodeParam [IN] encode data | 204 | * @param encodeParam [IN] encode data |
| 205 | * @param isNeedMac [IN] Identifies whether macData is required. | 205 | * @param isNeedMac [IN] Identifies whether macData is required. |
| @@ -39,7 +39,7 @@ HITLS_X509_StoreCtx *HITLS_X509_StoreCtxNew(void); | |||
| 39 | * @param libCtx [IN] Library context from CRYPT_EAL | 39 | * @param libCtx [IN] Library context from CRYPT_EAL |
| 40 | * @param attrName [IN] Provider attribute name for capability matching | 40 | * @param attrName [IN] Provider attribute name for capability matching |
| 41 | * | 41 | * |
| 42 | - * @return HITLS_X509_STORE* Store object or NULL on failure | 42 | + * @return HITLS_X509_StoreCtx* Store object or NULL on failure |
| 43 | */ | 43 | */ |
| 44 | HITLS_X509_StoreCtx *HITLS_X509_ProviderStoreCtxNew(HITLS_PKI_LibCtx *libCtx, const char *attrName); | 44 | HITLS_X509_StoreCtx *HITLS_X509_ProviderStoreCtxNew(HITLS_PKI_LibCtx *libCtx, const char *attrName); |
| 45 | 45 | ||
| @@ -68,6 +68,7 @@ void HITLS_X509_StoreCtxFree(HITLS_X509_StoreCtx *storeCtx); | |||
| 68 | * HITLS_X509_STORECTX_SET_CRL HITLS_X509_Crl - | 68 | * HITLS_X509_STORECTX_SET_CRL HITLS_X509_Crl - |
| 69 | * HITLS_X509_STORECTX_REF_UP int sizeof(int) | 69 | * HITLS_X509_STORECTX_REF_UP int sizeof(int) |
| 70 | * HITLS_X509_STORECTX_SET_VFY_SM2_USERID buffer > 0 | 70 | * HITLS_X509_STORECTX_SET_VFY_SM2_USERID buffer > 0 |
| 71 | + * HITLS_X509_STORECTX_GET_PARAM_DEPTH int32_t * sizeof(int32_t) | ||
| 71 | * @param val [IN/OUT] input and output value. | 72 | * @param val [IN/OUT] input and output value. |
| 72 | * @param valLen [IN] value length. | 73 | * @param valLen [IN] value length. |
| 73 | * @retval #HITLS_PKI_SUCCESS, success. | 74 | * @retval #HITLS_PKI_SUCCESS, success. |