已合并
Modify the code issues #811
Ooohui创建于 2025年11月17日
Modify the code issues #811
已合并
共 26 个文件变更+185-147
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | 22 | ||
| @@ -74,7 +74,7 @@ struct CRYPT_DECODER_PoolCtx { | |||
| 74 | const char *attrName; /* Attribute name */ | 74 | const char *attrName; /* Attribute name */ |
| 75 | const char *inputFormat; /* Input data format */ | 75 | const char *inputFormat; /* Input data format */ |
| 76 | const char *inputType; /* Input data type */ | 76 | const char *inputType; /* Input data type */ |
| 77 | - int32_t inputKeyType; /* Input data key type */ | 77 | + int32_t inputPkeyAlgId; /* Input pkey algorithm ID */ |
| 78 | BSL_Param *input; /* Input data */ | 78 | BSL_Param *input; /* Input data */ |
| 79 | const char *targetFormat; /* Target format */ | 79 | const char *targetFormat; /* Target format */ |
| 80 | const char *targetType; /* Target type */ | 80 | const char *targetType; /* Target type */ |
| @@ -157,11 +157,11 @@ ERR: | |||
| 157 | return NULL; | 157 | return NULL; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | -CRYPT_DECODER_Ctx *CRYPT_DECODE_ProviderNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t keyType, const char *attrName) | 160 | +CRYPT_DECODER_Ctx *CRYPT_DECODE_ProviderNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t pkeyAlgId, const char *attrName) |
| 161 | { | 161 | { |
| 162 | const CRYPT_EAL_Func *funcsDecoder = NULL; | 162 | const CRYPT_EAL_Func *funcsDecoder = NULL; |
| 163 | CRYPT_EAL_ProvMgrCtx *mgrCtx = NULL; | 163 | CRYPT_EAL_ProvMgrCtx *mgrCtx = NULL; |
| 164 | - int32_t ret = CRYPT_EAL_ProviderGetFuncsAndMgrCtx(libCtx, CRYPT_EAL_OPERAID_DECODER, keyType, attrName, | 164 | + int32_t ret = CRYPT_EAL_ProviderGetFuncsAndMgrCtx(libCtx, CRYPT_EAL_OPERAID_DECODER, pkeyAlgId, attrName, |
| 165 | &funcsDecoder, &mgrCtx); | 165 | &funcsDecoder, &mgrCtx); |
| 166 | if (ret != CRYPT_SUCCESS) { | 166 | if (ret != CRYPT_SUCCESS) { |
| 167 | BSL_ERR_PUSH_ERROR(ret); | 167 | BSL_ERR_PUSH_ERROR(ret); |
| @@ -56,7 +56,7 @@ static void FreeDecoderNode(CRYPT_DECODER_Node *decoderNode) | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | CRYPT_DECODER_PoolCtx *CRYPT_DECODE_PoolNewCtx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, | 58 | CRYPT_DECODER_PoolCtx *CRYPT_DECODE_PoolNewCtx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, |
| 59 | - int32_t keyType, const char *format, const char *type) | 59 | + int32_t pkeyAlgId, const char *format, const char *type) |
| 60 | { | 60 | { |
| 61 | CRYPT_DECODER_PoolCtx *poolCtx = BSL_SAL_Calloc(1, sizeof(CRYPT_DECODER_PoolCtx)); | 61 | CRYPT_DECODER_PoolCtx *poolCtx = BSL_SAL_Calloc(1, sizeof(CRYPT_DECODER_PoolCtx)); |
| 62 | if (poolCtx == NULL) { | 62 | if (poolCtx == NULL) { |
| @@ -80,7 +80,7 @@ CRYPT_DECODER_PoolCtx *CRYPT_DECODE_PoolNewCtx(CRYPT_EAL_LibCtx *libCtx, const c | |||
| 80 | } | 80 | } |
| 81 | poolCtx->inputFormat = format; | 81 | poolCtx->inputFormat = format; |
| 82 | poolCtx->inputType = type; | 82 | poolCtx->inputType = type; |
| 83 | - poolCtx->inputKeyType = keyType; | 83 | + poolCtx->inputPkeyAlgId = pkeyAlgId; |
| 84 | poolCtx->targetFormat = NULL; | 84 | poolCtx->targetFormat = NULL; |
| 85 | poolCtx->targetType = NULL; | 85 | poolCtx->targetType = NULL; |
| 86 | return poolCtx; | 86 | return poolCtx; |
| @@ -32,7 +32,6 @@ | |||
| 32 | "-Wstack-usage=8192", | 32 | "-Wstack-usage=8192", |
| 33 | "-Wframe-larger-than=4096", | 33 | "-Wframe-larger-than=4096", |
| 34 | "-Wconversion", | 34 | "-Wconversion", |
| 35 | - "-Wcast-qual", | ||
| 36 | "-Wcast-align", | 35 | "-Wcast-align", |
| 37 | "-Wvla", | 36 | "-Wvla", |
| 38 | "-Wunused", | 37 | "-Wunused", |
| @@ -135,8 +134,7 @@ | |||
| 135 | "-fpack-struct=4", | 134 | "-fpack-struct=4", |
| 136 | "-fno-exceptions", | 135 | "-fno-exceptions", |
| 137 | "-fno-delete-null-pointer-checks", | 136 | "-fno-delete-null-pointer-checks", |
| 138 | - "-fno-merge-constants", | 137 | + "-fno-merge-constants" |
| 139 | - "-fpack-struct=4" | ||
| 140 | ], | 138 | ], |
| 141 | "CC_OVERALL_FLAGS": [ | 139 | "CC_OVERALL_FLAGS": [ |
| 142 | "-pipe" | 140 | "-pipe" |
| @@ -177,7 +177,7 @@ | |||
| 177 | "mldsa": {"deps": ["sha3", "obj_default"]}, | 177 | "mldsa": {"deps": ["sha3", "obj_default"]}, |
| 178 | "paillier": {"deps":["bn_rand", "bn_prime"]}, | 178 | "paillier": {"deps":["bn_rand", "bn_prime"]}, |
| 179 | "elgamal": {"deps":["bn_rand", "bn_prime"]}, | 179 | "elgamal": {"deps":["bn_rand", "bn_prime"]}, |
| 180 | - "slh_dsa": { "deps": ["sha3", "sha2", "obj_default", "eal", "hmac", "sha256", "sha512"]}, | 180 | + "slh_dsa": { "deps": ["sha3", "obj_default", "eal", "hmac", "sha256", "sha512"]}, |
| 181 | "xmss": { "deps": ["sha3", "sha2", "obj_default", "eal", "sha256", "sha512"]}, | 181 | "xmss": { "deps": ["sha3", "sha2", "obj_default", "eal", "sha256", "sha512"]}, |
| 182 | "deps": ["params"] | 182 | "deps": ["params"] |
| 183 | }, | 183 | }, |
| @@ -553,9 +553,6 @@ | |||
| 553 | 553 | ||
| 554 | 554 | ||
| 555 | 555 | ||
| 556 | - | ||
| 557 | - | ||
| 558 | - | ||
| 559 | 556 | ||
| 560 | 557 | ||
| 561 | 558 | ||
| @@ -309,7 +309,7 @@ static int32_t GetObjectFromOutData(BSL_Param *outData, void **object) | |||
| 309 | return CRYPT_SUCCESS; | 309 | return CRYPT_SUCCESS; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | -int32_t ProviderDecodeBuffKeyEx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t keyType, | 312 | +int32_t ProviderDecodeBuffKeyEx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t pkeyAlgId, |
| 313 | const char *format, const char *type, BSL_Buffer *encode, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey) | 313 | const char *format, const char *type, BSL_Buffer *encode, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey) |
| 314 | { | 314 | { |
| 315 | char *targetType = "HIGH_KEY"; | 315 | char *targetType = "HIGH_KEY"; |
| @@ -323,7 +323,7 @@ int32_t ProviderDecodeBuffKeyEx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, | |||
| 323 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); | 323 | BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT); |
| 324 | return CRYPT_NULL_INPUT; | 324 | return CRYPT_NULL_INPUT; |
| 325 | } | 325 | } |
| 326 | - CRYPT_DECODER_PoolCtx *poolCtx = CRYPT_DECODE_PoolNewCtx(libCtx, attrName, keyType, format, type); | 326 | + CRYPT_DECODER_PoolCtx *poolCtx = CRYPT_DECODE_PoolNewCtx(libCtx, attrName, pkeyAlgId, format, type); |
| 327 | if (poolCtx == NULL) { | 327 | if (poolCtx == NULL) { |
| 328 | return CRYPT_MEM_ALLOC_FAIL; | 328 | return CRYPT_MEM_ALLOC_FAIL; |
| 329 | } | 329 | } |
| @@ -346,7 +346,7 @@ int32_t ProviderDecodeBuffKeyEx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, | |||
| 346 | goto EXIT; | 346 | goto EXIT; |
| 347 | } | 347 | } |
| 348 | int32_t algId = CRYPT_EAL_PkeyGetId(tmpPKey); | 348 | int32_t algId = CRYPT_EAL_PkeyGetId(tmpPKey); |
| 349 | - if (keyType != BSL_CID_UNKNOWN && algId != keyType) { | 349 | + if (pkeyAlgId != BSL_CID_UNKNOWN && algId != pkeyAlgId) { |
| 350 | ret = CRYPT_EAL_ERR_ALGID; | 350 | ret = CRYPT_EAL_ERR_ALGID; |
| 351 | BSL_ERR_PUSH_ERROR(CRYPT_EAL_ERR_ALGID); | 351 | BSL_ERR_PUSH_ERROR(CRYPT_EAL_ERR_ALGID); |
| 352 | goto EXIT; | 352 | goto EXIT; |
| @@ -390,15 +390,15 @@ int32_t ProviderDecodeBuffKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, in | |||
| 390 | } | 390 | } |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | -int32_t CRYPT_EAL_ProviderDecodeBuffKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t keyType, | 393 | +int32_t CRYPT_EAL_ProviderDecodeBuffKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t pkeyAlgId, |
| 394 | const char *format, const char *type, BSL_Buffer *encode, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey) | 394 | const char *format, const char *type, BSL_Buffer *encode, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey) |
| 395 | { | 395 | { |
| 396 | 396 | ||
| 397 | - return ProviderDecodeBuffKeyEx(libCtx, attrName, keyType, format, type, encode, pwd, ealPKey); | 397 | + return ProviderDecodeBuffKeyEx(libCtx, attrName, pkeyAlgId, format, type, encode, pwd, ealPKey); |
| 398 | 398 | ||
| 399 | (void)libCtx; | 399 | (void)libCtx; |
| 400 | (void)attrName; | 400 | (void)attrName; |
| 401 | - (void)keyType; | 401 | + (void)pkeyAlgId; |
| 402 | int32_t encodeType = CRYPT_EAL_GetEncodeType(type); | 402 | int32_t encodeType = CRYPT_EAL_GetEncodeType(type); |
| 403 | int32_t encodeFormat = CRYPT_EAL_GetEncodeFormat(format); | 403 | int32_t encodeFormat = CRYPT_EAL_GetEncodeFormat(format); |
| 404 | return ProviderDecodeBuffKey(libCtx, attrName, encodeFormat, encodeType, encode, pwd, ealPKey); | 404 | return ProviderDecodeBuffKey(libCtx, attrName, encodeFormat, encodeType, encode, pwd, ealPKey); |
| @@ -433,7 +433,7 @@ int32_t CRYPT_EAL_DecodeFileKey(int32_t format, int32_t type, const char *path, | |||
| 433 | return ret; | 433 | return ret; |
| 434 | } | 434 | } |
| 435 | 435 | ||
| 436 | -int32_t CRYPT_EAL_ProviderDecodeFileKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t keyType, | 436 | +int32_t CRYPT_EAL_ProviderDecodeFileKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t pkeyAlgId, |
| 437 | const char *format, const char *type, const char *path, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey) | 437 | const char *format, const char *type, const char *path, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey) |
| 438 | { | 438 | { |
| 439 | if (path == NULL || strlen(path) > PATH_MAX_LEN) { | 439 | if (path == NULL || strlen(path) > PATH_MAX_LEN) { |
| @@ -448,7 +448,7 @@ int32_t CRYPT_EAL_ProviderDecodeFileKey(CRYPT_EAL_LibCtx *libCtx, const char *at | |||
| 448 | return ret; | 448 | return ret; |
| 449 | } | 449 | } |
| 450 | BSL_Buffer encode = {data, dataLen}; | 450 | BSL_Buffer encode = {data, dataLen}; |
| 451 | - ret = CRYPT_EAL_ProviderDecodeBuffKey(libCtx, attrName, keyType, format, type, &encode, pwd, ealPKey); | 451 | + ret = CRYPT_EAL_ProviderDecodeBuffKey(libCtx, attrName, pkeyAlgId, format, type, &encode, pwd, ealPKey); |
| 452 | BSL_SAL_Free(data); | 452 | BSL_SAL_Free(data); |
| 453 | return ret; | 453 | return ret; |
| 454 | } | 454 | } |
| @@ -381,7 +381,7 @@ int32_t CRYPT_SM2_Export(const CRYPT_SM2_Ctx *ctx, BSL_Param *params) | |||
| 381 | } | 381 | } |
| 382 | if (ctx->pkey->pubkey != NULL) { | 382 | if (ctx->pkey->pubkey != NULL) { |
| 383 | (void)BSL_PARAM_InitValue(&sm2Params[index], CRYPT_PARAM_EC_PUBKEY, BSL_PARAM_TYPE_OCTETS, | 383 | (void)BSL_PARAM_InitValue(&sm2Params[index], CRYPT_PARAM_EC_PUBKEY, BSL_PARAM_TYPE_OCTETS, |
| 384 | - buffer, keyBytes); | 384 | + buffer + keyBytes, keyBytes); |
| 385 | ret = CRYPT_SM2_GetPubKeyEx(ctx, sm2Params); | 385 | ret = CRYPT_SM2_GetPubKeyEx(ctx, sm2Params); |
| 386 | if (ret != CRYPT_SUCCESS) { | 386 | if (ret != CRYPT_SUCCESS) { |
| 387 | BSL_SAL_Free(buffer); | 387 | BSL_SAL_Free(buffer); |
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | extern "C" { | 23 | extern "C" { |
| @@ -163,7 +163,6 @@ enum BSL_ERROR { | |||
| 163 | BSL_CONF_CONTEXT_ERR, | 163 | BSL_CONF_CONTEXT_ERR, |
| 164 | BSL_CONF_GET_FAIL, | 164 | BSL_CONF_GET_FAIL, |
| 165 | BSL_CONF_VALUE_NOT_FOUND, | 165 | BSL_CONF_VALUE_NOT_FOUND, |
| 166 | - BSL_CONF_CTRL_INVALID_PARAM, | ||
| 167 | BSL_CONF_DUMP_FAIL, | 166 | BSL_CONF_DUMP_FAIL, |
| 168 | BSL_CONF_BUFF_OVERFLOW, | 167 | BSL_CONF_BUFF_OVERFLOW, |
| 169 | BSL_CONF_INVALID_NAME, | 168 | BSL_CONF_INVALID_NAME, |
| @@ -199,11 +198,7 @@ enum BSL_ERROR { | |||
| 199 | BSL_ASN1_ERR_ENCODE_BIT_STRING, | 198 | BSL_ASN1_ERR_ENCODE_BIT_STRING, |
| 200 | BSL_ASN1_ERR_ENCODE_UTC_TIME, | 199 | BSL_ASN1_ERR_ENCODE_UTC_TIME, |
| 201 | BSL_ASN1_ERR_ENCODE_GENERALIZED_TIME, | 200 | BSL_ASN1_ERR_ENCODE_GENERALIZED_TIME, |
| 202 | - BSL_ASN1_ERR_PRINTF, | ||
| 203 | - BSL_ASN1_ERR_PRINTF_IO_ERR, | ||
| 204 | BSL_ASN1_ERR_LEN_OVERFLOW, | 201 | BSL_ASN1_ERR_LEN_OVERFLOW, |
| 205 | - BSL_ASN1_ERR_DECODE_T61_STRING, | ||
| 206 | - BSL_ASN1_ERR_ENCODE_T61_STRING, | ||
| 207 | 202 | ||
| 208 | BSL_PEM_INVALID = 0x03110001, | 203 | BSL_PEM_INVALID = 0x03110001, |
| 209 | BSL_PEM_DATA_NOT_ENOUGH, | 204 | BSL_PEM_DATA_NOT_ENOUGH, |
| @@ -24,7 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | - | ||
| 28 | 27 | ||
| 29 | 28 | ||
| 30 | extern "C" { | 29 | extern "C" { |
| @@ -14,13 +14,13 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * @defgroup crypt_eal_encode | 17 | + * @defgroup crypt_eal_codecs |
| 18 | * @ingroup crypt | 18 | * @ingroup crypt |
| 19 | - * @brief pubkey encode/decode of crypto module | 19 | + * @brief public/private key encode/decode |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | -#ifndef CRYPT_EAL_ENCODE_H | 22 | +#ifndef CRYPT_EAL_CODECS_H |
| 23 | -#define CRYPT_EAL_ENCODE_H | 23 | +#define CRYPT_EAL_CODECS_H |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| @@ -39,25 +39,25 @@ typedef struct CRYPT_DecoderCtx CRYPT_DECODER_Ctx; | |||
| 39 | /** | 39 | /** |
| 40 | * @brief Create a decoder context for the specified format and type | 40 | * @brief Create a decoder context for the specified format and type |
| 41 | * | 41 | * |
| 42 | - * @param libCtx EAL library context | 42 | + * @param libCtx [IN] provider library context |
| 43 | - * @param keyType Decoding target type (e.g., CRYPT_ALG_ID_RSA, CRYPT_ALG_ID_EC) | 43 | + * @param pkeyAlgId [IN] Input pkey algorithm ID, see CRYPT_PKEY_AlgId |
| 44 | - * @param attrName Attribute name for specific type decoding (can be NULL) | 44 | + * @param attrName [IN] Attribute name for specific type decoding (can be NULL) |
| 45 | * @return CRYPT_DECODER_Ctx* Decoder context, returns NULL on failure | 45 | * @return CRYPT_DECODER_Ctx* Decoder context, returns NULL on failure |
| 46 | */ | 46 | */ |
| 47 | -CRYPT_DECODER_Ctx *CRYPT_DECODE_ProviderNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t keyType, const char *attrName); | 47 | +CRYPT_DECODER_Ctx *CRYPT_DECODE_ProviderNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t pkeyAlgId, const char *attrName); |
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | * @brief Free the decoder context | 50 | * @brief Free the decoder context |
| 51 | * | 51 | * |
| 52 | - * @param ctx Decoder context | 52 | + * @param ctx [IN] Decoder context |
| 53 | */ | 53 | */ |
| 54 | void CRYPT_DECODE_Free(CRYPT_DECODER_Ctx *ctx); | 54 | void CRYPT_DECODE_Free(CRYPT_DECODER_Ctx *ctx); |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| 57 | * @brief Set decoder parameters | 57 | * @brief Set decoder parameters |
| 58 | * | 58 | * |
| 59 | - * @param ctx Decoder context | 59 | + * @param ctx [IN] Decoder context |
| 60 | - * @param param Parameter | 60 | + * @param param [IN] Parameter |
| 61 | * @return int32_t CRYPT_SUCCESS on success, error code on failure | 61 | * @return int32_t CRYPT_SUCCESS on success, error code on failure |
| 62 | */ | 62 | */ |
| 63 | int32_t CRYPT_DECODE_SetParam(CRYPT_DECODER_Ctx *ctx, const BSL_Param *param); | 63 | int32_t CRYPT_DECODE_SetParam(CRYPT_DECODER_Ctx *ctx, const BSL_Param *param); |
| @@ -65,8 +65,8 @@ int32_t CRYPT_DECODE_SetParam(CRYPT_DECODER_Ctx *ctx, const BSL_Param *param); | |||
| 65 | /** | 65 | /** |
| 66 | * @brief Get decoder parameters | 66 | * @brief Get decoder parameters |
| 67 | * | 67 | * |
| 68 | - * @param ctx Decoder context | 68 | + * @param ctx [IN] Decoder context |
| 69 | - * @param param Parameter (output) | 69 | + * @param param [IN/OUT] Parameter (output) |
| 70 | * @return int32_t CRYPT_SUCCESS on success, error code on failure | 70 | * @return int32_t CRYPT_SUCCESS on success, error code on failure |
| 71 | */ | 71 | */ |
| 72 | int32_t CRYPT_DECODE_GetParam(CRYPT_DECODER_Ctx *ctx, BSL_Param *param); | 72 | int32_t CRYPT_DECODE_GetParam(CRYPT_DECODER_Ctx *ctx, BSL_Param *param); |
| @@ -74,10 +74,9 @@ int32_t CRYPT_DECODE_GetParam(CRYPT_DECODER_Ctx *ctx, BSL_Param *param); | |||
| 74 | /** | 74 | /** |
| 75 | * @brief Perform decoding operation | 75 | * @brief Perform decoding operation |
| 76 | * | 76 | * |
| 77 | - * @param ctx Decoder context | 77 | + * @param ctx [IN] Decoder context |
| 78 | - * @param input Input data | 78 | + * @param inParam [IN] Input parameter |
| 79 | - * @param inParam Input parameter | 79 | + * @param outParam [OUT] Output object to store decoding results |
| 80 | - * @param out Output object to store decoding results | ||
| 81 | * @return int32_t CRYPT_SUCCESS on success, error code on failure | 80 | * @return int32_t CRYPT_SUCCESS on success, error code on failure |
| 82 | */ | 81 | */ |
| 83 | int32_t CRYPT_DECODE_Decode(CRYPT_DECODER_Ctx *ctx, const BSL_Param *inParam, BSL_Param **outParam); | 82 | int32_t CRYPT_DECODE_Decode(CRYPT_DECODER_Ctx *ctx, const BSL_Param *inParam, BSL_Param **outParam); |
| @@ -85,8 +84,8 @@ int32_t CRYPT_DECODE_Decode(CRYPT_DECODER_Ctx *ctx, const BSL_Param *inParam, BS | |||
| 85 | /** | 84 | /** |
| 86 | * @brief Free the output data | 85 | * @brief Free the output data |
| 87 | * | 86 | * |
| 88 | - * @param ctx Decoder context | 87 | + * @param ctx [IN] Decoder context |
| 89 | - * @param data Output data | 88 | + * @param outData [IN] Output data |
| 90 | */ | 89 | */ |
| 91 | void CRYPT_DECODE_FreeOutData(CRYPT_DECODER_Ctx *ctx, BSL_Param *outData); | 90 | void CRYPT_DECODE_FreeOutData(CRYPT_DECODER_Ctx *ctx, BSL_Param *outData); |
| 92 | 91 | ||
| @@ -100,34 +99,48 @@ typedef enum { | |||
| 100 | CRYPT_DECODE_POOL_CMD_SET_TARGET_FORMAT, | 99 | CRYPT_DECODE_POOL_CMD_SET_TARGET_FORMAT, |
| 101 | /** Set the target type */ | 100 | /** Set the target type */ |
| 102 | CRYPT_DECODE_POOL_CMD_SET_TARGET_TYPE, | 101 | CRYPT_DECODE_POOL_CMD_SET_TARGET_TYPE, |
| 103 | - /** Set the not free out data */ | 102 | + /** Set the flag for whether to free out data */ |
| 104 | CRYPT_DECODE_POOL_CMD_SET_FLAG_FREE_OUT_DATA, | 103 | CRYPT_DECODE_POOL_CMD_SET_FLAG_FREE_OUT_DATA, |
| 105 | } CRYPT_DECODE_POOL_CMD; | 104 | } CRYPT_DECODE_POOL_CMD; |
| 106 | 105 | ||
| 107 | /** | 106 | /** |
| 108 | * @brief Create a decoder pool context | 107 | * @brief Create a decoder pool context |
| 109 | * | 108 | * |
| 110 | - * @param libCtx EAL library context | 109 | + * @param libCtx [IN] EAL library context |
| 111 | - * @param attrName Provider attribute name, can be NULL | 110 | + * @param attrName [IN] Provider attribute name, can be NULL |
| 112 | - * @param format Input data format (e.g., BSL_FORMAT_PEM, BSL_FORMAT_DER) | 111 | + * @param pkeyAlgId [IN] Input pkey algorithm ID, see CRYPT_PKEY_AlgId |
| 113 | - * @param type Decoding target type (e.g., CRYPT_ALG_ID_RSA, CRYPT_ALG_ID_EC) | 112 | + * @param format [IN] Input data format: |
| 113 | + * "ASN1" | ||
| 114 | + * "PEM" | ||
| 115 | + * "PFX_COM" | ||
| 116 | + * "PKCS12" | ||
| 117 | + * "OBJECT" | ||
| 118 | + * @param type [IN] Decoding target type: | ||
| 119 | + * "PRIKEY_PKCS8_UNENCRYPT" | ||
| 120 | + * "PRIKEY_PKCS8_ENCRYPT" | ||
| 121 | + * "PRIKEY_RSA" | ||
| 122 | + * "PRIKEY_ECC" | ||
| 123 | + * "PUBKEY_SUBKEY" | ||
| 124 | + * "PUBKEY_RSA" | ||
| 125 | + * "PUBKEY_SUBKEY_WITHOUT_SEQ" | ||
| 114 | * @return CRYPT_DECODER_PoolCtx* Decoder pool context on success, NULL on failure | 126 | * @return CRYPT_DECODER_PoolCtx* Decoder pool context on success, NULL on failure |
| 115 | */ | 127 | */ |
| 116 | CRYPT_DECODER_PoolCtx *CRYPT_DECODE_PoolNewCtx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, | 128 | CRYPT_DECODER_PoolCtx *CRYPT_DECODE_PoolNewCtx(CRYPT_EAL_LibCtx *libCtx, const char *attrName, |
| 117 | - int32_t keyType, const char *format, const char *type); | 129 | + int32_t pkeyAlgId, const char *format, const char *type); |
| 130 | + | ||
| 118 | /** | 131 | /** |
| 119 | * @brief Free a decoder pool context | 132 | * @brief Free a decoder pool context |
| 120 | * | 133 | * |
| 121 | - * @param poolCtx Decoder pool context | 134 | + * @param poolCtx [IN] Decoder pool context |
| 122 | */ | 135 | */ |
| 123 | void CRYPT_DECODE_PoolFreeCtx(CRYPT_DECODER_PoolCtx *poolCtx); | 136 | void CRYPT_DECODE_PoolFreeCtx(CRYPT_DECODER_PoolCtx *poolCtx); |
| 124 | 137 | ||
| 125 | /** | 138 | /** |
| 126 | * @brief Decode the input data with the decoder chain | 139 | * @brief Decode the input data with the decoder chain |
| 127 | * | 140 | * |
| 128 | - * @param poolCtx Decoder pool context | 141 | + * @param poolCtx [IN] Decoder pool context |
| 129 | - * @param inParam Input data | 142 | + * @param inParam [IN] Input data |
| 130 | - * @param outParam Output Data | 143 | + * @param outParam [OUT] Output Data |
| 131 | * @return int32_t CRYPT_SUCCESS on success, error code on failure | 144 | * @return int32_t CRYPT_SUCCESS on success, error code on failure |
| 132 | */ | 145 | */ |
| 133 | int32_t CRYPT_DECODE_PoolDecode(CRYPT_DECODER_PoolCtx *poolCtx, const BSL_Param *inParam, BSL_Param **outParam); | 146 | int32_t CRYPT_DECODE_PoolDecode(CRYPT_DECODER_PoolCtx *poolCtx, const BSL_Param *inParam, BSL_Param **outParam); |
| @@ -135,20 +148,20 @@ int32_t CRYPT_DECODE_PoolDecode(CRYPT_DECODER_PoolCtx *poolCtx, const BSL_Param | |||
| 135 | /** | 148 | /** |
| 136 | * @brief Control operation for decoder pool | 149 | * @brief Control operation for decoder pool |
| 137 | * | 150 | * |
| 138 | - * @param poolCtx Decoder pool context | 151 | + * @param poolCtx [IN] Decoder pool context |
| 139 | - * @param cmd Control command | 152 | + * @param cmd [IN] Control command, see CRYPT_DECODE_POOL_CMD |
| 140 | - * @param val The value of the control command | 153 | + * @param val [IN/OUT] The value of the control command |
| 141 | - * @param valLen The length of the value | 154 | + * @param valLen [IN] The length of the value |
| 142 | * @return int32_t CRYPT_SUCCESS on success, error code on failure | 155 | * @return int32_t CRYPT_SUCCESS on success, error code on failure |
| 143 | */ | 156 | */ |
| 144 | int32_t CRYPT_DECODE_PoolCtrl(CRYPT_DECODER_PoolCtx *poolCtx, int32_t cmd, void *val, int32_t valLen); | 157 | int32_t CRYPT_DECODE_PoolCtrl(CRYPT_DECODER_PoolCtx *poolCtx, int32_t cmd, void *val, int32_t valLen); |
| 145 | 158 | ||
| 146 | /** | 159 | /** |
| 147 | - * @ingroup crypt_eal_encode | 160 | + * @ingroup crypt_eal_codecs |
| 148 | * @brief Decode formatted buffer of pkey | 161 | * @brief Decode formatted buffer of pkey |
| 149 | * | 162 | * |
| 150 | - * @param format [IN] the buffer format. | 163 | + * @param format [IN] the buffer format: BSL_FORMAT_UNKNOWN/BSL_FORMAT_PEM/BSL_FORMAT_DER |
| 151 | - * @param type [IN] the type of pkey. | 164 | + * @param type [IN] the type of pkey, see CRYPT_ENCDEC_TYPE |
| 152 | * @param encode [IN] the encoded asn1 buffer. | 165 | * @param encode [IN] the encoded asn1 buffer. |
| 153 | * @param pwd [IN] the password, maybe NULL for unencrypted private key / public key. | 166 | * @param pwd [IN] the password, maybe NULL for unencrypted private key / public key. |
| 154 | * @param pwdlen [IN] the length of password. | 167 | * @param pwdlen [IN] the length of password. |
| @@ -161,14 +174,26 @@ int32_t CRYPT_EAL_DecodeBuffKey(int32_t format, int32_t type, | |||
| 161 | BSL_Buffer *encode, const uint8_t *pwd, uint32_t pwdlen, CRYPT_EAL_PkeyCtx **ealPKey); | 174 | BSL_Buffer *encode, const uint8_t *pwd, uint32_t pwdlen, CRYPT_EAL_PkeyCtx **ealPKey); |
| 162 | 175 | ||
| 163 | /** | 176 | /** |
| 164 | - * @ingroup crypt_eal_encode | 177 | + * @ingroup crypt_eal_codecs |
| 165 | * @brief Decode formatted buffer of pkey with provider | 178 | * @brief Decode formatted buffer of pkey with provider |
| 166 | * | 179 | * |
| 167 | * @param libCtx [IN] the library context of provider. | 180 | * @param libCtx [IN] the library context of provider. |
| 168 | * @param attrName [IN] provider attribute name, maybe NULL. | 181 | * @param attrName [IN] provider attribute name, maybe NULL. |
| 169 | - * @param keyType [IN] the type of pkey. | 182 | + * @param pkeyAlgId [IN] Input pkey algorithm ID, see CRYPT_PKEY_AlgId |
| 170 | - * @param format [IN] the buffer format. | 183 | + * @param format [IN] the buffer format: |
| 171 | - * @param type [IN] the type of pkey. | 184 | + * "ASN1" |
| 185 | + * "PEM" | ||
| 186 | + * "PFX_COM" | ||
| 187 | + * "PKCS12" | ||
| 188 | + * "OBJECT" | ||
| 189 | + * @param type [IN] the type of pkey: | ||
| 190 | + * "PRIKEY_PKCS8_UNENCRYPT" | ||
| 191 | + * "PRIKEY_PKCS8_ENCRYPT" | ||
| 192 | + * "PRIKEY_RSA" | ||
| 193 | + * "PRIKEY_ECC" | ||
| 194 | + * "PUBKEY_SUBKEY" | ||
| 195 | + * "PUBKEY_RSA" | ||
| 196 | + * "PUBKEY_SUBKEY_WITHOUT_SEQ" | ||
| 172 | * @param encode [IN] the encoded asn1 buffer. | 197 | * @param encode [IN] the encoded asn1 buffer. |
| 173 | * @param pwd [IN] the password buffer, maybe NULL for unencrypted private key / public key. | 198 | * @param pwd [IN] the password buffer, maybe NULL for unencrypted private key / public key. |
| 174 | * @param ealPKey [OUT] created CRYPT_EAL_PkeyCtx which parsed from the ans1 buffer. | 199 | * @param ealPKey [OUT] created CRYPT_EAL_PkeyCtx which parsed from the ans1 buffer. |
| @@ -176,15 +201,15 @@ int32_t CRYPT_EAL_DecodeBuffKey(int32_t format, int32_t type, | |||
| 176 | * @retval #CRYPT_SUCCESS, if success. | 201 | * @retval #CRYPT_SUCCESS, if success. |
| 177 | * Other error codes see the crypt_errno.h | 202 | * Other error codes see the crypt_errno.h |
| 178 | */ | 203 | */ |
| 179 | -int32_t CRYPT_EAL_ProviderDecodeBuffKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t keyType, | 204 | +int32_t CRYPT_EAL_ProviderDecodeBuffKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t pkeyAlgId, |
| 180 | const char *format, const char *type, BSL_Buffer *encode, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey); | 205 | const char *format, const char *type, BSL_Buffer *encode, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey); |
| 181 | 206 | ||
| 182 | /** | 207 | /** |
| 183 | - * @ingroup crypt_eal_encode | 208 | + * @ingroup crypt_eal_codecs |
| 184 | * @brief Decode formatted file of pkey | 209 | * @brief Decode formatted file of pkey |
| 185 | * | 210 | * |
| 186 | - * @param format [IN] the file format. | 211 | + * @param format [IN] the file format: BSL_FORMAT_UNKNOWN/BSL_FORMAT_PEM/BSL_FORMAT_DER |
| 187 | - * @param type [IN] the type of pkey. | 212 | + * @param type [IN] the type of pkey, see CRYPT_ENCDEC_TYPE |
| 188 | * @param path [IN] the encoded file path. | 213 | * @param path [IN] the encoded file path. |
| 189 | * @param pwd [IN] the password, maybe NULL for unencrypted private key / public key. | 214 | * @param pwd [IN] the password, maybe NULL for unencrypted private key / public key. |
| 190 | * @param pwdlen [IN] the length of password. | 215 | * @param pwdlen [IN] the length of password. |
| @@ -197,13 +222,26 @@ int32_t CRYPT_EAL_DecodeFileKey(int32_t format, int32_t type, const char *path, | |||
| 197 | uint8_t *pwd, uint32_t pwdlen, CRYPT_EAL_PkeyCtx **ealPKey); | 222 | uint8_t *pwd, uint32_t pwdlen, CRYPT_EAL_PkeyCtx **ealPKey); |
| 198 | 223 | ||
| 199 | /** | 224 | /** |
| 200 | - * @ingroup crypt_eal_encode | 225 | + * @ingroup crypt_eal_codecs |
| 201 | * @brief Decode formatted file of pkey with extended parameters | 226 | * @brief Decode formatted file of pkey with extended parameters |
| 202 | * | 227 | * |
| 203 | * @param libCtx [IN] the library context of provider. | 228 | * @param libCtx [IN] the library context of provider. |
| 204 | * @param attrName [IN] provider attribute name, maybe NULL. | 229 | * @param attrName [IN] provider attribute name, maybe NULL. |
| 205 | - * @param format [IN] the file format. | 230 | + * @param pkeyAlgId [IN] Input pkey algorithm ID, see CRYPT_PKEY_AlgId |
| 206 | - * @param type [IN] the type of pkey. | 231 | + * @param format [IN] the file format: |
| 232 | + * "ASN1" | ||
| 233 | + * "PEM" | ||
| 234 | + * "PFX_COM" | ||
| 235 | + * "PKCS12" | ||
| 236 | + * "OBJECT" | ||
| 237 | + * @param type [IN] the type of pkey: | ||
| 238 | + * "PRIKEY_PKCS8_UNENCRYPT" | ||
| 239 | + * "PRIKEY_PKCS8_ENCRYPT" | ||
| 240 | + * "PRIKEY_RSA" | ||
| 241 | + * "PRIKEY_ECC" | ||
| 242 | + * "PUBKEY_SUBKEY" | ||
| 243 | + * "PUBKEY_RSA" | ||
| 244 | + * "PUBKEY_SUBKEY_WITHOUT_SEQ" | ||
| 207 | * @param path [IN] the encoded file path. | 245 | * @param path [IN] the encoded file path. |
| 208 | * @param pwd [IN] the password buffer, maybe NULL for unencrypted private key / public key. | 246 | * @param pwd [IN] the password buffer, maybe NULL for unencrypted private key / public key. |
| 209 | * @param ealPKey [OUT] created CRYPT_EAL_PkeyCtx which parsed from the path. | 247 | * @param ealPKey [OUT] created CRYPT_EAL_PkeyCtx which parsed from the path. |
| @@ -211,17 +249,17 @@ int32_t CRYPT_EAL_DecodeFileKey(int32_t format, int32_t type, const char *path, | |||
| 211 | * @retval #CRYPT_SUCCESS, if success. | 249 | * @retval #CRYPT_SUCCESS, if success. |
| 212 | * Other error codes see the crypt_errno.h | 250 | * Other error codes see the crypt_errno.h |
| 213 | */ | 251 | */ |
| 214 | -int32_t CRYPT_EAL_ProviderDecodeFileKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t keyType, | 252 | +int32_t CRYPT_EAL_ProviderDecodeFileKey(CRYPT_EAL_LibCtx *libCtx, const char *attrName, int32_t pkeyAlgId, |
| 215 | const char *format, const char *type, const char *path, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey); | 253 | const char *format, const char *type, const char *path, const BSL_Buffer *pwd, CRYPT_EAL_PkeyCtx **ealPKey); |
| 216 | 254 | ||
| 217 | /** | 255 | /** |
| 218 | - * @ingroup crypt_eal_encode | 256 | + * @ingroup crypt_eal_codecs |
| 219 | * @brief Encode formatted buffer of pkey | 257 | * @brief Encode formatted buffer of pkey |
| 220 | * | 258 | * |
| 221 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. | 259 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. |
| 222 | * @param encodeParam [IN] pkcs8 encode params. | 260 | * @param encodeParam [IN] pkcs8 encode params. |
| 223 | - * @param format [IN] the buffer format. | 261 | + * @param format [IN] the file format: BSL_FORMAT_UNKNOWN/BSL_FORMAT_PEM/BSL_FORMAT_DER |
| 224 | - * @param type [IN] the type of pkey. | 262 | + * @param type [IN] the type of pkey, see CRYPT_ENCDEC_TYPE |
| 225 | * @param encode [OUT] the encoded asn1 buffer. | 263 | * @param encode [OUT] the encoded asn1 buffer. |
| 226 | * | 264 | * |
| 227 | * @retval #CRYPT_SUCCESS, if success. | 265 | * @retval #CRYPT_SUCCESS, if success. |
| @@ -231,15 +269,27 @@ int32_t CRYPT_EAL_EncodeBuffKey(CRYPT_EAL_PkeyCtx *ealPKey, const CRYPT_EncodePa | |||
| 231 | int32_t format, int32_t type, BSL_Buffer *encode); | 269 | int32_t format, int32_t type, BSL_Buffer *encode); |
| 232 | 270 | ||
| 233 | /** | 271 | /** |
| 234 | - * @ingroup crypt_eal_encode | 272 | + * @ingroup crypt_eal_codecs |
| 235 | * @brief Encode formatted buffer of pkey with provider | 273 | * @brief Encode formatted buffer of pkey with provider |
| 236 | * | 274 | * |
| 237 | * @param libCtx [IN] the library context of provider. | 275 | * @param libCtx [IN] the library context of provider. |
| 238 | * @param attrName [IN] provider attribute name, maybe NULL. | 276 | * @param attrName [IN] provider attribute name, maybe NULL. |
| 239 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. | 277 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. |
| 240 | * @param encodeParam [IN] pkcs8 encode params. | 278 | * @param encodeParam [IN] pkcs8 encode params. |
| 241 | - * @param format [IN] the buffer format. | 279 | + * @param format [IN] the buffer format: |
| 242 | - * @param type [IN] the type of pkey. | 280 | + * "ASN1" |
| 281 | + * "PEM" | ||
| 282 | + * "PFX_COM" | ||
| 283 | + * "PKCS12" | ||
| 284 | + * "OBJECT" | ||
| 285 | + * @param type [IN] the type of pkey: | ||
| 286 | + * "PRIKEY_PKCS8_UNENCRYPT" | ||
| 287 | + * "PRIKEY_PKCS8_ENCRYPT" | ||
| 288 | + * "PRIKEY_RSA" | ||
| 289 | + * "PRIKEY_ECC" | ||
| 290 | + * "PUBKEY_SUBKEY" | ||
| 291 | + * "PUBKEY_RSA" | ||
| 292 | + * "PUBKEY_SUBKEY_WITHOUT_SEQ" | ||
| 243 | * @param encode [OUT] the encoded asn1 buffer. | 293 | * @param encode [OUT] the encoded asn1 buffer. |
| 244 | * | 294 | * |
| 245 | * @retval #CRYPT_SUCCESS, if success. | 295 | * @retval #CRYPT_SUCCESS, if success. |
| @@ -249,13 +299,13 @@ int32_t CRYPT_EAL_ProviderEncodeBuffKey(CRYPT_EAL_LibCtx *libCtx, const char *at | |||
| 249 | const CRYPT_EncodeParam *encodeParam, const char *format, const char *type, BSL_Buffer *encode); | 299 | const CRYPT_EncodeParam *encodeParam, const char *format, const char *type, BSL_Buffer *encode); |
| 250 | 300 | ||
| 251 | /** | 301 | /** |
| 252 | - * @ingroup crypt_eal_encode | 302 | + * @ingroup crypt_eal_codecs |
| 253 | * @brief Encode formatted file of pkey | 303 | * @brief Encode formatted file of pkey |
| 254 | * | 304 | * |
| 255 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. | 305 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. |
| 256 | * @param encodeParam [IN] pkcs8 encode params. | 306 | * @param encodeParam [IN] pkcs8 encode params. |
| 257 | - * @param format [IN] the file format. | 307 | + * @param format [IN] the file format: BSL_FORMAT_UNKNOWN/BSL_FORMAT_PEM/BSL_FORMAT_DER |
| 258 | - * @param type [IN] the type of pkey. | 308 | + * @param type [IN] the type of pkey, see CRYPT_ENCDEC_TYPE |
| 259 | * @param path [IN] the encoded file path. | 309 | * @param path [IN] the encoded file path. |
| 260 | * | 310 | * |
| 261 | * @retval #CRYPT_SUCCESS, if success. | 311 | * @retval #CRYPT_SUCCESS, if success. |
| @@ -265,15 +315,27 @@ int32_t CRYPT_EAL_EncodeFileKey(CRYPT_EAL_PkeyCtx *ealPKey, const CRYPT_EncodePa | |||
| 265 | int32_t format, int32_t type, const char *path); | 315 | int32_t format, int32_t type, const char *path); |
| 266 | 316 | ||
| 267 | /** | 317 | /** |
| 268 | - * @ingroup crypt_eal_encode | 318 | + * @ingroup crypt_eal_codecs |
| 269 | * @brief Encode formatted file of pkey with provider | 319 | * @brief Encode formatted file of pkey with provider |
| 270 | * | 320 | * |
| 271 | * @param libCtx [IN] the library context of provider. | 321 | * @param libCtx [IN] the library context of provider. |
| 272 | * @param attrName [IN] provider attribute name, maybe NULL. | 322 | * @param attrName [IN] provider attribute name, maybe NULL. |
| 273 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. | 323 | * @param ealPKey [IN] CRYPT_EAL_PkeyCtx to encode. |
| 274 | * @param encodeParam [IN] pkcs8 encode params. | 324 | * @param encodeParam [IN] pkcs8 encode params. |
| 275 | - * @param format [IN] the file format. | 325 | + * @param format [IN] the file format: |
| 276 | - * @param type [IN] the type of pkey. | 326 | + * "ASN1" |
| 327 | + * "PEM" | ||
| 328 | + * "PFX_COM" | ||
| 329 | + * "PKCS12" | ||
| 330 | + * "OBJECT" | ||
| 331 | + * @param type [IN] the type of pkey: | ||
| 332 | + * "PRIKEY_PKCS8_UNENCRYPT" | ||
| 333 | + * "PRIKEY_PKCS8_ENCRYPT" | ||
| 334 | + * "PRIKEY_RSA" | ||
| 335 | + * "PRIKEY_ECC" | ||
| 336 | + * "PUBKEY_SUBKEY" | ||
| 337 | + * "PUBKEY_RSA" | ||
| 338 | + * "PUBKEY_SUBKEY_WITHOUT_SEQ" | ||
| 277 | * @param path [IN] the encoded file path. | 339 | * @param path [IN] the encoded file path. |
| 278 | * | 340 | * |
| 279 | * @retval #CRYPT_SUCCESS, if success. | 341 | * @retval #CRYPT_SUCCESS, if success. |
| @@ -286,4 +348,4 @@ int32_t CRYPT_EAL_ProviderEncodeFileKey(CRYPT_EAL_LibCtx *libCtx, const char *at | |||
| 286 | } | 348 | } |
| 287 | 349 | ||
| 288 | 350 | ||
| 289 | -#endif // CRYPT_EAL_ENCODE_H | 351 | +#endif // CRYPT_EAL_CODECS_H |
| @@ -328,7 +328,6 @@ enum CRYPT_ERROR { | |||
| 328 | CRYPT_HKDF_DKLEN_OVERFLOW = 0x01110001, /**< The length of the derived key exceeds the maximum. */ | 328 | CRYPT_HKDF_DKLEN_OVERFLOW = 0x01110001, /**< The length of the derived key exceeds the maximum. */ |
| 329 | CRYPT_HKDF_NOT_SUPPORTED, /**< Unsupport HKDF algorithm. */ | 329 | CRYPT_HKDF_NOT_SUPPORTED, /**< Unsupport HKDF algorithm. */ |
| 330 | CRYPT_HKDF_PARAM_ERROR, /**< Incorrect input parameter. */ | 330 | CRYPT_HKDF_PARAM_ERROR, /**< Incorrect input parameter. */ |
| 331 | - CRYPT_HKDF_ERR_MAC_ID_NOT_SET, /**< Mac id not set. */ | ||
| 332 | CRYPT_HKDF_ERR_MAC_METH, /**< Mac method err. */ | 331 | CRYPT_HKDF_ERR_MAC_METH, /**< Mac method err. */ |
| 333 | 332 | ||
| 334 | CRYPT_CMAC_OUT_BUFF_LEN_NOT_ENOUGH = 0x01120001, /**< The length of the buffer that storing the output | 333 | CRYPT_CMAC_OUT_BUFF_LEN_NOT_ENOUGH = 0x01120001, /**< The length of the buffer that storing the output |
| @@ -345,7 +344,6 @@ enum CRYPT_ERROR { | |||
| 345 | CRYPT_PBKDF2_PARAM_ERROR = 0x01150001, /**< Incorrect input parameter. */ | 344 | CRYPT_PBKDF2_PARAM_ERROR = 0x01150001, /**< Incorrect input parameter. */ |
| 346 | CRYPT_PBKDF2_NOT_SUPPORTED, /**< Does not support the PBKDF2 algorithm. */ | 345 | CRYPT_PBKDF2_NOT_SUPPORTED, /**< Does not support the PBKDF2 algorithm. */ |
| 347 | CRYPT_PBKDF2_ERR_MAC_METH, /**< Mac method err. */ | 346 | CRYPT_PBKDF2_ERR_MAC_METH, /**< Mac method err. */ |
| 348 | - CRYPT_PBKDF2_ERR_MAC_ID_NOT_SET, /**< Mac id not set. */ | ||
| 349 | 347 | ||
| 350 | CRYPT_ECC_POINT_AT_INFINITY = 0x01160001, /**< Point at infinity. */ | 348 | CRYPT_ECC_POINT_AT_INFINITY = 0x01160001, /**< Point at infinity. */ |
| 351 | CRYPT_ECC_POINT_NOT_ON_CURVE, /**< Point is not on the curve. */ | 349 | CRYPT_ECC_POINT_NOT_ON_CURVE, /**< Point is not on the curve. */ |
| @@ -457,7 +455,6 @@ enum CRYPT_ERROR { | |||
| 457 | CRYPT_KDFTLS12_NOT_SUPPORTED = 0x01220001, /**< Unsupport the KDFTLS12 algorithm. */ | 455 | CRYPT_KDFTLS12_NOT_SUPPORTED = 0x01220001, /**< Unsupport the KDFTLS12 algorithm. */ |
| 458 | CRYPT_KDFTLS12_PARAM_ERROR, /**< Incorrect input parameter. */ | 456 | CRYPT_KDFTLS12_PARAM_ERROR, /**< Incorrect input parameter. */ |
| 459 | CRYPT_KDFTLS12_ERR_MAC_METH, /**< Mac method err. */ | 457 | CRYPT_KDFTLS12_ERR_MAC_METH, /**< Mac method err. */ |
| 460 | - CRYPT_KDFTLS12_ERR_MAC_ID_NOT_SET, /**< Mac id not set. */ | ||
| 461 | 458 | ||
| 462 | CRYPT_SIPHASH_OUT_BUFF_LEN_NOT_ENOUGH = 0x01220001, /**< The buffer size for storing the output | 459 | CRYPT_SIPHASH_OUT_BUFF_LEN_NOT_ENOUGH = 0x01220001, /**< The buffer size for storing the output |
| 463 | result is insufficient. */ | 460 | result is insufficient. */ |
| @@ -522,8 +519,6 @@ enum CRYPT_ERROR { | |||
| 522 | CRYPT_DECODE_ERR_NO_DECODER, /**< No decoder found. */ | 519 | CRYPT_DECODE_ERR_NO_DECODER, /**< No decoder found. */ |
| 523 | CRYPT_DECODE_ERR_NO_USABLE_DECODER, /**< No decoder found. */ | 520 | CRYPT_DECODE_ERR_NO_USABLE_DECODER, /**< No decoder found. */ |
| 524 | CRYPT_DECODE_RETRY, /**< Retry decode. */ | 521 | CRYPT_DECODE_RETRY, /**< Retry decode. */ |
| 525 | - CRYPT_DECODE_ERR_CURR_NODE_NOT_FOUND, /**< Current node not found. */ | ||
| 526 | - CRYPT_DECODE_ERR_NO_KEY_TYPE, /**< No key type found. */ | ||
| 527 | CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH, /**< Key type not match. */ | 522 | CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH, /**< Key type not match. */ |
| 528 | 523 | ||
| 529 | CRYPT_ENCODE_NO_SUPPORT_TYPE = 0x01330001, /**< encode no support key type. */ | 524 | CRYPT_ENCODE_NO_SUPPORT_TYPE = 0x01330001, /**< encode no support key type. */ |
| @@ -715,7 +715,7 @@ int32_t HITLS_PKCS12_ParseMacData(BSL_Buffer *encode, HITLS_PKCS12_MacData *macD | |||
| 715 | } | 715 | } |
| 716 | uint32_t iter = 0; | 716 | uint32_t iter = 0; |
| 717 | ret = BSL_ASN1_DecodePrimitiveItem(&asn1[HITLS_PKCS12_MACDATA_ITER_IDX], &iter); | 717 | ret = BSL_ASN1_DecodePrimitiveItem(&asn1[HITLS_PKCS12_MACDATA_ITER_IDX], &iter); |
| 718 | - if (ret != HITLS_PKI_SUCCESS) { | 718 | + if (ret != BSL_SUCCESS) { |
| 719 | BSL_SAL_Free(mac.data); | 719 | BSL_SAL_Free(mac.data); |
| 720 | BSL_SAL_Free(salt); | 720 | BSL_SAL_Free(salt); |
| 721 | BSL_ERR_PUSH_ERROR(ret); | 721 | BSL_ERR_PUSH_ERROR(ret); |
| @@ -778,12 +778,12 @@ static int32_t ParseAsn1PKCS12(const BSL_Buffer *encode, const HITLS_PKCS12_PwdP | |||
| 778 | BSL_ASN1_Buffer asn1[HITLS_PKCS12_TOPLEVEL_MAX_IDX] = {0}; | 778 | BSL_ASN1_Buffer asn1[HITLS_PKCS12_TOPLEVEL_MAX_IDX] = {0}; |
| 779 | BSL_ASN1_Template templ = {g_p12TopLevelTempl, sizeof(g_p12TopLevelTempl) / sizeof(g_p12TopLevelTempl[0])}; | 779 | BSL_ASN1_Template templ = {g_p12TopLevelTempl, sizeof(g_p12TopLevelTempl) / sizeof(g_p12TopLevelTempl[0])}; |
| 780 | int32_t ret = BSL_ASN1_DecodeTemplate(&templ, NULL, &temp, &tempLen, asn1, HITLS_PKCS12_TOPLEVEL_MAX_IDX); | 780 | int32_t ret = BSL_ASN1_DecodeTemplate(&templ, NULL, &temp, &tempLen, asn1, HITLS_PKCS12_TOPLEVEL_MAX_IDX); |
| 781 | - if (ret != HITLS_PKI_SUCCESS) { | 781 | + if (ret != BSL_SUCCESS) { |
| 782 | BSL_ERR_PUSH_ERROR(ret); | 782 | BSL_ERR_PUSH_ERROR(ret); |
| 783 | return ret; | 783 | return ret; |
| 784 | } | 784 | } |
| 785 | ret = BSL_ASN1_DecodePrimitiveItem(&asn1[HITLS_PKCS12_TOPLEVEL_VERSION_IDX], &version); | 785 | ret = BSL_ASN1_DecodePrimitiveItem(&asn1[HITLS_PKCS12_TOPLEVEL_VERSION_IDX], &version); |
| 786 | - if (ret != HITLS_PKI_SUCCESS) { | 786 | + if (ret != BSL_SUCCESS) { |
| 787 | BSL_ERR_PUSH_ERROR(ret); | 787 | BSL_ERR_PUSH_ERROR(ret); |
| 788 | return ret; | 788 | return ret; |
| 789 | } | 789 | } |
| @@ -942,7 +942,7 @@ static int32_t EncodeAttrValue(HITLS_PKCS12_SafeBagAttr *attribute, BSL_Buffer * | |||
| 942 | BSL_ERR_PUSH_ERROR(HITLS_PKCS12_ERR_INVALID_SAFEBAG_ATTRIBUTES); | 942 | BSL_ERR_PUSH_ERROR(HITLS_PKCS12_ERR_INVALID_SAFEBAG_ATTRIBUTES); |
| 943 | return HITLS_PKCS12_ERR_INVALID_SAFEBAG_ATTRIBUTES; | 943 | return HITLS_PKCS12_ERR_INVALID_SAFEBAG_ATTRIBUTES; |
| 944 | } | 944 | } |
| 945 | - if (ret != HITLS_PKI_SUCCESS) { | 945 | + if (ret != BSL_SUCCESS) { |
| 946 | BSL_ERR_PUSH_ERROR(ret); | 946 | BSL_ERR_PUSH_ERROR(ret); |
| 947 | } | 947 | } |
| 948 | return ret; | 948 | return ret; |
| @@ -1009,7 +1009,7 @@ static int32_t EncodeCertBag(HITLS_X509_Cert *cert, uint32_t certType, uint8_t * | |||
| 1009 | BSL_ASN1_Template templ = {g_pk12CommonBagTempl, sizeof(g_pk12CommonBagTempl) / sizeof(g_pk12CommonBagTempl[0])}; | 1009 | BSL_ASN1_Template templ = {g_pk12CommonBagTempl, sizeof(g_pk12CommonBagTempl) / sizeof(g_pk12CommonBagTempl[0])}; |
| 1010 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_COMMON_SAFEBAG_MAX_IDX, encode, encodeLen); | 1010 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_COMMON_SAFEBAG_MAX_IDX, encode, encodeLen); |
| 1011 | BSL_SAL_Free(certBuff.data); | 1011 | BSL_SAL_Free(certBuff.data); |
| 1012 | - if (ret != HITLS_PKI_SUCCESS) { | 1012 | + if (ret != BSL_SUCCESS) { |
| 1013 | BSL_ERR_PUSH_ERROR(ret); | 1013 | BSL_ERR_PUSH_ERROR(ret); |
| 1014 | } | 1014 | } |
| 1015 | return ret; | 1015 | return ret; |
| @@ -1036,7 +1036,7 @@ static int32_t EncodeSecretBag(BSL_Buffer *secret, uint32_t secretType, uint8_t | |||
| 1036 | 1036 | ||
| 1037 | BSL_ASN1_Template templ = {g_pk12CommonBagTempl, sizeof(g_pk12CommonBagTempl) / sizeof(g_pk12CommonBagTempl[0])}; | 1037 | BSL_ASN1_Template templ = {g_pk12CommonBagTempl, sizeof(g_pk12CommonBagTempl) / sizeof(g_pk12CommonBagTempl[0])}; |
| 1038 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_COMMON_SAFEBAG_MAX_IDX, encode, encodeLen); | 1038 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_COMMON_SAFEBAG_MAX_IDX, encode, encodeLen); |
| 1039 | - if (ret != HITLS_PKI_SUCCESS) { | 1039 | + if (ret != BSL_SUCCESS) { |
| 1040 | BSL_ERR_PUSH_ERROR(ret); | 1040 | BSL_ERR_PUSH_ERROR(ret); |
| 1041 | } | 1041 | } |
| 1042 | return ret; | 1042 | return ret; |
| @@ -1102,7 +1102,7 @@ static int32_t EncodeSafeBag(HITLS_PKCS12 *p12, HITLS_PKCS12_Bag *bag, uint32_t | |||
| 1102 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_SAFEBAG_MAX_IDX, output, outputLen); | 1102 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_SAFEBAG_MAX_IDX, output, outputLen); |
| 1103 | BSL_SAL_Free(encode.data); | 1103 | BSL_SAL_Free(encode.data); |
| 1104 | BSL_SAL_FREE(asnArr[HITLS_PKCS12_SAFEBAG_BAGATTRIBUTES_IDX].buff); | 1104 | BSL_SAL_FREE(asnArr[HITLS_PKCS12_SAFEBAG_BAGATTRIBUTES_IDX].buff); |
| 1105 | - if (ret != HITLS_PKI_SUCCESS) { | 1105 | + if (ret != BSL_SUCCESS) { |
| 1106 | BSL_ERR_PUSH_ERROR(ret); | 1106 | BSL_ERR_PUSH_ERROR(ret); |
| 1107 | } | 1107 | } |
| 1108 | return ret; | 1108 | return ret; |
| @@ -1117,7 +1117,7 @@ static int32_t EncodeP7Data(BSL_Buffer *input, BSL_Buffer *encode) | |||
| 1117 | BSL_ASN1_TemplateItem dataTemplItem = {BSL_ASN1_TAG_OCTETSTRING, 0, 0}; | 1117 | BSL_ASN1_TemplateItem dataTemplItem = {BSL_ASN1_TAG_OCTETSTRING, 0, 0}; |
| 1118 | BSL_ASN1_Template dataTempl = {&dataTemplItem, 1}; | 1118 | BSL_ASN1_Template dataTempl = {&dataTemplItem, 1}; |
| 1119 | int32_t ret = BSL_ASN1_EncodeTemplate(&dataTempl, &asnArr, 1, &encode->data, &encode->dataLen); | 1119 | int32_t ret = BSL_ASN1_EncodeTemplate(&dataTempl, &asnArr, 1, &encode->data, &encode->dataLen); |
| 1120 | - if (ret != HITLS_PKI_SUCCESS) { | 1120 | + if (ret != BSL_SUCCESS) { |
| 1121 | BSL_ERR_PUSH_ERROR(ret); | 1121 | BSL_ERR_PUSH_ERROR(ret); |
| 1122 | } | 1122 | } |
| 1123 | return ret; | 1123 | return ret; |
| @@ -1167,7 +1167,7 @@ int32_t HITLS_PKCS12_EncodeContentInfo(HITLS_PKI_LibCtx *libCtx, const char *att | |||
| 1167 | sizeof(g_pk12ContentInfoTempl) / sizeof(g_pk12ContentInfoTempl[0])}; | 1167 | sizeof(g_pk12ContentInfoTempl) / sizeof(g_pk12ContentInfoTempl[0])}; |
| 1168 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_CONTENT_MAX_IDX, &encode->data, &encode->dataLen); | 1168 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_CONTENT_MAX_IDX, &encode->data, &encode->dataLen); |
| 1169 | BSL_SAL_Free(initData.data); | 1169 | BSL_SAL_Free(initData.data); |
| 1170 | - if (ret != HITLS_PKI_SUCCESS) { | 1170 | + if (ret != BSL_SUCCESS) { |
| 1171 | BSL_ERR_PUSH_ERROR(ret); | 1171 | BSL_ERR_PUSH_ERROR(ret); |
| 1172 | } | 1172 | } |
| 1173 | return ret; | 1173 | return ret; |
| @@ -1254,12 +1254,12 @@ int32_t HITLS_PKCS12_EncodeAsn1List(HITLS_PKCS12 *p12, BSL_ASN1_List *list, uint | |||
| 1254 | BSL_ASN1_Buffer out = {0}; | 1254 | BSL_ASN1_Buffer out = {0}; |
| 1255 | ret = BSL_ASN1_EncodeListItem(BSL_ASN1_TAG_SEQUENCE, count, &templ, asnBuffers, count, &out); | 1255 | ret = BSL_ASN1_EncodeListItem(BSL_ASN1_TAG_SEQUENCE, count, &templ, asnBuffers, count, &out); |
| 1256 | FreeListBuff(asnBuffers, count); | 1256 | FreeListBuff(asnBuffers, count); |
| 1257 | - if (ret != HITLS_PKI_SUCCESS) { | 1257 | + if (ret != BSL_SUCCESS) { |
| 1258 | BSL_ERR_PUSH_ERROR(ret); | 1258 | BSL_ERR_PUSH_ERROR(ret); |
| 1259 | return ret; | 1259 | return ret; |
| 1260 | } | 1260 | } |
| 1261 | ret = BSL_ASN1_EncodeTemplate(&templ, &out, 1, &encode->data, &encode->dataLen); | 1261 | ret = BSL_ASN1_EncodeTemplate(&templ, &out, 1, &encode->data, &encode->dataLen); |
| 1262 | - if (ret != HITLS_PKI_SUCCESS) { | 1262 | + if (ret != BSL_SUCCESS) { |
| 1263 | BSL_ERR_PUSH_ERROR(ret); | 1263 | BSL_ERR_PUSH_ERROR(ret); |
| 1264 | } | 1264 | } |
| 1265 | BSL_SAL_FREE(out.buff); | 1265 | BSL_SAL_FREE(out.buff); |
| @@ -1302,7 +1302,7 @@ int32_t HITLS_PKCS12_EncodeMacData(HITLS_PKCS12 *p12, BSL_Buffer *initData, cons | |||
| 1302 | {BSL_ASN1_TAG_OCTETSTRING, p12Mac->macSalt->dataLen, p12Mac->macSalt->data}}; | 1302 | {BSL_ASN1_TAG_OCTETSTRING, p12Mac->macSalt->dataLen, p12Mac->macSalt->data}}; |
| 1303 | 1303 | ||
| 1304 | ret = BSL_ASN1_EncodeLimb(BSL_ASN1_TAG_INTEGER, p12Mac->iteration, &asnArr[HITLS_PKCS12_MACDATA_ITER_IDX]); | 1304 | ret = BSL_ASN1_EncodeLimb(BSL_ASN1_TAG_INTEGER, p12Mac->iteration, &asnArr[HITLS_PKCS12_MACDATA_ITER_IDX]); |
| 1305 | - if (ret != HITLS_PKI_SUCCESS) { | 1305 | + if (ret != BSL_SUCCESS) { |
| 1306 | BSL_SAL_Free(digestInfo.data); | 1306 | BSL_SAL_Free(digestInfo.data); |
| 1307 | BSL_ERR_PUSH_ERROR(ret); | 1307 | BSL_ERR_PUSH_ERROR(ret); |
| 1308 | return ret; | 1308 | return ret; |
| @@ -1311,7 +1311,7 @@ int32_t HITLS_PKCS12_EncodeMacData(HITLS_PKCS12 *p12, BSL_Buffer *initData, cons | |||
| 1311 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_MACDATA_MAX_IDX, &encode->data, &encode->dataLen); | 1311 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_MACDATA_MAX_IDX, &encode->data, &encode->dataLen); |
| 1312 | BSL_SAL_Free(digestInfo.data); | 1312 | BSL_SAL_Free(digestInfo.data); |
| 1313 | BSL_SAL_Free(asnArr[HITLS_PKCS12_MACDATA_ITER_IDX].buff); | 1313 | BSL_SAL_Free(asnArr[HITLS_PKCS12_MACDATA_ITER_IDX].buff); |
| 1314 | - if (ret != HITLS_PKI_SUCCESS) { | 1314 | + if (ret != BSL_SUCCESS) { |
| 1315 | BSL_ERR_PUSH_ERROR(ret); | 1315 | BSL_ERR_PUSH_ERROR(ret); |
| 1316 | } | 1316 | } |
| 1317 | return ret; | 1317 | return ret; |
| @@ -1331,7 +1331,7 @@ static int32_t EncodeCertListAddList(HITLS_PKCS12 *p12, const CRYPT_EncodeParam | |||
| 1331 | bag->attributes = p12->entityCert->attributes; | 1331 | bag->attributes = p12->entityCert->attributes; |
| 1332 | bag->value.cert = p12->entityCert->value.cert; | 1332 | bag->value.cert = p12->entityCert->value.cert; |
| 1333 | ret = BSL_LIST_AddElement(p12->certList, bag, BSL_LIST_POS_BEGIN); | 1333 | ret = BSL_LIST_AddElement(p12->certList, bag, BSL_LIST_POS_BEGIN); |
| 1334 | - if (ret != HITLS_PKI_SUCCESS) { | 1334 | + if (ret != BSL_SUCCESS) { |
| 1335 | BSL_SAL_FREE(bag); | 1335 | BSL_SAL_FREE(bag); |
| 1336 | BSL_ERR_PUSH_ERROR(ret); | 1336 | BSL_ERR_PUSH_ERROR(ret); |
| 1337 | return ret; | 1337 | return ret; |
| @@ -1478,7 +1478,7 @@ static int32_t EncodePkcs12(uint32_t version, BSL_Buffer *authSafe, BSL_Buffer * | |||
| 1478 | }}; | 1478 | }}; |
| 1479 | 1479 | ||
| 1480 | int32_t ret = BSL_ASN1_EncodeLimb(BSL_ASN1_TAG_INTEGER, version, asnArr); | 1480 | int32_t ret = BSL_ASN1_EncodeLimb(BSL_ASN1_TAG_INTEGER, version, asnArr); |
| 1481 | - if (ret != HITLS_PKI_SUCCESS) { | 1481 | + if (ret != BSL_SUCCESS) { |
| 1482 | BSL_ERR_PUSH_ERROR(ret); | 1482 | BSL_ERR_PUSH_ERROR(ret); |
| 1483 | return ret; | 1483 | return ret; |
| 1484 | } | 1484 | } |
| @@ -1487,7 +1487,7 @@ static int32_t EncodePkcs12(uint32_t version, BSL_Buffer *authSafe, BSL_Buffer * | |||
| 1487 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_TOPLEVEL_MAX_IDX, | 1487 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, HITLS_PKCS12_TOPLEVEL_MAX_IDX, |
| 1488 | &encode->data, &encode->dataLen); | 1488 | &encode->data, &encode->dataLen); |
| 1489 | BSL_SAL_Free(asnArr[HITLS_PKCS12_TOPLEVEL_VERSION_IDX].buff); | 1489 | BSL_SAL_Free(asnArr[HITLS_PKCS12_TOPLEVEL_VERSION_IDX].buff); |
| 1490 | - if (ret != HITLS_PKI_SUCCESS) { | 1490 | + if (ret != BSL_SUCCESS) { |
| 1491 | BSL_ERR_PUSH_ERROR(ret); | 1491 | BSL_ERR_PUSH_ERROR(ret); |
| 1492 | } | 1492 | } |
| 1493 | return ret; | 1493 | return ret; |
| @@ -1597,7 +1597,7 @@ int32_t HITLS_PKCS12_GenFile(int32_t format, HITLS_PKCS12 *p12, const HITLS_PKCS | |||
| 1597 | } | 1597 | } |
| 1598 | ret = BSL_SAL_WriteFile(path, encode.data, encode.dataLen); | 1598 | ret = BSL_SAL_WriteFile(path, encode.data, encode.dataLen); |
| 1599 | BSL_SAL_Free(encode.data); | 1599 | BSL_SAL_Free(encode.data); |
| 1600 | - if (ret != HITLS_PKI_SUCCESS) { | 1600 | + if (ret != BSL_SUCCESS) { |
| 1601 | BSL_ERR_PUSH_ERROR(ret); | 1601 | BSL_ERR_PUSH_ERROR(ret); |
| 1602 | } | 1602 | } |
| 1603 | return ret; | 1603 | return ret; |
| @@ -918,7 +918,7 @@ static int32_t EncodeAsn1Cert(HITLS_X509_Cert *cert) | |||
| 918 | }; | 918 | }; |
| 919 | uint32_t valLen = 0; | 919 | uint32_t valLen = 0; |
| 920 | int32_t ret = BSL_ASN1_DecodeTagLen(asns[0].tag, &asns[0].buff, &asns[0].len, &valLen); // 0 is tbs | 920 | int32_t ret = BSL_ASN1_DecodeTagLen(asns[0].tag, &asns[0].buff, &asns[0].len, &valLen); // 0 is tbs |
| 921 | - if (ret != HITLS_PKI_SUCCESS) { | 921 | + if (ret != BSL_SUCCESS) { |
| 922 | BSL_ERR_PUSH_ERROR(ret); | 922 | BSL_ERR_PUSH_ERROR(ret); |
| 923 | return ret; | 923 | return ret; |
| 924 | } | 924 | } |
| @@ -255,11 +255,6 @@ static int32_t EncodeReqExtAttr(HITLS_X509_Attrs *attributes, void *val, uint32_ | |||
| 255 | 255 | ||
| 256 | static int32_t SetAttr(HITLS_X509_Attrs *attributes, BslCid cid, void *val, uint32_t valLen, EncodeAttrCb encodeAttrCb) | 256 | static int32_t SetAttr(HITLS_X509_Attrs *attributes, BslCid cid, void *val, uint32_t valLen, EncodeAttrCb encodeAttrCb) |
| 257 | { | 257 | { |
| 258 | - if (val == NULL) { | ||
| 259 | - BSL_ERR_PUSH_ERROR(HITLS_X509_ERR_INVALID_PARAM); | ||
| 260 | - return HITLS_X509_ERR_INVALID_PARAM; | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | /* Check if the attribute already exists. */ | 258 | /* Check if the attribute already exists. */ |
| 264 | if (BSL_LIST_Search(attributes->list, &cid, CmpAttrEntryByCid, NULL) != NULL) { | 259 | if (BSL_LIST_Search(attributes->list, &cid, CmpAttrEntryByCid, NULL) != NULL) { |
| 265 | BSL_ERR_PUSH_ERROR(HITLS_X509_ERR_SET_ATTR_REPEAT); | 260 | BSL_ERR_PUSH_ERROR(HITLS_X509_ERR_SET_ATTR_REPEAT); |
| @@ -322,11 +317,6 @@ static int32_t DecodeReqExtAttr(HITLS_X509_Attrs *attributes, HITLS_X509_AttrEnt | |||
| 322 | 317 | ||
| 323 | static int32_t GetAttr(HITLS_X509_Attrs *attributes, BslCid cid, void *val, uint32_t valLen, DecodeAttrCb decodeAttrCb) | 318 | static int32_t GetAttr(HITLS_X509_Attrs *attributes, BslCid cid, void *val, uint32_t valLen, DecodeAttrCb decodeAttrCb) |
| 324 | { | 319 | { |
| 325 | - if (val == NULL) { | ||
| 326 | - BSL_ERR_PUSH_ERROR(HITLS_X509_ERR_INVALID_PARAM); | ||
| 327 | - return HITLS_X509_ERR_INVALID_PARAM; | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | HITLS_X509_AttrEntry *attrEntry = BSL_LIST_Search(attributes->list, &cid, CmpAttrEntryByCid, NULL); | 320 | HITLS_X509_AttrEntry *attrEntry = BSL_LIST_Search(attributes->list, &cid, CmpAttrEntryByCid, NULL); |
| 331 | if (attrEntry == NULL) { | 321 | if (attrEntry == NULL) { |
| 332 | BSL_ERR_PUSH_ERROR(HITLS_X509_ERR_ATTR_NOT_FOUND); | 322 | BSL_ERR_PUSH_ERROR(HITLS_X509_ERR_ATTR_NOT_FOUND); |
| @@ -370,7 +360,7 @@ int32_t HITLS_X509_EncodeAttrEntry(HITLS_X509_AttrEntry *node, BSL_ASN1_Buffer * | |||
| 370 | asnBuf[1] = node->attrValue; | 360 | asnBuf[1] = node->attrValue; |
| 371 | BSL_ASN1_Template templ = {g_x509AttrEntryTempl, sizeof(g_x509AttrEntryTempl) / sizeof(g_x509AttrEntryTempl[0])}; | 361 | BSL_ASN1_Template templ = {g_x509AttrEntryTempl, sizeof(g_x509AttrEntryTempl) / sizeof(g_x509AttrEntryTempl[0])}; |
| 372 | int32_t ret = BSL_ASN1_EncodeTemplate(&templ, asnBuf, X509_CSR_ATTR_ELEM_NUMBER, &attrBuff->buff, &attrBuff->len); | 362 | int32_t ret = BSL_ASN1_EncodeTemplate(&templ, asnBuf, X509_CSR_ATTR_ELEM_NUMBER, &attrBuff->buff, &attrBuff->len); |
| 373 | - if (ret != HITLS_PKI_SUCCESS) { | 363 | + if (ret != BSL_SUCCESS) { |
| 374 | BSL_ERR_PUSH_ERROR(ret); | 364 | BSL_ERR_PUSH_ERROR(ret); |
| 375 | return ret; | 365 | return ret; |
| 376 | } | 366 | } |
| @@ -378,7 +368,7 @@ int32_t HITLS_X509_EncodeAttrEntry(HITLS_X509_AttrEntry *node, BSL_ASN1_Buffer * | |||
| 378 | return ret; | 368 | return ret; |
| 379 | } | 369 | } |
| 380 | 370 | ||
| 381 | -void FreeAsnAttrsBuff(BSL_ASN1_Buffer *asnBuf, uint32_t count) | 371 | +static void FreeAsnAttrsBuff(BSL_ASN1_Buffer *asnBuf, uint32_t count) |
| 382 | { | 372 | { |
| 383 | for (uint32_t i = 0; i < count; i++) { | 373 | for (uint32_t i = 0; i < count; i++) { |
| 384 | BSL_SAL_FREE(asnBuf[i].buff); | 374 | BSL_SAL_FREE(asnBuf[i].buff); |
| @@ -429,7 +419,7 @@ int32_t HITLS_X509_EncodeAttrList(uint8_t tag, HITLS_X509_Attrs *attrs, HITLS_X5 | |||
| 429 | BSL_ASN1_Template templ = {&attrSeqTempl, 1}; | 419 | BSL_ASN1_Template templ = {&attrSeqTempl, 1}; |
| 430 | ret = BSL_ASN1_EncodeListItem(BSL_ASN1_TAG_SEQUENCE, count, &templ, asnBuf, iter, attrAsn1); | 420 | ret = BSL_ASN1_EncodeListItem(BSL_ASN1_TAG_SEQUENCE, count, &templ, asnBuf, iter, attrAsn1); |
| 431 | FreeAsnAttrsBuff(asnBuf, count); | 421 | FreeAsnAttrsBuff(asnBuf, count); |
| 432 | - if (ret != HITLS_PKI_SUCCESS) { | 422 | + if (ret != BSL_SUCCESS) { |
| 433 | BSL_ERR_PUSH_ERROR(ret); | 423 | BSL_ERR_PUSH_ERROR(ret); |
| 434 | return ret; | 424 | return ret; |
| 435 | } | 425 | } |
| @@ -134,7 +134,7 @@ static int32_t HITLS_X509_ParseNameNode(BSL_ASN1_Buffer *asn, HITLS_X509_NameNod | |||
| 134 | int32_t HITLS_X509_ParseListAsnItem(uint32_t layer, BSL_ASN1_Buffer *asn, void *cbParam, BSL_ASN1_List *list) | 134 | int32_t HITLS_X509_ParseListAsnItem(uint32_t layer, BSL_ASN1_Buffer *asn, void *cbParam, BSL_ASN1_List *list) |
| 135 | { | 135 | { |
| 136 | (void) cbParam; | 136 | (void) cbParam; |
| 137 | - int32_t ret = HITLS_PKI_SUCCESS; | 137 | + int32_t ret; |
| 138 | HITLS_X509_NameNode *node = BSL_SAL_Calloc(1, sizeof(HITLS_X509_NameNode)); | 138 | HITLS_X509_NameNode *node = BSL_SAL_Calloc(1, sizeof(HITLS_X509_NameNode)); |
| 139 | if (node == NULL) { | 139 | if (node == NULL) { |
| 140 | BSL_ERR_PUSH_ERROR(BSL_MALLOC_FAIL); | 140 | BSL_ERR_PUSH_ERROR(BSL_MALLOC_FAIL); |
| @@ -266,7 +266,7 @@ int32_t HITLS_X509_EncodeSignAlgInfo(HITLS_X509_Asn1AlgId *x509Alg, BSL_ASN1_Buf | |||
| 266 | // 2: alg + param | 266 | // 2: alg + param |
| 267 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, 2, &(asn->buff), &(asn->len)); | 267 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, 2, &(asn->buff), &(asn->len)); |
| 268 | BSL_SAL_FREE(asnArr[1].buff); | 268 | BSL_SAL_FREE(asnArr[1].buff); |
| 269 | - if (ret != HITLS_PKI_SUCCESS) { | 269 | + if (ret != BSL_SUCCESS) { |
| 270 | BSL_ERR_PUSH_ERROR(ret); | 270 | BSL_ERR_PUSH_ERROR(ret); |
| 271 | return ret; | 271 | return ret; |
| 272 | } | 272 | } |
| @@ -475,7 +475,7 @@ static int32_t HITLS_X509_ParseAsn1(CRYPT_EAL_LibCtx *libCtx, const char *attrNa | |||
| 475 | while (dataLen > 0) { | 475 | while (dataLen > 0) { |
| 476 | uint32_t elemLen = dataLen; | 476 | uint32_t elemLen = dataLen; |
| 477 | int32_t ret = BSL_ASN1_GetCompleteLen(data, &elemLen); | 477 | int32_t ret = BSL_ASN1_GetCompleteLen(data, &elemLen); |
| 478 | - if (ret != HITLS_PKI_SUCCESS) { | 478 | + if (ret != BSL_SUCCESS) { |
| 479 | return ret; | 479 | return ret; |
| 480 | } | 480 | } |
| 481 | BSL_Buffer asn1Buf = {data, elemLen}; | 481 | BSL_Buffer asn1Buf = {data, elemLen}; |
| @@ -505,7 +505,7 @@ static int32_t HITLS_X509_ParsePem(CRYPT_EAL_LibCtx *libCtx, const char *attrNam | |||
| 505 | BSL_Buffer asn1Buf = {0}; | 505 | BSL_Buffer asn1Buf = {0}; |
| 506 | int32_t ret = BSL_PEM_DecodePemToAsn1(&nextEncode, &nextEncodeLen, &symbol, &(asn1Buf.data), | 506 | int32_t ret = BSL_PEM_DecodePemToAsn1(&nextEncode, &nextEncodeLen, &symbol, &(asn1Buf.data), |
| 507 | &(asn1Buf.dataLen)); | 507 | &(asn1Buf.dataLen)); |
| 508 | - if (ret != HITLS_PKI_SUCCESS) { | 508 | + if (ret != BSL_SUCCESS) { |
| 509 | break; | 509 | break; |
| 510 | } | 510 | } |
| 511 | ret = X509_ParseAndAddRes(libCtx, attrName, &asn1Buf, parseFun, list); | 511 | ret = X509_ParseAndAddRes(libCtx, attrName, &asn1Buf, parseFun, list); |
| @@ -724,7 +724,7 @@ int32_t HITLS_X509_SignAsn1Data(CRYPT_EAL_PkeyCtx *priv, CRYPT_MD_AlgId mdId, | |||
| 724 | BSL_ASN1_Template templ = {&templItem, 1}; | 724 | BSL_ASN1_Template templ = {&templItem, 1}; |
| 725 | 725 | ||
| 726 | int32_t ret = BSL_ASN1_EncodeTemplate(&templ, asn1Buff, 1, &rawSignBuff->data, &rawSignBuff->dataLen); | 726 | int32_t ret = BSL_ASN1_EncodeTemplate(&templ, asn1Buff, 1, &rawSignBuff->data, &rawSignBuff->dataLen); |
| 727 | - if (ret != HITLS_PKI_SUCCESS) { | 727 | + if (ret != BSL_SUCCESS) { |
| 728 | BSL_ERR_PUSH_ERROR(ret); | 728 | BSL_ERR_PUSH_ERROR(ret); |
| 729 | return ret; | 729 | return ret; |
| 730 | } | 730 | } |
| @@ -732,6 +732,7 @@ int32_t HITLS_X509_SignAsn1Data(CRYPT_EAL_PkeyCtx *priv, CRYPT_MD_AlgId mdId, | |||
| 732 | sign->len = CRYPT_EAL_PkeyGetSignLen(priv); | 732 | sign->len = CRYPT_EAL_PkeyGetSignLen(priv); |
| 733 | sign->buff = (uint8_t *)BSL_SAL_Malloc(sign->len); | 733 | sign->buff = (uint8_t *)BSL_SAL_Malloc(sign->len); |
| 734 | if (sign->buff == NULL) { | 734 | if (sign->buff == NULL) { |
| 735 | + sign->len = 0; | ||
| 735 | BSL_SAL_FREE(rawSignBuff->data); | 736 | BSL_SAL_FREE(rawSignBuff->data); |
| 736 | rawSignBuff->dataLen = 0; | 737 | rawSignBuff->dataLen = 0; |
| 737 | BSL_ERR_PUSH_ERROR(BSL_MALLOC_FAIL); | 738 | BSL_ERR_PUSH_ERROR(BSL_MALLOC_FAIL); |
| @@ -78,12 +78,8 @@ int32_t HITLS_X509_GetEncodeDn(BslList *list, void *val, uint32_t valLen) | |||
| 78 | BSL_ASN1_Template templ = {item, 1}; | 78 | BSL_ASN1_Template templ = {item, 1}; |
| 79 | 79 | ||
| 80 | ret = BSL_ASN1_EncodeTemplate(&templ, &tmp, 1, &res->data, &res->dataLen); | 80 | ret = BSL_ASN1_EncodeTemplate(&templ, &tmp, 1, &res->data, &res->dataLen); |
| 81 | - if (ret != BSL_SUCCESS) { | ||
| 82 | - BSL_SAL_Free(tmp.buff); | ||
| 83 | - return ret; | ||
| 84 | - } | ||
| 85 | BSL_SAL_Free(tmp.buff); | 81 | BSL_SAL_Free(tmp.buff); |
| 86 | - return HITLS_PKI_SUCCESS; | 82 | + return ret; |
| 87 | } | 83 | } |
| 88 | 84 | ||
| 89 | 85 | ||
| @@ -217,7 +213,7 @@ static int32_t X509EncodeNameNodeEntry(const HITLS_X509_NameNode *nameNode, BSL_ | |||
| 217 | BSL_ASN1_Template dntTempl = {dnTempl, sizeof(dnTempl) / sizeof(dnTempl[0])}; | 213 | BSL_ASN1_Template dntTempl = {dnTempl, sizeof(dnTempl) / sizeof(dnTempl[0])}; |
| 218 | int32_t ret = BSL_ASN1_EncodeTemplate(&dntTempl, asnArr, X509_DN_NAME_ELEM_NUMBER, | 214 | int32_t ret = BSL_ASN1_EncodeTemplate(&dntTempl, asnArr, X509_DN_NAME_ELEM_NUMBER, |
| 219 | &asnDnBuff.buff, &asnDnBuff.len); | 215 | &asnDnBuff.buff, &asnDnBuff.len); |
| 220 | - if (ret != HITLS_PKI_SUCCESS) { | 216 | + if (ret != BSL_SUCCESS) { |
| 221 | BSL_ERR_PUSH_ERROR(ret); | 217 | BSL_ERR_PUSH_ERROR(ret); |
| 222 | return ret; | 218 | return ret; |
| 223 | } | 219 | } |
| @@ -553,7 +553,7 @@ int32_t HITLS_X509_ParseExtendedKeyUsage(HITLS_X509_ExtEntry *extEntry, HITLS_X5 | |||
| 553 | } | 553 | } |
| 554 | 554 | ||
| 555 | int32_t ret = BSL_ASN1_DecodeListItem(&listParam, &extEntry->extnValue, ParseExKeyUsageList, NULL, list); | 555 | int32_t ret = BSL_ASN1_DecodeListItem(&listParam, &extEntry->extnValue, ParseExKeyUsageList, NULL, list); |
| 556 | - if (ret != HITLS_PKI_SUCCESS) { | 556 | + if (ret != BSL_SUCCESS) { |
| 557 | BSL_LIST_DeleteAll(list, NULL); | 557 | BSL_LIST_DeleteAll(list, NULL); |
| 558 | BSL_SAL_Free(list); | 558 | BSL_SAL_Free(list); |
| 559 | return ret; | 559 | return ret; |
| @@ -1411,7 +1411,7 @@ int32_t HITLS_X509_EncodeExt(uint8_t tag, BSL_ASN1_List *list, BSL_ASN1_Buffer * | |||
| 1411 | BSL_ASN1_Template templ = {extTempl, 1}; | 1411 | BSL_ASN1_Template templ = {extTempl, 1}; |
| 1412 | ret = BSL_ASN1_EncodeTemplate(&templ, &extbuff, 1, &(ext->buff), &(ext->len)); | 1412 | ret = BSL_ASN1_EncodeTemplate(&templ, &extbuff, 1, &(ext->buff), &(ext->len)); |
| 1413 | BSL_SAL_Free(extbuff.buff); | 1413 | BSL_SAL_Free(extbuff.buff); |
| 1414 | - if (ret != HITLS_PKI_SUCCESS) { | 1414 | + if (ret != BSL_SUCCESS) { |
| 1415 | BSL_ERR_PUSH_ERROR(ret); | 1415 | BSL_ERR_PUSH_ERROR(ret); |
| 1416 | return ret; | 1416 | return ret; |
| 1417 | } | 1417 | } |
| @@ -552,7 +552,7 @@ int32_t HITLS_X509_EncodeCrlTbsRaw(HITLS_X509_CrlTbs *crlTbs, BSL_ASN1_Buffer *a | |||
| 552 | } | 552 | } |
| 553 | BSL_ASN1_Template templ = {g_crlTbsTempl, sizeof(g_crlTbsTempl) / sizeof(g_crlTbsTempl[0])}; | 553 | BSL_ASN1_Template templ = {g_crlTbsTempl, sizeof(g_crlTbsTempl) / sizeof(g_crlTbsTempl[0])}; |
| 554 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, X509_CRLTBS_ELEM_NUMBER, &(asn->buff), &(asn->len)); | 554 | ret = BSL_ASN1_EncodeTemplate(&templ, asnArr, X509_CRLTBS_ELEM_NUMBER, &(asn->buff), &(asn->len)); |
| 555 | - if (ret != HITLS_PKI_SUCCESS) { | 555 | + if (ret != BSL_SUCCESS) { |
| 556 | goto EXIT; | 556 | goto EXIT; |
| 557 | } | 557 | } |
| 558 | asn->tag = BSL_ASN1_TAG_CONSTRUCTED | BSL_ASN1_TAG_SEQUENCE; | 558 | asn->tag = BSL_ASN1_TAG_CONSTRUCTED | BSL_ASN1_TAG_SEQUENCE; |
| @@ -585,7 +585,7 @@ int32_t EncodeAsn1Crl(HITLS_X509_Crl *crl) | |||
| 585 | }; | 585 | }; |
| 586 | uint32_t valLen = 0; | 586 | uint32_t valLen = 0; |
| 587 | int32_t ret = BSL_ASN1_DecodeTagLen(asnArr[0].tag, &asnArr[0].buff, &asnArr[0].len, &valLen); // 0 is tbs | 587 | int32_t ret = BSL_ASN1_DecodeTagLen(asnArr[0].tag, &asnArr[0].buff, &asnArr[0].len, &valLen); // 0 is tbs |
| 588 | - if (ret != HITLS_PKI_SUCCESS) { | 588 | + if (ret != BSL_SUCCESS) { |
| 589 | BSL_ERR_PUSH_ERROR(ret); | 589 | BSL_ERR_PUSH_ERROR(ret); |
| 590 | return ret; | 590 | return ret; |
| 591 | } | 591 | } |
| @@ -296,7 +296,7 @@ static int32_t X509CsrPemParse(const BSL_Buffer *encode, HITLS_X509_Csr *csr) | |||
| 296 | BSL_PEM_Symbol symbol = {BSL_PEM_CERT_REQ_BEGIN_STR, BSL_PEM_CERT_REQ_END_STR}; | 296 | BSL_PEM_Symbol symbol = {BSL_PEM_CERT_REQ_BEGIN_STR, BSL_PEM_CERT_REQ_END_STR}; |
| 297 | int32_t ret = BSL_PEM_DecodePemToAsn1((char **)&tmpBuf, &tmpBufLen, &symbol, &asn1Buf.data, | 297 | int32_t ret = BSL_PEM_DecodePemToAsn1((char **)&tmpBuf, &tmpBufLen, &symbol, &asn1Buf.data, |
| 298 | &asn1Buf.dataLen); | 298 | &asn1Buf.dataLen); |
| 299 | - if (ret != HITLS_PKI_SUCCESS) { | 299 | + if (ret != BSL_SUCCESS) { |
| 300 | BSL_ERR_PUSH_ERROR(ret); | 300 | BSL_ERR_PUSH_ERROR(ret); |
| 301 | return ret; | 301 | return ret; |
| 302 | } | 302 | } |
| @@ -493,7 +493,7 @@ static int32_t X509EncodeAsn1CsrCore(HITLS_X509_Csr *csr) | |||
| 493 | }; | 493 | }; |
| 494 | uint32_t valLen = 0; | 494 | uint32_t valLen = 0; |
| 495 | int32_t ret = BSL_ASN1_DecodeTagLen(asnArr[0].tag, &asnArr[0].buff, &asnArr[0].len, &valLen); // 0 is reqInfo | 495 | int32_t ret = BSL_ASN1_DecodeTagLen(asnArr[0].tag, &asnArr[0].buff, &asnArr[0].len, &valLen); // 0 is reqInfo |
| 496 | - if (ret != HITLS_PKI_SUCCESS) { | 496 | + if (ret != BSL_SUCCESS) { |
| 497 | BSL_ERR_PUSH_ERROR(ret); | 497 | BSL_ERR_PUSH_ERROR(ret); |
| 498 | return ret; | 498 | return ret; |
| 499 | } | 499 | } |
| @@ -507,7 +507,7 @@ static int32_t X509EncodeAsn1CsrCore(HITLS_X509_Csr *csr) | |||
| 507 | BSL_ASN1_Template csrTempl = { g_briefCsrTempl, sizeof(g_briefCsrTempl) / sizeof(g_briefCsrTempl[0]) }; | 507 | BSL_ASN1_Template csrTempl = { g_briefCsrTempl, sizeof(g_briefCsrTempl) / sizeof(g_briefCsrTempl[0]) }; |
| 508 | ret = BSL_ASN1_EncodeTemplate(&csrTempl, asnArr, HITLS_X509_CSR_BRIEF_SIZE, &csr->rawData, &csr->rawDataLen); | 508 | ret = BSL_ASN1_EncodeTemplate(&csrTempl, asnArr, HITLS_X509_CSR_BRIEF_SIZE, &csr->rawData, &csr->rawDataLen); |
| 509 | BSL_SAL_FREE(asnArr[1].buff); | 509 | BSL_SAL_FREE(asnArr[1].buff); |
| 510 | - if (ret != HITLS_PKI_SUCCESS) { | 510 | + if (ret != BSL_SUCCESS) { |
| 511 | BSL_ERR_PUSH_ERROR(ret); | 511 | BSL_ERR_PUSH_ERROR(ret); |
| 512 | } | 512 | } |
| 513 | return ret; | 513 | return ret; |
| @@ -616,7 +616,7 @@ int32_t HITLS_X509_CsrGenFile(int32_t format, HITLS_X509_Csr *csr, const char *p | |||
| 616 | 616 | ||
| 617 | ret = BSL_SAL_WriteFile(path, encode.data, encode.dataLen); | 617 | ret = BSL_SAL_WriteFile(path, encode.data, encode.dataLen); |
| 618 | BSL_SAL_Free(encode.data); | 618 | BSL_SAL_Free(encode.data); |
| 619 | - if (ret != HITLS_PKI_SUCCESS) { | 619 | + if (ret != BSL_SUCCESS) { |
| 620 | BSL_ERR_PUSH_ERROR(ret); | 620 | BSL_ERR_PUSH_ERROR(ret); |
| 621 | } | 621 | } |
| 622 | 622 | ||
| @@ -370,7 +370,7 @@ static int32_t X509_SetCA(HITLS_X509_StoreCtx *storeCtx, void *val, bool isCopy) | |||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | ret = BSL_LIST_AddElement(storeCtx->store, val, BSL_LIST_POS_BEFORE); | 372 | ret = BSL_LIST_AddElement(storeCtx->store, val, BSL_LIST_POS_BEFORE); |
| 373 | - if (ret != HITLS_PKI_SUCCESS) { | 373 | + if (ret != BSL_SUCCESS) { |
| 374 | if (isCopy) { | 374 | if (isCopy) { |
| 375 | HITLS_X509_CertFree(val); | 375 | HITLS_X509_CertFree(val); |
| 376 | } | 376 | } |
| @@ -403,7 +403,7 @@ static int32_t X509_SetCRL(HITLS_X509_StoreCtx *storeCtx, void *val) | |||
| 403 | return ret; | 403 | return ret; |
| 404 | } | 404 | } |
| 405 | ret = BSL_LIST_AddElement(storeCtx->crl, val, BSL_LIST_POS_BEFORE); | 405 | ret = BSL_LIST_AddElement(storeCtx->crl, val, BSL_LIST_POS_BEFORE); |
| 406 | - if (ret != HITLS_PKI_SUCCESS) { | 406 | + if (ret != BSL_SUCCESS) { |
| 407 | HITLS_X509_CrlFree(val); | 407 | HITLS_X509_CrlFree(val); |
| 408 | BSL_ERR_PUSH_ERROR(ret); | 408 | BSL_ERR_PUSH_ERROR(ret); |
| 409 | } | 409 | } |
| @@ -422,7 +422,7 @@ static int32_t X509_AddCAPath(HITLS_X509_StoreCtx *storeCtx, const void *val, ui | |||
| 422 | 422 | ||
| 423 | char *existPath = BSL_LIST_GET_FIRST(storeCtx->caPaths); | 423 | char *existPath = BSL_LIST_GET_FIRST(storeCtx->caPaths); |
| 424 | while (existPath != NULL) { | 424 | while (existPath != NULL) { |
| 425 | - if (memcmp(existPath, caPath, valLen) == 0 && strlen(existPath) == valLen) { | 425 | + if (strlen(existPath) == valLen && memcmp(existPath, caPath, valLen) == 0) { |
| 426 | return HITLS_PKI_SUCCESS; | 426 | return HITLS_PKI_SUCCESS; |
| 427 | } | 427 | } |
| 428 | existPath = BSL_LIST_GET_NEXT(storeCtx->caPaths); | 428 | existPath = BSL_LIST_GET_NEXT(storeCtx->caPaths); |
| @@ -751,7 +751,7 @@ static int32_t X509_AddCertToChain(HITLS_X509_List *chain, HITLS_X509_Cert *cert | |||
| 751 | return ret; | 751 | return ret; |
| 752 | } | 752 | } |
| 753 | ret = BSL_LIST_AddElement(chain, cert, BSL_LIST_POS_END); | 753 | ret = BSL_LIST_AddElement(chain, cert, BSL_LIST_POS_END); |
| 754 | - if (ret != HITLS_PKI_SUCCESS) { | 754 | + if (ret != BSL_SUCCESS) { |
| 755 | HITLS_X509_CertFree(cert); | 755 | HITLS_X509_CertFree(cert); |
| 756 | BSL_ERR_PUSH_ERROR(ret); | 756 | BSL_ERR_PUSH_ERROR(ret); |
| 757 | } | 757 | } |
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | + | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | 27 | ||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | + | ||
| 22 | 23 | ||
| 23 | 24 | ||
| 24 | /* END_HEADER */ | 25 | /* END_HEADER */ |
| @@ -33,6 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | + | ||
| 36 | 37 | ||
| 37 | 38 | ||
| 38 | 39 | ||