Lines Matching refs:ctx

66 static size_t rsa_get_bitlen( const void *ctx )  in rsa_get_bitlen()  argument
68 return( 8 * ((const mbedtls_rsa_context *) ctx)->len ); in rsa_get_bitlen()
71 static int rsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, in rsa_verify_wrap() argument
77 if( sig_len < ((mbedtls_rsa_context *) ctx)->len ) in rsa_verify_wrap()
80 if( ( ret = mbedtls_rsa_pkcs1_verify( (mbedtls_rsa_context *) ctx, NULL, NULL, in rsa_verify_wrap()
85 if( sig_len > ((mbedtls_rsa_context *) ctx)->len ) in rsa_verify_wrap()
91 static int rsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, in rsa_sign_wrap() argument
96 *sig_len = ((mbedtls_rsa_context *) ctx)->len; in rsa_sign_wrap()
98 return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, f_rng, p_rng, MBEDTLS_RSA_PRIVATE, in rsa_sign_wrap()
102 static int rsa_decrypt_wrap( void *ctx, in rsa_decrypt_wrap() argument
107 if( ilen != ((mbedtls_rsa_context *) ctx)->len ) in rsa_decrypt_wrap()
110 return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx, f_rng, p_rng, in rsa_decrypt_wrap()
114 static int rsa_encrypt_wrap( void *ctx, in rsa_encrypt_wrap() argument
119 *olen = ((mbedtls_rsa_context *) ctx)->len; in rsa_encrypt_wrap()
124 return( mbedtls_rsa_pkcs1_encrypt( (mbedtls_rsa_context *) ctx, in rsa_encrypt_wrap()
136 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_context ) ); in rsa_alloc_wrap() local
138 if( ctx != NULL ) in rsa_alloc_wrap()
139 mbedtls_rsa_init( (mbedtls_rsa_context *) ctx, 0, 0 ); in rsa_alloc_wrap()
141 return( ctx ); in rsa_alloc_wrap()
144 static void rsa_free_wrap( void *ctx ) in rsa_free_wrap() argument
146 mbedtls_rsa_free( (mbedtls_rsa_context *) ctx ); in rsa_free_wrap()
147 mbedtls_free( ctx ); in rsa_free_wrap()
150 static void rsa_debug( const void *ctx, mbedtls_pk_debug_item *items ) in rsa_debug() argument
154 items->value = &( ((mbedtls_rsa_context *) ctx)->N ); in rsa_debug()
160 items->value = &( ((mbedtls_rsa_context *) ctx)->E ); in rsa_debug()
190 static size_t eckey_get_bitlen( const void *ctx ) in eckey_get_bitlen() argument
192 return( ((mbedtls_ecp_keypair *) ctx)->grp.pbits ); in eckey_get_bitlen()
197 static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
201 static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
206 static int eckey_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, in eckey_verify_wrap() argument
215 if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 ) in eckey_verify_wrap()
223 static int eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, in eckey_sign_wrap() argument
233 if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 ) in eckey_sign_wrap()
252 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecp_keypair ) ); in eckey_alloc_wrap() local
254 if( ctx != NULL ) in eckey_alloc_wrap()
255 mbedtls_ecp_keypair_init( ctx ); in eckey_alloc_wrap()
257 return( ctx ); in eckey_alloc_wrap()
260 static void eckey_free_wrap( void *ctx ) in eckey_free_wrap() argument
262 mbedtls_ecp_keypair_free( (mbedtls_ecp_keypair *) ctx ); in eckey_free_wrap()
263 mbedtls_free( ctx ); in eckey_free_wrap()
266 static void eckey_debug( const void *ctx, mbedtls_pk_debug_item *items ) in eckey_debug() argument
270 items->value = &( ((mbedtls_ecp_keypair *) ctx)->Q ); in eckey_debug()
324 static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, in ecdsa_verify_wrap() argument
331 ret = mbedtls_ecdsa_read_signature( (mbedtls_ecdsa_context *) ctx, in ecdsa_verify_wrap()
340 static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, in ecdsa_sign_wrap() argument
345 return( mbedtls_ecdsa_write_signature( (mbedtls_ecdsa_context *) ctx, in ecdsa_sign_wrap()
351 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) ); in ecdsa_alloc_wrap() local
353 if( ctx != NULL ) in ecdsa_alloc_wrap()
354 mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx ); in ecdsa_alloc_wrap()
356 return( ctx ); in ecdsa_alloc_wrap()
359 static void ecdsa_free_wrap( void *ctx ) in ecdsa_free_wrap() argument
361 mbedtls_ecdsa_free( (mbedtls_ecdsa_context *) ctx ); in ecdsa_free_wrap()
362 mbedtls_free( ctx ); in ecdsa_free_wrap()
391 static size_t rsa_alt_get_bitlen( const void *ctx ) in rsa_alt_get_bitlen() argument
393 const mbedtls_rsa_alt_context *rsa_alt = (const mbedtls_rsa_alt_context *) ctx; in rsa_alt_get_bitlen()
398 static int rsa_alt_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, in rsa_alt_sign_wrap() argument
403 mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx; in rsa_alt_sign_wrap()
411 static int rsa_alt_decrypt_wrap( void *ctx, in rsa_alt_decrypt_wrap() argument
416 mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx; in rsa_alt_decrypt_wrap()
460 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_alt_context ) ); in rsa_alt_alloc_wrap() local
462 if( ctx != NULL ) in rsa_alt_alloc_wrap()
463 memset( ctx, 0, sizeof( mbedtls_rsa_alt_context ) ); in rsa_alt_alloc_wrap()
465 return( ctx ); in rsa_alt_alloc_wrap()
468 static void rsa_alt_free_wrap( void *ctx ) in rsa_alt_free_wrap() argument
470 mbedtls_zeroize( ctx, sizeof( mbedtls_rsa_alt_context ) ); in rsa_alt_free_wrap()
471 mbedtls_free( ctx ); in rsa_alt_free_wrap()