Lines Matching refs:ctx
55 void mbedtls_pk_init( mbedtls_pk_context *ctx ) in mbedtls_pk_init() argument
57 PK_VALIDATE( ctx != NULL ); in mbedtls_pk_init()
59 ctx->pk_info = NULL; in mbedtls_pk_init()
60 ctx->pk_ctx = NULL; in mbedtls_pk_init()
66 void mbedtls_pk_free( mbedtls_pk_context *ctx ) in mbedtls_pk_free() argument
68 if( ctx == NULL ) in mbedtls_pk_free()
71 if ( ctx->pk_info != NULL ) in mbedtls_pk_free()
72 ctx->pk_info->ctx_free_func( ctx->pk_ctx ); in mbedtls_pk_free()
74 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pk_context ) ); in mbedtls_pk_free()
81 void mbedtls_pk_restart_init( mbedtls_pk_restart_ctx *ctx ) in mbedtls_pk_restart_init() argument
83 PK_VALIDATE( ctx != NULL ); in mbedtls_pk_restart_init()
84 ctx->pk_info = NULL; in mbedtls_pk_restart_init()
85 ctx->rs_ctx = NULL; in mbedtls_pk_restart_init()
91 void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx ) in mbedtls_pk_restart_free() argument
93 if( ctx == NULL || ctx->pk_info == NULL || in mbedtls_pk_restart_free()
94 ctx->pk_info->rs_free_func == NULL ) in mbedtls_pk_restart_free()
99 ctx->pk_info->rs_free_func( ctx->rs_ctx ); in mbedtls_pk_restart_free()
101 ctx->pk_info = NULL; in mbedtls_pk_restart_free()
102 ctx->rs_ctx = NULL; in mbedtls_pk_restart_free()
135 int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ) in mbedtls_pk_setup() argument
137 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_setup()
138 if( info == NULL || ctx->pk_info != NULL ) in mbedtls_pk_setup()
141 if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) in mbedtls_pk_setup()
144 ctx->pk_info = info; in mbedtls_pk_setup()
153 int mbedtls_pk_setup_opaque( mbedtls_pk_context *ctx, in mbedtls_pk_setup_opaque() argument
161 if( ctx == NULL || ctx->pk_info != NULL ) in mbedtls_pk_setup_opaque()
173 if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) in mbedtls_pk_setup_opaque()
176 ctx->pk_info = info; in mbedtls_pk_setup_opaque()
178 pk_ctx = (psa_key_id_t *) ctx->pk_ctx; in mbedtls_pk_setup_opaque()
189 int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, in mbedtls_pk_setup_rsa_alt() argument
197 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_setup_rsa_alt()
198 if( ctx->pk_info != NULL ) in mbedtls_pk_setup_rsa_alt()
201 if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) in mbedtls_pk_setup_rsa_alt()
204 ctx->pk_info = info; in mbedtls_pk_setup_rsa_alt()
206 rsa_alt = (mbedtls_rsa_alt_context *) ctx->pk_ctx; in mbedtls_pk_setup_rsa_alt()
220 int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ) in mbedtls_pk_can_do() argument
225 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_can_do()
228 return( ctx->pk_info->can_do( type ) ); in mbedtls_pk_can_do()
255 static int pk_restart_setup( mbedtls_pk_restart_ctx *ctx, in pk_restart_setup() argument
259 if( ctx == NULL || ctx->pk_info != NULL ) in pk_restart_setup()
266 if( ( ctx->rs_ctx = info->rs_alloc_func() ) == NULL ) in pk_restart_setup()
269 ctx->pk_info = info; in pk_restart_setup()
278 int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx, in mbedtls_pk_verify_restartable() argument
284 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_verify_restartable()
289 if( ctx->pk_info == NULL || in mbedtls_pk_verify_restartable()
297 ctx->pk_info->verify_rs_func != NULL ) in mbedtls_pk_verify_restartable()
301 if( ( ret = pk_restart_setup( rs_ctx, ctx->pk_info ) ) != 0 ) in mbedtls_pk_verify_restartable()
304 ret = ctx->pk_info->verify_rs_func( ctx->pk_ctx, in mbedtls_pk_verify_restartable()
316 if( ctx->pk_info->verify_func == NULL ) in mbedtls_pk_verify_restartable()
319 return( ctx->pk_info->verify_func( ctx->pk_ctx, md_alg, hash, hash_len, in mbedtls_pk_verify_restartable()
326 int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, in mbedtls_pk_verify() argument
330 return( mbedtls_pk_verify_restartable( ctx, md_alg, hash, hash_len, in mbedtls_pk_verify()
338 mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, in mbedtls_pk_verify_ext() argument
342 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_verify_ext()
347 if( ctx->pk_info == NULL ) in mbedtls_pk_verify_ext()
350 if( ! mbedtls_pk_can_do( ctx, type ) ) in mbedtls_pk_verify_ext()
369 if( sig_len < mbedtls_pk_get_len( ctx ) ) in mbedtls_pk_verify_ext()
372 ret = mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_pk_rsa( *ctx ), in mbedtls_pk_verify_ext()
381 if( sig_len > mbedtls_pk_get_len( ctx ) ) in mbedtls_pk_verify_ext()
394 return( mbedtls_pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) ); in mbedtls_pk_verify_ext()
400 int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx, in mbedtls_pk_sign_restartable() argument
407 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_sign_restartable()
412 if( ctx->pk_info == NULL || in mbedtls_pk_sign_restartable()
420 ctx->pk_info->sign_rs_func != NULL ) in mbedtls_pk_sign_restartable()
424 if( ( ret = pk_restart_setup( rs_ctx, ctx->pk_info ) ) != 0 ) in mbedtls_pk_sign_restartable()
427 ret = ctx->pk_info->sign_rs_func( ctx->pk_ctx, md_alg, in mbedtls_pk_sign_restartable()
439 if( ctx->pk_info->sign_func == NULL ) in mbedtls_pk_sign_restartable()
442 return( ctx->pk_info->sign_func( ctx->pk_ctx, md_alg, hash, hash_len, in mbedtls_pk_sign_restartable()
449 int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, in mbedtls_pk_sign() argument
454 return( mbedtls_pk_sign_restartable( ctx, md_alg, hash, hash_len, in mbedtls_pk_sign()
461 int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, in mbedtls_pk_decrypt() argument
466 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_decrypt()
471 if( ctx->pk_info == NULL ) in mbedtls_pk_decrypt()
474 if( ctx->pk_info->decrypt_func == NULL ) in mbedtls_pk_decrypt()
477 return( ctx->pk_info->decrypt_func( ctx->pk_ctx, input, ilen, in mbedtls_pk_decrypt()
484 int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, in mbedtls_pk_encrypt() argument
489 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_encrypt()
494 if( ctx->pk_info == NULL ) in mbedtls_pk_encrypt()
497 if( ctx->pk_info->encrypt_func == NULL ) in mbedtls_pk_encrypt()
500 return( ctx->pk_info->encrypt_func( ctx->pk_ctx, input, ilen, in mbedtls_pk_encrypt()
538 size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ) in mbedtls_pk_get_bitlen() argument
542 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_get_bitlen()
545 return( ctx->pk_info->get_bitlen( ctx->pk_ctx ) ); in mbedtls_pk_get_bitlen()
551 int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items ) in mbedtls_pk_debug() argument
553 PK_VALIDATE_RET( ctx != NULL ); in mbedtls_pk_debug()
554 if( ctx->pk_info == NULL ) in mbedtls_pk_debug()
557 if( ctx->pk_info->debug_func == NULL ) in mbedtls_pk_debug()
560 ctx->pk_info->debug_func( ctx->pk_ctx, items ); in mbedtls_pk_debug()
567 const char *mbedtls_pk_get_name( const mbedtls_pk_context *ctx ) in mbedtls_pk_get_name() argument
569 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_get_name()
572 return( ctx->pk_info->name ); in mbedtls_pk_get_name()
578 mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ) in mbedtls_pk_get_type() argument
580 if( ctx == NULL || ctx->pk_info == NULL ) in mbedtls_pk_get_type()
583 return( ctx->pk_info->type ); in mbedtls_pk_get_type()