+
+int ecdsa_signature_r_s_verify(mbedtls_ecp_group_id curveID, uint8_t *key_xy, uint8_t *input, int length, uint8_t *r_s, size_t r_s_len, bool hash) {
+ int res;
+ uint8_t signature[MBEDTLS_ECDSA_MAX_LEN];
+ size_t signature_len;
+
+ // convert r & s to ASN.1 signature
+ mbedtls_mpi r, s;
+ mbedtls_mpi_init(&r);
+ mbedtls_mpi_init(&s);
+ mbedtls_mpi_read_binary(&r, r_s, r_s_len/2);
+ mbedtls_mpi_read_binary(&s, r_s + r_s_len/2, r_s_len/2);
+
+ res = ecdsa_signature_to_asn1(&r, &s, signature, &signature_len);
+ if (res < 0) {
+ return res;
+ }
+
+ res = ecdsa_signature_verify(curveID, key_xy, input, length, signature, signature_len, hash);
+
+ mbedtls_mpi_free(&r);
+ mbedtls_mpi_free(&s);
+
+ return res;
+}
+
+