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

random 移植 #2

Open
Lanjiejie opened this issue May 2, 2019 · 6 comments
Open

random 移植 #2

Lanjiejie opened this issue May 2, 2019 · 6 comments

Comments

@Lanjiejie
Copy link

请问crate random是不是还不能移植呢?因为它的依赖库getrandom涉及到了syscall吗?

@dingelish
Copy link
Owner

已经有在 v1.0.6 上能够正常工作的 rand
https://github.com/mesalock-linux/rand-sgx

@Lanjiejie
Copy link
Author

已经有在 v1.0.6 上能够正常工作的 rand
https://github.com/mesalock-linux/rand-sgx

太感谢了🙏

@Lanjiejie
Copy link
Author

Lanjiejie commented May 3, 2019

您好,我想再请教一个问题。
我在移植primitive-types这个crate的时候,因为它有一个依赖库是fixed-hash,我根据您的教程操作,fixed-hash已经可以正常运行了,但是对primitive-types编译的时候出现了一些问题:

error[E0433]: failed to resolve: could not find `OsRng` in `rand`
   --> <::fixed_hash::hash::impl_rand_for_fixed_hash macros>:18:34
    |
1   |  / ( $ name : ident ) => {
2   |  | impl $ crate :: rand :: distributions :: Distribution < $ name > for $ crate
3   |  | :: rand :: distributions :: Standard {
4   |  | fn sample < R : $ crate :: rand :: Rng + ? Sized > ( & self , rng : & mut R )
...    |
18  |  | let mut rng = $ crate :: rand :: OsRng :: new (  ) . unwrap (  ) ; self .
    |  |                                  ^^^^^ could not find `OsRng` in `rand`
...    |
26  |  |  pub fn random (  ) -> Self {
27  |  | let mut hash = Self :: zero (  ) ; hash . randomize (  ) ; hash } } }
    |  |_____________________________________________________________________- in this expansion of `impl_rand_for_fixed_hash!`
    | 
   ::: <::fixed_hash::hash::construct_fixed_hash macros>:1:1
    |
1   | /  (
2   | |  $ ( # [ $ attr : meta ] ) * $ visibility : vis struct $ name : ident (
3   | |  $ n_bytes : expr ) ; ) => {
4   | |  # [ repr ( C ) ] $ ( # [ $ attr ] ) * $ visibility struct $ name (
...   |
137 |    impl_byteorder_for_fixed_hash ! ( $ name ) ; impl_rand_for_fixed_hash ! (
    |  _______________________________________________-
138 | |  $ name ) ; impl_libc_for_fixed_hash ! ( $ name ) ;
    | |___________- in this macro invocation
139 | |  impl_rustc_hex_for_fixed_hash ! ( $ name ) ; impl_heapsize_for_fixed_hash ! (
140 | |  $ name ) ; impl_quickcheck_for_fixed_hash ! ( $ name ) ; }
    | |___________________________________________________________- in this expansion of `construct_fixed_hash!`
    | 
   ::: primitive-types/src/lib.rs:71:1
    |
71  | /  construct_fixed_hash! {
72  | |      /// Fixed-size uninterpreted hash type with 64 bytes (512 bits) size.
73  | |      pub struct H512(64);
74  | |  }
    | |__- in this macro invocation



error[E0425]: cannot find function `memcmp` in module `$crate::libc`
    | 
   ::: <::fixed_hash::hash::construct_fixed_hash macros>:1:1
    |
1   | /  (
2   | |  $ ( # [ $ attr : meta ] ) * $ visibility : vis struct $ name : ident (
3   | |  $ n_bytes : expr ) ; ) => {
4   | |  # [ repr ( C ) ] $ ( # [ $ attr ] ) * $ visibility struct $ name (
...   |
138 | |  $ name ) ; impl_libc_for_fixed_hash ! ( $ name ) ;
    | |             --------------------------------------- in this macro invocation
139 | |  impl_rustc_hex_for_fixed_hash ! ( $ name ) ; impl_heapsize_for_fixed_hash ! (
140 | |  $ name ) ; impl_quickcheck_for_fixed_hash ! ( $ name ) ; }
    | |___________________________________________________________- in this expansion of `construct_fixed_hash!`
   --> <::fixed_hash::hash::impl_libc_for_fixed_hash macros>:5:20
    |
1   |  / ( $ name : ident ) => {
2   |  | impl $ crate :: core_ :: cmp :: PartialEq for $ name {
3   |  | # [ inline ] fn eq ( & self , other : & Self ) -> bool {
4   |  | unsafe {
5   |  | $ crate :: libc :: memcmp (
    |  |                    ^^^^^^
...    |
15  |  | return $ crate :: core_ :: cmp :: Ordering :: Greater ; } $ crate :: core_ ::
16  |  | cmp :: Ordering :: Equal } } }
    |  |______________________________- in this expansion of `impl_libc_for_fixed_hash!`
    | 
   ::: primitive-types/src/lib.rs:63:1
    |
63  | /  construct_fixed_hash! {
64  | |      /// Fixed-size uninterpreted hash type with 20 bytes (160 bits) size.
65  | |      pub struct H160(20);
66  | |  }
    | |__- in this macro invocation
help: a function with a similar name exists
    |
5   | $ crate :: libc :: memchr (
    |                    ^^^^^^
help: possible candidate is found in another module, you can import it into scope
    |
25  | use compiler_builtins::mem::memcmp;
    |

报错是说找不到fixed-hash中用到的rand::OsRng 和 libc::memcmp,请问这是什么原因呢?

@dingelish
Copy link
Owner

看上去你要移植的是parity-common下的fixed-hash。它依赖于 rand v0.5。这是一个非常罕见的版本,API 不同于 0.4 也不同于 0.6。如果你看 rand 的发布历史,你会发现 0.5 在历史上只“存活”了三个月,之后 rand 还在继续维护 0.4 以及推出了新的 0.6。上面我移植的 rand-sgx 是 0.6。

不明白为什么这个 fixed-hash 会固定依赖于这个稀有的并且失去维护的 0.5——说不定你需要重新移植
rand 0.5,或者让 fixed-hash 在0.6上能工作。

@Lanjiejie
Copy link
Author

嗯嗯,明白了,谢谢您!

@Lanjiejie
Copy link
Author

您好,最近读了一些论文,有一些疑问向您请教:

  1. rust sgx 解决了intel sgx 的enclave无法执行系统调用问题吗?
  2. rust sgx 对侧信道攻击有没有什么抵御机制呢?
  3. 之前使用v1.06版本,当输入数据规模较大时,程序就发生了错误,这是不是一个限制呢?
  4. enclave里面只适用规模较小的程序吗?

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

2 participants