Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved "env" dependencies in wasm module #60

Closed
coderPaddyS opened this issue Jan 16, 2022 · 2 comments
Closed

Unresolved "env" dependencies in wasm module #60

coderPaddyS opened this issue Jan 16, 2022 · 2 comments

Comments

@coderPaddyS
Copy link

Hey there!

I a trying to use your library in a software project at our university and switched from your oauth2 library to this one.
Sadly it is not working for me, there are unresolved dependencies which are then mapped to env by wasm_bindgen. Here is the dissassembly by wasm2wat for the relevant sections:

  (import "env" "LIMBS_equal" (func $env.LIMBS_equal (type $t6)))
  (import "env" "LIMBS_are_even" (func $env.LIMBS_are_even (type $t3)))
  (import "env" "GFp_bn_neg_inv_mod_r_u64" (func $env.GFp_bn_neg_inv_mod_r_u64 (type $t29)))
  (import "env" "LIMBS_shl_mod" (func $env.LIMBS_shl_mod (type $t4)))
  (import "env" "LIMBS_reduce_once" (func $env.LIMBS_reduce_once (type $t1)))
  (import "env" "GFp_bn_from_montgomery_in_place" (func $env.GFp_bn_from_montgomery_in_place (type $t21)))
  (import "env" "GFp_limbs_mul_add_limb" (func $env.GFp_limbs_mul_add_limb (type $t12)))
  (import "env" "LIMBS_less_than" (func $env.LIMBS_less_than (type $t6)))
  (import "env" "LIMBS_less_than_limb" (func $env.LIMBS_less_than_limb (type $t6)))
  (import "env" "GFp_memcmp" (func $env.GFp_memcmp (type $t6)))
  (import "env" "GFp_nistz256_sqr_mont" (func $env.GFp_nistz256_sqr_mont (type $t0)))
  (import "env" "GFp_nistz256_point_mul" (func $env.GFp_nistz256_point_mul (type $t4)))
  (import "env" "GFp_p256_scalar_mul_mont" (func $env.GFp_p256_scalar_mul_mont (type $t1)))
  (import "env" "GFp_p256_scalar_sqr_mont" (func $env.GFp_p256_scalar_sqr_mont (type $t0)))
  (import "env" "GFp_p256_scalar_sqr_rep_mont" (func $env.GFp_p256_scalar_sqr_rep_mont (type $t1)))
  (import "env" "GFp_nistz384_point_mul" (func $env.GFp_nistz384_point_mul (type $t4)))
  (import "env" "GFp_p384_scalar_mul_mont" (func $env.GFp_p384_scalar_mul_mont (type $t1)))
  (import "env" "GFp_p384_elem_mul_mont" (func $env.GFp_p384_elem_mul_mont (type $t1)))
  (import "env" "GFp_nistz256_add" (func $env.GFp_nistz256_add (type $t1)))
  (import "env" "GFp_nistz256_mul_mont" (func $env.GFp_nistz256_mul_mont (type $t1)))
  (import "env" "GFp_nistz256_point_add" (func $env.GFp_nistz256_point_add (type $t1)))
  (import "env" "GFp_p384_elem_add" (func $env.GFp_p384_elem_add (type $t1)))
  (import "env" "GFp_nistz384_point_add" (func $env.GFp_nistz384_point_add (type $t1)))
  (import "env" "LIMBS_are_zero" (func $env.LIMBS_are_zero (type $t3)))
  (import "env" "LIMB_shr" (func $env.LIMB_shr (type $t3)))

I am not experienced in cryptography, but it seems like your library depends on c libraries to handle the cryptography.

I want your library to be used in a SPA, therefore I really would like to bundle all dependencies in. Is there a way?

@sbihel
Copy link
Contributor

sbihel commented Jan 18, 2022

Hiya, I'm not sure if you've managed to make it work as you have closed the issue. But if you haven't, you could try my fork #58 which adds an alternative to ring with the rustcrypto feature.

Apologies if I'm overstepping.

@ctron
Copy link
Contributor

ctron commented Apr 12, 2022

Just ran into the same issue, I guess it is caused by the following code:

impl PartialEq for Nonce {
fn eq(&self, other: &Self) -> bool {
constant_time::verify_slices_are_equal(self.secret().as_bytes(), other.secret().as_bytes())
.is_ok()
}
}

I think it should be possible to just replace that in the case of wasm32.

ctron added a commit to ctron/openidconnect-rs that referenced this issue Apr 12, 2022
ctron added a commit to ctron/openidconnect-rs that referenced this issue Apr 12, 2022
The ring functionality used to check if the nonce is equal makes uses
of a memcpy function imported from the C world. However, this function
isn't available when compiling for wasm32.

This change uses a simple compare for wasm32, and keeps the current
behavior for all other targets.

closes issue ramosbugs#60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants