电 子 科 技 大 学
UNIVERSITY OF ELECTRONIC SCIENCE AND TECHNOLOGY OF CHINA
专业学位硕士学位论文
MASTER THESIS FOR PROFESSIONAL DEGREE
论文题目 随机数发生器随机性检测系统
的设计与实现
专 业 学 位 类 别 工程硕士
学 号
201251010145
作 者 姓 名 赵海英
指 导 教 师 贾宇明 教授
分类号 密级
UDC 注 1
学 位 论 文
随机数发生器随机性检测系统的
设计与实现
赵海英
指导教师 贾宇明 教 授
电子科技大学 成 都
何智 高 工
中国电科三十所 成 都
申请学位级别 硕士 专业学位类别 工程硕士
工程领域名称 电子与通信工程
提交论文日期 2014 年 3 月 论文答辩日期 2014 年 5 月
学位授予单位和日期 电子科技大学 2014 年 6 月 25 日
答辩委员会主席
评阅人
注 1:注明《国际十进分类法 UDC》的类号。
II
THE RESEARCH OF
RANDOM GENERATOR AND THE DESIGN OF
RANDOMIZATION TEST SYSTEM
A Master Thesis Submitted to
University of Electronic Science and Technology of China
Major: Master of Engineering
Author: Zhao Haiying
Advisor: Professor Jia Yuming
School: School of Communication & Information
Engineering
独创性声明
本人声明所呈交的学位论文是本人在导师指导下进行的研究工
作及取得的研究成果。据我所知,除了文中特别加以标注和致谢的地
方外,论文中不包含其他人已经发表或撰写过的研究成果,也不包含
为获得电子科技大学或其它教育机构的学位或证书而使用过的材料。
与我一同工作的同志对本研究所做的任何贡献均已在论文中作了明
确的说明并表示谢意。
作者签名: 日期: 年 月 日
论文使用授权
本学位论文作者完全了解电子科技大学有关保留、使用学位论文
的规定,有权保留并向国家有关部门或机构送交论文的复印件和磁盘,
允许论文被查阅和借阅。本人授权电子科技大学可以将学位论文的全
部或部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描
等复制手段保存、汇编学位论文。
(保密的学位论文在解密后应遵守此规定)
作者签名: 导师签名:
日期: 年 月 日
摘要
摘 要
随机数作为密钥或密码运算资源被广泛应用于信息安全系统,随机数的研究
越来越重要。随着计算技术和密码学的发展,在信息安全应用中不仅需要可输出
各种形式随机数的发生器,而且还需要对随机数的随机性做更深入的研究与分析,
为相关应用提供理论支撑。
本文综合讨论了随机数发生器及随机性检测器的设计与实现。
首先对随机数发生器进行了分类讨论,按照真随机数发生器与伪随机数发生
器两种产生方法及性能进行了分析和对比。本文研究并设计了两款伪随机数发生
器,并用软件实现这两个发生器,产生相应的实例以供随机性检测器测试。同时
在信息安全领域真随机数发生器中选择了一款常用的噪声源芯片 WNG4,用该芯
片产生真随机数,本软件系统调用该真随机数序列作为测试实例,以供随机性检
测器测试。
其次本文设计并实现了一款随机性检测器,该检测器实现了国内较常用的 15
种检测方法,包括单比特频数检测、块内频数检测、扑克检测、重叠子序列检测、
游程总数检测、游程分布检测、块内最大“1”游程检测、二元推导检测、自相关
检测、矩阵秩检测、累加和检测、近似熵检测、线性复杂度检测、Maurer 通用统
计检测、离散傅立叶检测等 15 项检测方法。以统计与概率学为理论依据,对 15
种检测方法进行软件实现,对每种方法的运算步骤及实现做了详细的研究与分析。
然后本文使用三个正向实例与一个反向实例作为测试案例对检测器进行测试。
正向实例为本文自行设计的随机数发生器产生的结果作为待测样本数据,即两款
伪随机数发生器与一款真随机数发生器产生的随机数。反向实例为模拟一个有明
显缺陷的随机数序列。本文详细讨论了测试结果,对随机数发生器与随机性检测
器同时进行测试与验证,以证明随机数发生器的良好性能及随机性检测器的运行
有效性,并得出结论,证明该检测系统的设计与实现与预期一致。
本文的亮点在于:
紧密结合工作实际,紧紧围绕随机数随机性检测这一课题的研究,系统地梳
理了相关检测方法,综合国内实际情况选择了最适合信息安全领域的 15 种检测方
法,再用简洁高效的软件语言实现这些检测方法,拓展了企业在随机性检测领域
的检测能力,使之成为信息安全领域的有效测试工具。
关键词:真随机数,伪随机数,随机性,随机数发生器,随机性检测器
I
ABSTRACT
ABSTRACT
As random is always used as KEY or cryptographic resource in information system,
so it is important for us to study random,randomness and random tester。Followed the
development of computer technology and cryptograph,the information security system
need not only all kinds of random generators,but also the support of the random theory,
which needs deep studying the character of random.
This article puts eyes on two points:the way to design random generator and the
way to test an array of random.
Firstly,we discussed several kinds of random generators,compared true random
generator by pseudo random generator。We designed two kinds of pseudo random
generator,and realized them in C language,then used those two kinds of pseudo
random generator to produce pseudo random。The output of pseudo random generator
used for random test。At the same time,we programed a software to get random from
true random generator,which used in true information system and produced random
using WNG4,a random chip。
Secondly,we design a random tester,which including 15 kinds of ways to test the
quality of an array of random which is called randomness,include:mono-bit frequency
test、frequency test within a block、poker test、serial test、runs test、runs distribution
test、test for the longest run of ones in a block、binary derivative test、autocorrelation test、
binary matrix rank test、cumulative test、 approximate entropy test、linear complexity
test、Maurer universal test 、discrete Fourier transform test。
Random produced by true random generator and pseudo random generator。And
the while,each way to test randomness based on statistics and probability theory。We
studied each way carefully and realized it by programming software。
Thirdly,we used random tester to test random by three forward examples input and
one backward example input。Three forward examples input used two array of random
produced by pseudo random generator and an array of random produced by true random
generator。Backward example input used an array of random which had certainly some
defect。We tested it and carefully studied the result,then we got the result according to
the designing primitive.
The performance of this article lied on three points:
II
ABSTRACT
1. According to the practical work;
2. Keeping eyes on random testing;
3. Carding the ways of random testing systematically.
In this article,we choose 15 kinds of ways to test an array of random,those ways
had mostly used in information security fields。We realized them and programmed a
software in C language including all of those 15 ways。This provided another way to
test randomness。
KEY words:true random,pseudo random,randomness,random generator,
random tester
III
目录
目 录
第一章 绪论 ..................................................... 1
1.1 研究背景 .................................................. 1
1.2 国内外发展现状 ............................................ 2
1.3 研究内容 .................................................. 3
1.4 章节安排 .................................................. 4
第二章 理论依据 ................................................. 5
2.1 基本理论 .................................................. 5
2.1.1 随机数 .............................................. 5
2.1.2 随机性 .............................................. 6
2.1.3 随机数产生 .......................................... 6
2.2 相关数学理论 .............................................. 7
2.2.1 概率公理化 .......................................... 7
2.2.2 概率分布 ............................................ 8
2.2.3 基本函数 ............................................ 9
2.3 随机性检测原理 ........................................... 10
2.3.1 思想依据 ........................................... 10
2.3.2 检测步骤 ........................................... 11
2.3.3 计算方法 ........................................... 12
2.4 检测方法的选择 ........................................... 14
第三章 总体方案 ................................................ 15
3.1 需求分析 ................................................. 15
3.1.1 系统目标 ........................................... 15
3.1.2 功能划分 ........................................... 15
3.1.3 性能指标 ........................................... 16
3.2 系统总体设计 ............................................. 16
3.2.1 模块单元 ........................................... 16
3.2.2 软件结构 ........................................... 17
3.3 随机性检测内容及方法 ..................................... 18
3.4 软件实现语言 ............................................. 20
3.5 本章小结 ................................................. 20
IV