SP 80090B熵
sp800-90b的Python项目详细描述
熵测量
密码随机位发生器(rbg),也称为随机数发生器(RNGs),需要一个噪声源来产生具有某种程度的不可预测性的数字输出,用最小熵表示。SP 800-90B提供了一种估计熵源质量的标准化方法。在
文件
查看documentation here (https://hnj2.github.io/sp800_90b/)。在
安装
先决条件
您需要安装bz2
和'divsufsort'库,以及支持c++11的g++兼容编译器。
在类似debian/ubuntu的系统上,以下命令就足够了:
sudo apt install libbz2-dev libdivsufsort-dev build-essential
您应该至少使用pythonversion3的虚拟环境。在
使用pip
您只需运行:
^{pr2}$使用setuptools
别忘了查看nist_impl
子模块:
git submodule init
git submodule update
您还需要setuptools
和pybind11
python包:
pip install setuptools pybind11
现在您可以使用以下方法安装软件包:
python setup.py build
python setup.py install
手动编译
使用与setuptools安装中相同的先决条件,您还可以运行
make -f Manual.make
手动编译包。在
注意:您只能在生成的.so
库所在的目录中使用它。在
安装
使用python命令help(sp800_90b)
获取文档。在
手动测试
以下命令可用于包的粗略测试:
(venv) hnj@prokrastinator:~/sp800_90b$ python
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import random
In [2]: r = bytes(random.getrandbits(8) for _ in range(1000000))
In [3]: n = bytes(random.getrandbits(8) for _ in range(500000))
In [4]: n = n + bytes(random.getrandbits(7) for _ in range(500000))
In [5]: import sp800_90b
In [6]: help(sp800_90b)
In [7]: rd = sp800_90b.Data(r)
In [8]: rd.iid_tests()
Beginning initial tests...
Beginning permutation tests... these may take some time
Out[8]: True
In [9]: rd.h_initial()
Out[9]: 7.189185202883665
In [10]: nd = sp800_90b.Data(n)
In [11]: nd.iid_tests()
igamc: UNDERFLOW
Out[11]: False
In [12]: nd.h_initial()
Out[12]: 5.194695581531671
免责声明
该软件是NIST开发的项目(that can be found here: https://github.com/usnistgov/SP800-90B_EntropyAssessment)的重新打包和稍作修改的版本。在
NIST原始免责声明
NIST开发的软件由NIST作为公共服务提供。您可以在任何介质中使用、复制和分发本软件的副本,但前提是您要保持本通知的完整性。您可以改进、修改和创建本软件或本软件任何部分的衍生作品,并且可以分发此类修改或作品。修改后的作品应附有通知,说明您更改了软件,并应注明任何此类更改的日期和性质。请明确承认国家标准与技术研究所是该软件的来源。在
修改
所做的修改是:
- 添加一个头文件和一些helper函数,将提供的nist代码包装在可以链接到其他组件(^{
} ans^{} )的对象文件中。在 - 编写一个提供nist代码功能的类作为类接口(^{
} ans^{} )。在 - 添加pybind11绑定和bolderplate代码以创建python包(^{
} 、^{} 和^{} )。在
更多信息
有关正在运行的nist代码的更多信息,look into the original repository。在
有关估计方法的更多信息,请参见SP 800-90B。在
- 项目
标签: