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

bcrypt: Merge the various key export Unix calls into one.

parent 9176251a
......@@ -268,13 +268,15 @@ struct key_asymmetric_verify_params
unsigned flags;
};
struct key_export_params
#define KEY_EXPORT_FLAG_PUBLIC 0x00000001
#define KEY_EXPORT_FLAG_RSA_FULL 0x00000002
struct key_asymmetric_export_params
{
struct key *key;
ULONG flags;
UCHAR *buf;
ULONG len;
ULONG *ret_len;
BOOL full;
};
struct key_import_params
......@@ -300,9 +302,7 @@ enum key_funcs
unix_key_asymmetric_sign,
unix_key_asymmetric_verify,
unix_key_asymmetric_destroy,
unix_key_export_dsa_capi,
unix_key_export_ecc,
unix_key_export_rsa,
unix_key_asymmetric_export,
unix_key_import_dsa_capi,
unix_key_import_ecc,
unix_key_import_rsa,
......
......@@ -1070,7 +1070,7 @@ static NTSTATUS key_import( BCRYPT_ALG_HANDLE algorithm, const WCHAR *type, BCRY
static NTSTATUS key_export( struct key *key, const WCHAR *type, UCHAR *output, ULONG output_len, ULONG *size )
{
struct key_export_params params;
struct key_asymmetric_export_params params;
if (!wcscmp( type, BCRYPT_KEY_DATA_BLOB ))
{
......@@ -1101,38 +1101,34 @@ static NTSTATUS key_export( struct key *key, const WCHAR *type, UCHAR *output, U
}
return STATUS_SUCCESS;
}
else if (!wcscmp( type, BCRYPT_RSAPUBLIC_BLOB ) || !wcscmp( type, BCRYPT_DSA_PUBLIC_BLOB ) ||
!wcscmp( type, BCRYPT_ECCPUBLIC_BLOB ) || !wcscmp( type, LEGACY_DSA_V2_PUBLIC_BLOB ))
else if (!wcscmp( type, BCRYPT_DSA_PRIVATE_BLOB ) || !wcscmp( type, LEGACY_DSA_V2_PRIVATE_BLOB ) ||
!wcscmp( type, BCRYPT_ECCPRIVATE_BLOB ))
{
*size = key->u.a.pubkey_len;
if (output_len < key->u.a.pubkey_len) return STATUS_SUCCESS;
if (output) memcpy( output, key->u.a.pubkey, key->u.a.pubkey_len );
return STATUS_SUCCESS;
}
else if (!wcscmp( type, BCRYPT_RSAPRIVATE_BLOB ) || !wcscmp( type, BCRYPT_RSAFULLPRIVATE_BLOB ))
{
params.key = key;
params.buf = output;
params.len = output_len;
params.key = key;
params.flags = 0;
params.buf = output;
params.len = output_len;
params.ret_len = size;
params.full = wcscmp( type, BCRYPT_RSAPRIVATE_BLOB );
return UNIX_CALL( key_export_rsa, &params );
return UNIX_CALL( key_asymmetric_export, &params );
}
else if (!wcscmp( type, BCRYPT_ECCPRIVATE_BLOB ))
else if (!wcscmp( type, BCRYPT_RSAPRIVATE_BLOB ) || !wcscmp( type, BCRYPT_RSAFULLPRIVATE_BLOB ))
{
params.key = key;
params.buf = output;
params.len = output_len;
params.key = key;
params.flags = (wcscmp( type, BCRYPT_RSAPRIVATE_BLOB )) ? KEY_EXPORT_FLAG_RSA_FULL : 0;
params.buf = output;
params.len = output_len;
params.ret_len = size;
return UNIX_CALL( key_export_ecc, &params );
return UNIX_CALL( key_asymmetric_export, &params );
}
else if (!wcscmp( type, LEGACY_DSA_V2_PRIVATE_BLOB ))
else if (!wcscmp( type, BCRYPT_DSA_PUBLIC_BLOB ) || !wcscmp( type, LEGACY_DSA_V2_PUBLIC_BLOB ) ||
!wcscmp( type, BCRYPT_ECCPUBLIC_BLOB ) || !wcscmp( type, BCRYPT_RSAPUBLIC_BLOB ))
{
params.key = key;
params.buf = output;
params.len = output_len;
params.key = key;
params.flags = KEY_EXPORT_FLAG_PUBLIC;
params.buf = output;
params.len = output_len;
params.ret_len = size;
return UNIX_CALL( key_export_dsa_capi, &params );
return UNIX_CALL( key_asymmetric_export, &params );
}
FIXME( "unsupported key type %s\n", debugstr_w(type) );
......
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