Re: [opensc-devel] [opensc-commits] svn opensc changed[4930] add to r4904: fix calculating of signature size for CKK_GOSTR3410

2010-12-09 Thread Martin Paljak
Hello,
On Dec 9, 2010, at 9:23 AM, webmas...@opensc-project.org wrote:

 Revision: 4930
 Author:   s
 Date: 2010-12-09 07:23:10 + (Thu, 09 Dec 2010)
 
 Log Message:
 ---
 add to r4904: fix calculating of signature size for CKK_GOSTR3410
 
 - *pLength *= 2;
 + *pLength = (*pLength + 7) / 8 * 2;

Could you also add a comment? Why not (*pLength + 7) /  4?

-- 
@MartinPaljak.net
+3725156495

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] [opensc-commits] svn opensc changed[4930] add to r4904: fix calculating of signature size for CKK_GOSTR3410

2010-12-09 Thread Kalev Lember
On 12/09/2010 11:40 AM, Martin Paljak wrote:
 Hello,
 On Dec 9, 2010, at 9:23 AM, webmas...@opensc-project.org wrote:

 Revision: 4930
 Author:   s
 Date: 2010-12-09 07:23:10 + (Thu, 09 Dec 2010)

 Log Message:
 ---
 add to r4904: fix calculating of signature size for CKK_GOSTR3410

 -*pLength *= 2;
 +*pLength = (*pLength + 7) / 8 * 2;

 Could you also add a comment? Why not (*pLength + 7) /  4?

Replying instead of the commit's author.

(length + 7) / 8 is a common way to calculate stride width so that the
result is aligned to 8. It might be a good idea to give a meaningful
name to 2, but please don't simplify the calculation by replacing / 8 *
2 with 4 as it would make it harder to understand.

Regards,
Kalev
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] [opensc-commits] svn opensc changed[4930] add to r4904: fix calculating of signature size for CKK_GOSTR3410

2010-12-09 Thread Aleksey Samsonov
Hello,

2010/12/9 Martin Paljak mar...@paljak.pri.ee:
 Hello,
 On Dec 9, 2010, at 9:23 AM, webmas...@opensc-project.org wrote:

 Revision: 4930
 Author:   s
 Date:     2010-12-09 07:23:10 + (Thu, 09 Dec 2010)

 Log Message:
 ---
 add to r4904: fix calculating of signature size for CKK_GOSTR3410

 -                                     *pLength *= 2;
 +                                     *pLength = (*pLength + 7) / 8 * 2;

 Could you also add a comment? Why not (*pLength + 7) /  4?

Yes of course. We need to convert a length in bits to bytes and
multiply by two. So if we divide by 4 then we have incorrect rounding
result (case (*pLength + 7) % 8 = 4).
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] [opensc-commits] svn opensc changed[4930] add to r4904: fix calculating of signature size for CKK_GOSTR3410

2010-12-09 Thread Andre Zepezauer
On Thu, 2010-12-09 at 14:31 +0300, Aleksey Samsonov wrote:
 Hello,
 
 2010/12/9 Martin Paljak mar...@paljak.pri.ee:
  Hello,
  On Dec 9, 2010, at 9:23 AM, webmas...@opensc-project.org wrote:
 
  Revision: 4930
  Author:   s
  Date: 2010-12-09 07:23:10 + (Thu, 09 Dec 2010)
 
  Log Message:
  ---
  add to r4904: fix calculating of signature size for CKK_GOSTR3410
 
  - *pLength *= 2;
  + *pLength = (*pLength + 7) / 8 * 2;
 
  Could you also add a comment? Why not (*pLength + 7) /  4?
 
 Yes of course. We need to convert a length in bits to bytes and
 multiply by two. So if we divide by 4 then we have incorrect rounding
 result (case (*pLength + 7) % 8 = 4).

Maybe it would be appropriate to define a macro for the conversion. The
Reason is, that there are a lot of places where the conversion is
computed as follows: byte_count = bit_count / 8. That is obviously wrong
in 7 of 8 cases. Also it would improve readability.

Regards
Andre

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] [opensc-commits] svn opensc changed[4930] add to r4904: fix calculating of signature size for CKK_GOSTR3410

2010-12-09 Thread Andre Zepezauer
On Thu, 2010-12-09 at 09:38 -0600, Douglas E. Engert wrote:
 
 On 12/9/2010 8:41 AM, Andre Zepezauer wrote:
  On Thu, 2010-12-09 at 14:31 +0300, Aleksey Samsonov wrote:
  Hello,
 
  2010/12/9 Martin Paljakmar...@paljak.pri.ee:
  Hello,
  On Dec 9, 2010, at 9:23 AM, webmas...@opensc-project.org wrote:
 
  Revision: 4930
  Author:   s
  Date: 2010-12-09 07:23:10 + (Thu, 09 Dec 2010)
 
  Log Message:
  ---
  add to r4904: fix calculating of signature size for CKK_GOSTR3410
 
  - *pLength *= 2;
  + *pLength = (*pLength + 7) / 8 * 2;
 
  Could you also add a comment? Why not (*pLength + 7) /  4?
 
  Yes of course. We need to convert a length in bits to bytes and
  multiply by two. So if we divide by 4 then we have incorrect rounding
  result (case (*pLength + 7) % 8= 4).
 
  Maybe it would be appropriate to define a macro for the conversion. The
  Reason is, that there are a lot of places where the conversion is
  computed as follows: byte_count = bit_count / 8. That is obviously wrong
  in 7 of 8 cases. Also it would improve readability.
 
 It may comes down to does an algorthim support non-multiple of 8 bits? And
 if it can, is it ever used with non multiple of 8 bits? I have never sees an
 RSA key that was not a multiple of 8, so it may not be an issue for most of
 OpenSC.
 
 If one is not a multiple of 8, how is it padded?

At least for RSA_PKCS1 the most significant octet is always zero. See
PKCS1 01- and 02-padding schema. Therefore the padded signature input is
always less than the modulus when compared numerical.

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel