Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/bcrypt/bcrypt_internal.h | 2 +- dlls/bcrypt/bcrypt_main.c | 11 +---------- dlls/bcrypt/gnutls.c | 18 ++++++------------ 3 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h index eb136111509..fef1e4585ee 100644 --- a/dlls/bcrypt/bcrypt_internal.h +++ b/dlls/bcrypt/bcrypt_internal.h @@ -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 ); diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 6729edf671f..59835014530 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -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, diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c index 2f0c62bc6da..9c1e7b5ab06 100644 --- a/dlls/bcrypt/gnutls.c +++ b/dlls/bcrypt/gnutls.c @@ -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; }