Commit 0013a3e1 authored by DanmeiChen's avatar DanmeiChen

add API for ciphersuite

parent 8a1d19db
......@@ -148,6 +148,11 @@ typedef enum bctbx_srtp_profile {
BCTBX_SRTP_NULL_HMAC_SHA1_32
} bctbx_dtls_srtp_profile_t;
typedef enum bctbx_type_implementation {
BCTBX_POLARSSL,
BCTBX_POLARSSL1_2,
BCTBX_MBEDTLS
} bctbx_type_implementation_t;
#ifdef __cplusplus
extern "C"{
......@@ -466,6 +471,7 @@ BCTBX_PUBLIC int32_t bctbx_x509_certificate_unset_flag(uint32_t *flags, uint32_t
/*****************************************************************************/
typedef struct bctbx_ssl_context_struct bctbx_ssl_context_t;
typedef struct bctbx_ssl_config_struct bctbx_ssl_config_t;
BCTBX_PUBLIC bctbx_type_implementation_t bctbx_ssl_get_implementation_type(void);
BCTBX_PUBLIC bctbx_ssl_context_t *bctbx_ssl_context_new(void);
BCTBX_PUBLIC void bctbx_ssl_context_free(bctbx_ssl_context_t *ssl_ctx);
BCTBX_PUBLIC int32_t bctbx_ssl_context_setup(bctbx_ssl_context_t *ssl_ctx, bctbx_ssl_config_t *ssl_config);
......@@ -482,11 +488,13 @@ BCTBX_PUBLIC void bctbx_ssl_set_io_callbacks(bctbx_ssl_context_t *ssl_ctx, void
int(*callback_recv_function)(void *, unsigned char *, size_t)); /* args: callback data, data buffer to be read, size of data buffer */
BCTBX_PUBLIC const bctbx_x509_certificate_t *bctbx_ssl_get_peer_certificate(bctbx_ssl_context_t *ssl_ctx);
BCTBX_PUBLIC const char *bctbx_ssl_get_ciphersuite(bctbx_ssl_context_t *ssl_ctx);
BCTBX_PUBLIC int bctbx_ssl_get_ciphersuite_id(const char* ciphersuite);
BCTBX_PUBLIC const char *bctbx_ssl_get_version(bctbx_ssl_context_t *ssl_ctx);
BCTBX_PUBLIC bctbx_ssl_config_t *bctbx_ssl_config_new(void);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_crypto_library_config(bctbx_ssl_config_t *ssl_config, void *internal_config);
BCTBX_PUBLIC void bctbx_ssl_config_free(bctbx_ssl_config_t *ssl_config);
BCTBX_PUBLIC void *bctbx_ssl_config_get_private_config(bctbx_ssl_config_t *ssl_config);
BCTBX_PUBLIC int32_t bctbx_ssl_config_defaults(bctbx_ssl_config_t *ssl_config, int endpoint, int transport);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_endpoint(bctbx_ssl_config_t *ssl_config, int endpoint);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_transport (bctbx_ssl_config_t *ssl_config, int transport);
......@@ -496,7 +504,8 @@ BCTBX_PUBLIC int32_t bctbx_ssl_config_set_callback_verify(bctbx_ssl_config_t *ss
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_callback_cli_cert(bctbx_ssl_config_t *ssl_config, int(*callback_function)(void *, bctbx_ssl_context_t *, unsigned char *, size_t), void *callback_data);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_ca_chain(bctbx_ssl_config_t *ssl_config, bctbx_x509_certificate_t *ca_chain);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_own_cert(bctbx_ssl_config_t *ssl_config, bctbx_x509_certificate_t *cert, bctbx_signing_key_t *key);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_ciphersuites(bctbx_ssl_config_t *ssl_config,const int *ciphersuites);
/***** DTLS-SRTP functions *****/
BCTBX_PUBLIC bctbx_dtls_srtp_profile_t bctbx_ssl_get_dtls_srtp_protection_profile(bctbx_ssl_context_t *ssl_ctx);
BCTBX_PUBLIC int32_t bctbx_ssl_config_set_dtls_srtp_protection_profiles(bctbx_ssl_config_t *ssl_config, const bctbx_dtls_srtp_profile_t *profiles, size_t profiles_number);
......
......@@ -948,6 +948,10 @@ const char *bctbx_ssl_get_ciphersuite(bctbx_ssl_context_t *ssl_ctx){
return mbedtls_ssl_get_ciphersuite(&(ssl_ctx->ssl_ctx));
}
int bctbx_ssl_get_ciphersuite_id(const char *ciphersuite){
return mbedtls_ssl_get_ciphersuite_id(ciphersuite);
}
const char *bctbx_ssl_get_version(bctbx_ssl_context_t *ssl_ctx){
return mbedtls_ssl_get_version(&(ssl_ctx->ssl_ctx));
}
......@@ -1056,6 +1060,10 @@ bctbx_ssl_config_t *bctbx_ssl_config_new(void) {
return ssl_config;
}
bctbx_type_implementation_t bctbx_ssl_get_implementation_type(void) {
return BCTBX_MBEDTLS;
}
int32_t bctbx_ssl_config_set_crypto_library_config(bctbx_ssl_config_t *ssl_config, void *internal_config) {
if (ssl_config == NULL) {
return BCTBX_ERROR_INVALID_SSL_CONFIG;
......@@ -1178,6 +1186,24 @@ int32_t bctbx_ssl_config_set_transport (bctbx_ssl_config_t *ssl_config, int tran
return 0;
}
int32_t bctbx_ssl_config_set_ciphersuites(bctbx_ssl_config_t *ssl_config, const int *ciphersuites) {
if (ssl_config == NULL) {
return BCTBX_ERROR_INVALID_SSL_CONFIG;
}
/* remap input arguments */
if (ciphersuites == NULL) {
return BCTBX_ERROR_INVALID_INPUT_DATA;
}
mbedtls_ssl_conf_ciphersuites(ssl_config->ssl_config, ciphersuites);
return 0;
}
void *bctbx_ssl_config_get_private_config(bctbx_ssl_config_t *ssl_config) {
return (void *)ssl_config->ssl_config;
}
int32_t bctbx_ssl_config_set_authmode(bctbx_ssl_config_t *ssl_config, int authmode) {
int mbedtls_authmode;
if (ssl_config == NULL) {
......
......@@ -57,6 +57,10 @@ static int bctbx_ssl_sendrecv_callback_return_remap(int32_t ret_code) {
}
}
bctbx_type_implementation_t bctbx_ssl_get_implementation_type(void) {
return BCTBX_POLARSSL;
}
void bctbx_strerror(int32_t error_code, char *buffer, size_t buffer_length) {
if (error_code>0) {
snprintf(buffer, buffer_length, "%s", "Invalid Error code");
......@@ -808,6 +812,9 @@ const char *bctbx_ssl_get_ciphersuite(bctbx_ssl_context_t *ssl_ctx){
return ssl_get_ciphersuite(&(ssl_ctx->ssl_ctx));
}
int bctbx_ssl_get_ciphersuite_id(const char *ciphersuite){
return BCTBX_ERROR_UNAVAILABLE_FUNCTION;
}
const char *bctbx_ssl_get_version(bctbx_ssl_context_t *ssl_ctx){
return ssl_get_version(&(ssl_ctx->ssl_ctx));
}
......@@ -1013,6 +1020,14 @@ int32_t bctbx_ssl_config_set_transport (bctbx_ssl_config_t *ssl_config, int tran
return 0;
}
int32_t bctbx_ssl_config_set_ciphersuites(bctbx_ssl_config_t *ssl_config, const int *ciphersuites) {
return BCTBX_ERROR_INVALID_SSL_CONFIG;
}
void *bctbx_ssl_config_get_mbedtls_config(bctbx_ssl_config_t *ssl_config) {
return BCTBX_ERROR_UNAVAILABLE_FUNCTION;
}
int32_t bctbx_ssl_config_set_authmode(bctbx_ssl_config_t *ssl_config, int authmode) {
if (ssl_config != NULL) {
switch (authmode) {
......
......@@ -57,6 +57,10 @@ static int bctbx_ssl_sendrecv_callback_return_remap(int32_t ret_code) {
}
}
bctbx_type_implementation_t bctbx_ssl_get_implementation_type(void) {
return BCTBX_POLARSSL1_2;
}
void bctbx_strerror(int32_t error_code, char *buffer, size_t buffer_length) {
if (error_code>0) {
snprintf(buffer, buffer_length, "%s", "Invalid Error code");
......@@ -569,6 +573,10 @@ const char *bctbx_ssl_get_ciphersuite(bctbx_ssl_context_t *ssl_ctx){
return ssl_get_ciphersuite(&(ssl_ctx->ssl_ctx));
}
int bctbx_ssl_get_ciphersuite_id(const char *ciphersuite){
return BCTBX_ERROR_UNAVAILABLE_FUNCTION;
}
const char *bctbx_ssl_get_version(bctbx_ssl_context_t *ssl_ctx){
return ssl_get_version(&(ssl_ctx->ssl_ctx));
}
......@@ -698,6 +706,14 @@ int32_t bctbx_ssl_config_set_transport (bctbx_ssl_config_t *ssl_config, int tran
return 0;
}
int32_t bctbx_ssl_config_set_ciphersuites(bctbx_ssl_config_t *ssl_config, const int *ciphersuites) {
return BCTBX_ERROR_INVALID_SSL_CONFIG;
}
void *bctbx_ssl_config_get_mbedtls_config(bctbx_ssl_config_t *ssl_config) {
return BCTBX_ERROR_UNAVAILABLE_FUNCTION;
}
int32_t bctbx_ssl_config_set_authmode(bctbx_ssl_config_t *ssl_config, int authmode) {
if (ssl_config != NULL) {
switch (authmode) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment