Rate This Document
Findability
Accuracy
Completeness
Readability

initTeeCtx

Registers the communication callback and node information configured in dgCfg with KCAL and initializes the KCAL context.

int initTeeCtx(
     DG_Cfg dgCfg, 
     DG_TeeCtx **dgTeeCtx
)

Parameters

Parameter

Description

Value Range

Input/Output

dgCfg

KCAL configuration

Depends on dgCfg configured in section DataGuard APIs for Configuring an Operation Set.

Input

dgTeeCtx

KCAL context

It is null as a single pointer and cannot be null as a double pointer.

Output

Return Values

  • Success: 0 is returned.
  • Failure: The error code is returned.

Error Codes

Error Code

Value

Description

Remarks

DG_SUCCESS

0

Success

-

DG_ERR_MALLOC_FAIL

51

Failed to allocate memory.

-

DG_ERR_MPC_TEE_INVALID_PARAM

4501

Failed to verify the parameters.

dgCfg is null or the dgTeeCtx double pointer is null.

DG_ERR_MPC_TEE_NODEID_NOT_SET

4506

The node ID is not set.

Each node needs to set its node information.

DG_ERR_MPC_TEE_NET_API_CALLBACK_NOT_SET

4507

The network send or receive function is not registered.

The communication callback is registered by the product.

DG_ERR_MPC_TEE_FXP_BITS_NOT_SET

4509

The number of fractional bits is not set.

-

DG_ERR_MPC_TEE_INVALID_CPUID

4511

The CPU ID is invalid.

The cryptographic computing feature can run only on servers with the Kunpeng 920 or new Kunpeng 920 model.

Dependency

  • This API depends on the KCAL configuration in section 3.1, and the configured dgCfg is used as the input parameter of this API.
  • pirOpts depends on the successful initialization in section 3.4.1 of the function group for the PIR operator.
  • #include "data_guard_mpc.h": required header file

Example

#include  "data_guard_mpc.h" 

     struct DG_TeeCtx *dgTee = NULL;
 
    // pirOpts is the result of the successful DG_InitPirOpts call, and teeCfg is the KCAL configuration initialized in "DataGuard APIs for Configuring an Operation Set".
int rv = pirOpts.initTeeCtx(teeCfg, &dgTee);
    if (rv != 0) {
        return rv;
}

Running result: rv is 0.

Call the initTeeCtx API using the pirOpts output of the successful DG_InitPirOpts call.