Added CyaSSL_get_ciphers() and necessary functions
This commit is contained in:
parent
9d4fb79009
commit
bb9696c9f2
@ -156,6 +156,10 @@ typedef byte word24[3];
|
||||
/* used by ssl.c and cyassl_int.c */
|
||||
void c32to24(word32 in, word24 out);
|
||||
|
||||
/* used by ssl.c */
|
||||
const char* const* GetCipherNames(void);
|
||||
int GetCipherNamesSize(void);
|
||||
|
||||
/* Define or comment out the cipher suites you'd like to be compiled in
|
||||
make sure to use at least one BUILD_SSL_xxx or BUILD_TLS_xxx is defined
|
||||
|
||||
@ -802,7 +806,6 @@ enum Misc {
|
||||
COPY = 1 /* should we copy static buffer for write */
|
||||
};
|
||||
|
||||
|
||||
#ifdef SESSION_INDEX
|
||||
/* Shift values for making a session index */
|
||||
#define SESSIDX_ROW_SHIFT 4
|
||||
|
@ -233,6 +233,7 @@ CYASSL_API int CyaSSL_PemCertToDer(const char*, unsigned char*, int);
|
||||
CYASSL_API CYASSL_CTX* CyaSSL_CTX_new(CYASSL_METHOD*);
|
||||
CYASSL_API CYASSL* CyaSSL_new(CYASSL_CTX*);
|
||||
CYASSL_API int CyaSSL_set_fd (CYASSL*, int);
|
||||
CYASSL_API int CyaSSL_get_ciphers(char*, int);
|
||||
CYASSL_API int CyaSSL_get_fd(const CYASSL*);
|
||||
CYASSL_API void CyaSSL_set_using_nonblock(CYASSL*, int);
|
||||
CYASSL_API int CyaSSL_get_using_nonblock(CYASSL*);
|
||||
|
@ -7482,7 +7482,8 @@ void SetErrorString(int error, char* str)
|
||||
}
|
||||
|
||||
|
||||
/* be sure to add to cipher_name_idx too !!!! */
|
||||
/* be sure to add to cipher_names in
|
||||
internal.h and cipher_name_idx too !!!! */
|
||||
static const char* const cipher_names[] =
|
||||
{
|
||||
#ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA
|
||||
@ -7868,7 +7869,6 @@ static const char* const cipher_names[] =
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* cipher suite number that matches above name table */
|
||||
static int cipher_name_idx[] =
|
||||
{
|
||||
@ -8255,6 +8255,17 @@ static int cipher_name_idx[] =
|
||||
};
|
||||
|
||||
|
||||
/* returns the cipher_names array */
|
||||
const char* const* GetCipherNames(void)
|
||||
{
|
||||
return cipher_names;
|
||||
}
|
||||
/* returns the size of the cipher_names array */
|
||||
int GetCipherNamesSize(void)
|
||||
{
|
||||
return sizeof(cipher_names) / sizeof(char*);
|
||||
}
|
||||
|
||||
/* return true if set, else false */
|
||||
/* only supports full name from cipher_name[] delimited by : */
|
||||
int SetCipherList(Suites* s, const char* list)
|
||||
|
31
src/ssl.c
31
src/ssl.c
@ -29,7 +29,6 @@
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/internal.h>
|
||||
#include <cyassl/error-ssl.h>
|
||||
@ -225,7 +224,37 @@ int CyaSSL_set_fd(CYASSL* ssl, int fd)
|
||||
CYASSL_LEAVE("SSL_set_fd", SSL_SUCCESS);
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
int CyaSSL_get_ciphers(char* buf, int len)
|
||||
{
|
||||
const char* const* ciphers = GetCipherNames();
|
||||
int totalInc = 0;
|
||||
int step = 0;
|
||||
char delim = ':';
|
||||
char* tmp = buf;
|
||||
int size = GetCipherNamesSize();
|
||||
int i;
|
||||
/* Loop the array, add each member to the
|
||||
buffer delimitted by a :
|
||||
*/
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
step = strlen(ciphers[i]) + strlen(&delim)-2;
|
||||
totalInc += step;
|
||||
|
||||
/* Check to make sure buf is large enough and will not overflow */
|
||||
if(totalInc <= len) {
|
||||
memcpy(tmp, ciphers[i], strlen(ciphers[i]));
|
||||
tmp += strlen(ciphers[i]);
|
||||
if(i < size - 1) {
|
||||
memcpy(tmp, &delim, strlen(&delim)-2);
|
||||
tmp += strlen(&delim)-2;
|
||||
}
|
||||
}
|
||||
else
|
||||
return BUFFER_E;
|
||||
}
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
|
||||
int CyaSSL_get_fd(const CYASSL* ssl)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user