src/wolfSSL/src/internal.c
int SetCipherList(Suites* suites, const char* list)
{
    int       ret          = 0;
    int       idx          = 0;
    int       haveRSAsig   = 0;
    int       haveECDSAsig = 0;
    int       haveAnon     = 0;
    const int suiteSz      = GetCipherNamesSize();
    char*     next         = (char*)list;

    if (suites == NULL || list == NULL) {
        WOLFSSL_MSG("SetCipherList parameter error");
        return 0;
    }

    if (next[0] == 0 || XSTRNCMP(next, "ALL", 3) == 0)
        return 1; /* wolfSSL defualt */

    do {
        char*  current = next;
        char   name[MAX_SUITE_NAME + 1];
        int    i;
        word32 length;

        next   = XSTRSTR(next, ":");
        length = min(sizeof(name), !next ? (word32)XSTRLEN(current) /* last */
                                         : (word32)(next - current));

        XSTRNCPY(name, current, length);
        name[(length == sizeof(name)) ? length - 1 : length] = 0;

        for (i = 0; i < suiteSz; i++) {
            if (XSTRNCMP(name, cipher_names[i], sizeof(name)) == 0) {
                suites->suites[idx++] = (XSTRSTR(name, "CHACHA")) ? CHACHA_BYTE
                                      : (XSTRSTR(name, "QSH"))    ? QSH_BYTE
                                      : (XSTRSTR(name, "EC"))     ? ECC_BYTE
                                      : (XSTRSTR(name, "CCM"))    ? ECC_BYTE
                                      : 0x00; /* normal */

                suites->suites[idx++] = (byte)cipher_name_idx[i];

                /* The suites are either ECDSA, RSA, PSK, or Anon. The RSA
                 * suites don't necessarily have RSA in the name. */
                if ((haveECDSAsig == 0) && XSTRSTR(name, "ECDSA"))
                    haveECDSAsig = 1;
                else if (XSTRSTR(name, "ADH"))
                    haveAnon = 1;
                else if ((haveRSAsig == 0) && (XSTRSTR(name, "PSK") == NULL))
                    haveRSAsig = 1;

                ret = 1; /* found at least one */
                break;
            }
        }
    }
    while (next++); /* ++ needed to skip ':' */

    if (ret) {
        suites->setSuites = 1;
        suites->suiteSz   = (word16)idx;
        InitSuitesHashSigAlgo(suites, haveECDSAsig, haveRSAsig, haveAnon);
    }

    return ret;
}
/**
Set the enabled cipher suites.

@param [out] suites Suites structure.
@param [in]  list   List of cipher suites, only supports full name from
                    cipher_name[] delimited by ':'.

@return true on success, else false.
*/
Set the enabled cipher suites.
Set the enabled cipher suites .
int SetCipherList(Suites* suites, const char* list)
{
    int       ret          = 0;
    int       idx          = 0;
    int       haveRSAsig   = 0;
    int       haveECDSAsig = 0;
    int       haveAnon     = 0;
    const int suiteSz      = GetCipherNamesSize();
    char*     next         = (char*)list;
    if (suites == NULL || list == NULL) {
        WOLFSSL_MSG("SetCipherList parameter error");
        return 0;
    }
    if (next[0] == 0 || XSTRNCMP(next, "ALL", 3) == 0)
        return 1; 
    do {
        char*  current = next;
        char   name[MAX_SUITE_NAME + 1];
        int    i;
        word32 length;
        next   = XSTRSTR(next, ":");
        length = min(sizeof(name), !next ? (word32)XSTRLEN(current) 
                                         : (word32)(next - current));
        XSTRNCPY(name, current, length);
        name[(length == sizeof(name)) ? length - 1 : length] = 0;
        for (i = 0; i < suiteSz; i++) {
            if (XSTRNCMP(name, cipher_names[i], sizeof(name)) == 0) {
                suites->suites[idx++] = (XSTRSTR(name, "CHACHA")) ? CHACHA_BYTE
                                      : (XSTRSTR(name, "QSH"))    ? QSH_BYTE
                                      : (XSTRSTR(name, "EC"))     ? ECC_BYTE
                                      : (XSTRSTR(name, "CCM"))    ? ECC_BYTE
                                      : 0x00; 
                suites->suites[idx++] = (byte)cipher_name_idx[i];
                if ((haveECDSAsig == 0) && XSTRSTR(name, "ECDSA"))
                    haveECDSAsig = 1;
                else if (XSTRSTR(name, "ADH"))
                    haveAnon = 1;
                else if ((haveRSAsig == 0) && (XSTRSTR(name, "PSK") == NULL))
                    haveRSAsig = 1;
                ret = 1; 
                break;
            }
        }
    }
    while (next++); 
    if (ret) {
        suites->setSuites = 1;
        suites->suiteSz   = (word16)idx;
        InitSuitesHashSigAlgo(suites, haveECDSAsig, haveRSAsig, haveAnon);
    }
    return ret;
}
int SetCipherList ( Suites * suites , const char * list ) { int ret = 0 ; int idx = 0 ; int haveRSAsig = 0 ; int haveECDSAsig = 0 ; int haveAnon = 0 ; const int suiteSz = GetCipherNamesSize ( ) ; char * next = ( char * ) list ; if ( suites == NULL || list == NULL ) { WOLFSSL_MSG ( " " ) ; return 0 ; } if ( next [ 0 ] == 0 || XSTRNCMP ( next , " " , 3 ) == 0 ) return 1 ; do { char * current = next ; char name [ MAX_SUITE_NAME + 1 ] ; int i ; word32 length ; next = XSTRSTR ( next , " " ) ; length = min ( sizeof ( name ) , ! next ? ( word32 ) XSTRLEN ( current ) : ( word32 ) ( next - current ) ) ; XSTRNCPY ( name , current , length ) ; name [ ( length == sizeof ( name ) ) ? length - 1 : length ] = 0 ; for ( i = 0 ; i < suiteSz ; i ++ ) { if ( XSTRNCMP ( name , cipher_names [ i ] , sizeof ( name ) ) == 0 ) { suites -> suites [ idx ++ ] = ( XSTRSTR ( name , " " ) ) ? CHACHA_BYTE : ( XSTRSTR ( name , " " ) ) ? QSH_BYTE : ( XSTRSTR ( name , " " ) ) ? ECC_BYTE : ( XSTRSTR ( name , " " ) ) ? ECC_BYTE : 0x00 ; suites -> suites [ idx ++ ] = ( byte ) cipher_name_idx [ i ] ; if ( ( haveECDSAsig == 0 ) && XSTRSTR ( name , " " ) ) haveECDSAsig = 1 ; else if ( XSTRSTR ( name , " " ) ) haveAnon = 1 ; else if ( ( haveRSAsig == 0 ) && ( XSTRSTR ( name , " " ) == NULL ) ) haveRSAsig = 1 ; ret = 1 ; break ; } } } while ( next ++ ) ; if ( ret ) { suites -> setSuites = 1 ; suites -> suiteSz = ( word16 ) idx ; InitSuitesHashSigAlgo ( suites , haveECDSAsig , haveRSAsig , haveAnon ) ; } return ret ; }
Set the enabled cipher suites.
Set the enabled cipher suites .
/* wolfSSL defualt */ /* last */ /* normal */ /* The suites are either ECDSA, RSA, PSK, or Anon. The RSA
                 * suites don't necessarily have RSA in the name. */ /* found at least one */ /* ++ needed to skip ':' */