# MsCng Certificate Keys

**API Group:** `xmlsec_mscng_certkeys`

Certificate-based key handling for the MsCng back-end.

XDH (X25519) key support functions for Microsoft Cryptography API: Next Generation (CNG).

DSA key support functions for Microsoft Cryptography API: Next Generation (CNG).

DH key support functions for Microsoft Cryptography API: Next Generation (CNG).

Certificate keys support functions for Microsoft Cryptography API: Next Generation (CNG).

## Functions

### `xmlSecMSCngCertAdopt`

```c
xmlSecKeyDataPtr xmlSecMSCngCertAdopt(void *pCert, xmlSecKeyDataType type);
```

*Source:* [include/xmlsec/mscng/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscng/certkeys.h#L23)

Creates key data value from the cert.

**Parameters:**

- `pCert` — the pointer to cert.
- `type` — the expected key type.


**Returns:** pointer to newly created xmlsec key or NULL if an error occurs.

---

### `xmlSecMSCngKeyDataGetPubKey`

```c
void * xmlSecMSCngKeyDataGetPubKey(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscng/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscng/certkeys.h#L25)

Native MSCng public key retrieval from xmlsec keydata. The returned key must.

**Parameters:**

- `data` — the key data to retrieve certificate from.
not be destroyed by the caller.

**Returns:** key on success or 0 otherwise.

---

### `xmlSecMSCngKeyDataGetPrivKey`

```c
void * xmlSecMSCngKeyDataGetPrivKey(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscng/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscng/certkeys.h#L26)

Native MSCng private key retrieval from xmlsec keydata. The returned key.

**Parameters:**

- `data` — the key data to retrieve certificate from.
must not be destroyed by the caller.

**Returns:** key on success or 0 otherwise.

---
