Lines Matching refs:ctx
88 void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ) in mbedtls_ecdh_init() argument
90 memset( ctx, 0, sizeof( mbedtls_ecdh_context ) ); in mbedtls_ecdh_init()
96 void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ) in mbedtls_ecdh_free() argument
98 if( ctx == NULL ) in mbedtls_ecdh_free()
101 mbedtls_ecp_group_free( &ctx->grp ); in mbedtls_ecdh_free()
102 mbedtls_ecp_point_free( &ctx->Q ); in mbedtls_ecdh_free()
103 mbedtls_ecp_point_free( &ctx->Qp ); in mbedtls_ecdh_free()
104 mbedtls_ecp_point_free( &ctx->Vi ); in mbedtls_ecdh_free()
105 mbedtls_ecp_point_free( &ctx->Vf ); in mbedtls_ecdh_free()
106 mbedtls_mpi_free( &ctx->d ); in mbedtls_ecdh_free()
107 mbedtls_mpi_free( &ctx->z ); in mbedtls_ecdh_free()
108 mbedtls_mpi_free( &ctx->_d ); in mbedtls_ecdh_free()
118 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, in mbedtls_ecdh_make_params() argument
126 if( ctx == NULL || ctx->grp.pbits == 0 ) in mbedtls_ecdh_make_params()
129 if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) in mbedtls_ecdh_make_params()
133 if( ( ret = mbedtls_ecp_tls_write_group( &ctx->grp, &grp_len, buf, blen ) ) in mbedtls_ecdh_make_params()
140 if( ( ret = mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, ctx->point_format, in mbedtls_ecdh_make_params()
155 int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, in mbedtls_ecdh_read_params() argument
160 if( ( ret = mbedtls_ecp_tls_read_group( &ctx->grp, buf, end - *buf ) ) != 0 ) in mbedtls_ecdh_read_params()
163 if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, buf, end - *buf ) ) in mbedtls_ecdh_read_params()
173 int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, in mbedtls_ecdh_get_params() argument
178 if( ( ret = mbedtls_ecp_group_copy( &ctx->grp, &key->grp ) ) != 0 ) in mbedtls_ecdh_get_params()
183 return( mbedtls_ecp_copy( &ctx->Qp, &key->Q ) ); in mbedtls_ecdh_get_params()
189 if( ( ret = mbedtls_ecp_copy( &ctx->Q, &key->Q ) ) != 0 || in mbedtls_ecdh_get_params()
190 ( ret = mbedtls_mpi_copy( &ctx->d, &key->d ) ) != 0 ) in mbedtls_ecdh_get_params()
199 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, in mbedtls_ecdh_make_public() argument
206 if( ctx == NULL || ctx->grp.pbits == 0 ) in mbedtls_ecdh_make_public()
209 if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) in mbedtls_ecdh_make_public()
213 return mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, ctx->point_format, in mbedtls_ecdh_make_public()
220 int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, in mbedtls_ecdh_read_public() argument
226 if( ctx == NULL ) in mbedtls_ecdh_read_public()
229 if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, &p, blen ) ) != 0 ) in mbedtls_ecdh_read_public()
241 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, in mbedtls_ecdh_calc_secret() argument
248 if( ctx == NULL ) in mbedtls_ecdh_calc_secret()
251 if( ( ret = mbedtls_ecdh_compute_shared( &ctx->grp, &ctx->z, &ctx->Qp, &ctx->d, in mbedtls_ecdh_calc_secret()
257 if( mbedtls_mpi_size( &ctx->z ) > blen ) in mbedtls_ecdh_calc_secret()
260 *olen = ctx->grp.pbits / 8 + ( ( ctx->grp.pbits % 8 ) != 0 ); in mbedtls_ecdh_calc_secret()
261 return mbedtls_mpi_write_binary( &ctx->z, buf, *olen ); in mbedtls_ecdh_calc_secret()