static int eckey_sign_wrap(void *ctx, ttls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len) { int ret; ttls_ecdsa_context ecdsa; ttls_ecdsa_init(&ecdsa); if ((ret = ttls_ecdsa_from_keypair(&ecdsa, ctx)) == 0) ret = ecdsa_sign_wrap(&ecdsa, md_alg, hash, hash_len, sig, sig_len); ttls_ecdsa_free(&ecdsa); return ret; }
static int eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret; mbedtls_ecdsa_context ecdsa; mbedtls_ecdsa_init( &ecdsa ); if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 ) ret = ecdsa_sign_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng ); mbedtls_ecdsa_free( &ecdsa ); return( ret ); }