|
|||
|
[ 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. |
|
|
||||
|
||||
|
|
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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" |
|
|||
|
"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... |
|
|||
|
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 |
|
|||
|
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> |
|
|||
|
"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 |
|
|||
|
"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 |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|