Chi2 10b

248 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
248
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Chi2 10b

  1. 1. DEKART Random Run’s Tests
  2. 2. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999K
  3. 3. Dekart S.R.L, Tel. +3732 24-14-30, 24-55-80 Fax. +3732 24-25-08 E-mail: valera@dekart.com D-2012, http://www.dekart.com!
  4. 4. #
  5. 5. $ %Dekart S.R.L.» ,
  6. 6. E-mail: petrova@dekart.com)
  7. 7. E-mail: owl@dekart.com)
  8. 8. !
  9. 9. _______________________ 2Copyright © DEKART S.R.L.
  10. 10. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999 ! # ! ! ! $!% # 2. # %#$ ()*+, +-./01 +2.34 ,5464 7# _______________________ 3Copyright © DEKART S.R.L.
  11. 11. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999
  12. 12. 1 ()*(+ ,-( ..............................................................................52 ()*(+ . (!(-+)(/ 0+)0 .............................................6 2.1 ......................................................................... 6 2.2 ........................................................................................ 6 2.3 ............................................................................... 6 2.4 8 ................................................................................................ 6 2.5 9 :# ......................................................................... 7 2.6 ........................................................................... 7 2.7 ...................................................................... 7 2.8 9 ;: 7 = ........................................................................... 7 2.9 9 0?5@A-BBC.D 1862BA5 6546E ............................................. 73 (*0+!!+01(2 !+,34500.......................................................84 DEKART RANDOM RUN’S TESTS ........................9 4.1 F@5G25.HI J !E ........................ 9 4.2 45@C-A J H............................................................................. 9 4.3 D-B J .................................................................... 10 4.4 B0K5@ J J :LE ........................................ 10 4.5 02B0. J :# ........................................................ 11 4.6 B5@1265 J .......................................................... 11 4.7 B5@1 J ! ML # .................... 12 4.8 @2.4 J .......................................................... 12 4.9 1-NC121 J O: 7 =P ...................................................... 13 4.10 162BA5 J ............................................................. 13 4.11 QRS J ! # ............................................................. 14 4.12 .QRS J ! # % ! : : TU .............................................................................................. 14 4.13 D-11- J ! 7!# %M V8ML ................ 15 4.14 5@F J ! 7!# % # .............................. 15 W XT H0115.6 J L# 7 # Y 216 W XZ B[?-A25 J ! # Bs # :# 16 W X 46C@] J ! ! ^% % .............................. 17 W X= F-H6 J ! M .............................................................. 175
  13. 13. DEKART RANDOM RUN’S TESTS ..............................................................19
  14. 14. ...............................................................................................23_______________________ 4Copyright © DEKART S.R.L.
  15. 15. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 19991
  16. 16. ! ! ! 77! # ! ^!# # ! !7 : ### 2 [1, 2].
  17. 17. 7# # ! ! 7# # !% # %!% M 2 1 s k (Ys n ps ) 2 n ps% Ys - ! %Y s; ps - # % ! 7 # %Y s; k - ! %_ n – :$ ! 7!Y 2 ! : = k – 1 !## p -# # :# 7 %7 ` n : !: # Y: ps 7 . ps: T a p 7 U JX b cc J XUU b 7 :Y# ! ! a p cc cTb T X b 7 !Y# ;7_ 7!# p, 7Y! cT cU b XU T b 7 ;%7 [1]. ( 6$ !7 0 – 1 %, 99 – 100 % d 1 – 5 %, 95 – 99 % 7 5 – 10 %, 90 – 95 % ^% 7 10 – 90 % e % DEKART Random Run’s Tests 7 ! # ! !
  18. 18. L 7# $Y # 2 #L %! _______________________ 5Copyright © DEKART S.R.L.
  19. 19. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 19992
  20. 20. 2.1
  21. 21. ^! ! : U d–1 (d = 256 M M $Y! d = 10 8 % #Y# #! LM) ## !# 7 ! ## k=d ## ps =1 / d.2.2 $ # ! 7 Y$ % 7 % n ! ! # %!# ! # ## k= dn ## ps = 1 / dn.2.3 ## ##7! $ 7 7 [, f # %## ! U X ] XT ! : 15) ! 7!# ::Y# H $Y# KgXZhX ## B0=p, p1=p(1-p), p2=p(1-p)2,...,p16=p(1-p)16 .2.4 8 i! 8 n % 7 # Y$ %7 % ! ! % # ! Y$! ` % T T 7 J 7_ W 7 J _ j 7 J j % _ ] 7 J : W % _ 7 J # % !# ! % # T8W8j8]8U7 ! 7 ## 2. d# ML# 7Y!# Y$ 7 m% Y$ % 7 % ! ! ! ## !Y$ J ! k_______________________ 6Copyright © DEKART S.R.L.
  22. 22. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999!# % % U8X8]8j8WE !% ## 2.2.5 0 # ! ! #Y# n % : # % !: : ;: L ! U d8X % ! 7 # % # 2.6 l# # n % T % 7 % T %# ! !# 7 !% ## k=5 ## p=1/5!2.7
  23. 23. 7 m 7 :Y$ ! !2.8 0 %#7 9 l# ! ! # % 7 =Y$ % 7 % ! % ### : k !# 7 7! ## 22.9 0 6$ :overlapping m-tuple test) ### ML l# ! ! # % j % 7 7 : V2) ( V3) % fjn 7# ! ME :: %Y# 7 V2) ojE#! LM _______________________ 7Copyright © DEKART S.R.L.
  24. 24. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 19993 ! #$
  25. 25. e 7 # % 7! ! ! ! U ]TT # ! E U XU # #! LME 7 # $ a 7 % !E Y$ % 7 % !! 7 % % #YE l7 % 7 % ! # ## !! Uj , $ 7 7 [, [ ( Uj ),!# ! Y$ 7 # 8 e 7 % 7! !! ## 7! :L ! Y$ % 7 %! 7 EY ## 0 # 8 #7 : ! ! % 7 :# ! # % ! :# # : ;% : !# !Y$ # a 7 # ! !# !
  26. 26. 7 l7 % 7% ! 7 % 7# ! Y 7 ## 0 %#7 9 e 7 % ! ! 7 = Y$ % 7% ! !# #Yp = 1/i8. 0 6$ a # 7 7 V3-V2 2 d3-d2E # :E ( Y! E Y$ % 7 % ! !7 _______________________ 8Copyright © DEKART S.R.L.
  27. 27. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 19994 7 # ML ML 7 #7 C . 7 BorlandC 3.02. pL L MS DOS. ML 7Y$ ! % ML 7! # ! !%# i ## ! !! 7 M 7 % : X q 7 # :L 7! 2 , # ## M 7 # 7# 7!# # 7## yy[9]%:# #E a %8: ## ! #7 (c 1 ) 7 : Y$ :$ Name of test (not enough statistics).
  28. 28. ML # # :: #7 C.4.1 frequency ;
  29. 29. : pL# void frequency(FILE *stream) frequency.c
  30. 30. $# ! # % !# 7 # 7 7 ! M LM J #! LME k !## stream.7$ 7! yy[i] %:# #E
  31. 31. %!# d4.2 serial ; =$pL# void serial(FILE *stream) serial.c_______________________ 9Copyright © DEKART S.R.L.
  32. 32. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999
  33. 33. # 7 ! ! E ! # #! E Y$ % 7 % ! ! !
  34. 34. ## ! 7 :L 7 #Y# pcount, 7# - % !# :$ ! npairsE !% ## stream.7$ 7! yy[i] %:# #E
  35. 35. %!# d4.3 gap ; pL# void gap(FILE *stream) gap.c
  36. 36. ## # ! ! Uj , $ 7 7 [, [ : Uj . count[0]...count[15] ## ! ## % U XT X8 J ! : XT ## stream.7$ 7! 9 yy[i] %:# #E
  37. 37. %!# d4.4 poker ; ; :
  38. 38. #$pL# void poker(void) poker.c
  39. 39. i ! 7 U dn %# :: J 7## W a, b, c, d._______________________ 10Copyright © DEKART S.R.L.
  40. 40. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999 !# ! Y$ ! Y$ % 7 % ! c $Y pcount, !% ML % serial, ## ! :L ## 5N65@. /02rA5 s2D5 BH02.6 fZTTjZtn # ! !#E_ 5N65@. /02rA5 s2D5 BH02.6 fXUUUUn # #! !#E_ extern double npairs; # ML serial.7$ 7! ` yy[i] %:# #E
  41. 41. %!# ML 7 :7 % 7# ML serial.4.5 ?@A?B ; # pL# void coupon(FILE *stream) coupon.c
  42. 42. # % ! ! : # % !: : P :P L ! U / ! ! ## % % 7# Y$ count, 7 9hX ! 9gWU_ count[T] c ! % 9E ## # ps # !# !#Y# $Y % p_value). stream.7$ 7! # yy[i] %:# #E
  43. 43. %!# d4.6 permute ; pL# void permute(FILE *stream)_______________________ 11Copyright © DEKART S.R.L.
  44. 44. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999 permute.c
  45. 45. l# ! ! 7## % T !# 7 !# ! % 7 7# $Y # . stream.7$ 7! u yy[i] %:# #E
  46. 46. %!# d! 9: % int perm(int a, int b, int c, int d, int e)4.7 perm ; 6 C pL# int perm(int a, int b, int c, int d, int e) permute.c
  47. 47. !# ! : # #!# ! ! a, b, c, d, e LY MLY F # 7 :7 % fXn .. V 7 # !# 7 int a, int b, int c, int d, int e.7$ 7! k! ML :7 7Y$ # # ! %
  48. 48. %!# d 4.8 runs ;
  49. 49. 7pL# void runs(FILE *stream) runs.c_______________________ 12Copyright © DEKART S.R.L.
  50. 50. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999
  51. 51. 7Y# :Y$ ! $Y # . stream.7$ 7! ^ yy[i] %:# #E
  52. 52. %!# d4.9 maximum ; “#7 ”pL# void maximum(FILE *stream) maximum.c
  53. 53. l# ! ! 7:# = ! k 7Y# 7!# # . stream.7$ 7! yy[i] %:# #E
  54. 54. %!# d4.10 mtuple ; 6$pL# void mtuple(FILE *stream) mtuple.c
  55. 55. l# ! ! 7:# % j k 7Y# : E : ! !#E : # #$ LM #!# !#E ^ LY MY# triples # ;E B-C@4 # OPE ### ! # :L OP OP # :_______________________ 13Copyright © DEKART S.R.L.
  56. 56. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999 OP ! Hvvrvv- rvv-E1 % a, b, c – ! 7 E ! 7 Y# $Y # stream.7$ 7! # yy[i] %:# #E
  57. 57. %!# d4.11 CHI ; 6 pL# double CHI(double x, int n) chi.c
  58. 58. !# # $# 2 7 # : ` : n 2 – x.7$ 7! # :#
  59. 59. %!# d! 7 ML $# 7% : - double CHI(double x, int n) double chi(double x, int n)4.12 nCHI ; 6 D $ #6 #7 EpL# double nCHI(double x, int n) chi.c1 || - L_______________________ 14Copyright © DEKART S.R.L.
  60. 60. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999
  61. 61. !# # $# 2 , % ! : : TU # ML# ### : # CHI. ` : n 2 - x.7$ 7! # :# a # % %:# # ier 1, nCHI 7$ 7!
  62. 62. %!# d4.13 gamma ; 6 DC
  63. 63. 8CpL# double gamma(double arg) chi.c
  64. 64. !# 7! %MV8ML 7% % k! % arg.7$ 7! %M V8ML
  65. 65. %!# d! pL# 7 : % static double pos (double arg), static double asym (double arg), static double neg(double arg) .4.14 erf ; 6 D pL# double erf(double x) chi.c
  66. 66. !# 7! % # ML :E c $Y L [5]. k! % % # 7$ 7! k! % #
  67. 67. %!# d_______________________ 15Copyright © DEKART S.R.L.
  68. 68. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999! ! # 7# %: ier # 7! X 4.15 comment ; 7 F 2pL# void comment(void) comment.c
  69. 69. 7 7 # ! X :$ 7Y ! # 7# ier=1, yy[i]0 IIfCnwX E # :$ O(@@0@ 0F 6546P Result of test is :A. Frequency Test - SatisfactoryB. Serial Test - SatisfactoryC. Gap Test - SatisfactoryD. Poker Test - Faintly suspiciousE. Coupon Test - SatisfactoryF. Permutation Test - SatisfactoryG. Runs Up Test - SatisfactoryH. Maxi-of-8 Test - SatisfactoryI. Lapped M-Tuple Test - Satisfactory k!# # H:: extern double yy[9].7$ 7! d
  70. 70. %!# d4.16 p_value ; 6 ps # pL# void p_value(void) p_value.c
  71. 71. % p_value (# : :7 MLYE !# 7!# # ps # :# (# % !# d, # ps YE ! # M ZE fX 7 j j ]]._______________________ 16Copyright © DEKART S.R.L.
  72. 72. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999 7 B[?-A25 : 7 M! 7!# 9 / 7L 9gWU_ /g= # ! : /gXU J # #!E a p_value : :7 MLY T d : ! .7$ 7! 7 ! # : : M
  73. 73. %!# d! pL# 7 : % float stir2 (int, int), double fact(int).4.17 stir2 ; 6 )D D pL# float p_value(int n, int k) p_value.c
  74. 74. !# ! ^% % M [4]: n, k 1 k 1) kj k j n! j 0 ( j n ! 7Y# L ! n k.7$ 7! ` ^% %
  75. 75. %!# d! pL# 7 :Y % double fact(int).4.18 fact ; 6 CpL# double fact(int n) p_value.c
  76. 76. !# M % ! n. d ! n.7$ 7! p n!._______________________ 17Copyright © DEKART S.R.L.
  77. 77. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999
  78. 78. %!# d_______________________ 18Copyright © DEKART S.R.L.
  79. 79. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 19995 ! #$% #() * !! DEKART Random Run’s Testsd ML %DEKART Random Run’s Tests : 7: % # #! ! – main2.exeE #! LM (main10.exe) # : L %#7 bat8M CHI_TEST.BAT:@echo offREM 1 - number system (2 or 10)REM 2 - input_file_nameREM 3 - output_file_name (NULL==CON)if %1 ==/? goto er1if %1 .==. goto er1if %2 .==. goto er1if %1 == 2 goto m2if %1 == 10 goto m10goto err:m2if %3 .==. goto m22main2 %1 %2 %3goto exit:m22main2 %1 %2goto exit:m10if %3 .==. goto m12main10 %1 %2 %3goto exit:m12main10 %1 %2goto exit:errecho Number system must be decimal (10) or binary (2)goto exit:er1echo*****************************************************************echo * Tests for randomness on characters of a file*echo * Copyright (c) Dekart SRL*echo **echo **_______________________ 19Copyright © DEKART S.R.L.
  80. 80. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999echo * Usage:*echo * 1. CHI_TEST number_system input_file_name*echo * 2. CHI_TEST number_system input_file_name output_file_name*echo **echo **echo * File should contain at least 1 Mbyte of random data*echo*****************************************************************:exit 6 D
  81. 81. 6 k % Hhi_test $ # :path chi_test.bat n_s path input_file_name (a)path chi_test.bat n_s path input_file_name path output_file_name (b)
  82. 82. ! 7Y!# : 7# EE M (b)). G6 6G6 6 ! 7Y# !# n_s ! ! 7# M input_file_name, 7 % : X q ! # # : ! 7 # 7## :Lx d7 # ! ` :# 2 : :L # L# 7 7 7!Y # # % ( 6$ !7 0 – 1 %, 99 – 100 % d 1 – 5 %, 95 – 99 % 7 5 – 10 %, 90 – 95 % ^% 7 10 – 90 % e 7 # 7 M b1: 1000000 characters in file: b1A. Frequency Test CHI = 0.659510 x2 = 263.715328 n = 255_______________________ 20Copyright © DEKART S.R.L.
  83. 83. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999B. Serial Test CHI = 0.367744 x2 = 65412.102144 n = 65535C. Gap Test CHI = 0.571380 x2 = 16.352818 n = 16D. Poker Test CHI = 0.073851 x2 = 0.888890 n = 4E. Coupon Test CHI = 0.284641 x2 = 27.051418 n = 32F. Permutations Test CHI = 0.351198 x2 = 112.558610 n = 119G. Runs Up Test CHI = 0.288077 x2 = 2.922561 n = 5H. Max-of-8 Test CHI = 0.534920 x2 = 55.252936 n = 55I. Lapped M-Tuple Test CHI = 0.695418 x2 = 462.797214 n = 448 Result of test is :A. Frequency Test - SatisfactoryB. Serial Test - SatisfactoryC. Gap Test - SatisfactoryD. Poker Test - Faintly suspiciousE. Coupon Test - SatisfactoryF. Permutation Test - SatisfactoryG. Runs Up Test - SatisfactoryH. Maxi-of-8 Test - SatisfactoryI. Lapped M-Tuple Test - Satisfactory! CHI J ! # _ n J ! :_ x2 J 7! 2. a %8: 7 7# Y CHI # U #:$ : “Error of test”. # ML# 7 : %# 7 E 7E 7# M output_file_name. )#H 7F a 7 % chi_test : 7 # % M input_file_name, : !# : 7 Y! /? - #:$ Tests for randomness on characters of a file Copyright (c) Dekart SRL Usage: 1. CHI_TEST number_system input_file_name 2. CHI_TEST number_system input_file_name output_file_name File should contain at least 1 Mbyte of random data !% % 7 Y : a ! % : 7 # $Y$% M ### :$ ***: no such file or directory_______________________ 21Copyright © DEKART S.R.L.
  84. 84. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999 % 7!# a %8: ## ! #7 , 7 : Y$ :$ Name of test (not enough statistics)._______________________ 22Copyright © DEKART S.R.L.
  85. 85. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999+ 1. i l %# # my 9 ] ! % 8 Xc 8 ] 2. 9 d! p d! d p ! 8 u Xc=W 8 T] 3. Wegentkittl S. Empirical testing of pseudorandom number generator/ Master’s thesis, University of Salzburg, Austria, 1995.4. ! L! y V z J ^ L# Xc== J =W 5. # ^! % % #7 : # m ^! 8 d Xc=c J ]WU _______________________ 23Copyright © DEKART S.R.L.
  86. 86. Data Security Section of Smart Card Technology, DEKART S.R.L.Moldova, Kishinev February 8, 1999_______________________ 24Copyright © DEKART S.R.L.

×