Welcome Guest [Log In] [Register]
Welcome to Crypto. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
A Python code for columnar transposition with RS44 (crossword puzzle) like matrices
Topic Started: Jan 15 2014, 11:08 AM (2,671 Views)
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
Code:
 
#[space]Columnar[space]transposition[space]with[space]RS44[space](crossword[space]puzzle)[space]like[space]matrices.

#[space]M.[space]K.[space]Shen,[space]15.01.2014.[space][space](mok-kong.shen@t-online.de)

#[space]Available[space]at:[space]http://s13.zetaboards.com/Crypto/topic/7145746/1/

#[space](Code[space]lines[space]of[space]the[space]same[space]date[space]are[space]always[space]identical.[space]There[space]may[space]however[space]be
#[space]interim[space]modifications[space]of[space]comment[space]lines.)


#[space]Prologue.

#[space]RS44[space](Rasterschluessel[space]44)[space][1,2][space]is[space]a[space]WWII[space]German[space]columnar[space]transposition[space]with
#[space]a[space]matrix[space]of[space]size[space]24*25[space]in[space]which[space]a[space]number[space]of[space]cells[space](15[space]in[space]a[space]row,[space]designated
#[space]as[space]windows[space]in[space]the[space]following)[space]are[space]not[space]to[space]be[space]filled[space]by[space]plaintext[space]characters[space]akin
#[space]to[space]the[space]common[space]crossword[space]puzzles.[space]The[space]function[space]crosswordtransp()[space]below
#[space]implements[space]such[space]a[space]scheme[space]for[space]the[space]more[space]general[space]case[space]of[space]arbitrarily[space]specified
#[space]dimensions[space]of[space]the[space]transposition[space]matrix[space]and[space]arbitrarily[space]specified[space]windows
#[space](either[space]directly[space]by[space]the[space]user[space]or[space]automatically[space]via[space]Python's[space]built-in[space]PRNG
#[space]according[space]to[space]a[space]secret[space]seed[space]provided[space]by[space]the[space]user.)[space](For[space]a[space]further[space]possibility
#[space]of[space]generalization[space]see[space]http://s13.zetaboards.com/Crypto/topic/7199087/1/.)

#[space]It[space]is[space]the[space]user's[space]responsibility[space]to[space]choose[space]appropriate[space]parameters[space]for[space]calling
#[space]crosswordtransp()[space]and[space]well[space]keep[space]certain[space]informations[space]secret,[space]though[space]the
#[space]historical[space]RS44[space]could[space]serve[space]as[space]a[space]guide.[space]

#[space][1][space]http://www.wondersandmarvels.com/2013/02/rasterschlussel-44-the-stencil-on-steroids.html
#[space][2][space]M.[space]J.[space]Cowan,[space]Rasterschluessel[space]-[space]The[space]Epitome[space]of[space]Hand[space]Field[space]Ciphers,
#[space][space][space][space][space]Cryptologia,[space]vol.28[space](2004),[space]pp.115-156.


import[space]random


#[space]The[space]transposition[space]matrix[space]has[space]n[space]rows[space]and[space]m[space]colums,[space]with[space]numbering[space]starting[space]from
#[space]1[space]at[space]the[space]upper[space]left[space]corner[space]of[space]the[space]matrix.[space]
#[space]The[space]parameter[space]windows[space]is[space]a[space](secret)[space]list[space]of[space]n[space]lists[space]each[space]of[space]which[space]gives[space]the
#[space]column[space]numbers[space]in[space]a[space]row[space]where[space]no[space]plaintext[space]characters[space]can[space]be[space]filled[space](like[space]the
#[space]black[space]cells[space]in[space]crossword[space]puzzles).[space]If[space]there[space]are[space]no[space]such[space]positions[space]at[space]all[space]in
#[space]the[space]matrix,[space]i.e.[space]one[space]has[space]the[space]degenerate[space]case[space]of[space]a[space]common[space]columnar
#[space]transposition,[space]windows[space]may[space]be[space]simply[space]specified[space]as[space]the[space]empty[space]list,[space]i.e.[space][].
#[space]On[space]encryption,[space]filling[space]of[space]plaintext[space](given[space]in[space]the[space]parameter[space]textstr)[space]is
#[space]row-wise,[space]starting[space]at[space]the[space](secret)[space]position[space]given[space]by[space]startrow[space]and[space]startcol,
#[space]skipping[space]all[space]locations[space]specified[space]in[space]the[space]parameter[space]windows.[space]If[space]the[space]lower[space]right
#[space]corner[space]of[space]the[space]matrix[space]is[space]attained[space]and[space]there[space]are[space]yet[space]plaintext[space]characters[space]left
#[space]to[space]be[space]filled[space]into[space]the[space]matrix,[space]filling[space]continues[space]at[space]the[space]upper[space]left[space]corner[space]of
#[space]the[space]matrix,[space]in[space]case[space]there[space]are[space]vacant[space]positions[space]there.[space]An[space]error[space]message[space]will[space]be
#[space]issued,[space]if[space]the[space]given[space]plaintext[space]cannot[space]be[space]completely[space]filled[space]into[space]the[space]matrix.
#[space]The[space]ciphertext[space]is[space]taken[space]out[space]column-wise[space]in[space]the[space](secret)[space]order[space]specified[space]by[space]the
#[space]sequence[space]of[space]column[space]numbers[space]given[space]in[space]the[space]parameter[space]numkeystr.
#[space]On[space]decryption[space]the[space]process[space]is[space]reversed[space]such[space]that[space]the[space]plaintext[space]is[space]correctly
#[space]recovered.
#[space]User[space]can[space]specify[space]the[space]parameter[space]windows[space]either[space]directly[space]or[space]use[space]the[space]function[space]
#[space]genwindows()[space]to[space]pseudo-randomly[space]generate[space]one[space]for[space]use.[space]
#[space]To[space]show[space]the[space]matrix[space]under[space]the[space]constraint[space]of[space]the[space]parameter[space]windows,[space]the[space]function
#[space]drawmatrix()[space]may[space]be[space]used.
#[space]We[space]assume[space]that[space]the[space]plaintext[space]doesn't[space]contain[space]the[space]symbol[space]given[space]by[space]the[space]parameter
#[space]skip.
#[space]Encryption:[space]kn=0.
#[space]Decryption:[space]kn=1.

def[space]crosswordtransp(n,m,windows,numkeystr,startrow,startcol,textstr,skip,kn):
[space][space]assert(len(skip)==1[space]and[space]textstr.count(skip)==0[space]and[space]0<=kn<=1)
[space][space]assert(len(numkeystr)==m)
[space][space]for[space]u[space]in[space]numkeystr:
[space][space][space][space]assert(numkeystr.count(u)==1[space]and[space](1<=int(u)<=m))
[space][space]assert(1<=startrow<=n[space]and[space]1<=startcol<=m)
[space][space]starti=startrow-1
[space][space]startj=startcol-1
[space][space]lw=len(windows)
[space][space]assert(lw==0[space]or[space]lw==n)
[space][space]t=[""[space]for[space]i[space]in[space]range(m)]
[space][space]matrix=[t[:][space]for[space]i[space]in[space]range(n)]
[space][space]if[space]lw>0:
[space][space][space][space]for[space]i[space]in[space]range(n):
[space][space][space][space][space][space]for[space]j[space]in[space]range(len(windows[i])):
[space][space][space][space][space][space][space][space]u=windows[i][j]-1
[space][space][space][space][space][space][space][space]assert(0<=u<m)
[space][space][space][space][space][space][space][space]matrix[i][u]=skip
[space][space]ltxt=len(textstr)
[space][space]k=0
[space][space]out=False
[space][space]for[space]i[space]in[space]range(starti,n):
[space][space][space][space]j1=startj[space]if[space]i==starti[space]else[space]0
[space][space][space][space]for[space]j[space]in[space]range(j1,m):
[space][space][space][space][space][space]if[space]matrix[i][j]!=skip:
[space][space][space][space][space][space][space][space]k+=1
[space][space][space][space][space][space][space][space]if[space]k==ltxt:
[space][space][space][space][space][space][space][space][space][space]for[space]j2[space]in[space]range(j+1,m):
[space][space][space][space][space][space][space][space][space][space][space][space]matrix[i][j2]=skip
[space][space][space][space][space][space][space][space][space][space]for[space]i1[space]in[space]range(i+1,n):
[space][space][space][space][space][space][space][space][space][space][space][space]for[space]j[space]in[space]range(m):
[space][space][space][space][space][space][space][space][space][space][space][space][space][space]matrix[i1][j]=skip
[space][space][space][space][space][space][space][space][space][space]for[space]i1[space]in[space]range(0,starti+1):
[space][space][space][space][space][space][space][space][space][space][space][space]j1=startj[space]if[space]i1==starti[space]else[space]m
[space][space][space][space][space][space][space][space][space][space][space][space]for[space]j2[space]in[space]range(0,j1):
[space][space][space][space][space][space][space][space][space][space][space][space][space][space]matrix[i1][j2]=skip[space][space][space][space][space][space][space][space][space][space][space][space]
[space][space][space][space][space][space][space][space][space][space]out=True
[space][space][space][space][space][space][space][space][space][space]break
[space][space][space][space]if[space]out:
[space][space][space][space][space][space]break[space][space][space][space]
[space][space]kk=k
[space][space]if[space]k<ltxt:
[space][space][space][space]out=False
[space][space][space][space]for[space]i[space]in[space]range(0,starti+1):
[space][space][space][space][space][space]j1=startj[space]if[space]i==starti[space]else[space]m
[space][space][space][space][space][space]for[space]j[space]in[space]range(0,j1):
[space][space][space][space][space][space][space][space]if[space]matrix[i][j]!=skip:
[space][space][space][space][space][space][space][space][space][space]k+=1
[space][space][space][space][space][space][space][space][space][space]if[space]k==ltxt:
[space][space][space][space][space][space][space][space][space][space][space][space]for[space]j2[space]in[space]range(j+1,j1):
[space][space][space][space][space][space][space][space][space][space][space][space][space][space]matrix[i][j2]=skip
[space][space][space][space][space][space][space][space][space][space][space][space]for[space]i1[space]in[space]range(i+1,starti+1):
[space][space][space][space][space][space][space][space][space][space][space][space][space][space]j1=startj[space]if[space]i1==starti[space]else[space]m
[space][space][space][space][space][space][space][space][space][space][space][space][space][space]for[space]j2[space]in[space]range(0,j1):
[space][space][space][space][space][space][space][space][space][space][space][space][space][space][space][space][space][space]matrix[i1][j2]=skip
[space][space][space][space][space][space][space][space][space][space][space][space]out=True
[space][space][space][space][space][space][space][space][space][space][space][space]break
[space][space][space][space][space][space]if[space]out:[space][space][space][space][space][space][space][space]
[space][space][space][space][space][space][space][space]break
[space][space][space][space]if[space]not[space]out:
[space][space][space][space][space][space]print("textstr[space]too[space]long[space]for[space]the[space]matrix")
[space][space][space][space][space][space]return[space][space][space]
[space][space]if[space]kn==0:
[space][space][space][space]textstr=textstr[kk:]+textstr[:kk][space]
[space][space][space][space]k=0
[space][space][space][space]for[space]i[space]in[space]range(0,n):
[space][space][space][space][space][space]for[space]j[space]in[space]range(m):
[space][space][space][space][space][space][space][space]if[space]matrix[i][j]!=skip:
[space][space][space][space][space][space][space][space][space][space]matrix[i][j]=textstr[k]
[space][space][space][space][space][space][space][space][space][space]k+=1
[space][space][space][space]str=""
[space][space][space][space]for[space]u[space]in[space]numkeystr:
[space][space][space][space][space][space]j=int(u)-1
[space][space][space][space][space][space]for[space]i[space]in[space]range(0,n):
[space][space][space][space][space][space][space][space]c=matrix[i][j]
[space][space][space][space][space][space][space][space]if[space]c!=skip:
[space][space][space][space][space][space][space][space][space][space]str+=c
[space][space]else:
[space][space][space][space]k=0
[space][space][space][space]for[space]u[space]in[space]numkeystr:
[space][space][space][space][space][space]j=int(u)-1
[space][space][space][space][space][space]for[space]i[space]in[space]range(0,n):
[space][space][space][space][space][space][space][space]if[space]matrix[i][j]!=skip:
[space][space][space][space][space][space][space][space][space][space]matrix[i][j]=textstr[k]
[space][space][space][space][space][space][space][space][space][space]k+=1
[space][space][space][space]str=""
[space][space][space][space]for[space]i[space]in[space]range(0,n):
[space][space][space][space][space][space]for[space]j[space]in[space]range(m):
[space][space][space][space][space][space][space][space]c=matrix[i][j]
[space][space][space][space][space][space][space][space]if[space]c!=skip:
[space][space][space][space][space][space][space][space][space][space]str+=c
[space][space][space][space]kk=ltxt-kk
[space][space][space][space]str=str[kk:]+str[:kk]
[space][space]return(str)


#[space]Generate[space]windows[space]automatically[space]for[space]use[space]in[space]calling[space]crosswordtransp().
#[space]nwinlow[space]and[space]nwinhigh[space]specify[space]the[space]lower[space]limit[space]and[space]upper[space]limit[space]of[space]the[space](pseudo-
#[space]randomly[space]determined)[space]number[space]of[space](pseudo-randomly[space]determined)[space]column[space]positions
#[space]of[space]a[space]row[space]of[space]the[space]transposition[space]matrix[space]where[space]no[space]plaintext[space]characters[space]are[space]to[space]be
#[space]filled.[space]0[space]<=[space]nwinlow[space]<=[space]nwinhigh[space]<[space]m.
#[space]seed[space]is[space]the[space]secret[space](dynamically[space]variable[space]across[space]sessions)[space]seed[space]for[space]seeding
#[space]Python's[space]built-in[space]PRNG.

def[space]genwindows(n,m,nwinlow,nwinhigh,seed):
[space][space]assert(0<=nwinlow<=nwinhigh<m)
[space][space]if[space]nwinhigh==0:
[space][space][space][space]return([])
[space][space]indx=[i+1[space]for[space]i[space]in[space]range(m)]
[space][space]random.seed(seed)
[space][space]w=[]
[space][space]for[space]i[space]in[space]range(n):
[space][space][space][space]k=random.randint(nwinlow,nwinhigh)
[space][space][space][space]random.shuffle(indx)
[space][space][space][space]w.append(indx[:k])
[space][space]return(w)


#[space]Draw[space]the[space]n*m[space]transposition[space]matrix[space]with[space]#[space]denoting[space]positions[space]where[space]the
#[space]plaintext[space]characters[space]will[space]not[space]be[space]filled[space]according[space]to[space]the[space]parameter[space]windows.

def[space]drawmatrix(n,m,windows):
[space][space]lw=len(windows)
[space][space]assert(lw==0[space]or[space]lw==n)
[space][space]g=(2*m+1)*"-"
[space][space]print(g)
[space][space]for[space]i[space]in[space]range(n):
[space][space][space][space]t=["[space]"[space]for[space]j[space]in[space]range(m)]
[space][space][space][space]if[space]lw>0:
[space][space][space][space][space][space]for[space]j[space]in[space]windows[i]:
[space][space][space][space][space][space][space][space]t[j-1]="#"
[space][space][space][space]s="|"
[space][space][space][space]for[space]j[space]in[space]range(m):
[space][space][space][space][space][space]s+=t[j]+"|"
[space][space][space][space]print(s)
[space][space][space][space]print(g)
[space][space]return

[space][space][space]
#[space]Illustrative[space]examples:[space]

#[space]Example[space]1,[space]windows[space]is[space]directly[space]specified[space]by[space]the[space]user.

print("Example[space]1.")
print()

n=4
m=4
#[space]We[space]assume[space]that[space]plaintext[space]doesn't[space]contain[space]spaces.
skip="[space]"
#[space]On[space]encryption[space]take[space]out[space]first[space]the[space]3rd[space]column,[space]etc.[space]to[space]obtain[space]the[space]ciphertext.
numkeystr="3214"
startrow=1
startcol=3

windows=[[3],[],[1,3],[3]]

print("windows[space]given:")
print(windows)
print()

#[space]Sender[space]side[space]processing:

pt="abcdefghijk"
print("pt[space]:",pt)
ct=crosswordtransp(n,m,windows,numkeystr,startrow,startcol,pt,skip,0)
print("ct[space]:",ct)

#[space]Recipient[space]side[space]processing:

pt1=crosswordtransp(n,m,windows,numkeystr,startrow,startcol,ct,skip,1)
print("pt1:",pt1)
print()

#[space]Example[space]2,[space]use[space]genwindows[space]to[space]automatically[space]generate[space]windows,[space]show[space]also[space]the
#[space]matrix[space]to[space]be[space]filled.

print("Example[space]2.")
print()

n=5
m=6
skip="[space]"
numkeystr="321465"
startrow=2
startcol=3

#[space]Generation[space]of[space]windows.

numwlow=2
numwhigh=3
seed="asecretseedtobeputhere"
windows=genwindows(n,m,numwlow,numwhigh,seed)
print("windows[space]generated:")
print(windows)
print()
print("The[space]corresponding[space]matrix:")
print()
drawmatrix(n,m,windows)
print()

#[space]Sender[space]side[space]processing:

pt="abcdefghijklmnopq"
print("pt[space]:",pt)
ct=crosswordtransp(n,m,windows,numkeystr,startrow,startcol,pt,skip,0)
print("ct[space]:",ct)

#[space]Recipient[space]side[space]processing:

pt1=crosswordtransp(n,m,windows,numkeystr,startrow,startcol,ct,skip,1)
print("pt1:",pt1)

################################################################################

#[space]Epilogue.

#[space]IMHO[space]at[space]least[space]some[space]number[space]of[space]classical[space]algorithms[space](eventual[space]with[space]a[space]few[space]more
#[space]recent[space]improvements)[space]retain[space]their[space]significant[space]values[space]for[space]practical[space]encryption
#[space]processing[space]today,[space]even[space]though[space]this[space]fact[space]is[space]often[space]disregarded/ignored.[space]For
#[space]there[space]are[space]situations[space]where[space]one[space]or[space]both[space]of[space]the[space]communication[space]partners[space]have[space]no
#[space]computers[space]available[space]and[space]hence[space]are[space]forced[space]to[space]encrypt[space]manually.[space]On[space]the[space]other
#[space]hand,[space]this[space]evidently[space]does[space]not[space]imply[space]that[space]there[space]is[space]no[space]need[space]at[space]all[space]of[space]computer
#[space]implementation[space]of[space]the[space]classical[space]algorithms.[space]For[space]the[space]availability[space]of[space]computer
#[space]software[space]could[space](1)[space]be[space]a[space]valuable[space]convenience[space]in[space]case[space]one[space]of[space]the[space]communication
#[space]partners[space]does[space]have[space]access[space]to[space]computers[space]and[space](2)[space]satisfy[space]the[space]needs[space]of[space]those
#[space]users[space]who[space]have[space]access[space]to[space]computers[space]but[space]prefer[space]to[space]employ[space]algorithms[space]that[space]are
#[space]more[space]easily[space]to[space]be[space]understood[space]by[space]them[space]in[space]comparison[space]to[space]many[space]of[space]the[space]modern
#[space]encryption[space]algorithms[space](note[space]that[space]employing[space]algorithms[space]that[space]one[space]doesn't[space]well
#[space]understand[space]highly[space]favours[space]the[space]chance[space]of[space]success[space]of[space]backdoor-implanters[space]of[space]the
#[space]software/hardware[space]involved[space]in[space]securing[space]one's[space]communications[space]in[space]general),[space](3)
#[space]serve[space]to[space]facilitate[space]further[space]studies[space]of[space]the[space]algorithms[space]in[space]respect[space]of[space]their
#[space]vulnerability[space]and[space]eventually[space]possible[space]improvements[space]and[space](4)[space]via[space]promoting
#[space](through[space]convenience[space]of[space]use)[space]the[space]practical[space]usage[space]of[space]the[space]algorithms[space]--[space]either
#[space]singly[space]or[space]in[space]combinations[space](also[space]with[space]the[space]modern[space]ciphers)[space]--[space]enhance[space]the[space]total
#[space]number[space]of[space]algorithms[space]that[space]the[space]post-Orwellian[space]mighty[space]agencies[space]have[space]to
#[space]realistically[space]take[space]into[space]consideration[space]as[space]potential[space]algorithms[space]involved[space]in[space]the
#[space]amassed[space]encrypted[space]messages[space]to[space]be[space]dealt[space]with,[space]thus[space]contributing[space]to[space]the
#[space]enhancement[space]of[space]the[space]workloads[space]of[space]their[space]supercomputers[space](which[space]are[space]faburously
#[space]ultra[space]fast[space]yet[space]albeit[space]of[space]certain[space]finite[space]limited[space]speed).[space]Anyway,[space]it[space]is
#[space]intuitively[space]clear[space]that[space]appropriate[space]superencipherments[space]with[space]a[space]sufficient[space]number
#[space]of[space]constituent[space]classical[space]algorithms[space](in[space]particular[space]sufficient[space]number[space]of[space]rounds
#[space]of[space]appropriate[space]combinations[space]of[space]diffusion[space]and[space]confusion,[space]i.e.[space]substitution[space]and
#[space]transposition)[space]could[space]result[space]in[space]a[space]practical[space]security[space]that[space]is[space]quite[space]comparable
#[space]to[space]the[space]use[space]of[space]the[space]appraised[space]modern[space]symmetric[space]algorithms,[space]if[space]only[space]the[space]issue[space]of
#[space]processing[space]efficiency[space]could[space]be[space]disregarded,[space]which[space]is[space]however[space]evidently[space]the
#[space]case[space]for[space]the[space]normal[space]vital[space](sensitive)[space]communications[space]of[space]the[space]common[space]people,[space]as
#[space]these[space]are[space]as[space]a[space]rule[space]of[space]fairly[space]low[space]volumes.

#[space]It[space]is[space]in[space]this[space]sense[space]that[space]I[space]am[space]publishing[space]the[space]above[space]Python[space]code[space]for[space]the[space]type
#[space]of[space]transposition[space]processing[space]employed[space]in[space]the[space]classical[space]cipher[space]RS44,[space]which[space]I
#[space]programmed[space]while[space]experimenting[space]a[space]little[space]bit[space]with[space]that[space]algorithm[space]and[space]which
#[space]hopefully[space]some[space]readers[space]may[space]find[space]useful.

#[space]The[space]function[space]is[space]named[space]crosswordtransp(),[space]because[space]the[space]transposition[space]matrix[space]is
#[space]most[space]easily[space]described[space]as[space]one[space]of[space]the[space]genre[space]of[space]the[space]common[space]crossword[space]puzzles,
#[space]where[space]a[space]number[space]of[space]windows[space](cells)[space]in[space]the[space]matrix[space]are[space]not[space]to[space]be[space]filled[space]in.[space]In
#[space]fact,[space]under[space]circumstances[space]communication[space]partners[space]using[space]the[space]present[space]algorithm
#[space]could[space]also[space]simply[space]agree[space]on[space]the[space]use[space]of[space]certain[space]crossword[space]puzzles[space]appearing[space]in
#[space]chosen[space]journals[space]as[space]the[space]matrices[space]for[space]doing[space]the[space]encryption[space]processing[space]in[space]the
#[space]different[space]sessions.[space]We[space]note[space]that[space]it[space]was[space]only[space]recently[space]that[space]a[space]challenge
#[space]ciphertext[space]of[space]a[space]doubled[space]columnar[space]transposition[space]of[space]the[space]common[space](simpler)[space]form
#[space]has[space]been[space]successfully[space]solved[space]in[space]the[space]public,[space]implying[space]that[space]an[space]appropriate
#[space]combination[space]of[space]the[space]present[space]transposition[space]with[space]substitution,[space]e.g.[space]two[space](or[space]more)
#[space]rounds[space]each[space]consisting[space]of[space]an[space]autokey[space]processing[space]followed[space]by[space]an[space]invocation[space]of
#[space]crosswordtransp(),[space]should[space]be[space]fairly[space]hard[space]for[space]the[space]analysis.

#[space]For[space]a[space]further[space]extension[space]possibilty[space]of[space]RS44[space](not[space]implemented[space]in[space]the[space]present
#[space]code)[space]see[space]http://s13.zetaboards.com/Crypto/topic/7199087/1/.

#[space](For[space]another[space]transposition[space]scheme,[space]which[space]is[space]based[space]on[space]key[space]character[space]sorting
#[space]order,[space]see[space]http://s13.zetaboards.com/Crypto/topic/7139297/1/)
Edited by mok-kong shen, Jul 21 2014, 06:45 AM.
Offline Profile Quote Post Goto Top
 
novice
Super member
[ *  *  *  * ]
The Python program given by Mok Kong Shen is far from implementing the concept of RS44. The only feature in common is the presence of unfilled spaces in the matrix. Other vital features of RS44 (not mentioned by MKS nor included in his program) are:

1. The message could be commenced at any point in the matrix. It did not have to begin in the top left corner;
2. If the message was not complete by the end of the matrix, then it would continue at the top of the matrix;
3. Taking out the ciphertext began in a different column to that chosen for writing in.

These features were an essential part of the cipher and added to its security.

Apart from not containing the above features, the MKS program does not reproduce the appearance of the RS44 matrix (or stencil as it was called in English), which is illustrated below.

Posted Image

Geoff Sullivan's working program for Windows, available for download here provides not only all the original features of RS44 but also the correct size, appearance and font.

Readers who are interested in RS44 may read a brief account here . A full account of RS44 is given in the original paper by M.J.Cowan published in Cryptologia Vol 28, Nr 2.
Offline Profile Quote Post Goto Top
 
Grip2000
no member
[ *  *  *  *  * ]
http://users.telenet.be/d.rijmenants/en/rasterschlussel44.htm

http://www.buha.info/showthread.php?54657-CHIFFRE-Rasterschl%FCssel-44-gt-Deutsches-Handverfahren-aus-dem-Zweiten-Weltkrieg
Offline Profile Quote Post Goto Top
 
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
novice
Jan 17 2014, 05:04 PM
The Python program given by Mok Kong Shen is far from implementing the concept of RS44. The only feature in common is the presence of unfilled spaces in the matrix. Other vital features of RS44 (not mentioned by MKS nor included in his program) are:

1. The message could be commenced at any point in the matrix. It did not have to begin in the top left corner;
2. If the message was not complete by the end of the matrix, then it would continue at the top of the matrix;
3.Taking out the ciphertext began in a different column to that chosen for writing in.

These features were an essential part of the cipher and added to its security.

Apart from not containing the above features, the MKS program does not reproduce the appearance of the RS44 matrix (or stencil as it was called in English), which is illustrated below.
What are you talking about??? You apparently have even ignored what I wrote at the very beginning: "The function crosswordtransp() below implements such a scheme for the more general case of arbitrarily specified dimensions of the transposition matrix and arbitrarily specified windows (either directly by the user or automatically via Python's built-in PRNG according to a secret seed provided by the user.)"

To your 1), note the paremeters startrow and startcol. To your 2), note the comment "If the lower right corner of the matrix is attained and there are yet plaintext characters left to be filled into the matrix, filling continues at the upper left corner of the matrix, in case there are vacant positions there." To your 3), note the parameter numkeystr.

To your last sentence above: The matrix with the black cells of the crossword puzzles can be arbitrarily specified by the user. See my Example 1. If you want to create one of the original RS44, just write a corresponding list of lists for use as the parameter windows. Is that clear?

(I have just done an editing of OP and added a 2nd literature reference but haven't changed a single word of what I referred to in the above.)
Edited by mok-kong shen, Jan 18 2014, 02:37 PM.
Offline Profile Quote Post Goto Top
 
novice
Super member
[ *  *  *  * ]

In my opinion your posting does not give an adequately clear description of RS44. I ran your program and found none of the features that I mentioned as absent. Your program is not in the same class as that provided years ago by Geoff Sullivan, which provides these features at the click of a mouse in drop-down boxes..

I am happy to have provided the interested reader with appropriate clarity, references and resources in my posting.

I leave it to the reader to make up his/her mind of where the clarity and proper descriptions lie.
Edited by novice, Jan 18 2014, 06:07 PM.
Offline Profile Quote Post Goto Top
 
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
novice
Jan 18 2014, 05:25 PM
In my opinion your posting does not give an adequately clear description of RS44. I ran your program and found none of the features that I mentioned as absent.
What do you mean?? You said, for example, (erroneously) that I always started filling of plaintext at the upper left corner. I answered that the starting position of filling is given by the two parameters startrow and startcol. These parameter names themselves give already clear informations, don't they?? And in the comment lines of the function crosswordtransp() did your read the sentence "On encryption, filling of plaintext (given in the parameter textstr) is row-wise, starting at the (secret) position given by startrow and startcol, skipping all locations specified in the parameter windows." or not?? In Example 1, startrow=1, startcol=3, did you see that?? (In fact, that position is a black cell (see the value of windows), so the actual filling starts at row 1 and column 4.)
Edited by mok-kong shen, Jan 18 2014, 07:03 PM.
Offline Profile Quote Post Goto Top
 
novice
Super member
[ *  *  *  * ]
Run your program and see what you get. Then run Geoff's program and see a clear and comprehensive implementation in which ALL features of RS44 can be selected without messing about with program code. And the implementation is a facsimile of the original. That is what I call a clear, concise and worthwhile program of which one can be proud :)

Offline Profile Quote Post Goto Top
 
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
Please first answer whether you twice erred in your claims, before I take a look of the other implementation.
Offline Profile Quote Post Goto Top
 
Grip2000
no member
[ *  *  *  *  * ]
could also be interesting for you...

From:Dirk Rijmenants' RS 44 Excel sheet, which is available for download to create your own RS 44 sheets
here -> http://users.telenet.be/d.rijmenants/rs44.zip
Offline Profile Quote Post Goto Top
 
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
The original RS44 has 24 rows and 25 columns and in each row there are 15 black cells (15 is a constant). To generate such a matrix with my code one would use:
Code:
 
n=24
m=25
numwlow=15
numwhigh=15
seed="asecretseedtobeputhere"
windows=genwindows(n,m,numwlow,numwhigh,seed)
drawmatrix(n,m,windows)
At this opportunity I like to call attention to my conjecture (readers please correct me, if I am wrong) that the other available implementations are (1) restricted to the original RS44, while my code is for the more general cases (of arbitrary sizes of the matrix and arbitrary user-specifiable distributions of the black cells) and/or (2) available only as exe-files instead of in source code. (The essential disadvantages of using foreign exe-files are well known and shouldn't be neglected IMHO.)
Edited by mok-kong shen, Jan 19 2014, 10:37 PM.
Offline Profile Quote Post Goto Top
 
novice
Super member
[ *  *  *  * ]
Grip
 
could also be interesting for you...

From:Dirk Rijmenants' RS 44 Excel sheet, which is available for download to create your own RS 44 sheets
here -> http://users.telenet.be/d.rijmenants/rs44.zip


Yes indeed this is another good reference to bring to the attention of readers. Like Geoff Sullivan's program recommended in post nr 2 above, it is a practical program that:

-reproduces the RS44 stencil in good graphics as a realistic facsimile;

-allows adjustment, while running the program, with keyboard and mouse to the stencil layout, keys and content (no need to stop the program and go scrabbling through the code in an effort to understand it and find where changes need to be made, as in Mok Kong Shen's program, and then start all over again);

-gives a professional simulation of RS44 compared with the nondescript output of the Mok Kong Shen program below:

output of Mok Kong Shen program
 

Example 1.
()
windows given:
[[3], [], [1, 3], [3]]
()
('pt :', 'abcdefghijk')
('ct :', 'dcfikbhaegj')
('pt1:', 'abcdefghijk')
()
Example 2.
()
windows generated:
[[6, 4], [1, 6, 2], [4, 2, 1], [2, 6, 5], [2, 3]]
()
The corresponding matrix:
()
-------------
| | | |#| |#|
-------------
|#|#| | | |#|
-------------
|#|#| |#| | |
-------------
| |#| | |#|#|
-------------
| |#|#| | | |
-------------
()
('pt :', 'abcdefghijklmnopq')
('ct :', 'padhongjbikfmqcel')
('pt1:', 'abcdefghijklmnopq')


A glance at Geoff Sullivan's program (output graphics shown in post nr 2) or at the Dirk Rijmenant's Excel program shows the excellent presentation in graphics and ease of entering data achieved by these two capable programmers which makes their work eminently worthwhile.
Edited by novice, Jan 20 2014, 09:21 AM.
Offline Profile Quote Post Goto Top
 
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
@novice: In your first post you "strongly" accused me of having incorrectly implemented the RS44 scheme (despite the fact that I have actually implemented a generalization of it) and in a succeeding post (no.5) wrote: "I ran your program and found none of the features that I mentioned as absent". Isn't it contrary to the common conduct of scientific discussions that you didn't mention a single word of your (repeated) mistakes till the present?

Besides possibly some nice graphical interfaces or maybe even runtime efficiciencies, what are the features that Sullivan's software has above/beyond of what I have implemented in my code? Could you please clearly list them one by one?
Offline Profile Quote Post Goto Top
 
novice
Super member
[ *  *  *  * ]
When I run a program that purports to simulate RS44, I expect (1) to see the stencil complete with transposition key and coordinate labels, (2) to be asked for my plaintext, (3) to be asked where I want the plaintext to be entered and (4) what the offset should be for taking out .

When I run your program I get none of this, as I have demonstrated to you. You appear to expect the user to go searching through your program code to understand how your program works and to unearth the appropriate place to enter the above details into the program itself. I doubt any user is going to be prepared to do this - I certainly was not. I would be ashamed to ask any reader to do such a thing!

Since you claim that your program implements all the features of RS44, which I haven't seen when running the program you provided, perhaps you would like to give me and other readers a clear and detailed description on how each of these features can be implemented, including the line number in your code where the user has to make entries:

-setting up the stencil as per the stencil I have given in post nr 2;
-entering the plaintext;
-entry of coordinates for starting the plaintext entry;
-entry of offset for taking out the ciphertext;
-entry of the transposition key

All of this should be in relation to the following plaintext:

A PESSIMIST IS A PERSON WHO HAS HAD TO LISTEN TO TOO MANY OPTIMISTS WHILE AN OPTIMIST IS A PERSON WHO ALWAYS SEES THE JUG THREE QUARTERS FULL

to be entered starting at row be, column ac with an offset of 16 places to the right and a transposition key of:

10 14 8 7 24 19 25 9 1 2 20 23 18 22 13 15 16 11 21 6 17 5 4 3 12
Offline Profile Quote Post Goto Top
 
jdege
Member Avatar
NSA worthy
[ *  *  *  *  *  * ]
novice
Jan 24 2014, 02:25 PM
When I run your program I get none of this, as I have demonstrated to you. You appear to expect the user to go searching through your program code to understand how your program works and to unearth the appropriate place to enter the above details into the program itself. I doubt any user is going to be prepared to do this - I certainly was not. I would be ashamed to ask any reader to do such a thing!
There's a huge difference between writing a program for someone else, and tossing off some code to explore an idea.

The rule of thumb is it takes three times as much work to wrap a routine in a clean API as it does to throw together the code in the first place, and ten times as much to build a decent UI for it.

Most of the code that's been posted here has been examples of approaches, not packaged solutions. Certainly every line of code I've posted here has been of that sort.

So I don't think it's fair to complain about how "polished" his program is. He's not claimed he was providing a packaged utility.

When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.
Offline Profile Quote Post Goto Top
 
novice
Super member
[ *  *  *  * ]
I have a different view.

If you post a program that is meant to be of some utility to a user (especially a user not used to programming) then it should be interactive. The user should not have to delve through the code to try and understand the program and find where to insert his chosen parameters. The program I complain of is a case in point.

The javascript programs of WTShaw are examples of what I like to see for the general reader.

If the program is of a development nature, for example to illustrate some novel idea or new approach, then it could be of interest as it stands.

[on edit: I don't remember seeing any of your programs. They are probably before my time. You may like to point one or two of them out to me.]







Edited by novice, Jan 24 2014, 04:11 PM.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · General · Next Topic »
Add Reply