- bool crypto_eucr_validate(void)
- {
- mbedtls_x509_crt ca, ic, crt;
- uint32_t flags;
- int err;
- CRY_DEBUG_PRINTF("Validating EUCR...");
- /* Load CA */
- mbedtls_x509_crt_init(&ca);
- err = mbedtls_x509_crt_parse(&ca, (unsigned char *) flash.flash_ver0.root_crt, CERT_SIZE);
- if (err != 0)
- {
- CRY_DEBUG_PRINTF("CA parsing error!");
- mbedtls_strerror(err, tmp_buff, TMP_BUFF_SIZE);
- CRY_DEBUG_PRINTF("%s", tmp_buff);
- return false;
- }
- /* Load IC */
- mbedtls_x509_crt_init(&ic);
- err = mbedtls_x509_crt_parse(&ca, (unsigned char *) flash.flash_ver0.ic_crt, CERT_SIZE);
- if (err != 0)
- {
- CRY_DEBUG_PRINTF("CI parsing error!");
- mbedtls_strerror(err, tmp_buff, TMP_BUFF_SIZE);
- CRY_DEBUG_PRINTF("%s", tmp_buff);
- return false;
- }
- /* Verify certificate */
- err = mbedtls_x509_crt_verify(&ca, &ca, NULL, NULL, &flags, NULL, NULL);
- if (err != 0)
- {
- CRY_DEBUG_PRINTF("Certificate validation error!");
- mbedtls_strerror(err, tmp_buff, TMP_BUFF_SIZE);
- CRY_DEBUG_PRINTF("%s", tmp_buff);
- mbedtls_x509_crt_verify_info(tmp_buff, TMP_BUFF_SIZE, "", flags);
- CRY_DEBUG_PRINTF("%s", tmp_buff);
- return false;
- }
- else
- {
- CRY_DEBUG_PRINTF("CI validation over CA: OK!");
- }
- return true;
- }
[text] Certificate validation
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: