# MsCrypto Certificate Keys

**API Group:** `xmlsec_mscrypto_certkeys`

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

Certificate keys support functions for Microsoft Crypto API.

## Functions

### `xmlSecMSCryptoKeyDataGetCert`

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

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

Native MSCrypto certificate retrieval from xmlsec keydata. The.

**Parameters:**

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

**Returns:** PCCERT_CONTEXT on success or NULL otherwise.

---

### `xmlSecMSCryptoKeyDataGetKey`

```c
void * xmlSecMSCryptoKeyDataGetKey(xmlSecKeyDataPtr data, xmlSecKeyDataType type);
```

*Source:* [include/xmlsec/mscrypto/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/mscrypto/certkeys.h#L24)

Native MSCrypto key retrieval from xmlsec keydata. The.

**Parameters:**

- `data` — the key data to retrieve certificate from.
- `type` — type of key requested (public/private)
returned HKEY must not be destroyed by the caller.

**Returns:** HKEY on success or NULL otherwise.

---

### `xmlSecMSCryptoKeyDataGetDecryptKey`

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

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

Native MSCrypto decrypt key retrieval from xmlsec keydata. The.

**Parameters:**

- `data` — the key data pointer
returned HKEY must not be destroyed by the caller.

**Returns:** HKEY on success or NULL otherwise.

---

### `xmlSecMSCryptoCertDup`

```c
void * xmlSecMSCryptoCertDup(void *pCert);
```

*Source:* [include/xmlsec/mscrypto/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/mscrypto/certkeys.h#L27)

Duplicates the `pCert`.

**Parameters:**

- `pCert` — the pointer to cert.


**Returns:** pointer to newly created PCCERT_CONTEXT object or NULL if an error occurs.

---

### `xmlSecMSCryptoCertAdopt`

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

*Source:* [include/xmlsec/mscrypto/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/mscrypto/certkeys.h#L28)

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.

---

### `xmlSecMSCryptoKeyDataGetMSCryptoProvider`

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

*Source:* [include/xmlsec/mscrypto/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/mscrypto/certkeys.h#L31)

Gets crypto provider handle.

**Parameters:**

- `data` — the key data


**Returns:** the crypto provider handler or 0 if there is an error.

---

### `xmlSecMSCryptoKeyDataGetMSCryptoKeySpec`

```c
unsigned long xmlSecMSCryptoKeyDataGetMSCryptoKeySpec(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscrypto/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/mscrypto/certkeys.h#L32)

Gets key spec info.

**Parameters:**

- `data` — the key data


**Returns:** the key spec info from key data

---

### `xmlSecMSCryptoKeyDataGetMSCryptoProviderInfo`

```c
PCRYPT_KEY_PROV_INFO xmlSecMSCryptoKeyDataGetMSCryptoProviderInfo(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscrypto/certkeys.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/mscrypto/certkeys.h#L33)

Gets key provider info.

**Parameters:**

- `data` — the key data


**Returns:** the key provider info.

---
