forked from wolfSSL/wolfssl
merge with master
This commit is contained in:
@ -997,7 +997,7 @@ int TLSX_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz,
|
|||||||
if (helloSz < offset + len16)
|
if (helloSz < offset + len16)
|
||||||
return BUFFER_ERROR;
|
return BUFFER_ERROR;
|
||||||
|
|
||||||
while (len16 > OPAQUE16_LEN + OPAQUE16_LEN) {
|
while (len16 >= OPAQUE16_LEN + OPAQUE16_LEN) {
|
||||||
word16 extType;
|
word16 extType;
|
||||||
word16 extLen;
|
word16 extLen;
|
||||||
|
|
||||||
@ -1047,7 +1047,7 @@ int TLSX_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz,
|
|||||||
len16 -= min(2 * OPAQUE16_LEN + extLen, len16);
|
len16 -= min(2 * OPAQUE16_LEN + extLen, len16);
|
||||||
}
|
}
|
||||||
|
|
||||||
return len16 ? BUFFER_ERROR : SSL_SUCCESS;
|
return len16 ? BUFFER_ERROR : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
35
tests/api.c
35
tests/api.c
@ -385,13 +385,36 @@ static void test_CyaSSL_SNI_GetFromBuffer(void)
|
|||||||
0x00, 0x0d, 0x00, 0x06, 0x00, 0x04, 0x04, 0x01, 0x02, 0x01
|
0x00, 0x0d, 0x00, 0x06, 0x00, 0x04, 0x04, 0x01, 0x02, 0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
|
byte buffer4[] = { /* last extension has zero size */
|
||||||
|
0x16, 0x03, 0x01, 0x00, 0xba, 0x01, 0x00, 0x00,
|
||||||
|
0xb6, 0x03, 0x03, 0x83, 0xa3, 0xe6, 0xdc, 0x16, 0xa1, 0x43, 0xe9, 0x45,
|
||||||
|
0x15, 0xbd, 0x64, 0xa9, 0xb6, 0x07, 0xb4, 0x50, 0xc6, 0xdd, 0xff, 0xc2,
|
||||||
|
0xd3, 0x0d, 0x4f, 0x36, 0xb4, 0x41, 0x51, 0x61, 0xc1, 0xa5, 0x9e, 0x00,
|
||||||
|
0x00, 0x28, 0xcc, 0x14, 0xcc, 0x13, 0xc0, 0x2b, 0xc0, 0x2f, 0x00, 0x9e,
|
||||||
|
0xc0, 0x0a, 0xc0, 0x09, 0xc0, 0x13, 0xc0, 0x14, 0xc0, 0x07, 0xc0, 0x11,
|
||||||
|
0x00, 0x33, 0x00, 0x32, 0x00, 0x39, 0x00, 0x9c, 0x00, 0x2f, 0x00, 0x35,
|
||||||
|
0x00, 0x0a, 0x00, 0x05, 0x00, 0x04, 0x01, 0x00, 0x00, 0x65, 0xff, 0x01,
|
||||||
|
0x00, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x06, 0x00, 0x17, 0x00,
|
||||||
|
0x18, 0x00, 0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x23, 0x00,
|
||||||
|
0x00, 0x33, 0x74, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1b, 0x00, 0x19, 0x06,
|
||||||
|
0x73, 0x70, 0x64, 0x79, 0x2f, 0x33, 0x08, 0x73, 0x70, 0x64, 0x79, 0x2f,
|
||||||
|
0x33, 0x2e, 0x31, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31,
|
||||||
|
0x75, 0x50, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x0d, 0x00, 0x12, 0x00, 0x10, 0x04, 0x01, 0x05, 0x01, 0x02,
|
||||||
|
0x01, 0x04, 0x03, 0x05, 0x03, 0x02, 0x03, 0x04, 0x02, 0x02, 0x02, 0x00,
|
||||||
|
0x12, 0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
byte result[32] = {0};
|
byte result[32] = {0};
|
||||||
word32 length = 32;
|
word32 length = 32;
|
||||||
|
|
||||||
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer3, sizeof(buffer3),
|
AssertIntEQ(0, CyaSSL_SNI_GetFromBuffer(buffer4, sizeof(buffer4),
|
||||||
0, result, &length));
|
0, result, &length));
|
||||||
|
|
||||||
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
AssertIntEQ(0, CyaSSL_SNI_GetFromBuffer(buffer3, sizeof(buffer3),
|
||||||
|
0, result, &length));
|
||||||
|
|
||||||
|
AssertIntEQ(0, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
||||||
1, result, &length));
|
1, result, &length));
|
||||||
|
|
||||||
AssertIntEQ(-228, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(-228, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
||||||
@ -410,15 +433,15 @@ static void test_CyaSSL_SNI_GetFromBuffer(void)
|
|||||||
result, &length));
|
result, &length));
|
||||||
buffer[4] = 0x64;
|
buffer[4] = 0x64;
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
result[length] = 0;
|
result[length] = 0;
|
||||||
AssertStrEQ("www.paypal.com", (const char*) result);
|
AssertStrEQ("www.paypal.com", (const char*) result);
|
||||||
|
|
||||||
length = 32;
|
length = 32;
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2), 0,
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
result[length] = 0;
|
result[length] = 0;
|
||||||
AssertStrEQ("api.textmate.org", (const char*) result);
|
AssertStrEQ("api.textmate.org", (const char*) result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user