bcrypt: Pad exported datums in export_gnutls_pubkey_dsa().
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c5c2b7da3e
commit
68171b1c3a
|
@ -795,7 +795,7 @@ static NTSTATUS export_gnutls_pubkey_dsa( gnutls_privkey_t gnutls_key, ULONG bit
|
||||||
{
|
{
|
||||||
BCRYPT_DSA_KEY_BLOB *dsa_blob;
|
BCRYPT_DSA_KEY_BLOB *dsa_blob;
|
||||||
gnutls_datum_t p, q, g, y;
|
gnutls_datum_t p, q, g, y;
|
||||||
UCHAR *dst, *src;
|
UCHAR *dst;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = pgnutls_privkey_export_dsa_raw( gnutls_key, &p, &q, &g, &y, NULL )))
|
if ((ret = pgnutls_privkey_export_dsa_raw( gnutls_key, &p, &q, &g, &y, NULL )))
|
||||||
|
@ -810,7 +810,7 @@ static NTSTATUS export_gnutls_pubkey_dsa( gnutls_privkey_t gnutls_key, ULONG bit
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dsa_blob = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*dsa_blob) + p.size + g.size + y.size )))
|
if (!(dsa_blob = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*dsa_blob) + bitlen / 8 * 3 )))
|
||||||
{
|
{
|
||||||
pgnutls_perror( ret );
|
pgnutls_perror( ret );
|
||||||
free( p.data ); free( q.data ); free( g.data ); free( y.data );
|
free( p.data ); free( q.data ); free( g.data ); free( y.data );
|
||||||
|
@ -818,40 +818,16 @@ static NTSTATUS export_gnutls_pubkey_dsa( gnutls_privkey_t gnutls_key, ULONG bit
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = (UCHAR *)(dsa_blob + 1);
|
dst = (UCHAR *)(dsa_blob + 1);
|
||||||
if (p.size == bitlen / 8 + 1 && !p.data[0])
|
export_gnutls_datum( dst, bitlen / 8, &p, NULL );
|
||||||
{
|
|
||||||
src = p.data + 1;
|
|
||||||
p.size--;
|
|
||||||
}
|
|
||||||
else src = p.data;
|
|
||||||
memcpy( dst, src, p.size );
|
|
||||||
|
|
||||||
dst += p.size;
|
dst += bitlen / 8;
|
||||||
if (g.size == bitlen / 8 + 1 && !g.data[0])
|
export_gnutls_datum( dst, bitlen / 8, &g, NULL );
|
||||||
{
|
|
||||||
src = g.data + 1;
|
|
||||||
g.size--;
|
|
||||||
}
|
|
||||||
else src = g.data;
|
|
||||||
memcpy( dst, src, g.size );
|
|
||||||
|
|
||||||
dst += g.size;
|
dst += bitlen / 8;
|
||||||
if (y.size == bitlen / 8 + 1 && !y.data[0])
|
export_gnutls_datum( dst, bitlen / 8, &y, NULL );
|
||||||
{
|
|
||||||
src = y.data + 1;
|
|
||||||
y.size--;
|
|
||||||
}
|
|
||||||
else src = y.data;
|
|
||||||
memcpy( dst, src, y.size );
|
|
||||||
|
|
||||||
dst = dsa_blob->q;
|
dst = dsa_blob->q;
|
||||||
if (q.size == sizeof(dsa_blob->q) + 1 && !q.data[0])
|
export_gnutls_datum( dst, sizeof(dsa_blob->q), &q, NULL );
|
||||||
{
|
|
||||||
src = q.data + 1;
|
|
||||||
q.size--;
|
|
||||||
}
|
|
||||||
else src = q.data;
|
|
||||||
memcpy( dst, src, sizeof(dsa_blob->q) );
|
|
||||||
|
|
||||||
dsa_blob->dwMagic = BCRYPT_DSA_PUBLIC_MAGIC;
|
dsa_blob->dwMagic = BCRYPT_DSA_PUBLIC_MAGIC;
|
||||||
dsa_blob->cbKey = bitlen / 8;
|
dsa_blob->cbKey = bitlen / 8;
|
||||||
|
@ -859,7 +835,7 @@ static NTSTATUS export_gnutls_pubkey_dsa( gnutls_privkey_t gnutls_key, ULONG bit
|
||||||
memset( dsa_blob->Seed, 0, sizeof(dsa_blob->Seed) ); /* FIXME */
|
memset( dsa_blob->Seed, 0, sizeof(dsa_blob->Seed) ); /* FIXME */
|
||||||
|
|
||||||
*pubkey = (UCHAR *)dsa_blob;
|
*pubkey = (UCHAR *)dsa_blob;
|
||||||
*pubkey_len = sizeof(*dsa_blob) + p.size + g.size + y.size;
|
*pubkey_len = sizeof(*dsa_blob) + dsa_blob->cbKey * 3;
|
||||||
|
|
||||||
free( p.data ); free( q.data ); free( g.data ); free( y.data );
|
free( p.data ); free( q.data ); free( g.data ); free( y.data );
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue