Commit e4f716bc authored by Alexandre Julliard's avatar Alexandre Julliard

bcrypt: Remove some no longer needed Unix backend functions.

parent 9aad4380
...@@ -197,15 +197,12 @@ struct secret ...@@ -197,15 +197,12 @@ struct secret
struct key_funcs struct key_funcs
{ {
NTSTATUS (CDECL *key_set_property)( struct key *, const WCHAR *, UCHAR *, ULONG, ULONG );
NTSTATUS (CDECL *key_symmetric_init)( struct key * );
void (CDECL *key_symmetric_vector_reset)( struct key * ); void (CDECL *key_symmetric_vector_reset)( struct key * );
NTSTATUS (CDECL *key_symmetric_set_auth_data)( struct key *, UCHAR *, ULONG ); NTSTATUS (CDECL *key_symmetric_set_auth_data)( struct key *, UCHAR *, ULONG );
NTSTATUS (CDECL *key_symmetric_encrypt)( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ); NTSTATUS (CDECL *key_symmetric_encrypt)( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG );
NTSTATUS (CDECL *key_symmetric_decrypt)( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ); NTSTATUS (CDECL *key_symmetric_decrypt)( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG );
NTSTATUS (CDECL *key_symmetric_get_tag)( struct key *, UCHAR *, ULONG ); NTSTATUS (CDECL *key_symmetric_get_tag)( struct key *, UCHAR *, ULONG );
void (CDECL *key_symmetric_destroy)( struct key * ); 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_generate)( struct key * );
NTSTATUS (CDECL *key_asymmetric_decrypt)( struct key *, UCHAR *, ULONG, UCHAR *, ULONG, 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_duplicate)( struct key *, struct key * );
......
...@@ -672,6 +672,36 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA ...@@ -672,6 +672,36 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA
} }
} }
static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
{
if (!wcscmp( prop, BCRYPT_CHAINING_MODE ))
{
if (!wcscmp( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB ))
{
key->u.s.mode = MODE_ID_ECB;
return STATUS_SUCCESS;
}
else if (!wcscmp( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC ))
{
key->u.s.mode = MODE_ID_CBC;
return STATUS_SUCCESS;
}
else if (!wcscmp( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM ))
{
key->u.s.mode = MODE_ID_GCM;
return STATUS_SUCCESS;
}
else
{
FIXME( "unsupported mode %s\n", debugstr_w((WCHAR *)value) );
return STATUS_NOT_IMPLEMENTED;
}
}
FIXME( "unsupported key property %s\n", debugstr_w(prop) );
return STATUS_NOT_IMPLEMENTED;
}
static NTSTATUS get_hash_property( const struct hash *hash, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size ) static NTSTATUS get_hash_property( const struct hash *hash, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
{ {
NTSTATUS status; NTSTATUS status;
...@@ -933,7 +963,6 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a ...@@ -933,7 +963,6 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a
const UCHAR *pubkey, ULONG pubkey_len ) const UCHAR *pubkey, ULONG pubkey_len )
{ {
struct key *key; struct key *key;
NTSTATUS status;
if (!key_funcs) if (!key_funcs)
{ {
...@@ -956,12 +985,6 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a ...@@ -956,12 +985,6 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a
memcpy( key->u.a.pubkey, pubkey, pubkey_len ); memcpy( key->u.a.pubkey, pubkey, pubkey_len );
key->u.a.pubkey_len = pubkey_len; key->u.a.pubkey_len = pubkey_len;
} }
if ((status = key_funcs->key_asymmetric_init( key )))
{
heap_free( key->u.a.pubkey );
heap_free( key );
return status;
}
*ret_key = key; *ret_key = key;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -1446,7 +1469,6 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_ ...@@ -1446,7 +1469,6 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
struct algorithm *alg = algorithm; struct algorithm *alg = algorithm;
struct key *key; struct key *key;
ULONG block_size; ULONG block_size;
NTSTATUS status;
TRACE( "%p, %p, %p, %u, %p, %u, %08x\n", algorithm, handle, object, object_len, secret, secret_len, flags ); TRACE( "%p, %p, %p, %u, %p, %u, %08x\n", algorithm, handle, object, object_len, secret, secret_len, flags );
...@@ -1476,13 +1498,6 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_ ...@@ -1476,13 +1498,6 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
memcpy( key->u.s.secret, secret, secret_len ); memcpy( key->u.s.secret, secret, secret_len );
key->u.s.secret_len = secret_len; key->u.s.secret_len = secret_len;
if ((status = key_funcs->key_symmetric_init( key )))
{
heap_free( key->u.s.secret );
heap_free( key );
return status;
}
*handle = key; *handle = key;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -1499,8 +1514,22 @@ NTSTATUS WINAPI BCryptGenerateKeyPair( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_H ...@@ -1499,8 +1514,22 @@ NTSTATUS WINAPI BCryptGenerateKeyPair( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_H
if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE; if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
if (!handle) return STATUS_INVALID_PARAMETER; if (!handle) return STATUS_INVALID_PARAMETER;
if (!(status = key_asymmetric_create( &key, alg, key_len, NULL, 0 ))) *handle = key; switch (alg->id)
return status; {
case ALG_ID_ECDH_P256:
case ALG_ID_ECDSA_P256:
case ALG_ID_ECDSA_P384:
case ALG_ID_RSA:
case ALG_ID_RSA_SIGN:
case ALG_ID_DSA:
if (!(status = key_asymmetric_create( &key, alg, key_len, NULL, 0 ))) *handle = key;
return status;
default:
FIXME( "algorithm %u not supported\n", alg->id );
return STATUS_NOT_SUPPORTED;
}
} }
NTSTATUS WINAPI BCryptFinalizeKeyPair( BCRYPT_KEY_HANDLE handle, ULONG flags ) NTSTATUS WINAPI BCryptFinalizeKeyPair( BCRYPT_KEY_HANDLE handle, ULONG flags )
...@@ -1767,7 +1796,7 @@ NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHA ...@@ -1767,7 +1796,7 @@ NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHA
case MAGIC_KEY: case MAGIC_KEY:
{ {
struct key *key = (struct key *)object; struct key *key = (struct key *)object;
return key_funcs->key_set_property( key, prop, value, size, flags ); return set_key_property( key, prop, value, size, flags );
} }
default: default:
WARN( "unknown magic %08x\n", object->magic ); WARN( "unknown magic %08x\n", object->magic );
......
...@@ -480,52 +480,6 @@ static void buffer_append_asn1_r_s( struct buffer *buffer, BYTE *r, DWORD r_len, ...@@ -480,52 +480,6 @@ static void buffer_append_asn1_r_s( struct buffer *buffer, BYTE *r, DWORD r_len,
buffer_free( &value ); buffer_free( &value );
} }
static NTSTATUS CDECL key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
{
if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
{
if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB ))
{
key->u.s.mode = MODE_ID_ECB;
return STATUS_SUCCESS;
}
else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC ))
{
key->u.s.mode = MODE_ID_CBC;
return STATUS_SUCCESS;
}
else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM ))
{
key->u.s.mode = MODE_ID_GCM;
return STATUS_SUCCESS;
}
else
{
FIXME( "unsupported mode %s\n", debugstr_w((WCHAR *)value) );
return STATUS_NOT_IMPLEMENTED;
}
}
FIXME( "unsupported key property %s\n", debugstr_w(prop) );
return STATUS_NOT_IMPLEMENTED;
}
static NTSTATUS CDECL key_symmetric_init( struct key *key )
{
if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
switch (key->alg_id)
{
case ALG_ID_3DES:
case ALG_ID_AES:
return STATUS_SUCCESS;
default:
FIXME( "algorithm %u not supported\n", key->alg_id );
return STATUS_NOT_SUPPORTED;
}
}
static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key ) static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
{ {
switch (key->alg_id) switch (key->alg_id)
...@@ -1271,26 +1225,6 @@ static NTSTATUS CDECL key_import_dsa_capi( struct key *key, UCHAR *buf, ULONG le ...@@ -1271,26 +1225,6 @@ static NTSTATUS CDECL key_import_dsa_capi( struct key *key, UCHAR *buf, ULONG le
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static NTSTATUS CDECL key_asymmetric_init( struct key *key )
{
if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
switch (key->alg_id)
{
case ALG_ID_ECDH_P256:
case ALG_ID_ECDSA_P256:
case ALG_ID_ECDSA_P384:
case ALG_ID_RSA:
case ALG_ID_RSA_SIGN:
case ALG_ID_DSA:
return STATUS_SUCCESS;
default:
FIXME( "algorithm %u not supported\n", key->alg_id );
return STATUS_NOT_SUPPORTED;
}
}
static NTSTATUS import_gnutls_pubkey_ecc( struct key *key, gnutls_pubkey_t *gnutls_key ) static NTSTATUS import_gnutls_pubkey_ecc( struct key *key, gnutls_pubkey_t *gnutls_key )
{ {
BCRYPT_ECCKEY_BLOB *ecc_blob; BCRYPT_ECCKEY_BLOB *ecc_blob;
...@@ -1871,15 +1805,12 @@ static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULO ...@@ -1871,15 +1805,12 @@ static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULO
static const struct key_funcs key_funcs = static const struct key_funcs key_funcs =
{ {
key_set_property,
key_symmetric_init,
key_symmetric_vector_reset, key_symmetric_vector_reset,
key_symmetric_set_auth_data, key_symmetric_set_auth_data,
key_symmetric_encrypt, key_symmetric_encrypt,
key_symmetric_decrypt, key_symmetric_decrypt,
key_symmetric_get_tag, key_symmetric_get_tag,
key_symmetric_destroy, key_symmetric_destroy,
key_asymmetric_init,
key_asymmetric_generate, key_asymmetric_generate,
key_asymmetric_decrypt, key_asymmetric_decrypt,
key_asymmetric_duplicate, key_asymmetric_duplicate,
......
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