Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Salsa20 test vectors

Reply
Thread Tools

Re: Salsa20 test vectors

 
 
Noob
Guest
Posts: n/a
 
      08-06-2012
[ 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
 
 
 
 
Mark Bluemel
Guest
Posts: n/a
 
      08-06-2012
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
 
 
 
 
Paul Rubin
Guest
Posts: n/a
 
      08-06-2012
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
 
Cristiano
Guest
Posts: n/a
 
      08-06-2012
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
 
Keith Thompson
Guest
Posts: n/a
 
      08-06-2012
Cristiano <(E-Mail Removed)> 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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
 
Paul Rubin
Guest
Posts: n/a
 
      08-06-2012
Cristiano <(E-Mail Removed)> writes:
> Thank you, but the problem is solved.


Oh good, I see it now. Thanks for the update.
 
Reply With Quote
 
Barry Schwarz
Guest
Posts: n/a
 
      08-07-2012
On Tue, 7 Aug 2012 10:22:30 +0200, "io_x" <(E-Mail Removed)> wrote:

>
>"Noob" <root@127.0.0.1> ha scritto nel messaggio
>news:jvo0bp$tbo$(E-Mail Removed)...
>>[ 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
 
Nick Keighley
Guest
Posts: n/a
 
      08-08-2012
On Aug 7, 9:22*am, "io_x" <(E-Mail Removed)> wrote:
> "Noob" <r...@127.0.0.1> ha scritto nel messaggionews:jvo0bp$tbo$(E-Mail Removed)...
> > 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
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ primer statement about vectors containing vectors pauldepstein@att.net C++ 3 03-26-2008 06:22 PM
Pure Python Salsa20 Stream Cipher Implementation betabrain.honshu@gmail.com Python 14 02-11-2008 10:05 PM
Ruby, SWIG and C++: how to properly wrap vector of vectors of doubles (2D vectors)? Ruby 0 09-14-2005 05:47 PM
millions combinations of test vectors for ALU Lily VHDL 16 05-10-2004 07:22 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments