[prev in list] [next in list] [prev in thread] [next in thread] 

List:       botan-devel
Subject:    Re: [botan-devel] Binary encoding of GOST private value
From:       Rickard Bellgrim <rickard () opendnssec ! org>
Date:       2014-08-17 8:48:08
Message-ID: CAKFiof=r63doLaOCd45KsJZ0NThvt9JbDxqzcoZtU_vfZf6vXQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sat, Aug 16, 2014 at 4:15 PM, Jack Lloyd <lloyd@randombit.net> wrote:

> On Sat, Aug 16, 2014 at 12:49:07PM +0200, Rickard Bellgrim wrote:
> > Is it possible that you get a buffer length shorter than 32 bytes when
> you
> > binary encode the BigInt value of the GOST private value because of the
> > little endian storage?
> >
> > The buffer is allocated based on x.bytes().
> >
> > If you always want a buffer with 32 bytes, should you pad it manually?
>
> BigInt::encode_1363 will encode to a vector and pad up to the desired
> size, then you can flip the bytes.
>
> The library just uses the ECDSA/ECDH format for GOST keys since there
> doesn't seem to be a standard encoding for GOST private keys (at least
> that I have seen). That just encodes x as an ASN.1 INTEGER type
> instead of the little-endian octet string bigint format that GOST
> uses, so would not be affected by an x that had low zero bytes.
>

Thank you, that explains the random error I have been getting in my code.
Did not think of the little-endian.

// Rickard

[Attachment #5 (text/html)]

<div dir="ltr">On Sat, Aug 16, 2014 at 4:15 PM, Jack Lloyd <span dir="ltr">&lt;<a \
href="mailto:lloyd@randombit.net" target="_blank">lloyd@randombit.net</a>&gt;</span> \
wrote:<br><div class="gmail_extra"><div class="gmail_quote"> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sat, Aug 16, 2014 at \
12:49:07PM +0200, Rickard Bellgrim wrote:<br> &gt; Is it possible that you get a \
buffer length shorter than 32 bytes when you<br> &gt; binary encode the BigInt value \
of the GOST private value because of the<br> &gt; little endian storage?<br>
&gt;<br>
&gt; The buffer is allocated based on x.bytes().<br>
&gt;<br>
&gt; If you always want a buffer with 32 bytes, should you pad it manually?<br>
<br>
</div></div>BigInt::encode_1363 will encode to a vector and pad up to the desired<br>
size, then you can flip the bytes.<br>
<br>
The library just uses the ECDSA/ECDH format for GOST keys since there<br>
doesn&#39;t seem to be a standard encoding for GOST private keys (at least<br>
that I have seen). That just encodes x as an ASN.1 INTEGER type<br>
instead of the little-endian octet string bigint format that GOST<br>
uses, so would not be affected by an x that had low zero \
bytes.<br></blockquote><div><br></div><div>Thank you, that explains the random error \
I have been getting in my code. Did not think of the little-endian.</div><div> \
<br></div><div>// Rickard  </div></div></div></div>



_______________________________________________
botan-devel mailing list
botan-devel@randombit.net
http://lists.randombit.net/mailman/listinfo/botan-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic