Commit 54c1b0ac authored by Alexandre Julliard's avatar Alexandre Julliard

bcrypt: Move the public key initialization to the generic code.

parent d70c8e46
......@@ -229,6 +229,13 @@ struct key_symmetric
enum mode_id mode;
};
struct key_asymmetric
{
ULONG bitlen; /* ignored for ECC keys */
UCHAR *pubkey;
ULONG pubkey_len;
};
struct key
{
struct object hdr;
......@@ -236,6 +243,7 @@ struct key
union
{
struct key_symmetric s;
struct key_asymmetric a;
} u;
};
#endif
......@@ -254,7 +262,7 @@ NTSTATUS key_symmetric_set_auth_data( struct key *, UCHAR *, ULONG ) DECLSPEC_HI
NTSTATUS key_symmetric_encrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
NTSTATUS key_symmetric_decrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
NTSTATUS key_symmetric_get_tag( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
NTSTATUS key_asymmetric_init( struct key *, struct algorithm *, ULONG, const UCHAR *, ULONG ) DECLSPEC_HIDDEN;
NTSTATUS key_asymmetric_init( struct key * ) DECLSPEC_HIDDEN;
NTSTATUS key_asymmetric_generate( struct key * ) DECLSPEC_HIDDEN;
NTSTATUS key_asymmetric_sign( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG *, ULONG ) DECLSPEC_HIDDEN;
NTSTATUS key_asymmetric_verify( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, DWORD ) DECLSPEC_HIDDEN;
......
......@@ -862,9 +862,22 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a
if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY;
key->hdr.magic = MAGIC_KEY;
key->alg_id = alg->id;
key->u.a.bitlen = bitlen;
if ((status = key_asymmetric_init( key, alg, bitlen, pubkey, pubkey_len )))
if (pubkey_len)
{
if (!(key->u.a.pubkey = heap_alloc( pubkey_len )))
{
heap_free( key );
return STATUS_NO_MEMORY;
}
memcpy( key->u.a.pubkey, pubkey, pubkey_len );
key->u.a.pubkey_len = pubkey_len;
}
if ((status = key_asymmetric_init( key )))
{
heap_free( key->u.a.pubkey );
heap_free( key );
return status;
}
......@@ -1321,8 +1334,7 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy )
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitlen, const UCHAR *pubkey,
ULONG pubkey_len )
NTSTATUS key_asymmetric_init( struct key *key )
{
ERR( "support for keys not available at build time\n" );
return STATUS_NOT_IMPLEMENTED;
......
......@@ -1121,12 +1121,11 @@ NTSTATUS key_import_dsa_capi( struct key *key, UCHAR *buf, ULONG len )
return STATUS_SUCCESS;
}
NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitlen, const UCHAR *pubkey,
ULONG pubkey_len )
NTSTATUS key_asymmetric_init( struct key *key )
{
if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
switch (alg->id)
switch (key->alg_id)
{
case ALG_ID_ECDH_P256:
case ALG_ID_ECDSA_P256:
......@@ -1134,23 +1133,12 @@ NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitl
case ALG_ID_RSA:
case ALG_ID_RSA_SIGN:
case ALG_ID_DSA:
break;
return STATUS_SUCCESS;
default:
FIXME( "algorithm %u not supported\n", alg->id );
FIXME( "algorithm %u not supported\n", key->alg_id );
return STATUS_NOT_SUPPORTED;
}
if (pubkey_len)
{
if (!(key->u.a.pubkey = heap_alloc( pubkey_len ))) return STATUS_NO_MEMORY;
memcpy( key->u.a.pubkey, pubkey, pubkey_len );
key->u.a.pubkey_len = pubkey_len;
}
key->alg_id = alg->id;
key->u.a.bitlen = bitlen;
return STATUS_SUCCESS;
}
static NTSTATUS import_gnutls_pubkey_ecc( struct key *key, gnutls_pubkey_t *gnutls_key )
......
......@@ -219,8 +219,7 @@ NTSTATUS key_symmetric_get_tag( struct key *key, UCHAR *tag, ULONG len )
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitlen, const UCHAR *pubkey,
ULONG pubkey_len )
NTSTATUS key_asymmetric_init( struct key *key )
{
FIXME( "not implemented on Mac\n" );
return STATUS_NOT_IMPLEMENTED;
......
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