Advertisement
Guest User

Untitled

a guest
Mar 5th, 2023
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #define SIGNATURE_LEN (sizeof(signature_p1363))
  2.         /* Parse public key */
  3.         mbedtls_pk_init(&pubkey_ctx);
  4.         res = mbedtls_pk_parse_public_key(&pubkey_ctx, ecc_public_key_text, sizeof(ecc_public_key_text));
  5.         printf("mbedtls_pk_parse_public_key: %d\r\n", res);
  6.         mbedtls_mpi r, s;
  7.         mbedtls_mpi_init(&r);
  8.         mbedtls_mpi_init(&s);
  9.         mbedtls_mpi_read_binary(&r, signature_p1363, SIGNATURE_LEN / 2);
  10.         mbedtls_mpi_read_binary(&s, signature_p1363 + SIGNATURE_LEN / 2, SIGNATURE_LEN / 2);
  11.  
  12.         /* Get ECDSA verify context from pk structure */
  13.         mbedtls_ecdsa_context* ctx = pubkey_ctx.private_pk_ctx;
  14.         res = mbedtls_ecdsa_verify(&ctx->private_grp, data_raw_hash_digest, sizeof(data_raw_hash_digest),
  15.                                    &ctx->private_Q, &r, &s);
  16.         printf("mbedtls_ecdsa_verify: %d\r\n", res);
  17.         printf("-----\r\n");
  18.         mbedtls_pk_free(&pubkey_ctx);
  19. #undef SIGNATURE_LEN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement