![]() |
API参考
|
Certificate related interfaces to be registered 更多...
类 | |
| struct | HITLS_CERT_MgrMethod |
| Structure for certificate management methods 更多... | |
| struct | HITLS_CRYPT_BaseMethod |
| Callback function that must be registered 更多... | |
类型定义 | |
| typedef HITLS_CERT_Store *(* | CERT_StoreNewCallBack) (void) |
| Create a certificate store | |
| typedef HITLS_CERT_Store *(* | CERT_StoreDupCallBack) (HITLS_CERT_Store *store) |
| Duplicate the certificate store. | |
| typedef void(* | CERT_StoreFreeCallBack) (HITLS_CERT_Store *store) |
| Release the certificate store. | |
| typedef int32_t(* | CERT_StoreCtrlCallBack) (HITLS_Config *config, HITLS_CERT_Store *store, HITLS_CERT_CtrlCmd cmd, void *input, void *output) |
| ctrl interface | |
| typedef int32_t(* | CERT_BuildCertChainCallBack) (HITLS_Config *config, HITLS_CERT_Store *store, HITLS_CERT_X509 *cert, HITLS_CERT_X509 **certList, uint32_t *num) |
| Create a certificate chain based on the device certificate in use. | |
| typedef int32_t(* | CERT_VerifyCertChainCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Store *store, HITLS_CERT_X509 **certList, uint32_t num) |
| Verify the certificate chain | |
| typedef int32_t(* | CERT_CertEncodeCallBack) (HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, uint8_t *buf, uint32_t len, uint32_t *usedLen) |
| Encode the certificate in ASN.1 DER format. | |
| typedef HITLS_CERT_X509 *(* | CERT_CertParseCallBack) (HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, HITLS_ParseFormat format) |
| Read the certificate. | |
| typedef HITLS_CERT_X509 *(* | CERT_CertDupCallBack) (HITLS_CERT_X509 *cert) |
| Duplicate the certificate. | |
| typedef HITLS_CERT_X509 *(* | CERT_CertRefCallBack) (HITLS_CERT_X509 *cert) |
| Certificate reference counting plus one. | |
| typedef void(* | CERT_CertFreeCallBack) (HITLS_CERT_X509 *cert) |
| Release the certificate. | |
| typedef int32_t(* | CERT_CertCtrlCallBack) (HITLS_Config *config, HITLS_CERT_X509 *cert, HITLS_CERT_CtrlCmd cmd, void *input, void *output) |
| Ctrl interface | |
| typedef HITLS_CERT_Key *(* | CERT_KeyParseCallBack) (HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, HITLS_ParseFormat format) |
| Read the certificate key. | |
| typedef HITLS_CERT_Key *(* | CERT_KeyDupCallBack) (HITLS_CERT_Key *key) |
| Duplicate the certificate key. | |
| typedef void(* | CERT_KeyFreeCallBack) (HITLS_CERT_Key *key) |
| Release the certificate key. | |
| typedef int32_t(* | CERT_KeyCtrlCallBack) (HITLS_Config *config, HITLS_CERT_Key *key, HITLS_CERT_CtrlCmd cmd, void *input, void *output) |
| Ctrl interface | |
| typedef int32_t(* | CERT_CreateSignCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, HITLS_SignAlgo signAlgo, HITLS_HashAlgo hashAlgo, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen) |
| Signature | |
| typedef int32_t(* | CERT_VerifySignCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, HITLS_SignAlgo signAlgo, HITLS_HashAlgo hashAlgo, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen) |
| Signature verification | |
| typedef int32_t(* | CERT_EncryptCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| Encrypted by the certificate public key. | |
| typedef int32_t(* | CERT_DecryptCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| Use the certificate private key to decrypt the data. | |
| typedef int32_t(* | CERT_CheckPrivateKeyCallBack) (HITLS_Config *config, HITLS_CERT_X509 *cert, HITLS_CERT_Key *key) |
| Check whether the private key matches the certificate. | |
函数 | |
| int32_t | SAL_CERT_KeyEncrypt (HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| Encrypted by the certificate public key, which is used for the RSA cipher suite. | |
| int32_t | SAL_CERT_KeyDecrypt (HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| Use the certificate private key to decrypt, which is used for the RSA cipher suite. | |
| uint8_t * | SAL_CERT_SrvrGmEncodeEncCert (HITLS_Ctx *ctx, uint32_t *useLen) |
| Encoded content of the TLCP encryption certificate obtained by the server. | |
| uint8_t * | SAL_CERT_ClntGmEncodeEncCert (HITLS_Ctx *ctx, CERT_Pair *peerCert, uint32_t *useLen) |
| The client obtains the encoded content of the TLCP encryption certificate. | |
| bool | SAL_CERT_CheckCertKeyUsage (HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, HITLS_CERT_CtrlCmd keyusage) |
| Check whether the certificate is an encrypted certificate, a digital signature, or a permission to issue the certificate. | |
| int32_t | SAL_CERT_CheckKeySecbits (HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, HITLS_CERT_Key *key) |
| Check the secbits of key | |
| int32_t | HITLS_CERT_RegisterMgrMethod (HITLS_CERT_MgrMethod *method) |
| Callback function related to certificate registration | |
| void | HITLS_CERT_DeinitMgrMethod (void) |
| Certificate deregistration callback function | |
| int32_t | HITLS_CFG_SetCheckPriKeyCb (HITLS_Config *config, CERT_CheckPrivateKeyCallBack checkPrivateKey) |
| Register the private key with the config file and certificate matching Check Interface. | |
| CERT_CheckPrivateKeyCallBack | HITLS_CFG_GetCheckPriKeyCb (HITLS_Config *config) |
| Interface for obtaining the registered private key and certificate matching check | |
| HITLS_CERT_MgrMethod * | HITLS_CERT_GetMgrMethod (void) |
| Get certificate callback function | |
Certificate related interfaces to be registered
| typedef int32_t(* CERT_BuildCertChainCallBack) (HITLS_Config *config, HITLS_CERT_Store *store, HITLS_CERT_X509 *cert, HITLS_CERT_X509 **certList, uint32_t *num) |
Create a certificate chain based on the device certificate in use.
| config | [IN] TLS link configuration |
| store | [IN] Certificate store |
| cert | [IN] Device certificate |
| certList | [OUT] Certificate chain, which is a pointer array. Each element indicates a certificate. The first element is the device certificate. |
| num | [IN/OUT] IN: maximum length of the certificate chain OUT: length of the certificate chain |
| typedef int32_t(* CERT_CertCtrlCallBack) (HITLS_Config *config, HITLS_CERT_X509 *cert, HITLS_CERT_CtrlCmd cmd, void *input, void *output) |
Ctrl interface
| config | [IN] TLS link configuration |
| cert | [IN] Certificate |
| cmd | [IN] Ctrl option |
| input | [IN] Input |
| output | [IN] Output |
| typedef HITLS_CERT_X509 *(* CERT_CertDupCallBack) (HITLS_CERT_X509 *cert) |
Duplicate the certificate.
| cert | [IN] Certificate |
| typedef int32_t(* CERT_CertEncodeCallBack) (HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, uint8_t *buf, uint32_t len, uint32_t *usedLen) |
Encode the certificate in ASN.1 DER format.
| ctx | [IN] TLS link object. |
| cert | [IN] Certificate. |
| buf | [OUT] Certificate encoding data. |
| len | [IN] Maximum encoding length. |
| usedLen | [OUT] Actual encoding length. |
| typedef void(* CERT_CertFreeCallBack) (HITLS_CERT_X509 *cert) |
Release the certificate.
| cert | [IN] Certificate |
| typedef HITLS_CERT_X509 *(* CERT_CertParseCallBack) (HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, HITLS_ParseFormat format) |
Read the certificate.
| config | [IN] TLS link configuration, which can be used to obtain the passwd callback. |
| buf | [IN] Certificate data. |
| len | [IN] Certificate data length. |
| type | [IN] Parsing type. |
| format | [IN] Data format. |
| typedef HITLS_CERT_X509 *(* CERT_CertRefCallBack) (HITLS_CERT_X509 *cert) |
Certificate reference counting plus one.
| cert | [IN] Certificate |
| typedef int32_t(* CERT_CheckPrivateKeyCallBack) (HITLS_Config *config, HITLS_CERT_X509 *cert, HITLS_CERT_Key *key) |
Check whether the private key matches the certificate.
| config | [IN] TLS link configuration. |
| cert | [IN] Certificate. |
| key | [IN] Private key. |
| typedef int32_t(* CERT_CreateSignCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, HITLS_SignAlgo signAlgo, HITLS_HashAlgo hashAlgo, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen) |
Signature
| ctx | [IN] TLS link object |
| key | [IN] Certificate private key |
| signAlgo | [IN] Signature algorithm |
| hashAlgo | [IN] Hash algorithm |
| data | [IN] Data to be signed |
| dataLen | [IN] Data length |
| sign | [OUT] Signature |
| signLen | [IN/OUT] IN: maximum signature length OUT: actual signature length |
| typedef int32_t(* CERT_DecryptCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
Use the certificate private key to decrypt the data.
| ctx | [IN] TLS link object. |
| key | [IN] Certificate private key. |
| in | [IN] Ciphertext. |
| inLen | [IN] Ciphertext length. |
| out | [OUT] Plaintext. |
| outLen | [IN/OUT] IN: maximum plaintext length OUT: actual plaintext length. |
| typedef int32_t(* CERT_EncryptCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
Encrypted by the certificate public key.
| ctx | [IN] TLS link object. |
| key | [IN] Certificate public key. |
| in | [IN] Plaintext. |
| inLen | [IN] Plaintext length. |
| out | [OUT] Ciphertext. |
| outLen | [IN/OUT] IN: maximum ciphertext length OUT: actual ciphertext length. |
| typedef int32_t(* CERT_KeyCtrlCallBack) (HITLS_Config *config, HITLS_CERT_Key *key, HITLS_CERT_CtrlCmd cmd, void *input, void *output) |
Ctrl interface
| config | [IN] TLS link configuration. |
| key | [IN] Certificate key. |
| cmd | [IN] Ctrl option. |
| input | [IN] Input. |
| output | [IN] Output. |
| typedef HITLS_CERT_Key *(* CERT_KeyDupCallBack) (HITLS_CERT_Key *key) |
Duplicate the certificate key.
| key | [IN] Certificate key |
| typedef void(* CERT_KeyFreeCallBack) (HITLS_CERT_Key *key) |
Release the certificate key.
| key | [IN] Certificate key |
| typedef HITLS_CERT_Key *(* CERT_KeyParseCallBack) (HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, HITLS_ParseFormat format) |
Read the certificate key.
| config | [IN] LTS link configuration, which can be used to obtain the passwd callback. |
| buf | [IN] Private key data |
| len | [IN] Data length |
| type | [IN] Parsing type |
| format | [IN] Data format |
| typedef int32_t(* CERT_StoreCtrlCallBack) (HITLS_Config *config, HITLS_CERT_Store *store, HITLS_CERT_CtrlCmd cmd, void *input, void *output) |
ctrl interface
| config | [IN] TLS link configuration. |
| store | [IN] Certificate store. |
| cmd | [IN] Ctrl option. |
| input | [IN] Input. |
| output | [IN] Output. |
| typedef HITLS_CERT_Store *(* CERT_StoreDupCallBack) (HITLS_CERT_Store *store) |
Duplicate the certificate store.
| store | [IN] Certificate store. |
| typedef void(* CERT_StoreFreeCallBack) (HITLS_CERT_Store *store) |
Release the certificate store.
| store | [IN] Certificate store. |
| typedef HITLS_CERT_Store *(* CERT_StoreNewCallBack) (void) |
Create a certificate store
| void |
| typedef int32_t(* CERT_VerifyCertChainCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Store *store, HITLS_CERT_X509 **certList, uint32_t num) |
Verify the certificate chain
| ctx | [IN] TLS link object |
| store | [IN] Certificate store. |
| certList | [IN] Certificate chain, a pointer array, each element indicates a certificate. The first element indicates the device certificate. |
| num | [IN] Certificate chain length. |
| typedef int32_t(* CERT_VerifySignCallBack) (HITLS_Ctx *ctx, HITLS_CERT_Key *key, HITLS_SignAlgo signAlgo, HITLS_HashAlgo hashAlgo, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen) |
Signature verification
| ctx | [IN] TLS link object |
| key | [IN] Certificate public key |
| signAlgo | [IN] Signature algorithm |
| hashAlgo | [IN] Hash algorithm |
| data | [IN] Data to be signed |
| dataLen | [IN] Data length |
| sign | [IN] Signature |
| signLen | [IN] Signature length |
| void HITLS_CERT_DeinitMgrMethod | ( | void | ) |
Certificate deregistration callback function
| method | [IN] Callback function |
| HITLS_CERT_MgrMethod * HITLS_CERT_GetMgrMethod | ( | void | ) |
Get certificate callback function
| int32_t HITLS_CERT_RegisterMgrMethod | ( | HITLS_CERT_MgrMethod * | method | ) |
Callback function related to certificate registration
| method | [IN] Callback function |
| HITLS_SUCCESS,succeeded. | |
| HITLS_NULL_INPUT,the | callback function is NULL. |
| CERT_CheckPrivateKeyCallBack HITLS_CFG_GetCheckPriKeyCb | ( | HITLS_Config * | config | ) |
Interface for obtaining the registered private key and certificate matching check
| config | [IN] Config context |
| The | interface for checking whether the registered private key matches the certificate is returned. If the registered private key does not match the certificate, NULL is returned. |
| int32_t HITLS_CFG_SetCheckPriKeyCb | ( | HITLS_Config * | config, |
| CERT_CheckPrivateKeyCallBack | checkPrivateKey ) |
Register the private key with the config file and certificate matching Check Interface.
| config | [IN/OUT] Config context |
| checkPrivateKey | [IN] API registration |
| HITLS_SUCCESS. | |
| For | other error codes, see hitls_error.h. |
| bool SAL_CERT_CheckCertKeyUsage | ( | HITLS_Ctx * | ctx, |
| HITLS_CERT_X509 * | cert, | ||
| HITLS_CERT_CtrlCmd | keyusage ) |
Check whether the certificate is an encrypted certificate, a digital signature, or a permission to issue the certificate.
| ctx | [IN] tls Context |
| cert | [IN] Certificate to be verified |
| true | indicates that is the encryption certificate. |
| int32_t SAL_CERT_CheckKeySecbits | ( | HITLS_Ctx * | ctx, |
| HITLS_CERT_X509 * | cert, | ||
| HITLS_CERT_Key * | key ) |
Check the secbits of key
| ctx | [IN] tls Context |
| cert | [IN] Certificate |
| key | [IN] key |
| HITLS_SUCCESS | succeeded. |
| For | other error codes, see hitls_error.h. |
The client obtains the encoded content of the TLCP encryption certificate.
| ctx | [IN] tls Context |
| peerCert | [IN] Peer certificate information |
| outLen | [OUT] OUT: length after encoding |
| Encoded | content |
| int32_t SAL_CERT_KeyDecrypt | ( | HITLS_Ctx * | ctx, |
| HITLS_CERT_Key * | key, | ||
| const uint8_t * | in, | ||
| uint32_t | inLen, | ||
| uint8_t * | out, | ||
| uint32_t * | outLen ) |
Use the certificate private key to decrypt, which is used for the RSA cipher suite.
| ctx | [IN] tls Context |
| key | [IN] Certificate private key |
| in | [IN] Ciphertext |
| inLen | [IN] length of ciphertext |
| out | [IN] Plaintext |
| outLen | [IN/OUT] IN: Maximum length of plaintext padding. OUT: Plaintext length |
| HITLS_SUCCESS | succeeded |
| int32_t SAL_CERT_KeyEncrypt | ( | HITLS_Ctx * | ctx, |
| HITLS_CERT_Key * | key, | ||
| const uint8_t * | in, | ||
| uint32_t | inLen, | ||
| uint8_t * | out, | ||
| uint32_t * | outLen ) |
Encrypted by the certificate public key, which is used for the RSA cipher suite.
| ctx | [IN] tls Context |
| key | [IN] Certificate public key |
| in | [IN] Plaintext |
| inLen | [IN] length of plaintext |
| out | [IN] Ciphertext |
| outLen | [IN/OUT] IN: Maximum length of the ciphertext padding. OUT: Length of the ciphertext |
| HITLS_SUCCESS | succeeded |
| uint8_t * SAL_CERT_SrvrGmEncodeEncCert | ( | HITLS_Ctx * | ctx, |
| uint32_t * | useLen ) |
Encoded content of the TLCP encryption certificate obtained by the server.
| ctx | [IN] tls Context |
| outLen | [OUT] OUT: length after encoding |
| Encoded | content |