mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 00:28:48 -05:00
Removed the #define of ciphernum since keeping a define updated to be the
number of entries in a provided table is doomed to fail in the long run. Now we use the NUM_OF_CIPHERS define instead to figure out the amount.
This commit is contained in:
parent
c1e2341f0a
commit
68b67e24f2
19
lib/nss.c
19
lib/nss.c
@ -93,12 +93,6 @@ typedef struct {
|
|||||||
PRInt32 version; /* protocol version valid for this cipher */
|
PRInt32 version; /* protocol version valid for this cipher */
|
||||||
} cipher_s;
|
} cipher_s;
|
||||||
|
|
||||||
#ifdef NSS_ENABLE_ECC
|
|
||||||
#define ciphernum 48
|
|
||||||
#else
|
|
||||||
#define ciphernum 23
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PK11_SETATTRS(x,id,v,l) (x)->type = (id); \
|
#define PK11_SETATTRS(x,id,v,l) (x)->type = (id); \
|
||||||
(x)->pValue=(v); (x)->ulValueLen = (l)
|
(x)->pValue=(v); (x)->ulValueLen = (l)
|
||||||
|
|
||||||
@ -106,7 +100,8 @@ typedef struct {
|
|||||||
|
|
||||||
enum sslversion { SSL2 = 1, SSL3 = 2, TLS = 4 };
|
enum sslversion { SSL2 = 1, SSL3 = 2, TLS = 4 };
|
||||||
|
|
||||||
static const cipher_s cipherlist[ciphernum] = {
|
#define NUM_OF_CIPHERS sizeof(cipherlist)/sizeof(cipherlist[0])
|
||||||
|
static const cipher_s cipherlist[] = {
|
||||||
/* SSL2 cipher suites */
|
/* SSL2 cipher suites */
|
||||||
{"rc4", SSL_EN_RC4_128_WITH_MD5, SSL2},
|
{"rc4", SSL_EN_RC4_128_WITH_MD5, SSL2},
|
||||||
{"rc4export", SSL_EN_RC4_128_EXPORT40_WITH_MD5, SSL2},
|
{"rc4export", SSL_EN_RC4_128_EXPORT40_WITH_MD5, SSL2},
|
||||||
@ -172,8 +167,8 @@ SECMODModule* mod = NULL;
|
|||||||
static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
|
static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
|
||||||
char *cipher_list)
|
char *cipher_list)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
PRBool cipher_state[ciphernum];
|
PRBool cipher_state[NUM_OF_CIPHERS];
|
||||||
PRBool found;
|
PRBool found;
|
||||||
char *cipher;
|
char *cipher;
|
||||||
SECStatus rv;
|
SECStatus rv;
|
||||||
@ -187,7 +182,7 @@ static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set every entry in our list to false */
|
/* Set every entry in our list to false */
|
||||||
for(i=0; i<ciphernum; i++) {
|
for(i=0; i<NUM_OF_CIPHERS; i++) {
|
||||||
cipher_state[i] = PR_FALSE;
|
cipher_state[i] = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +198,7 @@ static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
|
|||||||
|
|
||||||
found = PR_FALSE;
|
found = PR_FALSE;
|
||||||
|
|
||||||
for(i=0; i<ciphernum; i++) {
|
for(i=0; i<NUM_OF_CIPHERS; i++) {
|
||||||
if(strequal(cipher, cipherlist[i].name)) {
|
if(strequal(cipher, cipherlist[i].name)) {
|
||||||
cipher_state[i] = PR_TRUE;
|
cipher_state[i] = PR_TRUE;
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
@ -222,7 +217,7 @@ static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Finally actually enable the selected ciphers */
|
/* Finally actually enable the selected ciphers */
|
||||||
for(i=0; i<ciphernum; i++) {
|
for(i=0; i<NUM_OF_CIPHERS; i++) {
|
||||||
rv = SSL_CipherPrefSet(model, cipherlist[i].num, cipher_state[i]);
|
rv = SSL_CipherPrefSet(model, cipherlist[i].num, cipher_state[i]);
|
||||||
if(rv != SECSuccess) {
|
if(rv != SECSuccess) {
|
||||||
failf(data, "Unknown cipher in cipher list");
|
failf(data, "Unknown cipher in cipher list");
|
||||||
|
Loading…
Reference in New Issue
Block a user