Experience with AES.PRG - xharbour
This is a discussion on Experience with AES.PRG - xharbour ; Hi,
I have problem using AES encrypting by Christophe Devine. The sample from the .prg is here
local hFile
local hFileCrypted
local hAes
local cBuffer
local nPasswordLen
// 16bytes for 128bits
// 24bytes for 192bits
// 32bytes for 256bits
nPasswordLen ...
-
Experience with AES.PRG
Hi,
I have problem using AES encrypting by Christophe Devine. The sample from the .prg is here
local hFile
local hFileCrypted
local hAes
local cBuffer
local nPasswordLen
// 16bytes for 128bits
// 24bytes for 192bits
// 32bytes for 256bits
nPasswordLen := 16
hAES := aes_new( PadR( "password here", nPasswordLen ) )
hFile := FOpen( "test.txt", FO_READ )
hFileCrypted := FCreate( "test.txt.aes", FC_NORMAL )
cBuffer := Space( 16 )
do while FRead( hFile, @cBuffer, 16 ) # 0
cBuffer := aes_encrypt( hAES, cBuffer )
FWrite( hFileCrypted, cBuffer )
enddo
FClose( hFile )
FClose( hFileCrypted )
aes_delete( hAES )
*=================================================================
My problem is, that the encoded file size is larger than the orginal. Decoding it I get
some unwanted bytes on the end of the file. Original size: 1098 Byte, encrypted size 1104
Byte, (69x16) decripted file 1104 Byte, 6 unwanted bytes on the end.
It seems it always writes 16 bytes to the encrypted file, even the last read returns < 16
bytes.
Any experiences with this function?
Gejza Horvath
-
Re: Experience with AES.PRG
"Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
news:5nrdecFjqb5cU1@mid.individual.net...
> Hi,
>
> I have problem using AES encrypting by Christophe Devine. The sample from
> the .prg is here
>
> cBuffer := Space( 16 )
> do while FRead( hFile, @cBuffer, 16 ) # 0
> cBuffer := aes_encrypt( hAES, cBuffer )
> FWrite( hFileCrypted, cBuffer )
> My problem is, that the encoded file size is larger than the orginal.
> Decoding it I get some unwanted bytes on the end of the file. Original
> size: 1098 Byte, encrypted size 1104 Byte, (69x16) decripted file 1104
> Byte, 6 unwanted bytes on the end.
>
> It seems it always writes 16 bytes to the encrypted file, even the last
> read returns < 16 bytes.
> Any experiences with this function?
Hi Gejza
There are essentially two broad categories of ciphers: block and stream. A
block cipher requires a fixed length group of bits while a stream cipher
works on single character at a time. I've not used aes_encrypt but what you
are describing is normal for block ciphers.
You are reading 16-bytes at a time so you are using it in the 128-bit mode.
It requires 16 bytes or it can't do the transformation. As you note, 1104 is
an exact multiple of 16 as required. If you were using it in the 192-bit
mode then you would require an exact multiple of 24-bytes. For a 1098-byte
file the calculation is ceil(1098 % 24) *24 or 1104. The program would pad
your file to 1104-bytes but if you used the 256-byte encryption it would be
1120 -- ceil(1098%32)*32.
-
Re: Experience with AES.PRG
"bill robertson" <marydick2007@comcast.net> wrote in message news:0o-
> You are reading 16-bytes at a time so you are using it in the 128-bit
> mode. It requires 16 bytes or it can't do the transformation. As you note,
> 1104 is an exact multiple of 16 as required. If you were using it in the
> 192-bit mode then you would require an exact multiple of 24-bytes. For a
> 1098-byte file the calculation is ceil(1098 % 24) *24 or 1104. The program
> would pad your file to 1104-bytes but if you used the 256-byte encryption
> it would be 1120 -- ceil(1098%32)*32.
Sorry, Sometimes my brain doesn't work! The correct formula is
nBytes:= ceiling( size / block size ) not the modulus operator (%)
ceiling( 1098/32) * 32 = 1120
-
Re: Experience with AES.PRG
Hi
I have an working AES function done in C that work properly
Regards
Luiz
-
Re: Experience with AES.PRG
can share the source ?
TIA
"luiz Rafael Culik Guimaraes" <luiz@xharbour.com.br> Ľ¶Ľg©ó¶lĄó·s»D:47193a7f$0$1346$834e42db@reader.greatnowhere.com...
> Hi
>
> I have an working AES function done in C that work properly
>
> Regards
> Luiz
>
>
-
Re: Experience with AES.PRG
On Oct 19, 7:55 pm, "Gejza Horvath" <_hsof...@nextra.sk> wrote:
> Hi,
>
> I have problem using AES encrypting by Christophe Devine. The sample from the .prg is here
>
>
> Gejza Horvath
Hello Gejza...anybody.
I have searched but not found this AES.PRG. Can anyone please provide
a download link?
Regards,
Ross McKenzie
ValuSoft
Melbourne Australia
-
Re: Experience with AES.PRG
Hi,
I found it somewhere in the web, here is the complete source with sample app :
http://www.hsoftkn.sk/sk/sources.aspx
Please test it, and confirm the reported behaviour or the solution, how to avoid it. The
news server doesn't support binary attachments.
Gejza Horvath
"ValuSoft" <valusoft@optusnet.com.au> píąe v diskusním příspěvku
news:1193023054.063911.171730@i38g2000prf.googlegroups.com...
> On Oct 19, 7:55 pm, "Gejza Horvath" <_hsof...@nextra.sk> wrote:
>> Hi,
>>
>> I have problem using AES encrypting by Christophe Devine. The sample from the .prg is
>> here
>>
>
>>
>> Gejza Horvath
>
> Hello Gejza...anybody.
>
> I have searched but not found this AES.PRG. Can anyone please provide
> a download link?
>
> Regards,
>
> Ross McKenzie
> ValuSoft
> Melbourne Australia
>
>
-
Re: Experience with AES.PRG
Thanks Luiz, I already have the source...
Gejza
"luiz Rafael Culik Guimaraes" <luiz@xharbour.com.br> píąe v diskusním příspěvku
news:471c8d56$0$1344$834e42db@reader.greatnowhere.com...
> Hi
>
> I have AES functions for xharbour code in C, if you want i can send
>
> Regards
> Luiz
> "Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
> news:5o3ev0Fkt2svU2@mid.individual.net...
>> Hi,
>>
>> I found it somewhere in the web, here is the complete source with sample app :
>> http://www.hsoftkn.sk/sk/sources.aspx
>>
>> Please test it, and confirm the reported behaviour or the solution, how to avoid it.
>> The news server doesn't support binary attachments.
>>
>> Gejza Horvath
>>
>>
>>
>> "ValuSoft" <valusoft@optusnet.com.au> píąe v diskusním příspěvku
>> news:1193023054.063911.171730@i38g2000prf.googlegroups.com...
>>> On Oct 19, 7:55 pm, "Gejza Horvath" <_hsof...@nextra.sk> wrote:
>>>> Hi,
>>>>
>>>> I have problem using AES encrypting by Christophe Devine. The sample from the .prg is
>>>> here
>>>>
>>>
>>>>
>>>> Gejza Horvath
>>>
>>> Hello Gejza...anybody.
>>>
>>> I have searched but not found this AES.PRG. Can anyone please provide
>>> a download link?
>>>
>>> Regards,
>>>
>>> Ross McKenzie
>>> ValuSoft
>>> Melbourne Australia
>>>
>>>
>>
>>
>>
>
>
-
Re: Experience with AES.PRG
Hi
I have AES functions for xharbour code in C, if you want i can send
Regards
Luiz
"Gejza Horvath" <_hsoftkn@nextra.sk> wrote in message
news:5o3ev0Fkt2svU2@mid.individual.net...
> Hi,
>
> I found it somewhere in the web, here is the complete source with sample
> app : http://www.hsoftkn.sk/sk/sources.aspx
>
> Please test it, and confirm the reported behaviour or the solution, how to
> avoid it. The news server doesn't support binary attachments.
>
> Gejza Horvath
>
>
>
> "ValuSoft" <valusoft@optusnet.com.au> píąe v diskusním příspěvku
> news:1193023054.063911.171730@i38g2000prf.googlegroups.com...
>> On Oct 19, 7:55 pm, "Gejza Horvath" <_hsof...@nextra.sk> wrote:
>>> Hi,
>>>
>>> I have problem using AES encrypting by Christophe Devine. The sample
>>> from the .prg is
>>> here
>>>
>>
>>>
>>> Gejza Horvath
>>
>> Hello Gejza...anybody.
>>
>> I have searched but not found this AES.PRG. Can anyone please provide
>> a download link?
>>
>> Regards,
>>
>> Ross McKenzie
>> ValuSoft
>> Melbourne Australia
>>
>>
>
>
>
-
Re: Experience with AES.PRG
On Oct 22, 10:48 pm, "luiz Rafael Culik Guimaraes"
<l...@xharbour.com.br> wrote:
> Hi
>
> I have AES functions for xharbour code in C, if you want i can send
>
> Regards
> Luiz"Gejza Horvath" <_hsof...@nextra.sk> wrote in message
>
> news:5o3ev0Fkt2svU2@mid.individual.net...
>
> > Hi,
>
> > I found it somewhere in the web, here is the complete source with sample
> > app :http://www.hsoftkn.sk/sk/sources.aspx
>
> > Please test it, and confirm the reported behaviour or the solution, howto
> > avoid it. The news server doesn't support binary attachments.
>
> > Gejza Horvath
>
> > "ValuSoft" <valus...@optusnet.com.au> píąe v diskusním příspěvku
> >news:1193023054.063911.171730@i38g2000prf.googlegroups.com...
> >> On Oct 19, 7:55 pm, "Gejza Horvath" <_hsof...@nextra.sk> wrote:
> >>> Hi,
>
> >>> I have problem using AES encrypting by Christophe Devine. The sample
> >>> from the .prg is
> >>> here
>
> >>> Gejza Horvath
>
> >> Hello Gejza...anybody.
>
> >> I have searched but not found this AES.PRG. Can anyone please provide
> >> a download link?
>
> >> Regards,
>
> >> Ross McKenzie
> >> ValuSoft
> >> Melbourne Australia
Thank you Luiz.
Yes, I would like to receive the code.
email to valusoft AT optusnet DOT com DOT au
Regards,
Ross
Similar Threads
-
By Application Development in forum RUBY
Replies: 5
Last Post: 09-26-2007, 11:09 AM
-
By Application Development in forum Compilers
Replies: 2
Last Post: 05-14-2007, 02:37 PM
-
By Application Development in forum Java
Replies: 0
Last Post: 09-09-2005, 03:45 AM
-
By Application Development in forum DOTNET
Replies: 8
Last Post: 07-27-2005, 03:29 PM
-
By Application Development in forum Hardware
Replies: 1
Last Post: 07-15-2004, 10:31 AM