Commit ae194f69 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

bcrypt: Pass output length as a separate parameter to key_asymmetric_decrypt.

parent 3deb9615
......@@ -206,7 +206,7 @@ struct key_funcs
void (CDECL *key_symmetric_destroy)( struct key * );
NTSTATUS (CDECL *key_asymmetric_init)( struct key * );
NTSTATUS (CDECL *key_asymmetric_generate)( struct key * );
NTSTATUS (CDECL *key_asymmetric_decrypt)( struct key *, UCHAR *, ULONG, UCHAR *, ULONG * );
NTSTATUS (CDECL *key_asymmetric_decrypt)( struct key *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG * );
NTSTATUS (CDECL *key_asymmetric_duplicate)( struct key *, struct key * );
NTSTATUS (CDECL *key_asymmetric_sign)( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG *, ULONG );
NTSTATUS (CDECL *key_asymmetric_verify)( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, DWORD );
......
......@@ -1715,21 +1715,12 @@ NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG inp
return key_encrypt( key, input, input_len, padding, iv, iv_len, output, output_len, ret_len, flags );
}
static NTSTATUS key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len, UCHAR *output,
ULONG output_len, ULONG *ret_len )
{
NTSTATUS status;
if (!(status = key_funcs->key_asymmetric_decrypt( key, input, input_len, output, &output_len )))
*ret_len = output_len;
return status;
}
static NTSTATUS key_decrypt( struct key *key, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv,
ULONG iv_len, UCHAR *output, ULONG output_len, ULONG *ret_len, ULONG flags )
{
if (key_is_symmetric( key ))
return key_symmetric_decrypt( key, input, input_len, padding, iv, iv_len, output, output_len, ret_len, flags );
return key_asymmetric_decrypt( key, input, input_len, output, output_len, ret_len );
return key_funcs->key_asymmetric_decrypt( key, input, input_len, output, output_len, ret_len );
}
NTSTATUS WINAPI BCryptDecrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv,
......
......@@ -1846,32 +1846,26 @@ static NTSTATUS CDECL key_asymmetric_duplicate( struct key *key_orig, struct key
return STATUS_SUCCESS;
}
static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len,
UCHAR *output, ULONG *output_len )
static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len, UCHAR *output,
ULONG output_len, ULONG *ret_len )
{
gnutls_datum_t e, d = { 0 };
NTSTATUS status = STATUS_SUCCESS;
int ret;
e.data = (unsigned char *)input;
e.data = input;
e.size = input_len;
if ((ret = pgnutls_privkey_decrypt_data( key_data(key)->privkey, 0, &e, &d )))
{
pgnutls_perror( ret );
return STATUS_INTERNAL_ERROR;
}
if (*output_len >= d.size)
{
*output_len = d.size;
memcpy( output, d.data, *output_len );
}
else
status = STATUS_BUFFER_TOO_SMALL;
*ret_len = d.size;
if (output_len >= d.size) memcpy( output, d.data, *ret_len );
else status = STATUS_BUFFER_TOO_SMALL;
free( d.data );
return status;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment