New stream cipher algorithm, Adaptive Stream Cipher

From: Benjamin Choi (contact_at_technosoft21.com)
Date: 08/16/03


Date: 15 Aug 2003 21:21:29 -0700

Hello,

Lately I've created a simple encryption algorithm (inspired by RC4's
design) which generates a seemingly random stream of bytes which is
then combined with the message using bitwise XOR. It generates the key
using the supplied passphrase as well as the message to be encrypted,
giving it its name of Adaptive Stream Cipher. It achieves an avalanche
effect. It uses two arrays: the SBox and the Key Array.

I cannot claim that it is unbreakable; no encryption is unbreakable
except one time pads. However I have tried to make this a little like
a one time pad generator (but nowhere as random). And I am sure that
it is at least safer than normal XOR encryption with a plaintext key.

However, one interesting thing about the generated key: even when
encrypting a 30k text message with lots of patterns using a plain text
passphrase, the key generated (30k naturally) compressed into about
30k. The key generated by RC4 also fails to compress well. I think
this means both keystreams have few patterns. Does this make them more
random?

Please help me cryptanalyse it for weakness. I am sure there would be
quite a few.

Visual Basic 6 source code implementation:
------------------------------------------------------------

Option Explicit
Dim SBox(255) As Long
Dim KeyArr(255) As Long

Sub ASCInitialise(Msg As String, Key As String, Encrypt As Boolean)
    Dim i As Long
    Dim Seed As Long
    'Initialise arrays

    For i = 0 To 255
        KeyArr(i) = Asc(Mid(Key, (i Mod Len(Key)) + 1, 1))
        KeyArr(i) = (KeyArr(i) + Asc(Mid(Key, (i Mod (Len(Key) - 1)) +
2, 1))) Mod 255
        SBox(i) = KeyArr(i) Xor i
    Next
    'Replace SBox elements
    Seed = 0

    For i = 0 To 255
        Seed = ((Seed Xor SBox(i)) + KeyArr(i)) Mod 255
        SBox(i) = (SBox(i) + Seed) Mod 255
    Next
End Sub

Public Function ASCCrypt(Msg As String, Key As String, Encrypt As
Boolean) As String
    Dim i As Long
    Dim ASCMsg As String
    Dim ASCString As String
    ASCMsg = Msg
    ASCInitialise ASCMsg, Key, Encrypt

    For i = 1 To Len(ASCMsg)
        ASCString = ASCString & Chr(ASCPureCrypt(Asc(Mid(ASCMsg, i,
1)), Encrypt, i))
    Next
    ASCCrypt = ASCString
End Function

Public Function ASCPureCrypt(Msg As Byte, Encrypt As Boolean, BytePos
As Long) As Byte
    Dim k As Long
    Dim lngCipher As Long
    'Adapt SBox

    If Encrypt = True Then
        SBox((BytePos + 1) Mod 255) = (SBox((BytePos + 1) Mod 255) +
Msg) Mod 255
    End If
    k = SBox(BytePos Mod 255)
    k = k Xor KeyArr(BytePos Mod 255)
    'Combine message with keystream
    lngCipher = Msg Xor k
    'Adapt SBox

    If Encrypt = False Then
        SBox((BytePos + 1) Mod 255) = (SBox((BytePos + 1) Mod 255) +
lngCipher) Mod 255
    End If
    ASCPureCrypt = lngCipher
End Function

------------------------------
Benjamin Choi
contact at technosoft21 dot com



Relevant Pages

  • RE: 2007 User Level Security
    ... encrypted string. ... the way I use it is to encrypt user names and passwords and store the ... Dim prp As Property ... Dim dbs As Object, prp As Variant ...
    (microsoft.public.access.modulesdaovba)
  • DES ECB Encryption cannot decrypt
    ... If I have the value to encrypt = ... Dim globalexception As CryptographicException ... Public Function encrypt(ByRef textPIN As String, ByRef textKey As String, ... Catch exception As CryptographicUnexpectedOperationException ...
    (microsoft.public.dotnet.security)
  • Re: Help (cesar code)
    ... Here are a couple of functions that will encrypt and encrypt a whole word ... Function Encrypt(text As String) ... Dim sTemp As String ...
    (microsoft.public.excel.programming)
  • Re: How do I get this to work ?
    ... Unfortunately it is not possible to convert a byte array to a string and then back to byte array and get the same data ... Imports System.IO ... Dim cryptPIN As New MemoryStream ... encryptStream.Write(PIN, 0, CInt(PIN.Length)) 'encrypt writing to the encryptionstream ...
    (microsoft.public.dotnet.security)
  • Re: How to save PASSWORD in SQL Server with bit or binary type dat
    ... Encrypt the user password and store it ... Private Sub Button1_Click(ByVal sender As System.Object, ... Dim md5Hasher As New MD5CryptoServiceProvider ... Dim encryptedStream As MemoryStream = New MemoryStream ...
    (microsoft.public.dotnet.general)