I have an IOT
device that communicates with DTLS 1.2 protocol
. We've already integrated WolfSSL into our project and it's working fine. What I want to achieve is to set only a specific cipher suite to my WolfSSL client
so that I will make sure it's using the correct encryption method.
const char *CIPHER_LIST = "PSK-AES128-CCM-8";
WOLFSSL_CTX *ctx = wolfSSL_CTX_new(wolfDTLSv1_2_client_method());
wolfSSL_CTX_set_cipher_list(ctx, CIPHER_LIST);
WOLFSSL *ssl = wolfSSL_new(ctx)
wolfSSL_set_cipher_list(ssl, CIPHER_LIST);
When I print the cipher list;
for (int i = 0; i< 50; i++) {
// print cipher list based on priority
NSLog(@"->%s", wolfSSL_get_cipher_list(i));
}
The result will be
DHE-RSA-AES128-SHA
DHE-RSA-AES256-SHA
DHE-PSK-AES256-GCM-SHA384
DHE-PSK-AES128-GCM-SHA256
PSK-AES256-GCM-SHA384
PSK-AES128-GCM-SHA256
DHE-PSK-AES256-CBC-SHA384
DHE-PSK-AES128-CBC-SHA256
PSK-AES256-CBC-SHA384
PSK-AES128-CBC-SHA256
PSK-AES128-CBC-SHA
PSK-AES256-CBC-SHA
DHE-PSK-AES128-CCM
DHE-PSK-AES256-CCM
PSK-AES128-CCM
PSK-AES256-CCM
PSK-AES128-CCM-8
PSK-AES256-CCM-8
DHE-RSA-AES128-SHA256
DHE-RSA-AES256-SHA256
DHE-RSA-AES128-GCM-SHA256
DHE-RSA-AES256-GCM-SHA384
EDH-RSA-DES-CBC3-SHA
If I call wolfSSL_get_cipher(ssl)
I got result "NONE".
The library was working fine until our IOT device's firmware was updated, then we started to get no responses from it. After I backtracked the response failures I realised that it's an SSL handshake problem and I decided to set a cipher list. I'm wondering, is there anything that I'm missing or doing wrong?
Moreover, we have also an Android application that communicates with the same device using "PSK-AES128-CCM-8" encryption method. That's why I want to set my list only this specific method.
Additionally, this is the user_settings.h for WolfSSL;
/* Configuration */
#define IPHONE /* Needed for Xcode */
#define DEBUG_WOLFSSL
#define HAVE_HASHDRBG
#define HAVE_AESGCM
#define HAVE_AESCCM
#define WOLFSSL_SHA512
#define WOLFSSL_SHA384
#define WOLFSSL_STATIC_PSK
#define WOLFSSL_DTLS
#define NO_WOLFSSL_SERVER
#ifdef HAVE_FIPS
#define NO_MD4
#define NO_HC128
#define NO_RABBIT
#define NO_DSA
#define NO_PWDBASED
#else
#define USE_FAST_MATH
#endif