Page 3 of 6

Posted: Sat Apr 28, 2007 5:40 pm
by Jacobus
Thank you JCV, it's Ok! You can to continue to do, it's a very good job.
Try checking the end of the decrypted txt
checking...

Code: Select all

Procedure DecryptBF(ToDec$)
 ResultD$ = Space(1024)
  flags.l = #BlowFish_UseCBC | #BlowFish_UseBase64
  lengthD = Blowfish_DecryptText(@ToDec$, Len(ToDec$), @Pfe$, Len(Pfe$), @ResultD$, Len(ResultD$), flags) 
  If lengthD 
   SetGadgetText(#Text1, ResultD$) ;test 1 
   ;SetGadgetText(#Text1, Left(ResultD$, lengthD)) ;test 2 
   Debug StringByteLength(GetGadgetText(#Text1)); return the number of caracters. With test1 it's always the same, return 1024, totally space. With test2 return only the string$
   SetGadgetText(#Text2, "")
  ; Debug Len(ToDec$)
    Else 
   MessageRequester("Error!","Decrypt is failed",#MB_ICONEXCLAMATION)
  EndIf  
EndProcedure

Posted: Mon Apr 30, 2007 10:35 am
by Jacobus
Hello,
Here is a new example to encrypt text files with Blowfish lib. Two editors to see the process. You can open file or write in editor. Some files cause problems with AllocateMemory() and Freememory() but i don't know why. If you can repeat the bug and discover the reason, thanks to share.

Code: Select all

;Example to encrypt and decrypt text file in editor by Jacobus with JCV blowfish library
;-Constantes
Enumeration 
 #WIN_TEST
 #Text1
 #btnEnc
 #Text2
 #btnDec
 #editor
 #editorcrypt
 #btnOpen
 #btnCryptFile
 #btnDecryptFile
EndEnumeration

Structure BLOWFISH_CTX 
  K.q[18]  
  S0.q[256] 
  S1.q[256] 
  S2.q[256] 
  S3.q[256] 
EndStructure 

#FL                 = $FFFFFFFF 
#BlowFish_UseBase64 = $01 
#BlowFish_UseCBC    = $02 
;#BlowFish_UseCBC = Will always produce a different encrypted Text(or Memoryblock) 
;#BlowFish_UseBase64 = Will encrypt the result in base64. 

Procedure.l Blowfish_CryptText(*text, textlen.l, *Password, passlen.l, *Result, Resultlen.l, Mode.l = #BlowFish_UseBase64) 
  
  Protected BF.BLOWFISH_CTX, *Buffer, n.l, i.l, a.l, K.q, P.l, b.l 
  
  Blowfish_Init(@BF, *Password, passlen) 
  
  *Buffer = AllocateMemory(textlen * 2) ; problem with some files (invalid memory access)
  If *Buffer 
    n = textlen 
    If n % 8 <> 0 
      n = 8 - (n % 8) 
      For i = 0 To n - 1 
        PokeB(*text + textlen + i, 32) 
      Next i 
      textlen + n 
    EndIf 
    
    n = textlen / 4 
    
    Dim L.Quad(n) 
    Dim Cipher.Quad(n+2) 
    
    If Mode & #BlowFish_UseCBC 
      Cipher(0)\q = Date(); 
      Cipher(1)\q = ElapsedMilliseconds()*1000000 
      P = 2 
    EndIf 
    
    For i = 0 To n - 1 
      L(i)\q = PeekL(*text + i*4) & #FL 
    Next i 
    
    b = 1 
    If n*8 <= Resultlen 
      For i = 0 To n - 1 Step 2 
        
        If Mode & #BlowFish_UseCBC 
          L(i)\q   ! Cipher(b-1)\q 
          L(i+1)\q ! Cipher(b)\q 
        EndIf 
        
        Cipher(i+P)\q   = L(i)\q 
        Cipher(i+P+1)\q = L(i+1)\q 
        Blowfish_Encrypt(@BF, @Cipher(i + P), @Cipher(i + P+ 1)) 
        b + 2 
      Next i 
      
      a = 0 
      For i = 0 To n - 1 + P Step 2 
        K = Cipher(i)\q & #FL 
        PokeL(*Buffer + a, PeekL(@K)) 
        K = Cipher(i + 1)\q & #FL 
        PokeL(*Buffer + a + 4, PeekL(@K)) 
        a + 8 
      Next i 
      
      If Mode & #BlowFish_UseBase64 
        Base64Encoder(*Buffer, a, *Result, Resultlen) 
        a = MemoryStringLength(*Result) 
      Else 
        CopyMemory(*Buffer, *Result, a) 
      EndIf 
    EndIf 
    FreeMemory(*Buffer); problem with some files - pointer invalid
;    Else
;     Debug "Impossible d'allouer la mémoire demandée !" 
  EndIf 
  
  ProcedureReturn a 
  
EndProcedure 

Procedure.l Blowfish_DecryptText(*text, textlen.l, *Password, passlen.l, *Result, Resultlen.l, Mode.l = #BlowFish_UseBase64) 
  
  Protected BF.BLOWFISH_CTX, *Buffer, n.l, i.l, a.l, j.l, K1.q, K2.q 
  
  Blowfish_Init(@BF, *Password, passlen) 
  
  *Buffer = AllocateMemory(textlen * 2 + 64) 
  If *Buffer 
    If Mode & #BlowFish_UseBase64 
      textlen = Base64Decoder(*text, textlen, *Buffer, textlen * 2 + 64) 
      n = textlen / 4 
    Else 
      CopyMemory(*text, *Buffer, textlen) 
      n = textlen / 4 
    EndIf 
    
    Dim Cipher.Quad(n+2) 
    Dim L.Quad(n) 
    
    For i = 0 To n - 1 
      Cipher(i)\q = PeekL(*Buffer + i*4) & #FL 
    Next i 
    
    If Mode & #BlowFish_UseCBC 
      j = 2 
    Else 
      j = 0 
    EndIf 
    
    a = 0 
    If n*8 <= Resultlen 
      For i = j To n - 1 Step 2 
        K1 = Cipher(i)\q 
        K2 = Cipher(i+1)\q 
        Blowfish_Decrypt(@BF, @K1, @K2) 
        If Mode & #BlowFish_UseCBC 
          L(i-j)\q   = K1 ! Cipher(i-2)\q 
          L(i+1-j)\q = K2 ! Cipher(i-1)\q 
        Else 
          L(i-j)\q   = K1 
          L(i+1-j)\q = K2 
        EndIf 
      Next i 
      For i = 0 To n - 1 - j Step 2 
        K1 = L(i)\q & #FL 
        K2 = L(i + 1)\q & #FL 
        PokeL(*Result + a, PeekL(@K1)) 
        PokeL(*Result + a + 4, PeekL(@K2)) 
        a + 8 
      Next i 
    EndIf 
    
    FreeMemory(*Buffer) 
;    Else
;     Debug "Impossible d'allouer la mémoire demandée !"
  EndIf 
  ProcedureReturn a 
  
EndProcedure 

Global Pfe$
Pfe$ = "d41d8cd98f00b204e9800998ecf8427e" ; encryption key based on md5 file

Procedure.s CryptBF(ToEnc$)
  
  ResultC$ = Space(4096); necessary with long lines 
  flags.l = #BlowFish_UseCBC | #BlowFish_UseBase64
  lengthC = Blowfish_CryptText(@ToEnc$, Len(ToEnc$), @Pfe$, Len(Pfe$), @ResultC$, Len(ResultC$), flags) 
  If lengthC 
    ProcedureReturn ResultC$
   Else 
   MessageRequester("Error!","Encryption is failed",#MB_ICONEXCLAMATION)
  EndIf 
  
EndProcedure

Procedure.s DecryptBF(ToDec$)
  
  ResultD$ = Space(4096)
  flags.l = #BlowFish_UseCBC | #BlowFish_UseBase64
  lengthD = Blowfish_DecryptText(@ToDec$, Len(ToDec$), @Pfe$, Len(Pfe$), @ResultD$, Len(ResultD$), flags) 
  If lengthD 
     ProcedureReturn Left(ResultD$, lengthD)
    Else 
   MessageRequester("Error!","Decrypt is failed",#MB_ICONEXCLAMATION)
  EndIf 
  
EndProcedure

;-Fenêtre principale/Main window
If OpenWindow(#WIN_TEST,0,0, 790, 550,"Window test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)=0 Or CreateGadgetList(WindowID(#WIN_TEST))=0  
    End 
  EndIf 
 
  StringGadget(#Text1, 10,10,480,20,"")
  ButtonGadget(#btnEnc, 500,10,80,20,"Crypt>>")
  
  StringGadget(#Text2, 10,50,480,20,"")
  ButtonGadget(#btnDec, 500,50,80,20,"<<Decrypt")
  
  
  ButtonGadget(#btnOpen, 10,100,80,20,"OpenFile")
  ButtonGadget(#btnCryptFile, 100,100,80,20,"CryptFile>>")
  ButtonGadget(#btnDecryptFile, 190,100,80,20,"<<DecryptFile")
    
  EditorGadget(#editor,10,130,380,380)
  SendMessage_(GadgetID(#editor), #EM_SETLIMITTEXT, -1, 0)
  ;SendMessage_(GadgetID(#editor), #EM_SETTARGETDEVICE, #Null, 0)
  
  EditorGadget(#editorcrypt,395,130,380,380)
  SendMessage_(GadgetID(#editorcrypt), #EM_SETLIMITTEXT, -1, 0)
  
  
;-Programme / Event loop   
  Repeat
    Event = WaitWindowEvent() 
    If Event = #PB_Event_Gadget
      Select EventGadget() 
        
          Case #btnEnc ; encrypt first string
           Enc$ = GetGadgetText(#Text1)
           If Enc$<>""
            Debug Enc$
            TextEnc$ = CryptBF(Enc$) 
             SetGadgetText(#Text2, TextEnc$) 
             SetGadgetText(#Text1, "")
           EndIf        
              
                       
          Case #btnDec ; decrypt second string
           Dec$ = GetGadgetText(#Text2)
           If Dec$<>""
            Debug Dec$
            TextDec$ = DecryptBF(Dec$)
             SetGadgetText(#Text1, TextDec$) 
             SetGadgetText(#Text2, "")
           EndIf
          
          Case #btnOpen ; select and open file
           If DestRep$ = ""
             DestRep$ = "c:\"
           EndIf 
           Fichier.s = OpenFileRequester("Select and open one file", DestRep$, "Text files|*.txt", 0) 
            If Fichier <> ""
               If ReadFile(0, Fichier)
                ClearGadgetItemList(#editor)
                  While Eof(0) = 0
                    AddGadgetItem(#editor, -1 ,ReadString(0))       
                  Wend
                CloseFile(0)
               EndIf
              DestRep$ = GetPathPart(Fichier)
            EndIf 
          
          Case #btnCryptFile   ;encrypt text in left editor 
            ValText$ = GetGadgetText(#editor) 
             If ValText$<>""                 
               Nblines = CountGadgetItems(#editor)
                For ni = 0 To Nblines - 1
                  Encf$ = GetGadgetItemText(#editor,ni,0):Debug Len(Encf$)
                  If Encf$<>""
                     AddGadgetItem(#editorcrypt, -1 ,CryptBF(Encf$))
                    Else 
                     AddGadgetItem(#editorcrypt, -1 ,"")
                  EndIf 
                Next
                ClearGadgetItemList(#editor)
             EndIf  
             
         
          Case #btnDecryptFile ; decrypt text in right editor
            ValText$ = GetGadgetText(#editorcrypt) 
             If ValText$<>""                 
               Nblines = CountGadgetItems(#editorcrypt)
                For ni = 0 To Nblines - 1
                  Decf$ = GetGadgetItemText(#editorcrypt,ni,0)
                  If Decf$<>""
                    AddGadgetItem(#editor, -1 ,DecryptBF(Decf$))
                   Else 
                    AddGadgetItem(#editor, -1 ,"")
                  EndIf 
                Next
                ClearGadgetItemList(#editorcrypt)
             EndIf
          
      EndSelect  
    EndIf 
  Until Event = #PB_Event_CloseWindow
;-End 
  End 
Another thing, space created in procedures is not possible with len(file$) ?
example :

Code: Select all

Procedure.s CryptBF(FToEnc$)  
  FileLength = Len(FToEnc$)  <--- necessary space            
  ResultCf$ = Space(FileLength) ; why that's not work?  
  flags.l = #BlowFish_UseCBC | #BlowFish_UseBase64
  lengthCf = Blowfish_CryptText(@FToEnc$, Len(FToEnc$), @Pfe$, Len(Pfe$), @ResultCf$, Len(ResultCf$), flags) 
  If lengthCf 
    ProcedureReturn ResultCf$
   Else 
   MessageRequester("Error!","Encryption is failed",#MB_ICONEXCLAMATION)
  EndIf   
EndProcedure
@+

Posted: Wed May 09, 2007 10:14 am
by Jacobus
Suite of example...
To valid memory access in AllocateMemory() and pointer memory in FreeMemory(), if the string < 4 chars, you must add characters at the end of line to encryption. For that reason to remember the original string you must remove the added chars after deciphering. An easy way out to do that, it's to use Space(4) to encryption and RTrim(String$) to decipher.

You can use the code in the post above to try with event loop that here is.
Replace :

Code: Select all

;-Programme    
  Repeat
    Event = WaitWindowEvent() 
    If Event = #PB_Event_Gadget
      Select EventGadget() 
        
          Case #btnEnc 
           Enc$ = GetGadgetText(#Text1)
           If Enc$<>""
             If Enc$ > 4
               TextEnc$ = CryptBF(Enc$) 
              Else 
               TextEnc$ = CryptBF(Enc$+Space(4))
             EndIf  
              SetGadgetText(#Text2, TextEnc$) 
              SetGadgetText(#Text1, "")
           EndIf        
              
                       
          Case #btnDec 
           Dec$ = GetGadgetText(#Text2)
           If Dec$<>""
            TextDec$ = RTrim(DecryptBF(Dec$))
             SetGadgetText(#Text1, TextDec$) 
             SetGadgetText(#Text2, "")
           EndIf
          
          Case #btnOpen
           If DestRep$ = ""
             DestRep$ = "c:\"
           EndIf 
           Fichier.s = OpenFileRequester("Select and open one file", DestRep$, "Text files|*.txt", 0) 
            If Fichier <> ""
               If ReadFile(0, Fichier)
                ClearGadgetItemList(#editor)
                  While Eof(0) = 0
                    AddGadgetItem(#editor, -1 ,ReadString(0))       
                  Wend
                CloseFile(0)
               EndIf
              DestRep$ = GetPathPart(Fichier)
            EndIf 
          
          Case #btnCryptFile    
            ValText$ = GetGadgetText(#editor) 
             If ValText$<>""                 
               Nblines = CountGadgetItems(#editor)
                For ni = 0 To Nblines - 1
                  Encf$ = GetGadgetItemText(#editor,ni,0)
                  If Encf$<>"" And Len(Encf$)>4 
                     AddGadgetItem(#editorcrypt, -1 ,CryptBF(Encf$))
                   ElseIf Encf$<>"" And Len(Encf$)<4
                     AddGadgetItem(#editorcrypt, -1 ,CryptBF(Encf$+Space(4)))
                   ElseIf Encf$=""
                     AddGadgetItem(#editorcrypt, -1 ,"")
                  EndIf 
                Next
                ClearGadgetItemList(#editor)
             EndIf  
             
         
          Case #btnDecryptFile
            ValText$ = GetGadgetText(#editorcrypt) 
             If ValText$<>""                 
               Nblines = CountGadgetItems(#editorcrypt)
                For ni = 0 To Nblines - 1
                  Decf$ = GetGadgetItemText(#editorcrypt,ni,0)
                  If Decf$<>""
                    AddGadgetItem(#editor, -1 ,RTrim(DecryptBF(Decf$)))
                   Else 
                    AddGadgetItem(#editor, -1 ,"")
                  EndIf 
                Next
                ClearGadgetItemList(#editorcrypt)
             EndIf
@+

Posted: Wed May 16, 2007 10:46 pm
by macros
Thank you very much for your work,
but at the moment I am not able to use it,
because it has so many bugs.

Don't worry, I am only speaking about the Whirlpool Lib.
Take a look at this Code:

Code: Select all

#WP_DIGEST_SIZE = 64
#DIGESTBYTES = #WP_DIGEST_SIZE
#DIGESTBITS  = (8*#DIGESTBYTES) ; /* 512 */
#WBLOCKBYTES = 64
#WBLOCKBITS  = (8*#WBLOCKBYTES) ; /* 512 */
#LENGTHBYTES = 32
#LENGTHBITS  = (8*#LENGTHBYTES) ; /* 256 */

Structure Whirlpool_Struct
  bitLength.l[#LENGTHBYTES]   ;  /* global number of hashed bits (256-bit counter) */
  Buffer.l[#WBLOCKBYTES]      ;	 /* buffer of data to hash */
  bufferBits.l		            ;  /* current number of Bits on the Buffer */
  bufferPos.l		              ;  /* current (possibly incomplete) byte slot on the Buffer */
  hash.l[#DIGESTBYTES/8]      ;  /* the hashing state */
EndStructure

Procedure.s getHex(msg.s)
  If Len(msg) > 0
    For i = 1 To Len(msg)
      returnMsg$ + LCase(RSet(Hex(Asc(Mid(msg, i, 1))), 2, "0"))
    Next
  EndIf
  ProcedureReturn returnMsg$
EndProcedure

Procedure.s WhirlpoolFingerprint(*Buffer, length)

  WP.Whirlpool_Struct
  Dim hash.c(#WP_DIGEST_SIZE)
  Dim hex_hash.s(#WP_DIGEST_SIZE * 2)

  Whirlpool_Init(@WP)
  Whirlpool_Add(*Buffer, length * 8, @WP)
  Whirlpool_Finalize(@WP, @hash())
  Whirlpool_Free(@WP)

  ProcedureReturn getHex(PeekS(@hash()))
EndProcedure

Procedure.s Whirlpool(text$)
  ProcedureReturn WhirlpoolFingerprint(@text$,Len(text$))
EndProcedure

Debug Whirlpool("Many empty Whirlpool hashs:")     +"  ="+Str(Len(Whirlpool("Many empty Whirlpool hashs:")))
Debug Whirlpool("The above one is too short O.o") +"  ="+Str(Len(Whirlpool("The above one is too short O.o")))
Debug Whirlpool("Many many bugs :-(")             +"  ="+Str(Len(Whirlpool("Many many bugs :-(")))
Debug Whirlpool("Egb")                 +"      ="+Str(Len(Whirlpool("Egb")))
Debug Whirlpool("@@h")                 +"      ="+Str(Len(Whirlpool("@@h")))
Debug Whirlpool("Njq")                 +"      ="+Str(Len(Whirlpool("Njq")))
Debug Whirlpool("TAC")                 +"      ="+Str(Len(Whirlpool("TAC")))
Debug Whirlpool("j[@")                 +"      ="+Str(Len(Whirlpool("j[@")))
Debug Whirlpool("fjd")                 +"      ="+Str(Len(Whirlpool("fjd")))
Debug Whirlpool("Xmi")                 +"      ="+Str(Len(Whirlpool("Xmi")))
Debug Whirlpool("xZY")                 +"      ="+Str(Len(Whirlpool("xZY")))
Debug Whirlpool("Atk")                 +"      ="+Str(Len(Whirlpool("Atk")))
Debug Whirlpool("[?T")                 +"      ="+Str(Len(Whirlpool("[?T")))
Debug Whirlpool("kXH")                 +"      ="+Str(Len(Whirlpool("kXH")))
Debug Whirlpool("qEE")                 +"      ="+Str(Len(Whirlpool("qEE")))
Debug Whirlpool("TAC")                 +"      ="+Str(Len(Whirlpool("TAC")))
Debug Whirlpool("@bC")                 +"      ="+Str(Len(Whirlpool("@bC")))
Debug Whirlpool("aFJ")                 +"      ="+Str(Len(Whirlpool("aFJ")))
Debug Whirlpool("puI")                 +"      ="+Str(Len(Whirlpool("puI")))
Debug Whirlpool("OZv")                 +"      ="+Str(Len(Whirlpool("OZv")))
Debug Whirlpool("QWU")                 +"      ="+Str(Len(Whirlpool("QWU")))
Debug Whirlpool("<su")                 +"      ="+Str(Len(Whirlpool("<su")))
Debug Whirlpool("Mpd")                 +"      ="+Str(Len(Whirlpool("Mpd")))
Debug Whirlpool("puI")                 +"      ="+Str(Len(Whirlpool("puI")))
Debug Whirlpool("QKm")                 +"      ="+Str(Len(Whirlpool("QKm")))
Debug Whirlpool("TCX")                 +"      ="+Str(Len(Whirlpool("TCX")))
Debug Whirlpool("l]w")                 +"      ="+Str(Len(Whirlpool("l]w")))
Debug Whirlpool("[?b")                 +"      ="+Str(Len(Whirlpool("[?b")))
Debug Whirlpool("J\u")                 +"      ="+Str(Len(Whirlpool("J\u")))
Debug Whirlpool("jEK")                 +"      ="+Str(Len(Whirlpool("jEK")))
Debug Whirlpool("rou")                 +"      ="+Str(Len(Whirlpool("rou")))
Debug Whirlpool("?Ap")                 +"      ="+Str(Len(Whirlpool("?Ap")))
Debug Whirlpool("NKO")                 +"      ="+Str(Len(Whirlpool("NKO")))
Debug Whirlpool("qXs")                 +"      ="+Str(Len(Whirlpool("qXs")))
Debug Whirlpool("End")+"  ="+Str(Len(Whirlpool("End")))
I need the hashes for encryption,
and its very bad to encrypt with an empty key.

It would be very nice, if you fix it.

Posted: Tue Jul 31, 2007 5:41 pm
by Joakim Christiansen
Does these work with the latest beta version of PB on windows?

Posted: Wed Aug 01, 2007 2:58 am
by JCV
macros, its working fine heres a better example.
EnableExplicit

#WP_DIGEST_SIZE = 64
#DIGESTBYTES = #WP_DIGEST_SIZE
#DIGESTBITS  = (8*#DIGESTBYTES) ; /* 512 */
#WBLOCKBYTES = 64
#WBLOCKBITS  = (8*#WBLOCKBYTES) ; /* 512 */
#LENGTHBYTES = 32
#LENGTHBITS  = (8*#LENGTHBYTES) ; /* 256 */

Structure Whirlpool_Struct
  bitLength.l[#LENGTHBYTES]   ;  /* global number of hashed bits (256-bit counter) */
  Buffer.l[#WBLOCKBYTES]      ;    /* buffer of data to hash */
  bufferBits.l                  ;  /* current number of Bits on the Buffer */
  bufferPos.l                    ;  /* current (possibly incomplete) byte slot on the Buffer */
  hash.l[#DIGESTBYTES/8]      ;  /* the hashing state */
EndStructure

Procedure.WhirlpoolFingerprint(*Buffer, length)
  Protected WP.Whirlpool_Struct
  Protected BufferOut, x, strOut.s
  
  BufferOut = AllocateMemory(#WP_DIGEST_SIZE)
  
  Whirlpool_Init(@WP)
  Whirlpool_Add(*Buffer, length * 8, @WP)
  Whirlpool_Finalize(@WP, BufferOut)
  Whirlpool_Free(@WP)
  
  For = 0 To #WP_DIGEST_SIZE-1
    strOut + RSet(Hex(PeekC(BufferOut+x)), 2, "0")
  Next
  
  FreeMemory(BufferOut)
  
  ProcedureReturn strOut
EndProcedure

Procedure.WhirlpoolFileFingerprint(filename.s)
  Protected filelength.l, fileBuffer.l
  
  ReadFile(0, filename)
  filelength = Lof(0)
  fileBuffer = AllocateMemory(filelength)
  ReadData(0, fileBuffer, filelength)
  CloseFile(0)
  
  Protected WP.Whirlpool_Struct
  Protected BufferOut, x, strOut.s
  
  BufferOut = AllocateMemory(#WP_DIGEST_SIZE)
  
  Whirlpool_Init(@WP)
  Whirlpool_Add(fileBuffer, filelength * 8, @WP)
  Whirlpool_Finalize(@WP, BufferOut)
  Whirlpool_Free(@WP)
  
  For = 0 To #WP_DIGEST_SIZE-1
    strOut + RSet(Hex(PeekC(BufferOut+x)), 2, "0")
  Next
  
  FreeMemory(fileBuffer)
  FreeMemory(BufferOut)
  
  ProcedureReturn strOut
EndProcedure

Procedure.Whirlpool(input.s)
  ProcedureReturn WhirlpoolFingerprint(@input,Len(input))
EndProcedure

Debug WhirlpoolFileFingerprint("C:\YServer.txt") + " =" + Str(Len(WhirlpoolFileFingerprint("C:\YServer.txt")))
Debug Whirlpool("Egb")+"      ="+Str(Len(Whirlpool("Egb")))
Debug Whirlpool("@@h")+"      ="+Str(Len(Whirlpool("@@h")))
Debug Whirlpool("Njq")+"      ="+Str(Len(Whirlpool("Njq")))
Debug Whirlpool("TAC")+"      ="+Str(Len(Whirlpool("TAC")))
Debug Whirlpool("j[@")+"      ="+Str(Len(Whirlpool("j[@")))
Debug Whirlpool("fjd")+"      ="+Str(Len(Whirlpool("fjd")))
Debug Whirlpool("Xmi")+"      ="+Str(Len(Whirlpool("Xmi")))
Debug Whirlpool("xZY")+"      ="+Str(Len(Whirlpool("xZY")))
Debug Whirlpool("Atk")+"      ="+Str(Len(Whirlpool("Atk")))
Debug Whirlpool("[?T")+"      ="+Str(Len(Whirlpool("[?T")))
Debug Whirlpool("kXH")+"      ="+Str(Len(Whirlpool("kXH")))
Debug Whirlpool("qEE")+"      ="+Str(Len(Whirlpool("qEE")))
Debug Whirlpool("TAC")+"      ="+Str(Len(Whirlpool("TAC")))
Debug Whirlpool("@bC")+"      ="+Str(Len(Whirlpool("@bC")))
Debug Whirlpool("aFJ")+"      ="+Str(Len(Whirlpool("aFJ")))
Debug Whirlpool("puI")+"      ="+Str(Len(Whirlpool("puI")))
Debug Whirlpool("OZv")+"      ="+Str(Len(Whirlpool("OZv")))
Debug Whirlpool("QWU")+"      ="+Str(Len(Whirlpool("QWU")))
Debug Whirlpool("<su")+"      ="+Str(Len(Whirlpool("<su")))
Debug Whirlpool("Mpd")+"      ="+Str(Len(Whirlpool("Mpd")))
Debug Whirlpool("puI")+"      ="+Str(Len(Whirlpool("puI")))
Debug Whirlpool("QKm")+"      ="+Str(Len(Whirlpool("QKm")))
Debug Whirlpool("TCX")+"      ="+Str(Len(Whirlpool("TCX")))
Debug Whirlpool("l]w")+"      ="+Str(Len(Whirlpool("l]w")))
Debug Whirlpool("[?b")+"      ="+Str(Len(Whirlpool("[?b")))
Debug Whirlpool("J\u")+"      ="+Str(Len(Whirlpool("J\u")))
Debug Whirlpool("jEK")+"      ="+Str(Len(Whirlpool("jEK")))
Debug Whirlpool("rou")+"      ="+Str(Len(Whirlpool("rou")))
Debug Whirlpool("?Ap")+"      ="+Str(Len(Whirlpool("?Ap")))
Debug Whirlpool("NKO")+"      ="+Str(Len(Whirlpool("NKO")))
Debug Whirlpool("qXs")+"      ="+Str(Len(Whirlpool("qXs")))
Debug Whirlpool("End")+"  ="+Str(Len(Whirlpool("End"))) 
Joakim Christiansen, its working fine here.

Posted: Tue Oct 02, 2007 10:46 am
by dontmailme
Anybody have an example using AES ? I just don't get it :D

Posted: Tue Oct 02, 2007 10:56 am
by DoubleDutch
localmotion34 wrote:
Selling any software to or from the US without approval from the Gov't is a Federal Crime,
and for non-US citizens, can end you up in Gitmo or extradited to the US.

Really?

Kidnapped in Europe... Sent to U.S. in secret CIA flight, and jailed in Guantanamo ???

That's impossible.... Never heard about that ...
There is the case of the man who cracked (outside the USA) adobe pdf encryption so that people could edit password protected pdf's who was arrested as soon as he made a visit to the USA. I would not say it's unknown for this kind of thing to happen, remember all the prolems with PGP?

http://news.zdnet.co.uk/security/0,1000 ... 663,00.htm

http://en.wikipedia.org/wiki/Dmitry_Sklyarov

Posted: Mon Oct 29, 2007 10:50 am
by Kukulkan
Hi JVC,

I currently try your library. I want to use RSA with 1024 bits.

Here are some questions:
For RSA, a public key needs the modulus and the public exponent. The private key needs the modulus, the public and the private exponent. How is this information stored in your examples?

How fast is your RSA implementation? I try'd to test, but each second try to decode RSA fails with invalid memory access.

Would it be portable to PB on Linux or are you using WIN_API?

Here is the final question:

If the library is able to do 200 RSA decryptions per second using 1024 bit for a 512 bit message on my 2GHz computer, I'm very interested in buying your sourcecode (if written in PB. OpenSSL currently is doing 340 decryptions per second). I would pay you for the code and for adapting to my special key storage format (it is in HEX).

What will be the price? You can send me PN if you like!

Kukulkan

Posted: Tue Oct 30, 2007 6:31 am
by JCV
Hi Kukulkan,

My PB library is RSA 2048bits but I can recompile 1024bits.
All my RSA libraries are coded in C and its based from tutorials in the net.

I'll probably port it to PB if i have vacant time. Im busy with my newly opened business. :)

Posted: Tue Oct 30, 2007 8:15 am
by Kukulkan
Hi JVC,

And how fast is it? I currently can not test using 1024 bits. Please do the following check for me:

Generate a random 256 bit message and a 1024 bit RSA keypair.

Encrypt the message using the generated public key for 20 seconds and count how many it will do. So you can calculate the speed in seconds.

Then, do the same for decryption of this encoded message using RSA decryption with the generated private key (will be slower). Please count again.

If it manages to do more than 100 decryptions per second, I will be happy to use your library (if it is in C or not). Don't misunderstand me, I dont want to buy the complete source and rights from you. I only need to have a sourcecode-licence to be able to port it to linux if needed.

Kukulkan

Posted: Fri Nov 02, 2007 1:00 am
by hardfalcon
JVS: You stated that you made these libs out of some open source libraries. Depending on the license these open source libraries where published under (for example GPL), you might possibly have to publish you libraries under asimilar ("compatible") license, which means you would have to distribute both the sourcecode and the respective license with your libraries...
localmotion34 wrote:encryption is considered a munition like bombs and guns.
What the heck are they going to do if I dare to read a *book* in the USA? Burn me alive? :shock:
"Stars and Stripes,
Freedom is rushin' trough the drain pipes..."

Posted: Fri Nov 02, 2007 10:39 am
by JCV
Encryption/hash authors usually dont use GPL license because of its known limitation.

Im not a fan of GPL. It doesnt allow us to combine a GPL code unless we also GPL our code. :?
A good example is SMF & Joomla. So sad :(

@Kukulkan
I cannot test since I dont have my codes here in cafe. I might be able to test it when I go home this weekend.

Posted: Thu Nov 22, 2007 3:41 pm
by m0
Hi!

I would like to use your RIJNDAEL library, but i have some questions...
Is it possible to be used with the Linux-version of PB?
And would you pleas give me an example code, because i don't understand your functions totally......


Thank you very very much!
m0

Posted: Thu Dec 13, 2007 8:53 pm
by onny
dontmailme wrote:Anybody have an example using AES ? I just don't get it :D
need an example too! plz help!