Accelerate legacy WSS elliptic-curve operations and time TLS phases
Enable mbedTLS NIST modular reduction and report per-phase handshake timings. Add handshake-loop regression tests and a certificate verification benchmark, and document the full kernel and APP package requirement.
This commit is contained in:
@@ -36,6 +36,8 @@ int main(int argc, char **argv)
|
||||
char pem[16384];
|
||||
FILE *file;
|
||||
size_t length;
|
||||
clock_t verify_started;
|
||||
mbedtls_ecp_group group;
|
||||
unsigned char key[16] = {0}, iv[12] = {0}, plain[16] = {0}, cipher[16], tag[16];
|
||||
const unsigned char expected_cipher[16] = {0x03,0x88,0xda,0xce,0x60,0xb6,0xa3,0x92,0xf3,0x28,0xc2,0xb9,0x71,0xb2,0xfe,0x78};
|
||||
const unsigned char expected_tag[16] = {0xab,0x6e,0x47,0xd4,0x2c,0xec,0x13,0xbd,0xf5,0x3a,0x67,0xb2,0x12,0x57,0xbd,0xdf};
|
||||
@@ -60,6 +62,21 @@ int main(int argc, char **argv)
|
||||
ret = mbedtls_x509_crt_verify(&chain, &root, NULL, "banban.api.talkingq.com", &flags, NULL, NULL, 0);
|
||||
printf("SDK server chain + hostname verify: %d, flags=0x%08x\n", ret, (unsigned int)flags);
|
||||
assert(ret == 0 && flags == 0);
|
||||
verify_started = clock();
|
||||
for (i = 0; i < 20; ++i) {
|
||||
ret = mbedtls_x509_crt_verify(&chain, &root, NULL, "banban.api.talkingq.com", &flags, NULL, NULL, 0);
|
||||
assert(ret == 0 && flags == 0);
|
||||
}
|
||||
printf("Host certificate chain verify average: %.2f ms (20 runs)\n",
|
||||
1000.0 * (clock() - verify_started) / CLOCKS_PER_SEC / 20);
|
||||
mbedtls_ecp_group_init(&group);
|
||||
assert(mbedtls_ecp_group_load(&group, MBEDTLS_ECP_DP_SECP384R1) == 0);
|
||||
#ifdef MBEDTLS_ECP_NIST_OPTIM
|
||||
assert(group.modp != NULL);
|
||||
#else
|
||||
assert(group.modp == NULL);
|
||||
#endif
|
||||
mbedtls_ecp_group_free(&group);
|
||||
ret = mbedtls_x509_crt_verify(&chain, &root, NULL, "wrong.invalid", &flags, NULL, NULL, 0);
|
||||
assert(ret != 0 && (flags & MBEDTLS_X509_BADCERT_CN_MISMATCH));
|
||||
ret = mbedtls_x509_crt_verify(&chain, NULL, NULL, "banban.api.talkingq.com", &flags, NULL, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user