get_cipher fixes
This commit is contained in:
parent
aaf4e74453
commit
87564bdffe
@ -153,14 +153,6 @@
|
||||
|
||||
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);
|
||||
const char* GetCipherName(int);
|
||||
|
||||
/* 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
|
||||
|
||||
@ -2220,6 +2212,12 @@ CYASSL_LOCAL void FreeX509(CYASSL_X509*);
|
||||
CYASSL_LOCAL int CopyDecodedToX509(CYASSL_X509*, DecodedCert*);
|
||||
#endif
|
||||
|
||||
/* used by ssl.c and cyassl_int.c */
|
||||
CYASSL_LOCAL void c32to24(word32 in, word24 out);
|
||||
|
||||
CYASSL_LOCAL const char* const* GetCipherNames(void);
|
||||
CYASSL_LOCAL int GetCipherNamesSize(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -8290,17 +8290,15 @@ const char* const* GetCipherNames(void)
|
||||
{
|
||||
return cipher_names;
|
||||
}
|
||||
/* returns the cipher at the specified index of cipher_names */
|
||||
const char* GetCipherName(int index)
|
||||
{
|
||||
return cipher_names[index];
|
||||
}
|
||||
|
||||
|
||||
/* returns the size of the cipher_names array */
|
||||
int GetCipherNamesSize(void)
|
||||
{
|
||||
return sizeof(cipher_names) / sizeof(char*);
|
||||
return (int)(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)
|
||||
|
40
src/ssl.c
40
src/ssl.c
@ -224,31 +224,32 @@ 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;
|
||||
int totalInc = 0;
|
||||
int step = 0;
|
||||
char delim = ':';
|
||||
int size = GetCipherNamesSize();
|
||||
int i;
|
||||
|
||||
if (buf == NULL || len <= 0)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* Add each member to the buffer delimitted by a : */
|
||||
for (i = 0; i < size; i++) {
|
||||
step = (int)(XSTRLEN(ciphers[i]) + 1); /* delimiter */
|
||||
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;
|
||||
}
|
||||
if (totalInc < len) {
|
||||
XSTRNCPY(buf, ciphers[i], XSTRLEN(ciphers[i]));
|
||||
buf += XSTRLEN(ciphers[i]);
|
||||
|
||||
if (i < size - 1)
|
||||
*buf++ = delim;
|
||||
}
|
||||
else
|
||||
return BUFFER_E;
|
||||
@ -256,6 +257,7 @@ int CyaSSL_get_ciphers(char* buf, int len)
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int CyaSSL_get_fd(const CYASSL* ssl)
|
||||
{
|
||||
CYASSL_ENTER("SSL_get_fd");
|
||||
|
@ -161,6 +161,14 @@ int testsuite_test(int argc, char** argv)
|
||||
if (server_args.return_code != 0) return server_args.return_code;
|
||||
}
|
||||
|
||||
/* show ciphers */
|
||||
{
|
||||
char ciphers[1024];
|
||||
XMEMSET(ciphers, 0, sizeof(ciphers));
|
||||
CyaSSL_get_ciphers(ciphers, sizeof(ciphers)-1);
|
||||
printf("ciphers = %s\n", ciphers);
|
||||
}
|
||||
|
||||
/* validate output equals input */
|
||||
{
|
||||
byte input[SHA256_DIGEST_SIZE];
|
||||
|
Loading…
Reference in New Issue
Block a user