harmony 鸿蒙CryptoSignatureApi

2025-06-12 浏览 (1)

CryptoSignatureApi

Overview

Provides APIs for signature verification.

Since: 12

Summary

Files

NameDescription
crypto_signature.hDefines APIs for signature verification.

Types

NameDescription
typedef struct OH_CryptoVerify OH_CryptoVerifyDefines the data used for signature verification.

Enums

NameDescription
CryptoSignature_ParamType {
CRYPTO_PSS_MD_NAME_STR = 100, CRYPTO_PSS_MGF_NAME_STR = 101,
CRYPTO_PSS_MGF1_NAME_STR = 102, CRYPTO_PSS_SALT_LEN_INT = 103,
CRYPTO_PSS_TRAILER_FIELD_INT = 104, CRYPTO_SM2_USER_ID_DATABLOB = 105
}
Enumerates the types of signature verification parameters.

Functions

NameDescription
OH_Crypto_ErrCode OH_CryptoVerify_Create (const char *algoName, OH_CryptoVerify **verify)Creates a Verify instance for signature verification.
OH_Crypto_ErrCode OH_CryptoVerify_Init (OH_CryptoVerify *ctx, OH_CryptoPubKey *pubKey)Initializes a Verify instance by using the public key.
OH_Crypto_ErrCode OH_CryptoVerify_Update (OH_CryptoVerify *ctx, Crypto_DataBlob *in)Updates the data to be verified.
bool OH_CryptoVerify_Final (OH_CryptoVerify *ctx, Crypto_DataBlob *in, Crypto_DataBlob *signData)Verifies the signature of the data.
OH_Crypto_ErrCode OH_CryptoVerify_Recover (OH_CryptoVerify *ctx, Crypto_DataBlob *signData, Crypto_DataBlob *rawSignData)Restores the raw signature data.
const char * OH_CryptoVerify_GetAlgoName (OH_CryptoVerify *ctx)Obtains the signature verification algorithm.
OH_Crypto_ErrCode OH_CryptoVerify_SetParam (OH_CryptoVerify *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value)Sets a signature verification parameter.
OH_Crypto_ErrCode OH_CryptoVerify_GetParam (OH_CryptoVerify *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value)Obtains a signature verification parameter.
void OH_CryptoVerify_Destroy (OH_CryptoVerify *ctx)Destroys a Verify instance.

Type Description

OH_CryptoVerify

typedef struct OH_CryptoVerifyOH_CryptoVerify

Description

Defines the data used for signature verification.

Since: 12

Enum Description

CryptoSignature_ParamType

enum CryptoSignature_ParamType

Description

Enumerates the types of signature verification parameters.

Since: 12

EnumDescription
CRYPTO_PSS_MD_NAME_STRMD algorithm used with the PSS padding mode in RSA.
CRYPTO_PSS_MGF_NAME_STRMask generation algorithm used with the PSS padding mode in RSA. Currently, only MGF1 is supported.
CRYPTO_PSS_MGF1_NAME_STRMD parameters for the MGF1 mask generation used with the PSS padding mode in RSA.
CRYPTO_PSS_SALT_LEN_INTLength of the salt in bytes used with the PSS padding mode in RSA.
CRYPTO_PSS_TRAILER_FIELD_INTTrailer field used in the encoding operation when PSS padding mode is used in RSA. The value is 1.
CRYPTO_SM2_USER_ID_DATABLOBUser ID field in SM2.

Function Description

OH_CryptoVerify_Create()

OH_Crypto_ErrCode OH_CryptoVerify_Create (const char *algoName, OH_CryptoVerify **verify )

Description

Creates a Verify instance for signature verification.

Since: 12

Parameters

NameDescription
algoNamePointer to the algorithm used to generate the Verify instance. For example, 'RSA1024|PKCS1|SHA256'.
verifyPointer to the Verify instance created.

Returns

OH_Crypto_ErrCode:

0: The operation is successful.

401: Invalid parameters are detected.

801: The operation is not supported.

17620001: A memory error occurred.

17630001: Failed to call an API of a third-party algorithm library.

OH_CryptoVerify_Destroy()

void OH_CryptoVerify_Destroy (OH_CryptoVerify *ctx)

Description

Destroys a Verify instance.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance to destroy.

OH_CryptoVerify_Final()

bool OH_CryptoVerify_Final (OH_CryptoVerify *ctx, Crypto_DataBlob *in, Crypto_DataBlob *signData )

Description

Verifies the signature of the data.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.
inPointer to the data passed in.
outPointer to the signature data.

Returns

Returns a boolean value, indicating whether the signature verification is successful.

See

OH_CryptoVerify_Init

OH_CryptoVerify_Update

OH_CryptoVerify_GetAlgoName()

const char* OH_CryptoVerify_GetAlgoName (OH_CryptoVerify *ctx)

Description

Obtains the signature verification algorithm.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.

Returns

Signature verification algorithm obtained.

OH_CryptoVerify_GetParam()

OH_Crypto_ErrCode OH_CryptoVerify_GetParam (OH_CryptoVerify *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value )

Description

Obtains a signature verification parameter.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.
typeName of the signature verification parameter to obtain.
valuePointer to the parameter value obtained.

Returns

OH_Crypto_ErrCode:

0: The operation is successful.

401: Invalid parameters are detected.

801: The operation is not supported.

17620001: A memory error occurred.

17630001: Failed to call an API of a third-party algorithm library.

OH_CryptoVerify_Init()

OH_Crypto_ErrCode OH_CryptoVerify_Init (OH_CryptoVerify *ctx, OH_CryptoPubKey *pubKey )

Description

Initializes a Verify instance by using the public key.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.
pubKeyPointer to the public key.

Returns

OH_Crypto_ErrCode:

0: The operation is successful.

401: Invalid parameters are detected.

801: The operation is not supported.

17620001: A memory error occurred.

17630001: Failed to call an API of a third-party algorithm library.

See

OH_CryptoVerify_Update

OH_CryptoVerify_Final

OH_CryptoVerify_Recover()

OH_Crypto_ErrCode OH_CryptoVerify_Recover (OH_CryptoVerify *ctx, Crypto_DataBlob *signData, Crypto_DataBlob *rawSignData )

Description

Restores the signature data.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.
signDataPointer to the signature data to be restored.
rawSignDataPointer to the raw data restored.

Returns

OH_Crypto_ErrCode:

0: The operation is successful.

401: Invalid parameters are detected.

801: The operation is not supported.

17620001: A memory error occurred.

17630001: Failed to call an API of a third-party algorithm library.

OH_CryptoVerify_SetParam()

OH_Crypto_ErrCode OH_CryptoVerify_SetParam (OH_CryptoVerify *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value )

Description

Sets a signature verification parameter.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.
typeName of the signature verification parameter to set.
valuePointer to the value of the signature verification parameter to set.

Returns

OH_Crypto_ErrCode:

0: The operation is successful.

401: Invalid parameters are detected.

801: The operation is not supported.

17620001: A memory error occurred.

17630001: Failed to call an API of a third-party algorithm library.

OH_CryptoVerify_Update()

OH_Crypto_ErrCode OH_CryptoVerify_Update (OH_CryptoVerify *ctx, Crypto_DataBlob *in )

Description

Updates the data to be verified.

Since: 12

Parameters

NameDescription
ctxPointer to the Verify instance.
inPointer to the data to pass in.

Returns

OH_Crypto_ErrCode:

0: The operation is successful.

401: Invalid parameters are detected.

801: The operation is not supported.

17620001: A memory error occurred.

17630001: Failed to call an API of a third-party algorithm library.

See

OH_CryptoVerify_Init

OH_CryptoVerify_Final

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Crypto Architecture Kit (Crypto Architecture Service)

harmony 鸿蒙Crypto_DataBlob

harmony 鸿蒙CryptoAsymKeyApi

harmony 鸿蒙CryptoCommonApi

harmony 鸿蒙CryptoDigestApi

harmony 鸿蒙CryptoSymCipherApi

harmony 鸿蒙CryptoSymKeyApi

harmony 鸿蒙crypto_asym_key.h

harmony 鸿蒙crypto_common.h

harmony 鸿蒙crypto_digest.h

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/6VNScd