3#ifdef SONAME_LIBMBEDTLS
26static BOOL rng_seeded;
55C_ASSERT(
sizeof(
union key_data) <=
sizeof(((
struct key *)0)->
private));
57static union key_data *key_data(
struct key *
key)
63#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
167 ERR(
"failed to load libmbedtls, no support for crypto hashes\n");
171#define LOAD_FUNCPTR(f) \
172 if (!(p##f = wine_dlsym(libmbedtls_handle, #f, NULL, 0))) \
174 ERR("failed to load %s\n", #f); \
289#define mbedtls_md_init pmbedtls_md_init
290#define mbedtls_md_info_from_type pmbedtls_md_info_from_type
291#define mbedtls_md_get_size pmbedtls_md_get_size
292#define mbedtls_md_setup pmbedtls_md_setup
293#define mbedtls_md_update pmbedtls_md_update
294#define mbedtls_md_starts pmbedtls_md_starts
295#define mbedtls_md_finish pmbedtls_md_finish
296#define mbedtls_md_hmac_update pmbedtls_md_hmac_update
297#define mbedtls_md_hmac_starts pmbedtls_md_hmac_starts
298#define mbedtls_md_hmac_finish pmbedtls_md_hmac_finish
299#define mbedtls_md_free pmbedtls_md_free
300#define mbedtls_cipher_init pmbedtls_cipher_init
301#define mbedtls_cipher_setup pmbedtls_cipher_setup
302#define mbedtls_cipher_info_from_type pmbedtls_cipher_info_from_type
303#define mbedtls_cipher_setkey pmbedtls_cipher_setkey
304#define mbedtls_cipher_set_iv pmbedtls_cipher_set_iv
305#define mbedtls_cipher_set_padding_mode pmbedtls_cipher_set_padding_mode
306#define mbedtls_cipher_update pmbedtls_cipher_update
307#define mbedtls_cipher_update_ad pmbedtls_cipher_update_ad
308#define mbedtls_cipher_check_tag pmbedtls_cipher_check_tag
309#define mbedtls_cipher_write_tag pmbedtls_cipher_write_tag
310#define mbedtls_cipher_finish pmbedtls_cipher_finish
311#define mbedtls_cipher_free pmbedtls_cipher_free
312#define mbedtls_ctr_drbg_init pmbedtls_ctr_drbg_init
313#define mbedtls_ctr_drbg_random pmbedtls_ctr_drbg_random
314#define mbedtls_ctr_drbg_seed pmbedtls_ctr_drbg_seed
315#define mbedtls_ctr_drbg_free pmbedtls_ctr_drbg_free
316#define mbedtls_entropy_init pmbedtls_entropy_init
317#define mbedtls_entropy_func pmbedtls_entropy_func
318#define mbedtls_entropy_free pmbedtls_entropy_free
319#define mbedtls_pk_init pmbedtls_pk_init
320#define mbedtls_pk_get_type pmbedtls_pk_get_type
321#define mbedtls_pk_setup pmbedtls_pk_setup
322#define mbedtls_pk_info_from_type pmbedtls_pk_info_from_type
323#define mbedtls_pk_parse_key pmbedtls_pk_parse_key
324#define mbedtls_pk_parse_public_key pmbedtls_pk_parse_public_key
325#define mbedtls_pk_verify_ext pmbedtls_pk_verify_ext
326#define mbedtls_pk_sign pmbedtls_pk_sign
327#define mbedtls_pk_encrypt pmbedtls_pk_encrypt
328#define mbedtls_pk_decrypt pmbedtls_pk_decrypt
329#define mbedtls_pk_free pmbedtls_pk_free
330#define mbedtls_ecdh_init pmbedtls_ecdh_init
331#define mbedtls_ecdh_compute_shared pmbedtls_ecdh_compute_shared
332#define mbedtls_ecdh_free pmbedtls_ecdh_free
333#define mbedtls_rsa_gen_key pmbedtls_rsa_gen_key
334#define mbedtls_rsa_import_raw pmbedtls_rsa_import_raw
335#define mbedtls_rsa_export pmbedtls_rsa_export
336#define mbedtls_rsa_export_raw pmbedtls_rsa_export_raw
337#define mbedtls_rsa_export_crt pmbedtls_rsa_export_crt
338#define mbedtls_rsa_set_padding pmbedtls_rsa_set_padding
339#define mbedtls_rsa_complete pmbedtls_rsa_complete
340#define mbedtls_rsa_check_pubkey pmbedtls_rsa_check_pubkey
341#define mbedtls_rsa_check_privkey pmbedtls_rsa_check_privkey
342#define mbedtls_rsa_check_pub_priv pmbedtls_rsa_check_pub_priv
343#define mbedtls_ecp_gen_key pmbedtls_ecp_gen_key
344#define mbedtls_ecp_group_load pmbedtls_ecp_group_load
345#define mbedtls_ecp_point_read_binary pmbedtls_ecp_point_read_binary
346#define mbedtls_ecp_point_write_binary pmbedtls_ecp_point_write_binary
347#define mbedtls_ecp_check_pubkey pmbedtls_ecp_check_pubkey
348#define mbedtls_ecp_copy pmbedtls_ecp_copy
349#define mbedtls_mpi_init pmbedtls_mpi_init
350#define mbedtls_mpi_size pmbedtls_mpi_size
351#define mbedtls_mpi_lset pmbedtls_mpi_lset
352#define mbedtls_mpi_copy pmbedtls_mpi_copy
353#define mbedtls_mpi_cmp_mpi pmbedtls_mpi_cmp_mpi
354#define mbedtls_mpi_cmp_int pmbedtls_mpi_cmp_int
355#define mbedtls_mpi_read_binary pmbedtls_mpi_read_binary
356#define mbedtls_mpi_write_binary pmbedtls_mpi_write_binary
357#define mbedtls_mpi_read_string pmbedtls_mpi_read_string
358#define mbedtls_mpi_gen_prime pmbedtls_mpi_gen_prime
359#define mbedtls_mpi_sub_int pmbedtls_mpi_sub_int
360#define mbedtls_mpi_div_int pmbedtls_mpi_div_int
361#define mbedtls_mpi_is_prime_ext pmbedtls_mpi_is_prime_ext
362#define mbedtls_mpi_free pmbedtls_mpi_free
363#define mbedtls_asn1_get_len pmbedtls_asn1_get_len
364#define mbedtls_asn1_get_mpi pmbedtls_asn1_get_mpi
365#define mbedtls_asn1_get_tag pmbedtls_asn1_get_tag
366#define mbedtls_asn1_write_len pmbedtls_asn1_write_len
367#define mbedtls_asn1_write_mpi pmbedtls_asn1_write_mpi
368#define mbedtls_asn1_write_tag pmbedtls_asn1_write_tag
369#define mbedtls_asn1_write_raw_buffer pmbedtls_asn1_write_raw_buffer
370#define mbedtls_dhm_init pmbedtls_dhm_init
371#define mbedtls_dhm_make_params pmbedtls_dhm_make_params
372#define mbedtls_dhm_calc_secret pmbedtls_dhm_calc_secret
373#define mbedtls_dhm_free pmbedtls_dhm_free
374#define mbedtls_dsa_init pmbedtls_dsa_init
375#define mbedtls_dsa_set_group pmbedtls_dsa_set_group
376#define mbedtls_dsa_genkey pmbedtls_dsa_genkey
377#define mbedtls_dsa_check_pqg pmbedtls_dsa_check_pqg
378#define mbedtls_dsa_check_pubkey pmbedtls_dsa_check_pubkey
379#define mbedtls_dsa_check_privkey pmbedtls_dsa_check_privkey
380#define mbedtls_dsa_pubkey_from_privkey pmbedtls_dsa_pubkey_from_privkey
381#define mbedtls_dsa_verify pmbedtls_dsa_verify
382#define mbedtls_dsa_sign pmbedtls_dsa_sign
383#define mbedtls_dsa_free pmbedtls_dsa_free
404static int bcrypt_rng(
void *
ctx,
unsigned char *output,
size_t len)
415 ERR(
"cannot seed the random generator: %d\n",
ret);
533 WARN(
"handle block size\n");
537 WARN(
"handle block size\n");
538 switch (
key->
u.
s.mode)
547 FIXME(
"3DES mode %u with key length %u not supported\n",
key->
u.
s.mode,
key->
u.
s.secret_len);
551 WARN(
"handle block size\n");
552 switch (
key->
u.
s.mode)
566 if (
key->
u.
s.secret_len == 16)
return MBEDTLS_CIPHER_AES_128_CFB8;
567 if (
key->
u.
s.secret_len == 24)
return MBEDTLS_CIPHER_AES_192_CFB8;
568 if (
key->
u.
s.secret_len == 32)
return MBEDTLS_CIPHER_AES_256_CFB8;
573 FIXME(
"AES mode %u with key length %u not supported\n",
key->
u.
s.mode,
key->
u.
s.secret_len);
595 TRACE(
"invalidating cipher handle\n");
597 key_data(
key)->s.cipher_ctx.cipher_info =
NULL;
609 if (key_data(
key)->
s.cipher_ctx.cipher_info !=
NULL)
613 key_data(
key)->s.cipher_ctx.cipher_info =
NULL;
742 if (key_data(
key)->
s.cipher_ctx.cipher_info !=
NULL)
745 key_data(
key)->s.cipher_ctx.cipher_info =
NULL;
814 curve = keypair->
grp.
id;
818 FIXME(
"curve %u not supported\n", curve);
828 dst =
buf +
sizeof(*ecc_blob);
868 FIXME(
"algorithm %u does not yet support exporting ecc blob\n",
key->
alg_id);
875 curve = keypair->
grp.
id;
879 FIXME(
"curve %u not supported\n", curve);
890 dst =
buf +
sizeof(*ecc_blob);
909 size_t m_size, e_size;
928 *
ret_len =
sizeof(*rsa_blob) + e_size + m_size;
931 dst =
buf +
sizeof(*rsa_blob);
933 rsa_blob->cbPublicExp = e_size;
935 dst += rsa_blob->cbPublicExp;
937 rsa_blob->cbModulus = m_size;
940 rsa_blob->BitLength =
key->
u.
a.bitlen;
941 rsa_blob->cbPrime1 = 0;
942 rsa_blob->cbPrime2 = 0;
960 size_t m_size, e_size, d_size, p_size, q_size, u_size, e1_size, e2_size;
1022 *
ret_len =
sizeof(*rsa_blob) + e_size + m_size + p_size + q_size;
1024 if (full) *
ret_len += e1_size + e2_size + u_size + d_size;
1032 dst =
buf +
sizeof(*rsa_blob);
1034 rsa_blob->cbPublicExp = e_size;
1036 dst += rsa_blob->cbPublicExp;
1038 rsa_blob->cbModulus = m_size;
1040 dst += rsa_blob->cbModulus;
1042 rsa_blob->cbPrime1 = p_size;
1044 dst += rsa_blob->cbPrime1;
1046 rsa_blob->cbPrime2 = q_size;
1050 dst += rsa_blob->cbPrime2;
1096 dst =
buf +
sizeof(*dh_params);
1121 dst =
buf +
sizeof(*dh_blob);
1147 dst =
buf +
sizeof(*dh_blob);
1169 if (
key->
u.
a.bitlen > 1024)
1171 FIXME(
"bitlen > 1024 not supported\n");
1184 dst =
buf +
sizeof(*dsa_blob);;
1195 dsa_blob->cbKey =
size;
1196 memset(dsa_blob->Count, 0,
sizeof(dsa_blob->Count));
1197 memset(dsa_blob->Seed, 0,
sizeof(dsa_blob->Seed));
1209 for (
i = 0;
i <
len / 2; ++
i)
1226 if (
key->
u.
a.bitlen > 1024)
1228 FIXME(
"bitlen > 1024 not supported\n");
1237 *
ret_len =
sizeof(*hdr) +
sizeof(*dsskey) +
sizeof(
key->
u.
a.dss_seed) +
1281 if (
key->
u.
a.bitlen > 1024)
1283 FIXME(
"bitlen > 1024 not supported\n");
1295 dst =
buf +
sizeof(*dsa_blob);;
1308 dsa_blob->cbKey =
size;
1309 memset(dsa_blob->Count, 0,
sizeof(dsa_blob->Count));
1310 memset(dsa_blob->Seed, 0,
sizeof(dsa_blob->Seed));
1321 size_t q_size, x_size;
1330 if (q_size > 21 || x_size > 21)
1332 ERR(
"can't export key in this format\n");
1336 *
ret_len =
sizeof(*hdr) +
sizeof(*pubkey) +
sizeof(
key->
u.
a.dss_seed) +
1583 dh_key->
len = key_len;
1592 size_t key_len = dh_blob->
cbKey;
1608 dh_key->
len = key_len;
1617 size_t key_len = dh_blob->
cbKey;
1634 dh_key->
len = key_len;
1644 UCHAR *p_data, *q_data, *g_data, *y_data;
1646 size_t p_size, q_size, g_size, y_size;
1651 p_data =
buf +
sizeof(*dsa_blob);
1652 p_size = dsa_blob->
cbKey;
1653 q_data = dsa_blob->q;
1654 q_size =
sizeof(dsa_blob->q);
1655 g_data =
buf +
sizeof(*dsa_blob) + dsa_blob->cbKey;
1656 g_size = dsa_blob->cbKey;
1657 y_data =
buf +
sizeof(*dsa_blob) + dsa_blob->cbKey * 2;
1658 y_size = dsa_blob->cbKey;
1697 UCHAR *p_data, *q_data, *g_data, *y_data, *x_data;
1698 int ret, p_size, q_size, g_size, y_size, x_size;
1703 p_data =
buf +
sizeof(*dsa_blob);
1704 p_size = dsa_blob->
cbKey;
1705 q_data = dsa_blob->q;
1706 q_size =
sizeof(dsa_blob->q);
1707 g_data =
buf +
sizeof(*dsa_blob) + dsa_blob->cbKey;
1708 g_size = dsa_blob->cbKey;
1709 y_data =
buf +
sizeof(*dsa_blob) + dsa_blob->cbKey * 2;
1710 y_size = dsa_blob->cbKey;
1711 x_data =
buf +
sizeof(*dsa_blob) + dsa_blob->cbKey * 3;
1712 x_size = dsa_blob->cbKey;
1756 unsigned char *
data, p_data[128], q_data[20], g_data[128], y_data[128];
1757 int i,
ret,
size, p_size, q_size, g_size, y_size;
1763 if (
size >
sizeof(p_data))
1768 data =
buf +
sizeof(*hdr) +
sizeof(*pubkey);
1771 for (
i = 0;
i < p_size;
i++) p_data[
i] =
data[p_size -
i - 1];
1774 q_size =
sizeof(q_data);
1775 for (
i = 0;
i < q_size;
i++) q_data[
i] =
data[q_size -
i - 1];
1779 for (
i = 0;
i < g_size;
i++) g_data[
i] =
data[g_size -
i - 1];
1782 y_size =
sizeof(y_data);
1783 for (
i = 0;
i < y_size;
i++) y_data[
i] =
data[y_size -
i - 1];
1827 unsigned char *
data, p_data[128], q_data[20], g_data[128], x_data[20];
1828 int i,
ret,
size, p_size, q_size, g_size, x_size;
1833 if ((
size =
pubkey->bitlen / 8) >
sizeof(p_data))
1838 data =
buf +
sizeof(*hdr) +
sizeof(*pubkey);
1841 for (
i = 0;
i < p_size;
i++) p_data[
i] =
data[p_size -
i - 1];
1844 q_size =
sizeof(q_data);
1845 for (
i = 0;
i < q_size;
i++) q_data[
i] =
data[q_size -
i - 1];
1849 for (
i = 0;
i < g_size;
i++) g_data[
i] =
data[g_size -
i - 1];
1852 x_size =
sizeof(x_data);
1853 for (
i = 0;
i < x_size;
i++) x_data[
i] =
data[x_size -
i - 1];
1947 status = init_pk_key(&key_data(
key)->
a.pk.privkey, pk_type,
TRUE);
1953 status = init_pk_key(&key_data(
key)->
a.pk.privkey, pk_type,
TRUE);
1959 init_dsa_key(&key_data(
key)->
a.dsa.privkey, (
key->
u.
a.bitlen + 7) / 8,
TRUE);
1968 init_dh_key(&key_data(
key)->
a.dh.privkey,
TRUE);
1988 status = init_pk_key(&key_data(
key)->
a.pk.pubkey, pk_type,
TRUE);
1994 status = init_pk_key(&key_data(
key)->
a.pk.pubkey, pk_type,
TRUE);
2006 init_dsa_key(&key_data(
key)->
a.dsa.pubkey, (
key->
u.
a.bitlen + 7) / 8,
TRUE);
2023 init_dh_key(&key_data(
key)->
a.dh.pubkey,
TRUE);
2046#define MBEDTLS_DH_GEN_PRIME
2047#ifdef MBEDTLS_DH_GEN_PRIME
2048static int dh_gen_prime(
mbedtls_dhm_context *dh,
int nbits,
int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng)
2118 init_dh_key(&key_data(
key)->
a.dh.privkey,
FALSE);
2119#ifdef MBEDTLS_DH_GEN_PRIME
2120 ret = dh_gen_prime(&key_data(
key)->
a.dh.privkey,
key->
u.
a.bitlen, bcrypt_rng,
NULL);
2132 init_dsa_key(&key_data(
key)->
a.dsa.privkey, (
key->
u.
a.bitlen + 7) / 8,
FALSE);
2173 init_dsa_key(&key_data(
key)->
a.dsa.pubkey, (
key->
u.
a.bitlen + 7) / 8,
FALSE);
2180 init_dh_key(&key_data(
key)->
a.dh.pubkey,
FALSE);
2215 UCHAR *out_signature;
2216 ULONG out_signature_len;
2233 switch (
params->hash_len)
2246 FIXME(
"hash size %u not yet supported\n",
params->hash_len);
2259 if (!
info->pszAlgId)
2295 if (
params->hash_len != 20)
2297 FIXME(
"hash size %u not supported\n",
params->hash_len);
2318 p = out_signature +
params->signature_len + 6;
2319 start = out_signature;
2328 out_signature_len =
params->signature_len + 6;
2332 out_signature =
params->signature;
2333 out_signature_len =
params->signature_len;
2342 hash_alg,
params->hash,
params->hash_len, out_signature, out_signature_len);
2343 if (out_signature !=
params->signature)
free(out_signature);
2353 size_t sig_len,
len, expected_len;
2366 switch (
params->input_len)
2382 FIXME(
"hash size %u not yet supported\n",
params->input_len);
2400 if (
params->input_len != 20)
2402 FIXME(
"hash size %u not supported\n",
params->input_len);
2414 WARN(
"padding info not found\n");
2430 WARN(
"padding info not found\n");
2435 FIXME(
"BCRYPT_PAD_PSS not supported for key algorithm %u\n",
key->
alg_id);
2485 end = output + sig_len;
2488 expected_len = (
len / 2) * 2;
2489 if (!
ret && expected_len <
len)
p +=
len - expected_len;
2490 if (!
ret) sig_len = expected_len;
2494 expected_len = (
len / 2) * 2;
2495 if (!
ret && expected_len <
len)
p +=
len - expected_len;
2497 if (!
ret) sig_len += expected_len;
2500 if (sig_len <= params->output_len)
memcpy(
params->output, output, sig_len);
2503 *
params->ret_len = sig_len;
2564 switch (
params->key_orig->alg_id)
2569 pk_type = key_get_type(
params->key_orig->alg_id);
2570 init_pk_key(&key_data(
params->key_copy)->a.pk.privkey, pk_type,
TRUE);
2571 init_pk_key(&key_data(
params->key_copy)->a.pk.pubkey, pk_type,
TRUE);
2587 pk_type = key_get_type(
params->key_orig->alg_id);
2588 init_pk_key(&key_data(
params->key_copy)->a.pk.privkey, pk_type,
TRUE);
2589 init_pk_key(&key_data(
params->key_copy)->a.pk.pubkey, pk_type,
TRUE);
2605 init_dsa_key(&key_data(
params->key_copy)->a.dsa.privkey, (
params->key_orig->u.a.bitlen + 7) / 8,
TRUE);
2606 init_dsa_key(&key_data(
params->key_copy)->a.dsa.pubkey, (
params->key_orig->u.a.bitlen + 7) / 8,
TRUE);
2622 init_dh_key(&key_data(
params->key_copy)->a.dh.privkey,
TRUE);
2623 init_dh_key(&key_data(
params->key_copy)->a.dh.pubkey,
TRUE);
2637 FIXME(
"unsupported algorithm %u\n",
params->key_orig->alg_id);
2666 WARN(
"padding info not found\n");
2704 WARN(
"padding info not found\n");
2734 switch (
params->privkey->alg_id)
2762 FIXME(
"mbedtls_ecdh_compute_shared failed: %d\n",
ret);
2777 dhm = &key_data(
params->privkey)->a.dh.privkey;
2778 dhm_pub = &key_data(
params->pubkey)->a.dh.pubkey;
2789 FIXME(
"mbedtls_dhm_calc_secret failed with %d\n",
ret);
2792 *
params->ret_len = secret_len;
2797 FIXME(
"unsupported algorithm %u\n",
params->privkey->alg_id);
ASN.1 buffer writing functionality.
int mbedtls_asn1_write_raw_buffer(unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size)
Write raw buffer data.
int mbedtls_asn1_write_tag(unsigned char **p, unsigned char *start, unsigned char tag)
Write an ASN.1 tag in ASN.1 format.
int mbedtls_asn1_write_len(unsigned char **p, unsigned char *start, size_t len)
Write a length field in ASN.1 format.
int mbedtls_asn1_write_mpi(unsigned char **p, unsigned char *start, const mbedtls_mpi *X)
Write a arbitrary-precision number (MBEDTLS_ASN1_INTEGER) in ASN.1 format.
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
#define BCRYPT_DH_PUBLIC_MAGIC
#define BCRYPT_ECDH_PRIVATE_P256_MAGIC
#define BCRYPT_ECDSA_PUBLIC_P256_MAGIC
#define BCRYPT_ECDH_PUBLIC_P384_MAGIC
#define BCRYPT_ECDSA_PUBLIC_P384_MAGIC
#define BCRYPT_SHA512_ALGORITHM
#define BCRYPT_RSAFULLPRIVATE_MAGIC
#define BCRYPT_MD2_ALGORITHM
#define BCRYPT_SHA256_ALGORITHM
#define BCRYPT_RSAPRIVATE_MAGIC
#define BCRYPT_ECDH_PUBLIC_P256_MAGIC
#define BCRYPT_ECDSA_PRIVATE_P256_MAGIC
#define BCRYPT_ECDSA_PRIVATE_P384_MAGIC
#define BCRYPT_DH_PARAMETERS_MAGIC
#define BCRYPT_RSAPUBLIC_MAGIC
#define BCRYPT_ECDH_PRIVATE_P384_MAGIC
#define BCRYPT_SHA384_ALGORITHM
#define BCRYPT_DSA_PUBLIC_MAGIC
#define BCRYPT_SHA1_ALGORITHM
#define BCRYPT_MD5_ALGORITHM
#define BCRYPT_DH_PRIVATE_MAGIC
NTSTATUS key_symmetric_vector_reset(void *args)
NTSTATUS key_symmetric_encrypt_internal(void *args)
NTSTATUS key_asymmetric_export(void *args)
#define KEY_FLAG_FINALIZED
NTSTATUS key_symmetric_set_auth_data(void *args)
NTSTATUS key_symmetric_get_tag(void *args)
NTSTATUS hash_update(struct hash *hash, UCHAR *input, ULONG size)
NTSTATUS key_asymmetric_encrypt(void *args)
NTSTATUS key_symmetric_destroy(void *args)
#define KEY_EXPORT_FLAG_DH_PARAMETERS
NTSTATUS key_symmetric_decrypt_internal(void *args)
NTSTATUS hash_get_size(struct hash *hash, ULONG *output)
NTSTATUS hash_finish(struct hash *hash, UCHAR *output)
#define KEY_IMPORT_FLAG_PUBLIC
NTSTATUS key_asymmetric_generate(void *args)
NTSTATUS key_asymmetric_destroy(void *args)
NTSTATUS process_attach(void *args)
#define KEY_EXPORT_FLAG_RSA_FULL
NTSTATUS key_asymmetric_verify(void *args)
NTSTATUS key_asymmetric_derive_key(void *args)
NTSTATUS key_asymmetric_import(void *args)
NTSTATUS hash_init(struct hash *hash)
#define KEY_IMPORT_FLAG_DH_PARAMETERS
#define KEY_FLAG_LEGACY_DSA_V2
NTSTATUS key_asymmetric_sign(void *args)
NTSTATUS key_asymmetric_decrypt(void *args)
NTSTATUS key_asymmetric_duplicate(void *args)
#define KEY_EXPORT_FLAG_PUBLIC
static void reverse_bytes(UCHAR *buf, ULONG len)
int mbedtls_mpi_read_string(mbedtls_mpi *X, int radix, const char *s)
Import an MPI from an ASCII string.
int mbedtls_mpi_sub_int(mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b)
Perform a signed subtraction of an MPI and an integer: X = A - b.
int mbedtls_mpi_is_prime_ext(const mbedtls_mpi *X, int rounds, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Miller-Rabin primality test.
int mbedtls_mpi_copy(mbedtls_mpi *X, const mbedtls_mpi *Y)
Make a copy of an MPI.
@ MBEDTLS_MPI_GEN_PRIME_FLAG_DH
size_t mbedtls_mpi_size(const mbedtls_mpi *X)
Return the total size of an MPI value in bytes.
int mbedtls_mpi_lset(mbedtls_mpi *X, mbedtls_mpi_sint z)
Store integer value in MPI.
int mbedtls_mpi_read_binary(mbedtls_mpi *X, const unsigned char *buf, size_t buflen)
Import an MPI from unsigned big endian binary data.
int mbedtls_mpi_cmp_mpi(const mbedtls_mpi *X, const mbedtls_mpi *Y)
Compare two MPIs.
int mbedtls_mpi_div_int(mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b)
Perform a division with remainder of an MPI by an integer: A = Q * b + R.
int mbedtls_mpi_gen_prime(mbedtls_mpi *X, size_t nbits, int flags, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Generate a prime number.
void mbedtls_mpi_init(mbedtls_mpi *X)
Initialize an MPI context.
void mbedtls_mpi_free(mbedtls_mpi *X)
This function frees the components of an MPI context.
int mbedtls_mpi_write_binary(const mbedtls_mpi *X, unsigned char *buf, size_t buflen)
Export an MPI into unsigned big endian binary data of fixed size.
int mbedtls_mpi_cmp_int(const mbedtls_mpi *X, mbedtls_mpi_sint z)
Compare an MPI with an integer.
#define G(r, i, a, b, c, d)
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info)
This function initializes and fills the cipher-context structure with the appropriate values....
mbedtls_cipher_type_t
Supported {cipher type, cipher mode} pairs.
@ MBEDTLS_CIPHER_DES_EDE3_CBC
@ MBEDTLS_CIPHER_AES_128_CBC
@ MBEDTLS_CIPHER_AES_192_GCM
@ MBEDTLS_CIPHER_AES_256_GCM
@ MBEDTLS_CIPHER_AES_128_GCM
@ MBEDTLS_CIPHER_AES_192_CBC
@ MBEDTLS_CIPHER_AES_256_CBC
@ MBEDTLS_CIPHER_ARC4_128
@ MBEDTLS_CIPHER_DES_EDE3_ECB
int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx, const unsigned char *key, int key_bitlen, const mbedtls_operation_t operation)
This function sets the key to use with the given context.
int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len)
This function sets the initialization vector (IV) or nonce.
int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen)
The generic cipher finalization function. If data still needs to be flushed from an incomplete block,...
#define MBEDTLS_ERR_CIPHER_AUTH_FAILED
void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx)
This function initializes a cipher_context as NONE.
int mbedtls_cipher_update_ad(mbedtls_cipher_context_t *ctx, const unsigned char *ad, size_t ad_len)
This function adds additional data for AEAD ciphers. Currently supported with GCM and ChaCha20+Poly13...
int mbedtls_cipher_write_tag(mbedtls_cipher_context_t *ctx, unsigned char *tag, size_t tag_len)
This function writes a tag for AEAD ciphers. Currently supported with GCM and ChaCha20+Poly1305....
static mbedtls_operation_t mbedtls_cipher_get_operation(const mbedtls_cipher_context_t *ctx)
This function returns the operation of the given cipher.
void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx)
This function frees and clears the cipher-specific context of ctx. Freeing ctx itself remains the res...
int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen)
The generic cipher update function. It encrypts or decrypts using the given cipher context....
int mbedtls_cipher_check_tag(mbedtls_cipher_context_t *ctx, const unsigned char *tag, size_t tag_len)
This function checks the tag for AEAD ciphers. Currently supported with GCM and ChaCha20+Poly1305....
int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode)
This function sets the padding mode, for cipher modes that use padding.
This file contains definitions and functions for the CTR_DRBG pseudorandom generator.
#define STATUS_INVALID_HANDLE
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
This file contains Diffie-Hellman-Merkle (DHM) key exchange definitions and functions.
void mbedtls_dhm_free(mbedtls_dhm_context *ctx)
This function frees and clears the components of a DHM context.
void mbedtls_dhm_init(mbedtls_dhm_context *ctx)
This function initializes the DHM context.
int mbedtls_dhm_calc_secret(mbedtls_dhm_context *ctx, unsigned char *output, size_t output_size, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function derives and exports the shared secret (G^Y)^X mod P.
int mbedtls_dhm_make_params(mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a DHM key pair and exports its public part together with the DHM parameters i...
static const WCHAR pubkey[]
static void process_detach(void)
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
int mbedtls_dsa_set_group(mbedtls_dsa_context *ctx, const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *G)
This function sets the DSA group parameters.
int mbedtls_dsa_pubkey_from_privkey(mbedtls_dsa_context *ctx)
This function derived public key from private key.
int mbedtls_dsa_verify(mbedtls_dsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen)
This function reads and verifies a DSA signature.
int mbedtls_dsa_check_pubkey(const mbedtls_dsa_context *ctx)
This function checks if the public key is valid.
int mbedtls_dsa_sign(mbedtls_dsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function computes the DSA signature of a message hash.
void mbedtls_dsa_init(mbedtls_dsa_context *ctx)
This function initializes a DSA context.
int mbedtls_dsa_check_privkey(const mbedtls_dsa_context *ctx)
This function checks if the private key is valid.
int mbedtls_dsa_genkey(mbedtls_dsa_context *ctx, size_t group_size, size_t modulus_size, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a DSA keypair.
int mbedtls_dsa_check_pqg(const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *G)
This function checks if the DSA group parameters are valid.
void mbedtls_dsa_free(mbedtls_dsa_context *ctx)
This function frees a DSA context.
This file contains ECDH definitions and functions.
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
void mbedtls_ecdh_init(mbedtls_ecdh_context *ctx)
This function initializes an ECDH context.
int mbedtls_ecdh_compute_shared(mbedtls_ecp_group *grp, mbedtls_mpi *z, const mbedtls_ecp_point *Q, const mbedtls_mpi *d, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function computes the shared secret.
Entropy accumulator implementation.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble GLdouble q
GLenum const GLfloat * params
GLenum GLuint GLenum GLsizei const GLchar * buf
GLboolean GLboolean GLboolean GLboolean a
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
int mbedtls_asn1_get_mpi(unsigned char **p, const unsigned char *end, mbedtls_mpi *X)
Retrieve a MPI value from an integer ASN.1 tag. Updates the pointer to immediately behind the full ta...
#define MBEDTLS_ASN1_SEQUENCE
#define MBEDTLS_ASN1_INTEGER
#define MBEDTLS_ASN1_CONSTRUCTED
int mbedtls_asn1_get_len(unsigned char **p, const unsigned char *end, size_t *len)
Get the length of an ASN.1 element. Updates the pointer to immediately behind the length.
int mbedtls_asn1_get_tag(unsigned char **p, const unsigned char *end, size_t *len, int tag)
Get the tag and length of the tag. Check for the requested tag. Updates the pointer to immediately be...
void * wine_dlopen(const char *filename, int flag, char *error, size_t errorsize)
int wine_dlclose(void *handle, char *error, size_t errorsize)
This file contains the generic message-digest wrapper.
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
This function selects the message digest algorithm to use, and allocates internal structures.
mbedtls_md_type_t
Supported message digests.
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
This function starts a message-digest computation.
int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the HMAC operation, and writes the result to the output buffer.
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing message-digest computation.
int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing HMAC computation.
int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen)
This function sets the HMAC key and prepares to authenticate a new message.
void mbedtls_md_init(mbedtls_md_context_t *ctx)
This function initializes a message-digest context without binding it to a particular message-digest ...
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the digest operation, and writes the result to the output buffer.
unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info)
This function extracts the message-digest size from the message-digest information structure.
void mbedtls_md_free(mbedtls_md_context_t *ctx)
This function clears the internal structure of ctx and frees any embedded internal structure,...
#define memcpy(s1, s2, n)
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
#define STATUS_INTERNAL_ERROR
#define STATUS_AUTH_TAG_MISMATCH
#define STATUS_DLL_NOT_FOUND
#define STATUS_INVALID_SIGNATURE
Public Key abstraction layer.
int mbedtls_pk_parse_key(mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
Parse a private key in PEM or DER format.
mbedtls_pk_type_t
Public key types.
int mbedtls_pk_decrypt(mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Decrypt message (including padding if relevant).
static mbedtls_rsa_context * mbedtls_pk_rsa(const mbedtls_pk_context pk)
int mbedtls_pk_sign(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Make signature, including padding if relevant.
static mbedtls_ecp_keypair * mbedtls_pk_ec(const mbedtls_pk_context pk)
int mbedtls_pk_setup(mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info)
Initialize a PK context with the information given and allocates the type-specific PK subcontext.
int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options, mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature, with options. (Includes verification of the padding depending on type....
void mbedtls_pk_init(mbedtls_pk_context *ctx)
Initialize a mbedtls_pk_context (as NONE).
const mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type)
Return information associated with the given PK type.
mbedtls_pk_type_t mbedtls_pk_get_type(const mbedtls_pk_context *ctx)
Get the key type.
void mbedtls_pk_free(mbedtls_pk_context *ctx)
Free the components of a mbedtls_pk_context.
int mbedtls_pk_parse_public_key(mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen)
Parse a public key in PEM or DER format.
int mbedtls_pk_encrypt(mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Encrypt message (including padding if relevant).
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE
This file provides an API for the RSA public-key cryptosystem.
int mbedtls_rsa_complete(mbedtls_rsa_context *ctx)
This function completes an RSA context from a set of imported core parameters.
int mbedtls_rsa_check_pub_priv(const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv)
This function checks a public-private RSA key pair.
int mbedtls_rsa_import_raw(mbedtls_rsa_context *ctx, unsigned char const *N, size_t N_len, unsigned char const *P, size_t P_len, unsigned char const *Q, size_t Q_len, unsigned char const *D, size_t D_len, unsigned char const *E, size_t E_len)
This function imports core RSA parameters, in raw big-endian binary format, into an RSA context.
int mbedtls_rsa_gen_key(mbedtls_rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, unsigned int nbits, int exponent)
This function generates an RSA keypair.
int mbedtls_rsa_export(const mbedtls_rsa_context *ctx, mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q, mbedtls_mpi *D, mbedtls_mpi *E)
This function exports the core parameters of an RSA key.
int mbedtls_rsa_export_raw(const mbedtls_rsa_context *ctx, unsigned char *N, size_t N_len, unsigned char *P, size_t P_len, unsigned char *Q, size_t Q_len, unsigned char *D, size_t D_len, unsigned char *E, size_t E_len)
This function exports core parameters of an RSA key in raw big-endian binary format.
#define MBEDTLS_RSA_PKCS_V21
int mbedtls_rsa_export_crt(const mbedtls_rsa_context *ctx, mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP)
This function exports CRT parameters of a private RSA key.
int mbedtls_rsa_check_privkey(const mbedtls_rsa_context *ctx)
This function checks if a context contains an RSA private key and perform basic consistency checks.
int mbedtls_rsa_check_pubkey(const mbedtls_rsa_context *ctx)
This function checks if a context contains at least an RSA public key.
void mbedtls_rsa_set_padding(mbedtls_rsa_context *ctx, int padding, int hash_id)
This function sets padding for an already initialized RSA context. See mbedtls_rsa_init() for details...
static void * libmbedtls_handle
#define mbedtls_md_info_from_type
#define mbedtls_ctr_drbg_seed
#define mbedtls_ctr_drbg_random
#define mbedtls_entropy_free
#define mbedtls_ctr_drbg_init
#define mbedtls_entropy_init
#define mbedtls_entropy_func
#define mbedtls_cipher_info_from_type
#define mbedtls_ctr_drbg_free
This file provides an API for Elliptic Curves over GF(P) (ECP).
int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, const unsigned char *buf, size_t ilen)
This function imports a point from unsigned binary data.
int mbedtls_ecp_gen_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an ECP key.
int mbedtls_ecp_group_load(mbedtls_ecp_group *grp, mbedtls_ecp_group_id id)
This function sets up an ECP group context from a standardized set of domain parameters.
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function copies the contents of point Q into point P.
int mbedtls_ecp_check_pubkey(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt)
This function checks that a point is a valid public key on this curve.
@ MBEDTLS_ECP_DP_SECP384R1
@ MBEDTLS_ECP_DP_SECP256R1
int mbedtls_ecp_point_write_binary(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, int format, size_t *olen, unsigned char *buf, size_t buflen)
This function exports a point into unsigned binary data.
#define SONAME_LIBMBEDTLS
#define STATUS_BUFFER_TOO_SMALL
UINT64 private[PRIVATE_DATA_SIZE]
The CTR_DRBG context structure.
The DHM context structure.
The ECDH context structure.
The ECP key-pair structure.
Entropy context structure.
Options for RSASSA-PSS signature verification. See mbedtls_rsa_rsassa_pss_verify_ext()
mbedtls_md_type_t mgf1_hash_id
The RSA context structure.
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)