* This file is part of the openHiTLS project.
*
* openHiTLS is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#ifndef RECV_COMMON_H
#define RECV_COMMON_H
#include <stdint.h>
#include "tls.h"
#include "cipher_suite.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
CERT_Type certType;
uint16_t *signSchemeList;
uint32_t signSchemeNum;
uint16_t *ellipticCurveList;
uint32_t ellipticCurveNum;
uint8_t *ecPointFormatList;
uint32_t ecPointFormatNum;
HITLS_TrustedCAList *caList;
} CERT_ExpectInfo;
* @brief Check the certificate information.
*
* @param ctx [IN] TLS context
* @param expectCertInfo [IN] Expected certificate information
* @param cert [IN] Certificate
* @param isNegotiateSignAlgo [IN] Indicates whether to select the signature algorithm used in handshake messages.
* @param signCheck [IN] Indicates whether to check the certificate signature information.
*
* @retval HITLS_SUCCESS succeeded.
* @retval HITLS_UNREGISTERED_CALLBACK No callback is set.
* @retval HITLS_CERT_CTRL_ERR_GET_PUB_KEY Failed to obtain the public key.
* @retval HITLS_CERT_KEY_CTRL_ERR_GET_TYPE Failed to obtain the public key type.
* @retval HITLS_CERT_ERR_UNSUPPORT_CERT_TYPE The certificate type does not match.
* @retval HITLS_CERT_ERR_NO_SIGN_SCHEME_MATCH signature algorithm mismatch
* @retval HITLS_CERT_ERR_NO_CURVE_MATCH elliptic curve mismatch
* @retval HITLS_CERT_ERR_NO_POINT_FORMAT_MATCH Point format mismatch
*/
int32_t HS_CheckCertInfo(HITLS_Ctx *ctx, const CERT_ExpectInfo *expectCertInfo, HITLS_CERT_X509 *cert,
bool isNegotiateSignAlgo, bool signCheck);
* @brief Select the certificate chain to be sent to the peer end.
*
* @param ctx [IN] tls Context
* @param info [IN] Expected certificate information
*
* @retval HITLS_SUCCESS succeeded.
* @retval HITLS_UNREGISTERED_CALLBACK No callback is set.
* @retval HITLS_CERT_ERR_SELECT_CERTIFICATE Failed to select the certificate.
*/
int32_t HS_SelectCertByInfo(HITLS_Ctx *ctx, CERT_ExpectInfo *info);
CERT_Type CertKeyType2CertType(HITLS_CERT_KeyType keyType);
#ifdef __cplusplus
}
#endif
#endif