API参考
载入中...
搜索中...
未找到
Auth_privpass

Private Pass token interfaces. 更多...

Auth_privpass 的协作图:

类型定义

typedef struct PrivPass_Ctx HITLS_AUTH_PrivPassCtx
typedef struct PrivPass_Token HITLS_AUTH_PrivPassToken
typedef void *(* HITLS_AUTH_PrivPassNewPkeyCtx) (void *libCtx, const char *attrName, int32_t algId)
 Creates a new public/private key context for the specified algorithm.
typedef void(* HITLS_AUTH_PrivPassFreePkeyCtx) (void *pkeyCtx)
 Frees a previously allocated key context.
typedef int32_t(* HITLS_AUTH_PrivPassDigest) (void *libCtx, const char *attrName, int32_t algId, const uint8_t *input, uint32_t inputLen, uint8_t *digest, uint32_t *digestLen)
 Computes a cryptographic digest of the input data.
typedef int32_t(* HITLS_AUTH_PrivPassBlind) (void *pkeyCtx, int32_t algId, const uint8_t *data, uint32_t dataLen, uint8_t *blindedData, uint32_t *blindedDataLen)
 Blinds data using the key context and hash algorithm for blind signature protocol. The default algorithm callback implementation is supported only from RSASSA-PSS.
typedef int32_t(* HITLS_AUTH_PrivPassUnblind) (void *pkeyCtx, const uint8_t *blindedData, uint32_t blindedDataLen, uint8_t *data, uint32_t *dataLen)
 Unblinds previously blinded data to reveal the actual signature. The default algorithm callback implementation is supported only from RSASSA-PSS.
typedef int32_t(* HITLS_AUTH_PrivPassSignData) (void *pkeyCtx, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen)
 Signs data using the private key context.
typedef int32_t(* HITLS_AUTH_PrivPassVerify) (void *pkeyCtx, int32_t algId, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen)
 Verifies a signature using the public key context.
typedef int32_t(* HITLS_AUTH_PrivPassDecodePubKey) (void *libCtx, const char *attrName, uint8_t *pubKey, uint32_t pubKeyLen, void **pkeyCtx)
 Decodes a public key and gen a key ctx. The default algorithm callback implementation is supported only from a DER-encoded SubjectPublicKeyInfo (SPKI) object using the RSASSA-PSS OID.
typedef int32_t(* HITLS_AUTH_PrivPassDecodePrvKey) (void *libCtx, const char *attrName, void *param, uint8_t *prvKey, uint32_t prvKeyLen, void **pkeyCtx)
 Decodes a private key and gen a key ctx. The default algorithm callback implementation is supported only from PEM-encoded PKCS #8 unencrypted RSA issuer private key.
typedef int32_t(* HITLS_AUTH_PrivPassCheckKeyPair) (void *pubKeyCtx, void *prvKeyCtx)
 Verifies that a public/private key pair matches.
typedef int32_t(* HITLS_AUTH_PrivPassRandom) (uint8_t *buffer, uint32_t bufferLen)
 Generates random bytes.

函数

HITLS_AUTH_PrivPassCtxHITLS_AUTH_PrivPassNewCtx (int32_t protocolType)
 Create a new PrivPass context object, all library callbacks by default are setted when created.
void HITLS_AUTH_PrivPassFreeCtx (HITLS_AUTH_PrivPassCtx *ctx)
 Free a PrivPass context object.
HITLS_AUTH_PrivPassTokenHITLS_AUTH_PrivPassNewToken (int32_t tokenType)
 Create a new PrivPass token object.
void HITLS_AUTH_PrivPassFreeToken (HITLS_AUTH_PrivPassToken *object)
 Free a PrivPass token object.
int32_t HITLS_AUTH_PrivPassSetCryptCb (HITLS_AUTH_PrivPassCtx *ctx, int32_t cbType, void *cryptCb)
 Set cryptographic callback functions for the context. When setting callbacks, the input callbacks will be checked. Non-NULL callbacks will override the default callbacks.
int32_t HITLS_AUTH_PrivPassSerialization (HITLS_AUTH_PrivPassCtx *ctx, const HITLS_AUTH_PrivPassToken *object, uint8_t *buffer, uint32_t *outBuffLen)
 Serialize a PrivPass token object to binary format, If the object == NULL, outbufferlen returns the length required for serialization
int32_t HITLS_AUTH_PrivPassDeserialization (HITLS_AUTH_PrivPassCtx *ctx, int32_t tokenType, const uint8_t *buffer, uint32_t buffLen, HITLS_AUTH_PrivPassToken **object)
 Deserialize binary data into a PrivPass token object. The object needs to be freed by the caller using HITLS_AUTH_PrivPassFreeToken
int32_t HITLS_AUTH_PrivPassGenTokenChallenge (HITLS_AUTH_PrivPassCtx *ctx, const BSL_Param *param, HITLS_AUTH_PrivPassToken **challenge)
 Generate a token challenge. The challenge token is generated based on the input param. The construct of param refer to auth_params.h.
int32_t HITLS_AUTH_PrivPassGenTokenReq (HITLS_AUTH_PrivPassCtx *ctx, const HITLS_AUTH_PrivPassToken *tokenChallenge, HITLS_AUTH_PrivPassToken **tokenRequest)
 Generate a token request.
int32_t HITLS_AUTH_PrivPassGenTokenResponse (HITLS_AUTH_PrivPassCtx *ctx, const HITLS_AUTH_PrivPassToken *tokenRequest, HITLS_AUTH_PrivPassToken **tokenResponse)
 Generate a token response.
int32_t HITLS_AUTH_PrivPassGenToken (HITLS_AUTH_PrivPassCtx *ctx, const HITLS_AUTH_PrivPassToken *tokenChallenge, const HITLS_AUTH_PrivPassToken *tokenResponse, HITLS_AUTH_PrivPassToken **token)
 Generate final token.
int32_t HITLS_AUTH_PrivPassVerifyToken (HITLS_AUTH_PrivPassCtx *ctx, const HITLS_AUTH_PrivPassToken *tokenChallenge, const HITLS_AUTH_PrivPassToken *token)
 Verify the validity of a token.
int32_t HITLS_AUTH_PrivPassSetPubkey (HITLS_AUTH_PrivPassCtx *ctx, uint8_t *pki, uint32_t pkiLen)
 Set the public key for the ctx. We support the repeated setting of the public key. If the ctx contains the private key when the public key is set, we will check whether the public key matches the private key. If its not match, an exception is returned.
int32_t HITLS_AUTH_PrivPassSetPrvkey (HITLS_AUTH_PrivPassCtx *ctx, void *param, uint8_t *ski, uint32_t skiLen)
 Set the private key for the ctx. We support the repeated setting of the private key. If the ctx contains the public key when the private key is set, we will check whether the private key matches the public key. If its not match, an exception is returned.
int32_t HITLS_AUTH_PrivPassTokenCtrl (HITLS_AUTH_PrivPassToken *object, int32_t cmd, void *param, uint32_t paramLen)
 Control interface for getting/setting various parameters in token object.
int32_t HITLS_AUTH_PrivPassCtxCtrl (HITLS_AUTH_PrivPassCtx *ctx, int32_t cmd, void *param, uint32_t paramLen)
 Control interface for getting/setting various parameters in Priv-Pass Ctx.

详细描述

Private Pass token interfaces.

类型定义说明

◆ HITLS_AUTH_PrivPassBlind

typedef int32_t(* HITLS_AUTH_PrivPassBlind) (void *pkeyCtx, int32_t algId, const uint8_t *data, uint32_t dataLen, uint8_t *blindedData, uint32_t *blindedDataLen)

Blinds data using the key context and hash algorithm for blind signature protocol. The default algorithm callback implementation is supported only from RSASSA-PSS.

参数
pkeyCtx[IN] Key context
algId[IN] hash algorithm identifier
data[IN] Data to be blinded
dataLen[IN] Length of input data
blindedData[OUT] Buffer to store blinded data
blindedDataLen[IN/OUT] Size of buffer/Length of blinded data
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassCheckKeyPair

typedef int32_t(* HITLS_AUTH_PrivPassCheckKeyPair) (void *pubKeyCtx, void *prvKeyCtx)

Verifies that a public/private key pair matches.

参数
pubKeyCtx[IN] Public key context
prvKeyCtx[IN] Private key context
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassCtx

priv pass context structure.

◆ HITLS_AUTH_PrivPassDecodePrvKey

typedef int32_t(* HITLS_AUTH_PrivPassDecodePrvKey) (void *libCtx, const char *attrName, void *param, uint8_t *prvKey, uint32_t prvKeyLen, void **pkeyCtx)

Decodes a private key and gen a key ctx. The default algorithm callback implementation is supported only from PEM-encoded PKCS #8 unencrypted RSA issuer private key.

参数
libCtx[IN] Library context
attrName[IN] Specify expected attribute values
param[IN] Parameters may need by private key decoding.
prvKey[IN] A PEM-encoded PKCS #8 RSA unencrypted issuer private Key
prvKeyLen[IN] Length of private key data
pkeyCtx[OUT] Pointer to store created key context
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassDecodePubKey

typedef int32_t(* HITLS_AUTH_PrivPassDecodePubKey) (void *libCtx, const char *attrName, uint8_t *pubKey, uint32_t pubKeyLen, void **pkeyCtx)

Decodes a public key and gen a key ctx. The default algorithm callback implementation is supported only from a DER-encoded SubjectPublicKeyInfo (SPKI) object using the RSASSA-PSS OID.

参数
libCtx[IN] Library context
attrName[IN] Specify expected attribute values
pubKey[IN] A DER-encoded SubjectPublicKeyInfo (SPKI) object using the RSASSA-PSS OID
pubKeyLen[IN] Length of public key data
pkeyCtx[OUT] Pointer to store created key context
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassDigest

typedef int32_t(* HITLS_AUTH_PrivPassDigest) (void *libCtx, const char *attrName, int32_t algId, const uint8_t *input, uint32_t inputLen, uint8_t *digest, uint32_t *digestLen)

Computes a cryptographic digest of the input data.

参数
libCtx[IN] Library context
attrName[IN] Specify expected attribute values
algId[IN] Algorithm identifier, defined in HITLS_AUTH_PrivPassCryptAlgId.
input[IN] Input data to be hashed
inputLen[IN] Length of input data
digest[OUT] Buffer to store the computed digest
digestLen[IN/OUT] Size of digest buffer/Length of computed digest
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassFreePkeyCtx

typedef void(* HITLS_AUTH_PrivPassFreePkeyCtx) (void *pkeyCtx)

Frees a previously allocated key context.

参数
pkeyCtx[IN] Key context to be freed

◆ HITLS_AUTH_PrivPassNewPkeyCtx

typedef void *(* HITLS_AUTH_PrivPassNewPkeyCtx) (void *libCtx, const char *attrName, int32_t algId)

Creates a new public/private key context for the specified algorithm.

参数
libCtx[IN] Library context
attrName[IN] Specify expected attribute values
algId[IN] Algorithm identifier, defined in HITLS_AUTH_PrivPassCryptAlgId.
返回值
Pointerto the created key context. NULL, if the operation fails.

◆ HITLS_AUTH_PrivPassRandom

typedef int32_t(* HITLS_AUTH_PrivPassRandom) (uint8_t *buffer, uint32_t bufferLen)

Generates random bytes.

参数
buffer[IN] Buffer to store random bytes
bufferLen[IN] Length of buffer
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassSignData

typedef int32_t(* HITLS_AUTH_PrivPassSignData) (void *pkeyCtx, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen)

Signs data using the private key context.

参数
pkeyCtx[IN] Private key context
data[IN] Data to be signed
dataLen[IN] Length of input data
sign[OUT] Buffer to store signature
signLen[IN/OUT] Size of buffer/Length of signature
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassToken

priv pass token structure.

◆ HITLS_AUTH_PrivPassUnblind

typedef int32_t(* HITLS_AUTH_PrivPassUnblind) (void *pkeyCtx, const uint8_t *blindedData, uint32_t blindedDataLen, uint8_t *data, uint32_t *dataLen)

Unblinds previously blinded data to reveal the actual signature. The default algorithm callback implementation is supported only from RSASSA-PSS.

参数
pkeyCtx[IN] Key context
blindedData[IN] Blinded data to be unblinded
blindedDataLen[IN] Length of blinded data
data[OUT] Buffer to store unblinded data
dataLen[IN/OUT] Size of buffer/Length of unblinded data
返回值
0,ifsuccessful. other error codes, failed.

◆ HITLS_AUTH_PrivPassVerify

typedef int32_t(* HITLS_AUTH_PrivPassVerify) (void *pkeyCtx, int32_t algId, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen)

Verifies a signature using the public key context.

参数
pkeyCtx[IN] Public key context
algId[IN] hash algorithm identifier
data[IN] Original data
dataLen[IN] Length of data
sign[IN] Signature to verify
signLen[IN] Length of signature
返回值
0,ifsuccessful. other error codes, failed.

函数说明

◆ HITLS_AUTH_PrivPassCtxCtrl()

int32_t HITLS_AUTH_PrivPassCtxCtrl ( HITLS_AUTH_PrivPassCtx * ctx,
int32_t cmd,
void * param,
uint32_t paramLen )

Control interface for getting/setting various parameters in Priv-Pass Ctx.

参数
ctx[IN] PrivPass context
cmd[IN] Command to execute, defined in HITLS_AUTH_PrivPassCmd
param[IN/OUT] Command parameters
paramLen[IN] Length of parameters
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassDeserialization()

int32_t HITLS_AUTH_PrivPassDeserialization ( HITLS_AUTH_PrivPassCtx * ctx,
int32_t tokenType,
const uint8_t * buffer,
uint32_t buffLen,
HITLS_AUTH_PrivPassToken ** object )

Deserialize binary data into a PrivPass token object. The object needs to be freed by the caller using HITLS_AUTH_PrivPassFreeToken

参数
ctx[IN] PrivPass context
tokenType[IN] Expected token type
buffer[IN] Serialized data buffer
buffLen[IN] Length of serialized data
object[OUT] Pointer to store deserialized token
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassFreeCtx()

void HITLS_AUTH_PrivPassFreeCtx ( HITLS_AUTH_PrivPassCtx * ctx)

Free a PrivPass context object.

参数
ctx[IN] Context to be freed

◆ HITLS_AUTH_PrivPassFreeToken()

void HITLS_AUTH_PrivPassFreeToken ( HITLS_AUTH_PrivPassToken * object)

Free a PrivPass token object.

参数
object[IN] Token to be freed

◆ HITLS_AUTH_PrivPassGenToken()

int32_t HITLS_AUTH_PrivPassGenToken ( HITLS_AUTH_PrivPassCtx * ctx,
const HITLS_AUTH_PrivPassToken * tokenChallenge,
const HITLS_AUTH_PrivPassToken * tokenResponse,
HITLS_AUTH_PrivPassToken ** token )

Generate final token.

参数
ctx[IN] PrivPass context
tokenChallenge[IN] Challenge token
tokenResponse[IN] Response token
token[OUT] Generated final token
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassGenTokenChallenge()

int32_t HITLS_AUTH_PrivPassGenTokenChallenge ( HITLS_AUTH_PrivPassCtx * ctx,
const BSL_Param * param,
HITLS_AUTH_PrivPassToken ** challenge )

Generate a token challenge. The challenge token is generated based on the input param. The construct of param refer to auth_params.h.

参数
ctx[IN] PrivPass context
param[IN] Parameters for challenge generation, the param is limited to the library specification, the argument passed by the caller should ensure that the serialized length cannot exceed the upper limit. The tokenType, issuerName, redemption must be contained in the param, and originalInfo can be NULL.
challenge[OUT] Generated challenge token
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassGenTokenReq()

int32_t HITLS_AUTH_PrivPassGenTokenReq ( HITLS_AUTH_PrivPassCtx * ctx,
const HITLS_AUTH_PrivPassToken * tokenChallenge,
HITLS_AUTH_PrivPassToken ** tokenRequest )

Generate a token request.

参数
ctx[IN] PrivPass context
tokenChallenge[IN] Challenge token
tokenRequest[OUT] Generated request token
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassGenTokenResponse()

int32_t HITLS_AUTH_PrivPassGenTokenResponse ( HITLS_AUTH_PrivPassCtx * ctx,
const HITLS_AUTH_PrivPassToken * tokenRequest,
HITLS_AUTH_PrivPassToken ** tokenResponse )

Generate a token response.

参数
ctx[IN] PrivPass context
tokenRequest[IN] Request token
tokenResponse[OUT] Generated response token
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassNewCtx()

HITLS_AUTH_PrivPassCtx * HITLS_AUTH_PrivPassNewCtx ( int32_t protocolType)

Create a new PrivPass context object, all library callbacks by default are setted when created.

参数
tokenType[IN] Type of token to create, defined in HITLS_AUTH_PrivPassTokenType.
返回值
HITLS_AUTH_PrivPassCtxpointer. NULL, if the operation fails.

◆ HITLS_AUTH_PrivPassNewToken()

HITLS_AUTH_PrivPassToken * HITLS_AUTH_PrivPassNewToken ( int32_t tokenType)

Create a new PrivPass token object.

参数
tokenType[IN] Type of token to create, defined in HITLS_AUTH_PrivPassTokenType.
返回值
HITLS_AUTH_PrivPassTokenpointer. NULL, if the operation fails.

◆ HITLS_AUTH_PrivPassSerialization()

int32_t HITLS_AUTH_PrivPassSerialization ( HITLS_AUTH_PrivPassCtx * ctx,
const HITLS_AUTH_PrivPassToken * object,
uint8_t * buffer,
uint32_t * outBuffLen )

Serialize a PrivPass token object to binary format, If the object == NULL, outbufferlen returns the length required for serialization

参数
ctx[IN] PrivPass context
object[IN] Token to serialize
buffer[OUT] Buffer to store serialized data
outBuffLen[IN/OUT] Length of the serialized data
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassSetCryptCb()

int32_t HITLS_AUTH_PrivPassSetCryptCb ( HITLS_AUTH_PrivPassCtx * ctx,
int32_t cbType,
void * cryptCb )

Set cryptographic callback functions for the context. When setting callbacks, the input callbacks will be checked. Non-NULL callbacks will override the default callbacks.

参数
ctx[IN/OUT] PrivPass context
cbType[IN] Callback type, defined in PrivPassCryptCbType
cryptCb[IN] Callback functions to be set
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassSetPrvkey()

int32_t HITLS_AUTH_PrivPassSetPrvkey ( HITLS_AUTH_PrivPassCtx * ctx,
void * param,
uint8_t * ski,
uint32_t skiLen )

Set the private key for the ctx. We support the repeated setting of the private key. If the ctx contains the public key when the private key is set, we will check whether the private key matches the public key. If its not match, an exception is returned.

参数
ctx[IN] PrivPass context
param[IN] Parameters may need by private key decoding.
ski[IN] A PEM-encoded PKCS #8 RSA unencrypted issuer private key
skiLen[IN] Length of private key data
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassSetPubkey()

int32_t HITLS_AUTH_PrivPassSetPubkey ( HITLS_AUTH_PrivPassCtx * ctx,
uint8_t * pki,
uint32_t pkiLen )

Set the public key for the ctx. We support the repeated setting of the public key. If the ctx contains the private key when the public key is set, we will check whether the public key matches the private key. If its not match, an exception is returned.

参数
ctx[IN] PrivPass context
pki[IN] A DER-encoded SubjectPublicKeyInfo (SPKI) object using the RSASSA-PSS OID
pkiLen[IN] Length of public key data
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassTokenCtrl()

int32_t HITLS_AUTH_PrivPassTokenCtrl ( HITLS_AUTH_PrivPassToken * object,
int32_t cmd,
void * param,
uint32_t paramLen )

Control interface for getting/setting various parameters in token object.

参数
object[IN] token object
cmd[IN] Command to execute, defined in HITLS_AUTH_PrivPassCmd
param[IN/OUT] Command parameters
paramLen[IN] Length of parameters
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.

◆ HITLS_AUTH_PrivPassVerifyToken()

int32_t HITLS_AUTH_PrivPassVerifyToken ( HITLS_AUTH_PrivPassCtx * ctx,
const HITLS_AUTH_PrivPassToken * tokenChallenge,
const HITLS_AUTH_PrivPassToken * token )

Verify the validity of a token.

参数
ctx[IN] PrivPass context
tokenChallenge[IN] Challenge token
token[IN] Token to verify
返回值
#HITLS_AUTH_SUCCESS,ifsuccessful. For other error codes, see auth_errno.h.