Commit 35be3bee authored by johan's avatar johan
Browse files

Add API to get availables key exchange algorithms

parent 4c02d8cf
/* /*
crypto.h crypto.h
Copyright (C) 2016 Belledonne Communications SARL Copyright (C) 2017 Belledonne Communications SARL
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
...@@ -21,12 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -21,12 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <bctoolbox/port.h> #include <bctoolbox/port.h>
/* DHM settings defines */ /* key agreements settings defines */
#define BCTBX_DHM_UNSET 0 /* Each algo is defined as a bit toggled in a 32 bits integer,
#define BCTBX_DHM_2048 1 * so we can easily ask for all availables ones
#define BCTBX_DHM_3072 2 */
#define BCTBX_ECDH_X25519 3 #define BCTBX_DHM_UNSET 0x00000000
#define BCTBX_ECDH_X448 4 #define BCTBX_DHM_2048 0x00000001
#define BCTBX_DHM_3072 0x00000002
#define BCTBX_ECDH_X25519 0x00000004
#define BCTBX_ECDH_X448 0x00000008
/* EdDSA defines */ /* EdDSA defines */
#define BCTBX_EDDSA_UNSET 0 #define BCTBX_EDDSA_UNSET 0
...@@ -484,6 +487,16 @@ BCTBX_PUBLIC int32_t bctbx_ssl_config_set_dtls_srtp_protection_profiles(bctbx_ss ...@@ -484,6 +487,16 @@ BCTBX_PUBLIC int32_t bctbx_ssl_config_set_dtls_srtp_protection_profiles(bctbx_ss
BCTBX_PUBLIC int32_t bctbx_ssl_get_dtls_srtp_key_material(bctbx_ssl_context_t *ssl_ctx, char *output, size_t *output_length); BCTBX_PUBLIC int32_t bctbx_ssl_get_dtls_srtp_key_material(bctbx_ssl_context_t *ssl_ctx, char *output, size_t *output_length);
BCTBX_PUBLIC uint8_t bctbx_dtls_srtp_supported(void); BCTBX_PUBLIC uint8_t bctbx_dtls_srtp_supported(void);
/*****************************************************************************/
/***** Key exchanges defined algorithms *****/
/*****************************************************************************/
/**
* @brief Return a 32 bits unsigned integer, each bit set to one matches an
* available key agreement algorithm as defined in bctoolbox/include/crypto.h
*
* @return An unsigned integer of 32 flags matching key agreement algos
*/
BCTBX_PUBLIC uint32_t bctbx_key_agreement_algo_list(void);
/*****************************************************************************/ /*****************************************************************************/
/***** Diffie-Hellman-Merkle key exchange *****/ /***** Diffie-Hellman-Merkle key exchange *****/
......
...@@ -33,6 +33,19 @@ int bctbx_crypto_have_ecc(void) { ...@@ -33,6 +33,19 @@ int bctbx_crypto_have_ecc(void) {
return TRUE; return TRUE;
} }
/**
* @brief Return a 32 bits unsigned integer, each bit set to one matches an
* available key agreement algorithm as defined in bctoolbox/include/crypto.h
*
* This function is implemented in ecc.c as all other backend crypto libraries
* (polarssl-1.2, polarssl-1.3/1.4, mbedtls implement DHM2048 and DHM3072
*
* @return An unsigned integer of 32 flags matching key agreement algos
*/
uint32_t bctbx_key_agreement_algo_list(void) {
return BCTBX_DHM_2048|BCTBX_DHM_3072|BCTBX_ECDH_X25519|BCTBX_ECDH_X448;
}
/*****************************************************************************/ /*****************************************************************************/
/*** Elliptic Curve Diffie-Hellman - ECDH ***/ /*** Elliptic Curve Diffie-Hellman - ECDH ***/
/*****************************************************************************/ /*****************************************************************************/
...@@ -439,6 +452,13 @@ void bctbx_EDDSA_ECDH_publicKeyConversion(const bctbx_EDDSAContext_t *ed, bctbx_ ...@@ -439,6 +452,13 @@ void bctbx_EDDSA_ECDH_publicKeyConversion(const bctbx_EDDSAContext_t *ed, bctbx_
} }
#else /* HAVE_DECAF */ #else /* HAVE_DECAF */
/* This function is implemented in ecc.c as all other backend crypto libraries
* (polarssl-1.2, polarssl-1.3/1.4, mbedtls implement DHM2048 and DHM3072
*/
uint32_t bctbx_key_agreement_algo_list(void) {
return BCTBX_DHM_2048|BCTBX_DHM_3072;
}
/* We do not have lib decaf, implement empty stubs */ /* We do not have lib decaf, implement empty stubs */
int bctbx_crypto_have_ecc(void) { return FALSE;} int bctbx_crypto_have_ecc(void) { return FALSE;}
bctbx_ECDHContext_t *bctbx_CreateECDHContext(uint8_t ECDHAlgo) {return NULL;} bctbx_ECDHContext_t *bctbx_CreateECDHContext(uint8_t ECDHAlgo) {return NULL;}
......
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