Int ern at i onal  Journ al of Ele ctrical  an d  Co mput er  En gin eeri ng   (IJ E C E)   Vo l.  9 , No . 6, Dece m ber  20 19, p p.   5615 ~ 5627   IS S N: 20 88 - 8708, DO I:   10 .11 591/ijece .v9i6 . pp5615 - 56 27          5615       Journ al h om e page :  http: // ia es core .c om/ journa ls /i ndex. ph p/IJECE   Cryptog ra ph ic a daptati on  of  th e mi dd le square gen erator       Ha n a Ali - P ac ha 1 ,   N aima  H ad j - S aid 2 ,  Adda  Ali - P acha 3 ,   Moham ad A fe ndee  Moham e d 4 , Must afa  Mam at 5   1 ,2,3 La b.   of  Cod i ng  and  Se cur i t y   of  Inform at ion   ( LACOS I),   Univer sit y   of   Sci enc e s a nd  T ec hno log y   of  Oran ,   Alg er ia   4,5 Facul t y   of  Inf orm at ic s a nd   Co m puti ng,   Univer siti   Sult an Za in a l  Abidin ,   B esut Cam pus,  Malay s ia       Art ic le  In f o     ABSTR A CT    Art ic le  history:   Re cei ved   A pr   5 , 2 01 9   Re vised  Ju l   19 ,  201 9   Accepte d  J ul   28 , 2 01 9       Curre ntly ,   cr y p togra ph y   pl a y s   a  m aj or  rol e   in  var ious  co m pute r  and   te chno logi c al   ap pli c at ions.   W it h  the   high   num ber   of  i nt ern et  users ,   th e  use  of   cr y p togra ph y   t o  provide   info rm at ion  sec ur ity   h as  be come  a  prio rity .   Sever al   appl i ca t i ons  such  as  e - ma il s,  el e ct roni c  banki ng,   m edica l  dat ab ase s   and  e - c om m erce  req uir e  the   exc hang e   of  p riva t e  information.  W hil e ,   if  the   connect io n  is  not  sec ure ,   thi s  sensiti ve   i nform at ion  ca n  be  attac k ed .     The   best - known   cr y p togra ph ic   s y stems   rely   on   the   generation   of  ran dom  num ber s,  which  are   funda m ent a l  in  var ious  cr y p to gra phi c  appl i c at ions  such  as  ke y   gen era t i on  and  dat a  en cr y p ti on .   In  what  foll ows ,   we  want  to  use  pseudo - ran dom   seque nce s  gen er at ed  b y   the   m id dle   square   gen er at or.   In  thi s  work,  it   m ust  be  poss ibl e  to  es ti m at e  th at   th e  dat a  produc ed  h as  ran dom  cha ra cteri sti cs,   k nowing  tha t  th e  al gorit hm   used  i s  det erministi c .   Overa ll,  thi s  pape r  foc uses  on  the   te sting   of  ps eudo - ran dom   seque nce s  gene rated   b y   the m iddl e   square   g ene r at or   a nd  it s use   in   data   enc r y p ti on .   Ke yw or d s :   Crypto gr a phy     Entr op y  t est     Mi dd le   s qu a re  g ene r at or     Ra ndom   n ic kna m es     V on  n e um ann   Copyright   ©   201 9   Instit ut e  o f Ad vanc ed   Engi n ee r ing  and  S cienc e .    Al l   rights re serv ed .   Corres pond in g  Aut h or :   Han a   Ali - Pach a ,   Lab. o f  C od i ng and Sec uri ty  of In form ation   ( LACO SI) ,   Un i ver sit y o f S ci ences a nd Te chnolo gy   of Or an ,   Po  B ox  1505  Or a n  M’ Na oue r  Al ger ia .   Em a il :  han a.ali pach a @ un i v - ust o.dz       1.   INTROD U CTION     The  de velo pme nt  of   al gorit hm s   gen erati ng  ps e udo - ra ndom   nu m ber s  is  ver y  m uch   relat ed  to  that  of  crypto gr a phy  [ 1 - 8].   Es pecial ly ,  t he  m il i ta r ily   i m po rtance  s uch   as   c omm un ic at ion   a nd   m on it or ing   [9 - 10 ]   of  this  sci ence   ha v e   m otivate d  m any  researc he s  thr ough out  histor y.   But  t he re  is  no  ps e udo - ra ndom   al gorithm   that  can  esca pe   from   sta ti s tical   analy sis,  especial ly   beca us e  the   "seed"   m us t  theor et ic al ly   it sel f  be  rand om ,  an d  the  al gorithm   us ed  canno t  be  init ia li zed   by  it sel f.   The  current  cry ptogra phic   gen e ra tors  are  th us   obli ge d  to  include  el e m ent  that  is   no t  gen e rated  in   a  deter m inist i c  way.  On e  th us   m ov es  towa rd s  hybr i d  ge ne rators,  fou nd i ng   a  r obus t  al gorithm   of  pse ud or a nd om   nu m ber   gen e rati on  by  init ia li zi ng   it sel f  thr ough  a   physi cal   m eans of  c hance p rod uction.   On  the  oth e r  ha nd,  the   im age  bec om es  m or e  an d  m or e  in di sp e ns able  i n  se ver al   fiel ds   a nd  esse ntial ly  in  com m un ic at ion   betwee n  pe op le .  I nd ee d,   t he  ex pone ntial   dev el op m e nt  of   c omm un ic ation   m edia  on   t he  one   hand,   a nd   di gital   storag e  m edia  on   the  oth e r   hand,   ha ve  en or m ou sly   trans form ed  the  way  we  co m m un ic at e.   These   ne w  te c hnologies  a re  ba sed  e ssentia ll y  on  the   ef fici ent  e xch a nge  a nd  st or a ge  of  m ultim edia  data  and  i n  par ti cu la r digit al  i m ages,  he nc e the  nee d  f or  i m age en c rypt ion  al gorithm s.   In   w hat  f ollo w s,  we   disc us s  t he  desig n  a nd  reali zat ion   of   t he  m idd le - squ are  ge ne rato r  i n  the   co ntext  of   pr oducin g  pse udo - ra ndom   seq uen ces .  The   si m plistic  of   m idd le - squa re  gen e rato r  can  be  ex plo it ed  f or  go od   rand om   sequ ence.  I n  or der   t o  eval uate  these  sequ e nces  and   validat e  our   gen e rato r,   we  i m ple m ented  five   sta ti c test s .       Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om p  En g,   V ol.  9 , N o.   6 ,  Dece m ber  2 01 9  :   5615   -   5627   5616   This  pa per   is  structu re d  as  fo ll ows.  Sect io n  2  intr oduces   so m e   basic  pri nciples  of   ps e udo - ra ndom  nu m ber   ge ne ra tor.   Sect i on  3   di scusses  the f or m at ion   of   m idd le   square g e ne rator,  outl inin g  the p r ocedu r e  with  an  e xam ples.  S ect ion   4  pr ese nts  va rio us  ty pe s  of  te sti ngs  pur posedly   to   e valuate  th e  qual it y  of   our   pr opos e d  m et ho d.   Sect i on   5  repo rts  the  fin dings  ac cordin g  to  va r iou s  te sts  pro po s ed  earli er  Sect ion   6  c oncl ud es    our   st ud ie s .       2.   PSEU DO - R A NDOM  GE N ERATO RS   The  nee d  f or  rando m   num ber s  is  felt  in  m any  app li cat ion s  of  crypto gr a phy.   In   com m on   crypto gr a phic   syst e m s,  the k e ys (num ber s)  t hat are use d  m us t be  r a ndom l y gen e rated . For   e xam ple, when o ne   consults  on  th e  In te rn et   his  e - m ail  accounts  or,  w hen  one   carries   out  a n  orde r  by  I nter net  s om e  "sensit ive"  inf or m at ion   (your  acce ss  c od e  or   y our  cre di t  card   nu m ber )   m us t  rem a in  confide ntial   to  ens ur e  a uth e nt ic ity,  nobody  s hould  be  able  t o  ac cess  the  acco unts  or  orde r  w it h  the  car d.   T o  ens ure  these   functi ons,  I nt ern e t   protoc ols  hav e   bee n  pu t   in  pl ace.  They  al l ow  yo u  to   ent er  yo ur  co des   on  a  web  pa ge   with ou t  t he  risk  of     an  outsi de  pe rson  ha ving  a ccess  to  them .  These  pr otoc ols  us e  ra nd om   nu m ber s  to  enc rypt  dat a  and   pr e ve nt sp yi ng .     2.1.   Def ini ti on   of  a ran do m  seq u ence   In   m at he m at ics,   a  rand om   se qu e nce,  or   ra ndom   infin it e  sequ e nce,  is  a  s equ e nce  of   sy m bo ls  of   an   al ph a bet  ha vin g  no   str uctu re,  no  re gu la r it y,  or   identif ia ble  pr e dicti on   r ule  [ 11 - 12 ] .  Su ch  a  seq uen c e   corres ponds  to  the  intuit ive   no ti on  of  nu m ber s  dr aw n  at   ran dom .  A  sequ e nce  of  rand om   nu m ber s  is    a  sequ e nce  of  nu m ber s  ra ndom ly  cho se n.   T his  seq uen c e  ha s  the  pro per ty   that  we  canno t  pr edict   the  nu m ber s  to co m e from  t he  al rea dy  known  num ber s , w hateve r  they  a r e   [ 13 ] .     2.2.   Def ini ti on   of  a pseud o - ra nd om  seque nce   The  ps e udo - ra ndom   te r m   is  us e d  in  m at hem at ic s  and   co m pu te r  sci ence   to  de sig nate  a   seq uen ce   of   nu m ber s  that  a ppr oach es  a  st at ist ic ally  per f ect   hazard   [14 - 16 ] .  By   the  al gorithm ic   pr oce sses  us e d  to  cr eat e  i t   and   t he  s ource s  us e d,   t he  se qu e nce  ca nnot   be  c om plete l y  con si der e d  a s  truly  ra ndom .   A  ps eu do - r andom   seq uen ce   (Pse udo  Ra ndom   Sequ e nce  i n  E ngli sh )   [ 17]   is  a   seq ue nce  of  intege rs  x 0 ,  x 1 ,   x 2 ,  ...  ta king  it s  val u es  in  the  set   M  =  {0,   1,   2,   ... ,   m - 1}.   The  te rm   x n   (n >  0)   is  the  resu lt   of  a   cal culat ion  (to  be  de fine d)   on   the  pre vious   te rm   (s) .  The  first  te r m   x 0   is  called  the  se ed .  W it h  the   sam e  init ial  seed,     the  seq uen ce  of  ps e udoran do m   nu m ber s  produce d  by  the   ps eu dora ndom   nu m ber   generator  is  dete r m inist i c   and can  the refor e  b e  r e pro duced.   A  ps e udo - ra ndom   nu m ber   ge ner at or  is  a n  al gorithm   that  ge ner at es  a   seq uen ce   of  num ber s  wit h  certai n  pro per t ie s  of  c han ce .  The  pri nciple   of  these   ge ne r at or s   is  to   crea te   from   an  init ia l  seed,   a  s o - cal le d  ps e udo - ra ndom   nu m ber , whi ch has  no appa ren t l ogic al  or  arit hm etic connecti on w it h t he  seed. T his g e ner at e d  nu m ber   is  then   us ed  to  create   a  second  ps e udo - ra ndom   num ber .  W e  ca n  thu s  rec ursivel y  gen erate  a  se ries  of  nu m ber s  that  do  not  ap pea r  to  ha ve  a ny  logi cal   li nk   in  t he ir  seq uen ce ,  but  w hich  a re  in  fact  al l  obta ined  by     a  determ inist ic  f or m ula.  T his  cl ass  of  ge ne rators  is  easy   to  im ple m ent  and  al lo ws  high  th r oughputs  wh il e   pro du ci ng   s uites  that  hav e  go od   sta ti sti cal   pr operti es.  It  is  therefo re  ver y  su it able  for  ap plica ti on s  that  do   no t   require  the  un pr e dicta bili ty   of   the  su it es  (s uch   as  dig it al   si m ulati on ),   but  can  al so   be  us e d  in  cry ptogra phic   app li cat io ns   prov i ded that ce r ta in cr it eria are  m e t.       3.   MIDDLE  S Q UARE GE NE RA TO R   This  gen e rato r  is  base d  on  th e   m edian  sq ua re   m e t ho d,  kn own  in  t he  E ng li s h  li te ratur e  al so   as  m idd le   sq ua re,   wa s  in ven te d  by  the   Am erican - H ungar ia n  m at he m at ic ia n  an d  physi ci st  Jo hn  V on  Ne um ann   i n  1946.   The  m idd le   s quare   is  c onsid ered  as  t he  fir st  m e tho d  of  autom at ic   generati on  of  ps e udoran dom   num ber s.     T he  pri nciple  of   this  m et ho d  is  ver y  sim ple,  we  ge ne r at e  a  sequ enc e  of   num ber s  each  ha ving  2k  dig it s     (ev e n  nu m ber ) .  The   su cc esso r  of  a  num ber   in  this  se qu e nc e  is  obta ined   by   raisi ng   t his  nu m ber   s quare d  a nd   then ret ai ning t he 2k m idd le  num ber s.  T he pr incipl e of t his  m et ho d  is  d esc ribe d by the  fo l lowing  ste ps :     Start wit h a see d (a  nu m ber )  of  n - dig it  (n  dig i ts),     Ra ise  squar e d  t o get a  nu m ber o f 2n di gits, a dd zer os  i f nec essary,     Take t he  m idd le  n   num ber s as  the  nex t  ra ndom  n u m ber ,     Re peat 1 - 2 - 3  (t he pr ocess ).         Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om p  En g     IS S N: 20 88 - 8 708       Crypto graphic   adaptati on  of t he mid dle s quare  g e ner ato r  (Han a  Ali - P ac ha)   5617   Exam ple   :  If   w e  gen e rate  4 - di git  nu m ber s  f r om   35 67,  we  ge t  72 34  as  the  nex t  val ue  sinc e  the  3 56 7   sq ua re  is  e qu al   to  1272 3489,   c on ti nuin g  in  t he  sam e  way,  the  ne xt  num ber   will   be   3307 ,   3567,  7234,   3307,   9362  ,  6470,   8609,   11 48,  31 79,  1060,  1236,  5276,  836 1,  9063,  1379,   9016,   28 82,  30 59,  3574,  7734,  81 47 ,   3736,  9576,   6997,   95 80,  77 64,  2796,   81 76,  8469,   7239   ,  4031,   24 89,   1951,   8064,  280,  78 4,  61 46,  7733 ,  7992,  8720,   384,  1474,  1726,  9790,   84 41,   2504,   27 00,  2900,  4100,   8100,   61 00,  2100,  4100 ,  a nd   so   on .     The   res ulti ng  s equ e nce  retu r ns afte r  46 iterat ion s  in  a  p e rio dic or bit .       4.   TE ST A GE N ERATO R   Determ ining   w hethe r  a  gen e r at or   is  rand om  or  not  is  a  tric ky  pro blem .  Indeed,  the re  is  no  unive rsal   te st,  that  can  s ay   with  certai nty  that  a  generator  is  rand om   [18 - 19] .  T he   pr in ci ple  is  to  sho w  that  it   is  no t  biased  by  study ing   the  pro pe rtie s  of   the  num ber s  it   gen erates.  I n  pr a c ti ce,  a  ran dom   gen e rator   pro du ce s     a  sequ e nce  of  nu m ber s  with  pro per ti es  of   unpre dicta bili ty  [ 20 - 22 ]   an d  ind e pe nd e nce,  and   fo ll ows  a  certai n  dis trib ution   (unif or m   in  cryptography,  Ga ussi an  in  te le co m m un ic at ion s,   et c.).   The  e va luati on   of  the  r andom   qu al it y  of   a  ge ner at or   th us   passes  th rou gh  the  con tr ol  of  the  prop e rtie s  of   the  seq ue nc e  that  it  gen e rates.     This  is  achieve d  thr ough  sta ti sti cal   te sts   that  com par e  the  per f or m ance  of   the  gen e rato r  s tud ie d  c om par ed  to   tho se , th e or et ic al .   The  pur pose of  stat istica l  te sts  is to  m easur e the quali ty  o f  a  rand om sequ e nc e.  W e can  co nc lud e that   a  su it e  ge ner at ed  by  a  PR NG  is  rando m   and  of   good  qual it y,  if  it   sat isfie s  these  te sts.  Th eref or e ,  a  sta ti sti cal   te st  can  in  no  way  guara ntee  that  a  giv e n  se qu e nce  is  ra nd om .  The  on ly   inf or m at ion   tha t  a  sta ti st ic al   test  can  pro vid e  is  that   the  seq ue nce  seem s  ran do m .   Seve ral  sta ndar ds   e xist  to  evaluate  a nd   c erti fy  the  qual i ty   of   ps e udor a ndom   nu m ber   ge ne rators.  W e  will   pr ese nt  so m e  te s ts  us ed  to  eval uate   the  perform a nce  of     our ge ner at or .     4.1.   Entropy   tes t   An   e ntr op y  ca lc ulate s  the  am ou nt  of   in f orm ation   co ntained  i n  a  file .  The  file   is  co ns ide red   a s     a seq ue nce  of   words  of   1 o r 8   bits. T he  e ntr opy i s calc ulate d  as  sho wn b el ow :     ( ) = − ∑ ( ) .  2 ( 2 − 1 = 0 ( ) )       W he re  X  is  the   stud ie d  s ource ,  P i   is  the   pro ba bili ty   of   ap pe aran ce  of  the  word  i  of  n  bit s.   T he  com pu t at ion   of   the  ent ropy  m akes  t he  m inim u m   nu m ber   of  bits  per  w ord  c onta inin g  al l  the  in f orm at ion .   F or  e xam ple,   if  the  e ntr opy  is  6  bits/ w ord  for  8 - bit  w ords   the n  2  bits  car ry  re dund ant  in form at io n  a nd  the   file   co ul d  theo reti cal ly  b e com pr esse d  t o  th ree  quarter s of its  or igi nal size .     4.2.   Mean,  st an d ar d  de viation  and  au t o - correl at i on   fa c t or   This  is  the  si m plest  te st  po s sible.  It  con sist s  of  cal culat ing   t he  m ean,  the  va riance  a nd     the  autoc orrela ti on   facto r  of  the  ps e udo - ra ndom   sequ e nce.   L e t   x i ,   f or   i   =  1,   2,   . . ,   n,   be   a   s e qu e nc e   ob t a i ne d  f r om   a   ps e ud o - r a n d om   num be r   ge ne r a t or .   T h e   s e qu e nc e   of   u i =x i / n,   f or   i   =   1,   2,   . . ,   n  i s   a   se qu e nc e   o f   ps e ud o - r a nd om   num be r s   di s t r i bu t e d  u ni f or m ly   i n  t he   i nt e r va l   [ 0, 1] .   F or   a   r a nd om   se qu e nc e ,   t he s e   f a c t or s   t e nd   t o w a r ds   i de a l   va l ue s ,   w hi c h  a r e   t hu s   s uf f i c i e nt   t o  c om pa r e   w i t h  th e   c a l c ul a t e d  va l ue s   f or   t he   f ol l ow i ng   U .   I de a l l y ,   w e   m us t   f i nd   th e   t hr e e   va l ue s   be l ow :     a)   Av e ra ge:   = 1 . ∑ = 1 = 1 2 .   b)   Var ia nce:   = 1 . ∑ ( 2 − 2 ) = 1 12 .     c)   Au t o  C orrelat ion :  = 1 . ∑ ( ∗ + 1 ) = 1 4 − 1 .       4.3.   Spectr al  te st   The  i dea  is  to   visu al ly   re pr es ent  the  s eq ue nc e  of  pse ud o - r andom   nu m bers  in  1  dim e ns i on  ( 1D),  2D  and  3D.   F or  3D  Re pr ese ntati on ,   th ree  c onse cutive  values   will   be  t he  c oord i nates  of   a   point  i n  s pace.   We  l ook  at   wh et her   t he  po i nts  are  eve nly  distrib uted   in  a  c ub e .   B y   t ur ni ng   t he   c ub e   a s   s ho w n  i n  F i gu r e   1 ,   o ne   s e e s   a n   un de s i r a bl e   e f f e c t   a pp e a r ,   t ha t   i s  t he   pl a ns   of  M a r s a gl i a   [20] .   I t   i s  c l e a r   be l ow   t ha t   t he   poi nt s   a r e   l oc a te d  on   pl a ns .   I n  f a c t ,   a l l   l i ne a r   c on gr u e nt i a l  ge ne r a t or s   ( L C G )   s uf f e r   f r om   t hi s   e f f e c t   ( t hi s   i s   du e   to   t he   f a c t   t ha t   w e   do   no t   ge ne r a t e   a l l  r e a l s ,   bu t   o nl y   f r a c t i on s ) .   T he   sm a ll e r   t he   i nt er - pl a na r   di s t a nc e ,   t he   be t t e r   t he   ge ne r a t or .         Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om p  En g,   V ol.  9 , N o.   6 ,  Dece m ber  2 01 9  :   5615   -   5627   5618       Figure  1. Ma rs aglia   shots         4.4.   Pok er   tes t   The  idea  of  thi s  te st  is  to  com par e  t he  the or e ti cal   fr eq uen ci es  of   ha nds  in  poke r  with  t he  fr e qu e ncies   ob s er ved  by  si m ula ti ng   these   ha nd s   (a   ha nd   is   a  set   of   ca r ds ) .  A  re su lt   ca n  be  c on si der e d  as  a n  orde re d  li st  of   4 digit s.  T he re  are in  all  10 4 .  The  t heoreti cal  proba bili ti es o btained  are  as  f ollows:   a)   F or   4  di f f e r e nt   di gi t s   ( e g.   15 74 ) ,   t he   n um be r   of   p os s i bl e   c a s e s   i s   10   *   9  *  8  *  7,   10   f o r   t he   f i r s t   nu m be r ,     9  f or   t he   ne xt ,   a nd   s o  o n  t he   p r ob a bi l i ty   i s   t he r e f or e   ( 1 0  *  9  *  8  *  7)   /   1 00 0 0.   b)   F or   a   pa i r ,   t y pe   A B C C   ( e g.   4 84 9) ,   w e   ha ve   10   *  9  *  8  *  1  w a y s   t o  m a ke   it ,   t o  m ul t i pl y   by   t he   nu m be r   o f   w a y s   t o  pl a c e   t he   pa i r   a m on g  t he   4  p os s i bl e   pl a c e s :   T he   pr o ba bi l i ty   i s :   ( 4 2 ) ∗ 10 ∗ 9 ∗ 8 10 4 .   c)   F or   a   do ub l e   p a i r ,   t y pe   A A B B   ( e x:   73 37 ) ,   w e   ha ve   10   w a y s   t o  c ho os e   t he   f i r s t   nu m be r ,   t he n  9  w a y s   t o  c ho os e   t he   s e c on d  o ne   ( w hi c h  m us t   be   di f f e r e nt ) ,   i n  a l l   10   *  9  =   90   c ho i c e s ,   t o  m ul ti pl y   by   t he   nu m be r   o f   w a y s   t o  pl a c e   t he s e   nu m be r s   a m on g  t he   4  p os s i bl e   pl a c e s   (   1 2 ∗ ( 4 2 )   =   3) ,   t he   pr ob a bi l i ty   i s   =   1 2 ∗ ( 4 2 ) ∗ 10 ∗ 9 10 4 .   d)   F or   t h r e e   i de n t i c al   di gi t s ,   t yp e   A A A B   ( e x :   55 1 5) ,   t he r e   a r e   1 0  *  9  w a y s   t o  m a ke   i t ,   t o  m ul t i pl y   by     t he   nu m be r   of   w a y s   t o  pl a c e   t he   t hr e e   di gi t s   am on g  t he   4  po s s i bl e   pl a c e s ,   th e   pr ob a bi l i ty   is   =   ( 4 3 ) ∗ 10 ∗ 9 10 4 .   e)   Finall y, f or   f our  ide ntica l digit s ( e x: 44 44), i t i s  worth   10 10 4 = 0 . 001 .    No te  t hat the  s um  o f  these  f i ve  proba bili ti es g ives  1.       5.   RESU LT S  AND INTE RP RETATIO N   The  resu lt s  a r e  m ade  un de r  a  PC  TO S H IB A,   on  w hich   is  instal le d  W i ndows  7  ( 32  bits),  R AM:  4.00 GB,  AMD   E - 45 0  A PU  proces sor  with   Ra deon  ( TM)  HD   G raphics  1.65   G Hz.   T he   functi ons  devel op e d  us in g  M ATL AB  [ 23 - 24]   al low  us  to  ge ne rate  pse ud o - r andom   sequ e nc es  an d  a naly ze  their  pe rform ance.   Figure  2  i ll us tr at es  the  se que nce  of  ps e udo  rand om   nu m ber s  acc ordin g  t o  the  Von  Ne um ann   m edial   sq ua re  m et ho d,   we  t ake  as  par am et er  n  represe nting   t he  le ngth  of   t he  s e qu e nce  n  =  6553 6,   a nd   t he   seed   x0 =  236589 741.   Af te r gene ra ti ng  the  s uite,  we  a pp li ed  stat ist ic al  t est s to  evaluate i t.       Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om p  En g     IS S N: 20 88 - 8 708       Crypto graphic   adaptati on  of t he mid dle s quare  g e ner ato r  (Han a  Ali - P ac ha)   5619       Figure  2. Ra nd om   data su it e       5.1.   Te st 1:   mea n ,  stand ard devi at i on   an d  aut o - c orrela tion f actor   Table  1  il lustra te s sev e ral te sts wit h t he  sam e seed  and  of di ff ere nt  value n :       Table  1 .   Me a n,  sta ndar d dev ia ti on  a nd au t o - c orrelat ion   fac tor   Test   Seed   n   Mean   Au to - Co rr elatio n   Variance   1   5746   5000   0 .52 1 7 4 8   0 .27 2 4 0 4   0 .05 2 6 8 9   2   1 0 0 0 0   0 .52 1 7 9 7   0 .27 2 3 6 3   0 .05 2 5 2 0   3   2 0 0 0 0   0 .52 1 8 2 1   0 .27 2 3 4 3   0 .05 2 4 3 5   4   6 5 3 3 6   0 .52 1 8 3 8   0 .27 2 3 2 9   0 .05 2 3 7 6   5   2 3 6 5 8 9 7 4 1   5000   0 .50 9 8 3 4   0 .26 0 2 5 8   0 .08 2 7 5 8   6   1 0 0 0 0   0 .5 0 7 5 8 8   0 .25 7 6 2 9   0 .08 3 0 9 7   7   2 0 0 0 0   0 .50 4 4 8 1   0 .25 4 2 4 8   0 .08 3 0 5 4   8   6 5 3 3 6   0 .50 4 0 3 2   0 .25 4 1 0 5   0 .08 3 5 2 3   9   6 5 3 3 6   0 .49 4 6 6 0   0 .24 4 0 5 6   0 .08 3 4 6 2   10   2 3 6 5 8 9 7 4 1   5000   0 .50 9 8 3 4   0 .26 0 2 5 8   0 .08 2 7 5 8   11   2 3 6 6 8 4 7 4 1   6000   0 .50 1 7 2 8   0 .25 1 2 0 7   0 .08 3 3 0 0   12   2 8 9 7 8 4 7 4 1   7000   0 .49 6 6 6 4   0 .24 7 9 7 7   0 .08 4 1 1 9   13   2 3 6 5 8 9 7 4 1   5000   0 .50 9 8 3 4   0 .26 0 2 5 8   0 .08 2 7 5 8   14   6000   0 .50 9 9 8 4   0 .25 9 9 6 0   0 .08 3 1 8 8   15   7000   0 .51 1 1 3 0   0 .26 0 5 9 8   0 .08 3 0 1 2       No te   t hat  Test   9  c orres ponds   to  t he  sta nda r d  se quence   of  the  co ntin uatio n  of  Test   8.  A ccordin g  t o  the  resu lt s  obta in ed  an d  afte r  sever al   te sts,  it   has  been   fou nd   that  with  n  suffici entl y  la rg e,  and   with   su f fici ently   la rg e  see d  ( of  la r ge  di git  or  >  6)  the  cal c ulate d  val ues  gr a du al ly   te nd   towa r ds   the  i deal  as  sh ow n  in Figu re  3  ( Te st 8).    Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om p  En g,   V ol.  9 , N o.   6 ,  Dece m ber  2 01 9  :   5615   -   5627   5620       Figure  3 .   The   gr a phic al  curv e o f  the  thr e e c al culat ed value s       5.2.   Te st 2:   th e  spe ctra l  test   This  te st  ai m s  to  a naly ze  the   di stribu ti on o f  points  i n  2D  a nd 3 D   s pace,   Fi gure 4   il lust rates  the v is ual   represe ntati on   of   the  se qu e nc e  gen e rated  (T est   8) .  I n  the  3D  represe ntati on,  by  ro ta ti ng   the  cub e,  on e  visu al ly   no ti ces  the   ab sence  of   t he  Ma rsag li a  pla nes  a nd  the  points  a re  unif or m ly   distribut ed,   this  im pli es  that     the test ed  s uite  is ra ndom .              Figure  4.   Distri bu ti on  of  value s in 2D a nd 3D       5.3.   Te st 3:   freq ue ncy tes t   Re cal l  that  this   te st  ev al uates  wh et her   the  se qu e nce  is  ra ndom   by  co m par ing   the  cal c ulate d  P - val ue   with  th e  sig nifi cance  t hr es hold  α  ( ta king  α   =   0.0 1).  I f  P - val ue  >   α ,  the n  t he   seq ue nce  is r andom   oth er wi se  it   is   no t  ra ndom .  The  sta ndar di zed  P - value  c olu m n  corresponds  to  the  norm a li zed  sequ ence  (in  m od   256).     The res ults are  pr ese nted  in T able 2.       Table  2 .   Fr e quency te st res ults   Test   n   Seed   P - v alu e   P - v alu e  (no r m alized )   Interpretatio n   1   5000   2 3 6 5 8 9 7 4 1   0 .92 5 1   0 .78 7 8   +   2   1 0 0 0 0   0 .98 8 5   0 .56 3 7   +   3   2 0 0 0 0   1   0 .38 0 6   +   4   6 5 5 3 6   1 .54 0 3   0 .04 4 7   +       No te   t hat  f or  al l  four   te sts,   the  P - va lue  is  gr eat er   tha n  α ,   so   we  ac cept  the  null   hy po t hesis  wh i c h  sta te s that "t he se quence  is ra ndom " .    Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om p  En g     IS S N: 20 88 - 8 708       Crypto graphic   adaptati on  of t he mid dle s quare  g e ner ato r  (Han a  Ali - P ac ha)   5621   5.4.   Te st 4:   e nt r opy  test   In   Ta ble  3  we   find   t he  ent ropy  value s  f or   the  norm al iz ed  sequ e nces  with  dif fe ren t  n,   the  highe r     the  e ntropy,   th e  m or e  ra ndom  the  s eq ue nce  i s.  I n  the  i deal  c ase  the   entr opy  val ue  is  e qual   to  8.   N ote  that  eac h  tim e the v al ue of  n is i nc rease d,  t he value  of  the en t ropy als o  inc reases .       Table  3 .   E ntr opy t est  r es ults   Test   n   Seed   Entro p y  ( n o r m aliz ed )   1   5 000   2 3 6 5 8 9 7 4 1   7 .96 2 8   2   1 0 0 0 0   7 .97 9 3   3   2 0 0 0 0   7 .98 9 9   4   6 5 5 3 6   7 .99 3 4       5.5.   Te st 5:   poker  test   The  pu rpose  of   this  te st  is  to  com par e  the  theo reti cal   prob a bili ti es  Pt  of   po ker  hands  with     the  pro bab il it ie s  ob s er ved   Po   by  si m ulati ng   these  ha nds  (a  s et   of   car ds).  N oting   here  that  the  Po   a re  obta ine d  by d i vid in g  t he  observe d fr e quencies  of eac h  case  on t he  t otal n um ber  n.     5.5.1.   For 4's h and   This ti m e w e cal culat e the the or et ic al  pr ob a bi li t ie s,  with  k  =  4   s how n  i n  Ta ble 4 .       Table  4 .   T he oret ic al   pr oba bili ti es f or  han d p ok e r of 4     4  dif f erent car d s   1  pair on ly   2  d istin cts   p airs   3  iden tical car d s   4  iden tical car d s   n   Pt   0 .50 4   0 .43 2   0 .02 7   0 .03 6   0 .00 1     Po   0 .46 0 0   0 .44 0 0   0 .06 0 0   0 .03 0 0   0 .01 0 0   100   0 .00 9 2   0 .98 8 8   0 .00 1 2   0 .00 0 6   0 .00 0 2   5000   0 .00 4 6   0 .99 4 4   0 .00 0 6   0 .00 0 3   0 .00 0 1   1 0 0 0 0   0 .00 0 2 3   0 .99 7 2   0 .00 0 3   0 .00 0 1   0 .00 0 1   2 0 0 0 0   7 .01 9 * 1 0 - 4   0 .99 9 1   9 .15 5 * 1 0 - 5   4 .57 7 * 1 0 - 5   1 .52 5 * 1 0 - 5   6 5 5 3 6       5.5.2.   For 3  hand   The  sam e  pr inciple   is  us ed  to  cal culat e  the  t heoreti cal   pr ob abili ti es,  bu t  this  tim e  with  k  =  3.   In   thi s   case t he  te st i s  app li ed  to   t he  s ta nd a rd seque nc e or the  num ber   of   dig it s  reduced  to 3   sho w n  in  Ta ble 5 .       Table  5 .   T he oret ic al   pr oba bili ti es f or  hand p ok e r  of  3     3  dif f erent car d s   1  pair on ly   3  iden tical car d s   n   Pt   0 .72 0 0   0 .27 0 0   0 .01 0 0     Po   0 .64 0 0   0 .36 0 0   0 .02 0 0   100   0 .69 8 2   0 .28 9 8   0 .01 2 0   5000   0 .70 4 2   0 .28 4 6   0 .01 1 2   1 0 0 0 0   0 .70 1 4   0 .28 6 4   0 .01 2 2   2 0 0 0 0   0 .70 3 2   0 .28 4 4   0 .01 2 4   6 5 5 3 6       5.6.   Encr ypting  ima ges   Using  the  MA TLAB  softwa r e,  we  hav e  devel op e d  an  ap pl ic at ion   to  encry pt  and   dec ryp t  an  i m age,   us in g  t he  valu es  pro duced   by   the  m idd le   sq ua re  ge ner at or,  as so ci at ed   w it h  the  X OR  s ymm et ric  encry ption  te chn iq ue.  T he   X OR  ‘ 1 ’   di git  ha nd le s   the  bi ts,  base d  on  th e  operati on  or  exclusi ve  bitwise  ( XO R )  as  s how n  in Figu re  5.           Figure  5 .   Pr i nc iple o f  e ncr ypti on   Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om p  En g,   V ol.  9 , N o.   6 ,  Dece m ber  2 01 9  :   5615   -   5627   5622   We  us e  as  a  ke y  a  bit  string   K  of   g ive n  le ng t h  L.  It  is  encr y pted  by  pe rfor m ing   the  exclusi ve - or  op e rati on  bit  by   bit  of  t he  ke y  K  with  t he  cl ear  te xt,   di vid ed   int o  blo c ks  M  of  le ngth  L  each .  Re cal l   that   the  excl us ive - or   is  ass ociat iv e,  com m utati v e  and,  that  it   ha s  a  ne utral  el e m ent  0,   a nd   t hat  any  c hain  K  is  it s   own  in ve rse:  K ⊕ K   =  0.  T hu s ,  we  can  s ee  that  the  de crypti on  al gori thm   is  identic al   to  the  enc r ypti on   al gorithm , w it h  the  sam e k ey :     M = C ⊕ K  =  (M ⊕ K)  ⊕ K  =   M ⊕   (K ⊕ K )  =  M ⊕ 0  =  M     The  ba sic   idea  of   this  pr oce ss  is  to  perfor m   an  "exclusi ve"  or  " ⊕ ",  bi t  by  bit  between   the  key   gen e rated  by  a  PRNG,  an d  th e  i m age  to  be  encr y pted,   IO.  This  al gorithm   is  co m plete ly   sy m m e tric al ,  t hat  is  the  sam e   op era ti on   is  app li ed  again  to  the  en crypted  im age,  IC  to  find   the  or i gin al   i m age.  The  i m ages  us ed  in   our  a ppli cat ion are as  in Fi gur e 6  a nd  of si ze  256x25 6.   We  pr ese nt  in   the  f ollo wing   Fig ur es   7 - 14  i m ages  of  the  two  im ages  "E I:  I nnoce nt  Ch il dr en"   a nd   "FA:  Alge rian  Wo m an"  acco r ding  to  dif fer e nt  seeds  to  see  the  influ e nce  of  the  siz e  of   th e  seed  in  this  ci ph e r .   No te   that  the  encr y ption   of   t he  2  im ages  ha s  fail ed  with  seq uels  that  ha ve  a  see d  of  2,  3,   4,   5  or   6  dig it s .   Fr om   these  resu lt s  we  can  co nclu de  that  to  qu a ntify  an  im age  it   is  necessary  that  the  seed  is  su f fici ently   wide  (larg e  d i git i s great er tha n 6 ).   This c onfirm s the c ond it io n  m ade  by Vo n Ne um ann  usi ng   10 - dig it   nu m bers.                 Figure  6 .   IO - E I  –   IO - FA                 Figure  7 .   IC - EI   –   IC - F A wit h  seed= 26         Figure  8 .   IC - EI   –   IC - F A wit h  seed= 684                 Figure  9. IC - EI   –   IC - F A wit h  seed= 2863     Figure  10. IC - EI  –   IC - F A wit h  see d= 43295   Evaluation Warning : The document was created with Spire.PDF for Python.
In t J  Elec  &  C om p  En g     IS S N: 20 88 - 8 708       Crypto graphic   adaptati on  of t he mid dle s quare  g e ner ato r  (Han a  Ali - P ac ha)   5623             Figure  11. IC - EI  –   IC - F A wit h  see d= 928763         Figure  1 2.   IC - EI  –   IC - F A wit h  see d= 854726 7                 Figure  13. IC - EI  –   IC - F A wit h  see d= 594126 78     Figure  14. IC - EI  –   IC - F A wit h   see d= 236589 741       5.7.     Analysis  of  hi stogr ams   A  histo gram   is  a  st at ist ic a l  c urve  in dicat ing  the  distrib utio n  of  the  pi xels   of   a n  i m age  accor ding  to   their  value .  I n  our  w ork,   processe d  im age s  are  gr ay scal e  i m ages  wh ose   pix el   val ue s  var y  in  the  range     [0,  25 5].  We  ha ve  dr a w n  an d  analy zed  t he  histo gr am s  of   the  enc rypte d  i m ages  of  "EI -   Inn oce nt  Chil dr e n"   and  "FA - Alge r ia n  Wo m en",  the  il lustrate d  pl ots  the  histo gra m s  of   the   enc rypted  im ages,   HC  of   t he  im ages     EI  a nd  F A  re sp ect ively   acc ordin g  t o  the   siz e  of  the  se ed.   N ote  that,   the  historg ra m   fo r  the  plai ntext  is     denoted  as  HP .   It  th us   em erges  f ro m   the  prece di ng  res ults  that  the   histogram s  of   Fig ur es   21 - 23  a r e  unif or m ly  distrib uted  wit h  res pect  to  th e  histogram s  of   the  or i gin al   im ages  from   Fi gure  15  with  r especti ve  enc r ypte d  i m ages  fr om   Figures  16 - 20  ( there  is  a  le ak age  of  inf o rm at ion   ab out  th e  pix el   distri buti on   of   t he  im ages) .    This  m akes  cryptanaly sis  increasin gly  diff i cult  becau se  th e  encr ypte d  i m ages  pro vid e  no  el e m ent,  bas ed  on   the exploit at io n of t he hist ogr a m , to  d e sig n  a  stat ist ic al  att a ck on t he p rop os e d  im age encrypti on tech ni qu e .             Figure  15 .   HP - EI  –   HP   – FA   Evaluation Warning : The document was created with Spire.PDF for Python.
                          IS S N :   2088 - 8708   In t J  Elec  &  C om p  En g,   V ol.  9 , N o.   6 ,  Dece m ber  2 01 9  :   5615   -   5627   5624         Figure  16. HC - EI  –   HC - F A w it h  seed= 26             Figure  17. HC - EI  –   HC - F A  a ve c  seed= 684             Figure  18. HC - EI  –   HC - F A w it h  seed= 2863   Evaluation Warning : The document was created with Spire.PDF for Python.