目录

CryptoDigestApi

Overview

Provides APIs for message digest (MD) algorithms.

Since: 12

Summary

[h2]Files

Name Description
crypto_digest.h Defines APIs for MD algorithms.

[h2]Types

Name Description
typedef struct OH_CryptoDigest OH_CryptoDigest Defines an MD.

[h2]Functions

Name Description
OH_Crypto_ErrCode OH_CryptoDigest_Create (const char *algoName, OH_CryptoDigest **ctx) Creates an MD instance based on the given algorithm name.
OH_Crypto_ErrCode OH_CryptoDigest_Update (OH_CryptoDigest *ctx, Crypto_DataBlob *in) Updates the data used for generating an MD.
OH_Crypto_ErrCode OH_CryptoDigest_Final (OH_CryptoDigest *ctx, Crypto_DataBlob *out) Generates an MD.
uint32_t OH_CryptoDigest_GetLength (OH_CryptoDigest *ctx) Obtains the length of an MD.
const char * OH_CryptoDigest_GetAlgoName (OH_CryptoDigest *ctx) Obtains the digest algorithm.
void OH_DigestCrypto_Destroy (OH_CryptoDigest *ctx) Destroys an MD instance.

Type Description

[h2]OH_CryptoDigest

typedef struct OH_CryptoDigestOH_CryptoDigest

Description

Defines an MD.

Since: 12

Function Description

[h2]OH_CryptoDigest_Create()

OH_Crypto_ErrCode OH_CryptoDigest_Create (const char *algoName, OH_CryptoDigest **ctx )

Description

Creates an MD instance based on the given algorithm name.

Since: 12

Parameters

Name Description
algoName Pointer to the algorithm used to generate the MD instance. For example, 'SHA256'.
ctx Pointer to the MD 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.

[h2]OH_CryptoDigest_Final()

OH_Crypto_ErrCode OH_CryptoDigest_Final (OH_CryptoDigest *ctx, Crypto_DataBlob *out )

Description

Generates an MD.

Since: 12

Parameters

Name Description
ctx Pointer to the MD instance.
out Pointer to the MD generated.

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_CryptoDigest_Update

[h2]OH_CryptoDigest_GetAlgoName()

const char* OH_CryptoDigest_GetAlgoName (OH_CryptoDigest *ctx)

Description

Obtains the digest algorithm.

Since: 12

Parameters

Name Description
ctx Pointer to the MD instance.

Returns

MD algorithm obtained.

[h2]OH_CryptoDigest_GetLength()

uint32_t OH_CryptoDigest_GetLength (OH_CryptoDigest *ctx)

Description

Obtains the length of an MD.

Since: 12

Parameters

Name Description
ctx Pointer to the MD instance.

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.

[h2]OH_CryptoDigest_Update()

OH_Crypto_ErrCode OH_CryptoDigest_Update (OH_CryptoDigest *ctx, Crypto_DataBlob *in )

Description

Updates the data used for generating an MD.

Since: 12

Parameters

Name Description
ctx Pointer to the MD 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_CryptoDigest_Final

[h2]OH_DigestCrypto_Destroy()

void OH_DigestCrypto_Destroy (OH_CryptoDigest *ctx)

Description

Destroys an MD instance.

Since: 12

Parameters

Name Description
ctx Pointer to the MD instance.

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.