Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.c

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-06-2012, 08:48 AM
Noob
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

[ Adding comp.lang.c so they can correct me ]

Paul Rubin wrote:

> Cristiano wrote:
>
>> static const char sigma[16] = "expand 32-byte k";
>> static const char tau[16] = "expand 16-byte k";

>
> This makes a 32-byte block in memory whose contents are
> |expand 32-byte kexpand 16-byte k|
> where the vertical bars delimit block.


This is incorrect. The compiler has no obligation to store
sigma and tau contiguously.

In other words, assert(tau == sigma + sizeof sigma) may fail.

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 08-06-2012, 08:54 AM
Mark Bluemel
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

On 06/08/2012 09:48, Noob wrote:
> [ Adding comp.lang.c so they can correct me ]
>
> Paul Rubin wrote:
>
>> Cristiano wrote:
>>
>>> static const char sigma[16] = "expand 32-byte k";
>>> static const char tau[16] = "expand 16-byte k";

>>
>> This makes a 32-byte block in memory whose contents are
>> |expand 32-byte kexpand 16-byte k|
>> where the vertical bars delimit block.

>
> This is incorrect. The compiler has no obligation to store
> sigma and tau contiguously.
>
> In other words, assert(tau == sigma + sizeof sigma) may fail.


Indeed.
Reply With Quote
  #3 (permalink)  
Old 08-06-2012, 08:27 PM
Paul Rubin
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

Noob <root@127.0.0.1> writes:
>> This makes a 32-byte block in memory whose contents are
>> |expand 32-byte kexpand 16-byte k|
>> where the vertical bars delimit block.

> This is incorrect. The compiler has no obligation to store
> sigma and tau contiguously.


You are right, and of course DJB would not have made such a silly error.
It looks like I read the keysetup function incorrectly for some reason.
It actually chooses between sigma and tau based on the key size, and
doesn't use both or rely on them being contiguous.

So I guess we still don't know why Cristiano's tests are getting wrong
results. I may spend a little time investigating further later, but
have other things going on right now.
Reply With Quote
  #4 (permalink)  
Old 08-06-2012, 09:40 PM
Cristiano
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

On 06/08/2012 22:27, Paul Rubin wrote:
> So I guess we still don't know why Cristiano's tests are getting wrong
> results.


But I posted 10 hours ago... I said: "To get the right result I need to
do a single call to ECRYPT_encrypt_bytes() with a 512-byte plaintext."

> I may spend a little time investigating further later, but
> have other things going on right now.


Thank you, but the problem is solved. :-)

Cristiano
Reply With Quote
  #5 (permalink)  
Old 08-06-2012, 10:00 PM
Keith Thompson
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

Cristiano <cristiapi@NSgmail.com> writes:
> On 06/08/2012 22:27, Paul Rubin wrote:
>> So I guess we still don't know why Cristiano's tests are getting wrong
>> results.

>
> But I posted 10 hours ago... I said: "To get the right result I need to
> do a single call to ECRYPT_encrypt_bytes() with a 512-byte plaintext."


You only posted that to sci.crypt.

Your original article was posted only to sci.crypt. "Noob"
cross-posted a followup to sci.crypt and comp.lang.c, which resulted
in comp.lang.c readers seeing only part of the thread (and probably
not being aware of it).

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Reply With Quote
  #6 (permalink)  
Old 08-06-2012, 10:39 PM
Paul Rubin
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

Cristiano <cristiapi@NSgmail.com> writes:
> Thank you, but the problem is solved. :-)


Oh good, I see it now. Thanks for the update.
Reply With Quote
  #7 (permalink)  
Old 08-07-2012, 08:22 AM
io_x
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors


"Noob" <root@127.0.0.1> ha scritto nel messaggio
news:jvo0bp$tbo$1@dont-email.me...
>[ Adding comp.lang.c so they can correct me ]
>
> Paul Rubin wrote:
>
>> Cristiano wrote:
>>
>>> static const char sigma[16] = "expand 32-byte k";
>>> static const char tau[16] = "expand 16-byte k";


because the string is 16 char + \0 it has to be >=17

it has to be
static const char sigma[17] = "expand 32-byte k";

or if that number scare you
static const char sigma[18] = "expand 32-byte k";


>> This makes a 32-byte block in memory whose contents are
>> |expand 32-byte kexpand 16-byte k|
>> where the vertical bars delimit block.

>
> This is incorrect. The compiler has no obligation to store
> sigma and tau contiguously.
>
> In other words, assert(tau == sigma + sizeof sigma) may fail.


if you make wrong 1 char the size of the string
the compiler can do what it want better...




Reply With Quote
  #8 (permalink)  
Old 08-07-2012, 10:33 PM
Barry Schwarz
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

On Tue, 7 Aug 2012 10:22:30 +0200, "io_x" <a@b.c.invalid> wrote:

>
>"Noob" <root@127.0.0.1> ha scritto nel messaggio
>news:jvo0bp$tbo$1@dont-email.me...
>>[ Adding comp.lang.c so they can correct me ]
>>
>> Paul Rubin wrote:
>>
>>> Cristiano wrote:
>>>
>>>> static const char sigma[16] = "expand 32-byte k";
>>>> static const char tau[16] = "expand 16-byte k";

>
>because the string is 16 char + \0 it has to be >=17


The two definitions above define character arrays that do not contain
strings. Unless they need to be strings, there is nothing wrong with
the definitions. They only need to have 17 elements if they are
indeed strings.

--
Remove del for email
Reply With Quote
  #9 (permalink)  
Old 08-08-2012, 07:53 AM
Nick Keighley
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors

On Aug 7, 9:22*am, "io_x" <a...@b.c.invalid> wrote:
> "Noob" <r...@127.0.0.1> ha scritto nel messaggionews:jvo0bp$tbo$1@dont-email.me...
> > Paul Rubin wrote:
> >> Cristiano wrote:



> >>> * *static const char sigma[16] = "expand 32-byte k";
> >>> * *static const char tau[16] = "expand 16-byte k";

>
> because the string is 16 char + \0 it has to be >=17
>
> it has to be
> static const char sigma[17] = "expand 32-byte k";


no. The compiler simply omits the '\0' if the array size is
the same as the number of characters. As Barry remarks it isn't
a string tho'

[C++ behaves differently]

> or if that number scare you
> static const char sigma[18] = "expand 32-byte k";


? why would 17 scare me? Do you have a phobia about prime numbers?

<snip>
Reply With Quote
  #10 (permalink)  
Old 08-09-2012, 06:30 AM
io_x
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors


"Barry Schwarz" <schwarzb@dqel.com> ha scritto nel messaggio
news:jl3328pq6a6f3o24usboh95lg66evugc5j@4ax.com...
> On Tue, 7 Aug 2012 10:22:30 +0200, "io_x" <a@b.c.invalid> wrote:
>
>>
>>"Noob" <root@127.0.0.1> ha scritto nel messaggio
>>news:jvo0bp$tbo$1@dont-email.me...
>>>[ Adding comp.lang.c so they can correct me ]
>>>
>>> Paul Rubin wrote:
>>>
>>>> Cristiano wrote:
>>>>
>>>>> static const char sigma[16] = "expand 32-byte k";
>>>>> static const char tau[16] = "expand 16-byte k";

>>
>>because the string is 16 char + \0 it has to be >=17

>
> The two definitions above define character arrays that do not contain
> strings. Unless they need to be strings, there is nothing wrong with
> the definitions. They only need to have 17 elements if they are
> indeed strings.


thank you



Reply With Quote
  #11 (permalink)  
Old 08-09-2012, 06:30 AM
io_x
Guest
 
Posts: n/a
Default Re: Salsa20 test vectors


"Nick Keighley" <nick_keighley_nospam@hotmail.com> ha scritto nel messaggio
news:eb1539c1-32a0-44af-b59b-56c6ff925932@n13g2000vby.googlegroups.com...
On Aug 7, 9:22 am, "io_x" <a...@b.c.invalid> wrote:
> "Noob" <r...@127.0.0.1> ha scritto nel
> messaggionews:jvo0bp$tbo$1@dont-email.me...
> > Paul Rubin wrote:
> >> Cristiano wrote:


> >>> static const char sigma[16] = "expand 32-byte k";
> >>> static const char tau[16] = "expand 16-byte k";

>
> because the string is 16 char + \0 it has to be >=17
>
> it has to be
> static const char sigma[17] = "expand 32-byte k";


no. The compiler simply omits the '\0' if the array size is
the same as the number of characters. As Barry remarks it isn't
a string tho'

[C++ behaves differently]

> or if that number scare you
> static const char sigma[18] = "expand 32-byte k";


? why would 17 scare me? Do you have a phobia about prime numbers?

#no i have a 'phobia' about 17 only
#thank you



Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 06:52 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.