Java如何检查运行时使用的实际securerandom.source?

时间:2018-09-29 09:55:09

标签: java

我看到某个地方可以使用strace命令。 给定一个简单的Java程序,如下所示:

import java.security.SecureRandom;
public class A{
    public static void main(String[] args){
        SecureRandom sr = new SecureRandom();
        int out = 0;
        for(int i = 0; i < 1; i++){
            out ^= sr.nextInt();
        }
        System.out.println(out);
    }
}

将securerandom.source设置为/ dev / random时使用命令:

strace -o a.strace -f -e file java A

我有这样的东西:

7490  access("/dev/random", R_OK)       = 0
7490  access("/dev/random", R_OK)       = 0
7490  access("/dev/urandom", R_OK)      = 0
7490  openat(AT_FDCWD, "/dev/random", O_RDONLY) = 5
7490  openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 6
7490  access("/dev/random", R_OK)       = 0
7490  access("/dev/random", R_OK)       = 0
7490  openat(AT_FDCWD, "/dev/random", O_RDONLY) = 7
7490  openat(AT_FDCWD, "/dev/random", O_RDONLY) = 8
7490  access("/dev/urandom", R_OK)      = 0
7490  access("/dev/urandom", R_OK)      = 0
7490  openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 9
7490  openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 10

然后我将securerandom.source更改为/ dev / urandom,我得到了这样的内容:

12914 access("/dev/urandom", R_OK)      = 0
12914 access("/dev/urandom", R_OK)      = 0
12914 access("/dev/urandom", R_OK)      = 0
12914 openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 5
12914 openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 6
12914 access("/dev/random", R_OK)       = 0
12914 access("/dev/random", R_OK)       = 0
12914 openat(AT_FDCWD, "/dev/random", O_RDONLY) = 7
12914 openat(AT_FDCWD, "/dev/random", O_RDONLY) = 8
12914 access("/dev/urandom", R_OK)      = 0
12914 access("/dev/urandom", R_OK)      = 0
12914 openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 9
12914 openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 10

这似乎有所不同,但我如何确定?

如果有更好的方法来检查securerandom.source,请告诉我。

0 个答案:

没有答案