[botan-devel] Binary encoding of GOST private value

Rickard Bellgrim rickard at opendnssec.org
Sun Aug 17 04:48:08 EDT 2014

On Sat, Aug 16, 2014 at 4:15 PM, Jack Lloyd <lloyd at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20140817/8c146088/attachment.html>

More information about the botan-devel mailing list