harmony 鸿蒙CryptoSignatureApi

  • 2025-06-12
  • 浏览 (5)

CryptoSignatureApi

Overview

Provides APIs for signature verification.

Since: 12

Summary

Files

Name Description
crypto_signature.h Defines APIs for signature verification.

Types

Name Description
typedef struct OH_CryptoVerify OH_CryptoVerify Defines the data used for signature verification.

Enums

Name Description
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

Name Description
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

Enum Description
CRYPTO_PSS_MD_NAME_STR MD algorithm used with the PSS padding mode in RSA.
CRYPTO_PSS_MGF_NAME_STR Mask generation algorithm used with the PSS padding mode in RSA. Currently, only MGF1 is supported.
CRYPTO_PSS_MGF1_NAME_STR MD parameters for the MGF1 mask generation used with the PSS padding mode in RSA.
CRYPTO_PSS_SALT_LEN_INT Length of the salt in bytes used with the PSS padding mode in RSA.
CRYPTO_PSS_TRAILER_FIELD_INT Trailer field used in the encoding operation when PSS padding mode is used in RSA. The value is 1.
CRYPTO_SM2_USER_ID_DATABLOB User 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

Name Description
algoName Pointer to the algorithm used to generate the Verify instance. For example, ‘RSA1024|PKCS1|SHA256’.
verify Pointer 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

Name Description
ctx Pointer 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

Name Description
ctx Pointer to the Verify instance.
in Pointer to the data passed in.
out Pointer 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

Name Description
ctx Pointer 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

Name Description
ctx Pointer to the Verify instance.
type Name of the signature verification parameter to obtain.
value Pointer 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

Name Description
ctx Pointer to the Verify instance.
pubKey Pointer 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

Name Description
ctx Pointer to the Verify instance.
signData Pointer to the signature data to be restored.
rawSignData Pointer 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

Name Description
ctx Pointer to the Verify instance.
type Name of the signature verification parameter to set.
value Pointer 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

Name Description
ctx Pointer to the Verify instance.
in Pointer 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

0  赞