Have to reply....newbie wrote:May be now someone can create an AES (Rindjael) code in PB ?
Blowfish Encryption Componet
DLL does not suit to everyone needs, and if you can do the DDL code in PB, why not post this code ?
It can then be added into a PB lib by someone else ?
Personally, I have quit visual basic mainly because of dependencies.
EDIT : if Sec does the PB lib, you can do the DLL, and everyone is happy
It can then be added into a PB lib by someone else ?
Personally, I have quit visual basic mainly because of dependencies.
EDIT : if Sec does the PB lib, you can do the DLL, and everyone is happy
- Registered PB user -
Using PB 4.00
Using PB 4.00
Not I, I am pretty much 100% against DLL use for PB. That is why I pretty much ignore this thread, it talks about using a DLL in PB instead of a PB lib.newbie wrote:can't wait for it, and I'm sure Shannara too
I am pretty much like you, I got away from VB due to dependancies, and firmly believe to keep DLLs and other such dependencies away from PB. This component counters that so....
Adding AES support to this is well, nobody is interested
-
sec
- Enthusiast

- Posts: 792
- Joined: Sat Aug 09, 2003 3:13 am
- Location: 90-61-92 // EU or ASIA
- Contact:
Code: Select all
;Test from fips-197.pdf
;PLAINTEXT: 00112233445566778899aabbccddeeff
;KEY: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
Procedure.s bytetohex(bb.l)
hexnum.s = "0123456789abcdef"
bb = bb & $FF
ProcedureReturn PeekS(@hexnum+ (bb>>4),1) + PeekS(@hexnum+ (bb & $0F),1)
EndProcedure
plain.s=Space(16)
PokeB(@plain,0)
For i = 1 To 15
PokeB(@plain+i, PeekB(@plain+i-1)+$11)
Next i
key.s = Space(32)
For i = 0 To 31
PokeB(@key+i,i)
Next i
AES256Encrypt(@plain,@key) ; notice: plain/cipher is at same place
Debug "#####ciphertext#####"
For i = 0 To 15
Debug bytetohex(PeekB(@plain+i))
Next i
AES256Decrypt(@plain,@key) ; notice: plain/cipher is at same place
Debug "#####plaintext#####"
For i = 0 To 15
Debug bytetohex(PeekB(@plain+i))
Next i
;other functions included
;AES128/192Encrypt()
;AES128/192Decrypt()Hope you like.
Last edited by sec on Wed Aug 11, 2004 4:18 pm, edited 2 times in total.
8O
Sec should be the offcicial PB encryption algorithm manager !
Your FIPS test works fine, no trouble, but from a user point of view, I am trying this :
I probably didn't understand what is AES, I thought it was encrypting by 128bits blocs, but I should do something wrong because the above example crash.
(if I just crypt/decrypt one time, the first 16 bytes of the text is correctly encrypted/decrypted).
If you can show how to use your AES lib as shown above, I think Shannara and me (no link lol) will be extremely happy
EDIT : the link to the PDF document is broken, it returns something like "the pdf document is corrupted".
official link : http://csrc.nist.gov/publications/fips/ ... ps-197.pdf
Sec should be the offcicial PB encryption algorithm manager !
Your FIPS test works fine, no trouble, but from a user point of view, I am trying this :
Code: Select all
plain.s = "I am a fan of SEC now :-)"
key.s = MD5Fingerprint("toto", 4)
Debug "clear = " + plain
Debug "len(clear) = " + Str(Len(plain))
Debug "key = " + key
;-encryption
For a = 0 To Len(plain) Step 16
AES256Encrypt(@plain + a, @key)
Next a
Debug "encrypted = " + plain
;- decryption
For a = 0 To Len(plain) Step 16
AES256Decrypt(@plain + a, @key)
Next a
Debug "clear = " + plain
(if I just crypt/decrypt one time, the first 16 bytes of the text is correctly encrypted/decrypted).
If you can show how to use your AES lib as shown above, I think Shannara and me (no link lol) will be extremely happy
EDIT : the link to the PDF document is broken, it returns something like "the pdf document is corrupted".
official link : http://csrc.nist.gov/publications/fips/ ... ps-197.pdf
Last edited by newbie on Wed Aug 11, 2004 5:45 pm, edited 1 time in total.
- Registered PB user -
Using PB 4.00
Using PB 4.00
-
sec
- Enthusiast

- Posts: 792
- Joined: Sat Aug 09, 2003 3:13 am
- Location: 90-61-92 // EU or ASIA
- Contact:
Code: Select all
FunctionName || Key Length || BlockSize
AES128* 128 bit 128 bit
AES192* 192 bit 128 bit
AES256* 256 bit 128 bit
-----
128 bit = 16 byte
192 bit = 24 byte
256 bit = 32 byteCode: Select all
plain.s = "I am a fan of SEC now :-) lololo"
key.s = MD5Fingerprint("toto", 4)
Debug "clear = " + plain
Debug "len(clear) = " + Str(Len(plain))
Debug "key = " + key
;-encryption
oldlen = Len(plain)
For a = 0 To oldlen Step 16
AES256Encrypt(@plain + a, @key)
Next a
Debug "encrypted = " + plain
;- decryption
For a = 0 To oldlen Step 16
AES256Decrypt(@plain + a, @key)
Next a
Debug "clear = " + plain
ok Sec, I have managed to code a complete example to use your lib, which works without any errors :
edited : this code is not good, see the posts on page 5
These two functions can be easily combined with your libs, it's more convenient. If you have any correction to do, feel free to do it of course, I whish to learn 
Even if this code works perfectly, I do not understand something.
From the FIPS PDF document about AES, the output cypher text size depends on the size of the plain text size, as follow :
0 <= Len(plain_text) <= 16 -> output size of 128 bits
( '<=' means less or equal)
So obviously, a 32 bytes string will have a 256 bits output.
But so, shouldn't a 33 bytes string have a 256 + 128 = 348 bits output ??
In the code, the plain text example is 35 bytes (280 bits), So if you take
the first 32 bytes, you need 256 bits of buffer + another 128 bits buffer for the remaining 3 bytes.
However in the code above, I only give 35 bytes of buffer (instead of 48 which crash ?!) and it works just fine.
I need to know if the code above is right and reliable (you know you can do a perfect lib, if it's not used right, especially for encryption, it will give BS and won't have the security level expected), and to understand what is
the problem with my understanding of the buffer encoding size.
Anyway, that's a _very_ great job from Sec, and I hope to know soon if Shannara has found what she was looking at for some time now
edited : this code is not good, see the posts on page 5
Code: Select all
Procedure AESEncrypt(*Buffer, *Key)
For a = 0 To Len(PeekS(*Buffer)) Step 16
AES256Encrypt(*Buffer + a, *Key)
Next a
ProcedureReturn *Buffer
EndProcedure
Procedure AESDecrypt(*Buffer, *Key)
For a = 0 To Len(PeekS(*Buffer)) Step 16
AES256Decrypt(*Buffer + a, *Key)
Next a
ProcedureReturn *Buffer
EndProcedure
plain.s = "I am a fan of SEC now :-) lololoLOL" ; our plain text
key.s = MD5Fingerprint("toto", 4) ; creating an AES key of 256 bits
Debug "clear = " + plain
Debug "len(clear) = " + Str(Len(plain))
Debug "key = " + key
length_required.l = Len(plain) ; length required for the buffer
Debug "length_required = " + Str(length_required)
*cypher_text = AllocateMemory(length_required) ; creating the buffer to the right input/output size
PokeS(*cypher_text, plain, length_required) ; copying our plain text into the buffer
Debug "LEN *cypher_text = " + Str(Len(PeekS(*cypher_text)))
;-encryption
*cypher_text = AESEncrypt(*cypher_text, @key) ; encrypting our plain text
Debug "encrypted = " + PeekS(*cypher_text, length_required)
Debug "LEN encrypted = " + Str(Len(PeekS(*cypher_text, length_required)))
;- decryption
;let's assume that this is a break in the code, like for instance an encrypted file that we did not encrypt
;or any encrypted data for which we do not know the size of the plain text
;*cypher_text would be @plain_text$ for instance
*plain_text = AESDecrypt(*cypher_text, @key) ; decrypting the cypher text
Debug "clear = " + PeekS(*plain_text);, length_required)
Debug "LEN clear = " + Str(Len(PeekS(*plain_text)))
Even if this code works perfectly, I do not understand something.
From the FIPS PDF document about AES, the output cypher text size depends on the size of the plain text size, as follow :
0 <= Len(plain_text) <= 16 -> output size of 128 bits
( '<=' means less or equal)
So obviously, a 32 bytes string will have a 256 bits output.
But so, shouldn't a 33 bytes string have a 256 + 128 = 348 bits output ??
In the code, the plain text example is 35 bytes (280 bits), So if you take
the first 32 bytes, you need 256 bits of buffer + another 128 bits buffer for the remaining 3 bytes.
However in the code above, I only give 35 bytes of buffer (instead of 48 which crash ?!) and it works just fine.
I need to know if the code above is right and reliable (you know you can do a perfect lib, if it's not used right, especially for encryption, it will give BS and won't have the security level expected), and to understand what is
the problem with my understanding of the buffer encoding size.
Anyway, that's a _very_ great job from Sec, and I hope to know soon if Shannara has found what she was looking at for some time now
Last edited by newbie on Thu Aug 12, 2004 9:56 pm, edited 1 time in total.
- Registered PB user -
Using PB 4.00
Using PB 4.00
"He", as mentioned in my title and my previous posts/threads concerning my wife 
Anyways, this isn't. Turns out the code I need translated from VB to PB is a AES hybrid that was found and used on PSCode.com/vb.
As mentioned in a different thread, that is what I use on the server and needed the equivilent for the PB client. However... if there was an encryption that is available via code (or regular lib, not dll) for both pb and vb, I would use that... 
Anyways, this isn't. Turns out the code I need translated from VB to PB is a AES hybrid that was found and used on PSCode.com/vb.
Sorry Shannara, your name sounds a lot more female than male in my native language
In addition your picture is a woman, so don't complain of being seen as a woman and not a man, Mr Shannara
Apart of that, you have at least a full working code for PB
Personally I am still trying to understand my own code for now lol
In addition your picture is a woman, so don't complain of being seen as a woman and not a man, Mr Shannara
Apart of that, you have at least a full working code for PB
Personally I am still trying to understand my own code for now lol
- Registered PB user -
Using PB 4.00
Using PB 4.00
