Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: gcrypt

PSS code question

 

 

GnuPG gcrypt RSS feed   Index | Next | Previous | View Threaded


wk at gnupg

Jun 9, 2011, 12:23 AM

Post #1 of 9 (998 views)
Permalink
PSS code question

Hi,

I reworked the PSS code in the uene-pss branch and merged it with
master. I did this similar to my changes for OAEP to help reading and
comparing the code to the the specs.

I see one problem with it. According to rfc-3447 we are doing this

+-----------+
| M |
+-----------+
|
V
Hash
|
V
+--------+----------+----------+
M' = |Padding1| mHash | salt |
+--------+----------+----------+

[....]

Out input is the actual message; for example:

{ "(data\n (flags pss)\n"
" (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n",

However we don't consider #1122...# a hash value but the actual message
to be signed. If we really want to do this it would be better to use a
new construct than this "(hash ALGO DIGEST)" pattern. However I dount
that it is a good idea. We have always used gcry_pk_sign in the way
that the caller passed the hash of the message (here mHash) to it and
not the entire message. Many applications have large messages and it
should be possigble to stream them.

Having said this, I'd propose to change the semantics and require that
mHash is passed to gcry_pk_sign and gcry_pk_verify if PSS is used.
rfc-3447 actually allows this:

3. Without compromising the security proof for RSASSA-PSS, one may
perform steps 1 and 2 of EMSA-PSS-ENCODE and EMSA-PSS-VERIFY (the
application of the hash function to the message) outside the
module that computes the rest of the signature operation, so that
mHash rather than the message M itself is input to the module. In
[...]

Shall I do these changes?

I'd also like to see a way to test at least the verification of a PSS
message against a known test vector. Are there any real world
application of PSS or even test vectors?


Salam-Shalom,

Werner


--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


simon at josefsson

Jun 9, 2011, 12:50 AM

Post #2 of 9 (982 views)
Permalink
Re: PSS code question [In reply to]

Werner Koch <wk [at] gnupg> writes:

> I'd also like to see a way to test at least the verification of a PSS
> message against a known test vector. Are there any real world
> application of PSS or even test vectors?

Test vectors:
ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1d2-vec.zip

As for real world applications, I dunno.

/Simon

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


ueno at unixuser

Jun 9, 2011, 1:40 AM

Post #3 of 9 (979 views)
Permalink
Re: PSS code question [In reply to]

Werner Koch <wk [at] gnupg> writes:

> Having said this, I'd propose to change the semantics and require that
> mHash is passed to gcry_pk_sign and gcry_pk_verify if PSS is used.
> rfc-3447 actually allows this:
>
> 3. Without compromising the security proof for RSASSA-PSS, one may
> perform steps 1 and 2 of EMSA-PSS-ENCODE and EMSA-PSS-VERIFY (the
> application of the hash function to the message) outside the
> module that computes the rest of the signature operation, so that
> mHash rather than the message M itself is input to the module. In
> [...]
>
> Shall I do these changes?

Certainly - thanks for pointing out this.

> I'd also like to see a way to test at least the verification of a PSS
> message against a known test vector. Are there any real world
> application of PSS or even test vectors?

I used the test vectors Simon mentioned, manually comparing the step
results with pss-int.txt. Maybe good to have selftests using the test
vector, though I guess it is not that easy since both PSS and OAEP use
random bits during the computation.

Regards,
--
Daiki Ueno

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


simon at josefsson

Jun 9, 2011, 2:08 AM

Post #4 of 9 (979 views)
Permalink
Re: PSS code question [In reply to]

Daiki Ueno <ueno [at] unixuser> writes:

>> I'd also like to see a way to test at least the verification of a PSS
>> message against a known test vector. Are there any real world
>> application of PSS or even test vectors?
>
> I used the test vectors Simon mentioned, manually comparing the step
> results with pss-int.txt. Maybe good to have selftests using the test
> vector, though I guess it is not that easy since both PSS and OAEP use
> random bits during the computation.

Would it be possible to specify the random bits to use to gcry_pk_sign
in the sexp somehow? Is it a fixed size random buffer? It would be
useful for self testing.

/Simon

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


wk at gnupg

Jun 9, 2011, 2:20 AM

Post #5 of 9 (977 views)
Permalink
Re: PSS code question [In reply to]

On Thu, 9 Jun 2011 11:08, simon [at] josefsson said:

> Would it be possible to specify the random bits to use to gcry_pk_sign
> in the sexp somehow? Is it a fixed size random buffer? It would be

Yes. We did something similar for DSS, iirc.


Shalom-Salam,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


wk at gnupg

Jun 9, 2011, 6:01 AM

Post #6 of 9 (975 views)
Permalink
Re: PSS code question [In reply to]

Hi,

Is there a reason why you use (ctx->nbits - 1) when passing the size of
the key to the OAEP and PSS functions? The functions round them to full
bytes anyway but there at least in PSS some leading bits are cleared
depending on the number of bits (i.e. if not a multiple of 8).


Shalom-Salam,

Werner


--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


ueno at unixuser

Jun 9, 2011, 6:23 AM

Post #7 of 9 (976 views)
Permalink
Re: PSS code question [In reply to]

Werner Koch <wk [at] gnupg> writes:

> Is there a reason why you use (ctx->nbits - 1) when passing the size of
> the key to the OAEP and PSS functions? The functions round them to full
> bytes anyway but there at least in PSS some leading bits are cleared
> depending on the number of bits (i.e. if not a multiple of 8).

For PSS, that is defined in RFC3447 8.1.1:

EM = EMSA-PSS-ENCODE (M, modBits - 1).

Note that the octet length of EM will be one less than k if
modBits - 1 is divisible by 8 and equal to k otherwise.

IIUC, this is necessary to make sure EM is smaller than RSA modulus n.

Regards,
--
Daiki Ueno

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


wk at gnupg

Jun 9, 2011, 6:43 AM

Post #8 of 9 (975 views)
Permalink
Re: PSS code question [In reply to]

On Thu, 9 Jun 2011 15:23, ueno [at] unixuser said:

> For PSS, that is defined in RFC3447 8.1.1:

Oops, I missed that. I add a note.

I am currently hacking the test vectors.


Salam-Shalom,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


wk at gnupg

Jun 9, 2011, 9:59 AM

Post #9 of 9 (982 views)
Permalink
Re: PSS code question [In reply to]

On Thu, 9 Jun 2011 15:43, wk [at] gnupg said:

> I am currently hacking the test vectors.

OAEP test vectors done.

It was useful: A bug turned out. It is the usual thing with leading
zero bytes. This is due to our use of integers for conveying some of
the parameters. I need to see how they can be fixed.


Shalom-Salam,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel

GnuPG gcrypt RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.