[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

description of my stream cipher




Subject:      description of my stream cipher
From:         Jouni Vuorio <[email protected]>
Date:         1998/02/17
Message-ID:   <[email protected]>
Newsgroups:   sci.crypt

[Subscribe to sci.crypt] 
[More Headers]


Here is description of my stream cipher, it operates one
byte at time, instead of one bit at time.
it�s key length is up to 255 bytes (2040 bits)

im sure that there are no need for longer description,
becourse that vb source code explanes details.
only thing that could be difficult to understund is
Asc(Mid(Text2, R2 - 1, 1)) that simppely means that
take asci value from text (in this case string text2)
starting from R2 - 1 and length of 1. i think that
everyone understunds the rest.


VB source code:

Initializing the substitution-box
On Error Resume Next

D = Len(Key)
R = 1

For R2 = 1 To 256
H1 = Asc(Mid(Text2, R2 - 1, 1))
K1 = Asc(Mid(Text2, R, 1))
K2 = Asc(Mid(Text2, D Mod Len(Text2), 1))
K3 = Asc(Mid(Text2, D * R Mod Len(Text2), 1))
K4 = Asc(Mid(Text2, R + D Mod Len(Text2), 1))

R1 = ((R1 + R2 + K + 1) Xor (R1 * R2 + 1)) Mod 256
R3 = ((R3 + R1 + 1) + R2 + (R1 * K + 1 Mod (R3 + R1 + 1))) Mod 256
R4 = (R4 + R3 + R1 + 1) ^ 2 Mod 256

R = R + 1
If (R - 1) = Len(Text2) Then R = 1

C = (C + (H1 + K1 + K2 + K3 + K4 + D + R1 + R3 + R4) Mod 256) Mod 256
C = C Mod 256


SBox = SBox & Chr(C Mod 255 + 1)
Next






On Error Resume Next

Key = Text2
texti = Text1
Text1 = ""


R = 1
S1 = Len(Key)
S2 = 11
For R2 = 1 To Len(texti)
C = Asc(Mid(texti, R2, 1)) - 1
K = (K + Asc(Mid(Key, R2 Mod Len(Key), 1))) Mod 256
K = (K + Asc(Mid(SBox, (((K * R2 Mod 256) - 255) * -1) Mod 257, 1))) Mod
256

R1 = ((R1 + R2 + K) Xor (R1 * R2)) Mod 256
R3 = ((R3 + R1) + R2 + (R1 * K Mod (R3 + R1))) Mod 256
R4 = (R4 + R3 + R1) ^ 2 Mod 256


F1 = (F1 + (Asc(Mid(SBox, R1 Mod 256, 1)) Mod 256) Mod 256)
F2 = (F2 + (Asc(Mid(SBox, R2 Mod 256, 1)) Mod 256) Mod 256)
F3 = (F3 + (Asc(Mid(SBox, R3 Mod 256, 1)) Mod 256) Mod 256)
F4 = (F4 + (Asc(Mid(SBox, R4 Mod 256, 1)) Mod 256) Mod 256)
F5 = (F5 + (Asc(Mid(SBox, K Mod 256, 1)) Mod 256) Mod 256)
temp = F1 + F2 + F3 + F4 + F5 + M Mod 256
F = (F + (Asc(Mid(SBox, temp, 1)) Mod 256) Mod 256)

M = M + 1
If M = 2 Then M = 0


If M = 0 Then C = C Xor ((F + K) Mod 256)
If M = 1 Then C = C Xor ((((F + K) Mod 256) - 255) * -1)


C = (C Mod 256) + 1


Mid(texti, R2, 1) = Chr(C)
Next



Text1 = texti

-- 
[email protected]             GSM 050-5456235
PahaeNTeist� soNTaa viNTi�t peNTteihin aseNTavat...