Lines Matching refs:ctx
50 void mbedtls_pk_init( mbedtls_pk_context *ctx ) in mbedtls_pk_init() argument
52 if( ctx == NULL ) in mbedtls_pk_init()
55 ctx->pk_info = NULL; in mbedtls_pk_init()
56 ctx->pk_ctx = NULL; in mbedtls_pk_init()
62 void mbedtls_pk_free( mbedtls_pk_context *ctx ) in mbedtls_pk_free() argument
64 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_free()
67 ctx->pk_info->ctx_free_func( ctx->pk_ctx ); in mbedtls_pk_free()
69 mbedtls_zeroize( ctx, sizeof( mbedtls_pk_context ) ); in mbedtls_pk_free()
101 int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ) in mbedtls_pk_setup() argument
103 if( ctx == NULL || info == NULL || ctx->pk_info != NULL ) in mbedtls_pk_setup()
106 if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) in mbedtls_pk_setup()
109 ctx->pk_info = info; in mbedtls_pk_setup()
118 int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, in mbedtls_pk_setup_rsa_alt() argument
126 if( ctx == NULL || ctx->pk_info != NULL ) in mbedtls_pk_setup_rsa_alt()
129 if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) in mbedtls_pk_setup_rsa_alt()
132 ctx->pk_info = info; in mbedtls_pk_setup_rsa_alt()
134 rsa_alt = (mbedtls_rsa_alt_context *) ctx->pk_ctx; in mbedtls_pk_setup_rsa_alt()
148 int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ) in mbedtls_pk_can_do() argument
151 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_can_do()
154 return( ctx->pk_info->can_do( type ) ); in mbedtls_pk_can_do()
177 int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, in mbedtls_pk_verify() argument
181 if( ctx == NULL || ctx->pk_info == NULL || in mbedtls_pk_verify()
185 if( ctx->pk_info->verify_func == NULL ) in mbedtls_pk_verify()
188 return( ctx->pk_info->verify_func( ctx->pk_ctx, md_alg, hash, hash_len, in mbedtls_pk_verify()
196 mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, in mbedtls_pk_verify_ext() argument
200 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_verify_ext()
203 if( ! mbedtls_pk_can_do( ctx, type ) ) in mbedtls_pk_verify_ext()
217 if( sig_len < mbedtls_pk_get_len( ctx ) ) in mbedtls_pk_verify_ext()
220 ret = mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_pk_rsa( *ctx ), in mbedtls_pk_verify_ext()
229 if( sig_len > mbedtls_pk_get_len( ctx ) ) in mbedtls_pk_verify_ext()
242 return( mbedtls_pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) ); in mbedtls_pk_verify_ext()
248 int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, in mbedtls_pk_sign() argument
253 if( ctx == NULL || ctx->pk_info == NULL || in mbedtls_pk_sign()
257 if( ctx->pk_info->sign_func == NULL ) in mbedtls_pk_sign()
260 return( ctx->pk_info->sign_func( ctx->pk_ctx, md_alg, hash, hash_len, in mbedtls_pk_sign()
267 int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, in mbedtls_pk_decrypt() argument
272 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_decrypt()
275 if( ctx->pk_info->decrypt_func == NULL ) in mbedtls_pk_decrypt()
278 return( ctx->pk_info->decrypt_func( ctx->pk_ctx, input, ilen, in mbedtls_pk_decrypt()
285 int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, in mbedtls_pk_encrypt() argument
290 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_encrypt()
293 if( ctx->pk_info->encrypt_func == NULL ) in mbedtls_pk_encrypt()
296 return( ctx->pk_info->encrypt_func( ctx->pk_ctx, input, ilen, in mbedtls_pk_encrypt()
329 size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ) in mbedtls_pk_get_bitlen() argument
331 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_get_bitlen()
334 return( ctx->pk_info->get_bitlen( ctx->pk_ctx ) ); in mbedtls_pk_get_bitlen()
340 int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items ) in mbedtls_pk_debug() argument
342 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_debug()
345 if( ctx->pk_info->debug_func == NULL ) in mbedtls_pk_debug()
348 ctx->pk_info->debug_func( ctx->pk_ctx, items ); in mbedtls_pk_debug()
355 const char *mbedtls_pk_get_name( const mbedtls_pk_context *ctx ) in mbedtls_pk_get_name() argument
357 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_get_name()
360 return( ctx->pk_info->name ); in mbedtls_pk_get_name()
366 mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ) in mbedtls_pk_get_type() argument
368 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_get_type()
371 return( ctx->pk_info->type ); in mbedtls_pk_get_type()