3 Star 19 Fork 17

Cliven / randomness

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Randomness 二元序列随机性检测方法

Documentation GitHub go.mod Go version GitHub tag (latest SemVer)

在使用randomness前,请务必悉知 《randomness 免责声明》

项目概述

该工具库实现了《GM/T 0005-2021 随机性检测规范》中描述的15种随机性检测方法。

rundesp.png

检测工具

若您需要使用相关测试工具需要可以 从Release中下载编译版本手动编译程序,详见文档:

快速入门

rddetector检测工具只是randomness的一种应用方式,randomness提供丰富的API接口,您可以在根据需要定制化的使用。

安装randomness

go get -u github.com/Trisia/randomness

下面是10^6比特数据规模的扑克检测的例子:

package main

import (
	"crypto/rand"
	"fmt"
	"github.com/Trisia/randomness"
)

func main() {
	// 产生随机数序列
	n := 1000_000
	buf := make([]byte, n/8)
	_, _ = rand.Read(buf)
	// 转换为字节数组
	bits := randomness.B2bitArr(buf)

	// 运行测试组
	p, _ := randomness.PokerTest(bits)
	fmt.Printf("扑克检测 n: 1000000, P-value: %f\n", p)
}

更多API使用方法见:randomness API 文档

随机数发生器检测

randomness 实现了 《GM/T 0025-2014 SSL VPN 网关产品规范》 5.4.4.3 随机数发生器 4个不同应用阶段的随机数检测:

使用方法见 测试用例 detect_test.go

如果您的主机处理器含有多个核心,那么可以使用Fast系列的API来加速检测,见 测试用例 detect_fast_test.go

注意:离散傅里叶检测 10^8 bit 规模数据检测为了加速计算单次检测需要消耗1024MB以上内存,请注意主机并发数量防止发生内存溢出(OOM)。

发展

检测规范:

在 GM/T 0005-2021 中在 样本通过率判定 的基础上,增加了 样本均匀性判定 作为检测通过判定依据,详见 GM/T 0005-2021 6.3。

目前 randomness 已经升级至《GM/T 0005-2021 随机性检测规范》。

MIT License Copyright (c) 2022 Quan Guanyu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

实现了《GB/T 32915-2016 信息安全技术 二元序列随机性检测方法》/《GM/T 0005-2021 随机性检测规范》中描述的15中随机性检测方法。 展开 收起
Go 等 3 种语言
MIT
取消

发行版 (5)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/Trisia/randomness.git
git@gitee.com:Trisia/randomness.git
Trisia
randomness
randomness
master

搜索帮助