# NSS PKI Keys

**API Group:** `xmlsec_nss_pkikeys`

PKI key-data handling for the NSS back-end.

Private/public keys implementation for NSS.

## Functions

### `xmlSecNssPKIAdoptKey`

```c
xmlSecKeyDataPtr xmlSecNssPKIAdoptKey(SECKEYPrivateKey *privkey, SECKEYPublicKey *pubkey);
```

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

Build a KeyData object from the given Private Key and Public.

**Parameters:**

- `privkey` — the NSS Private Key handle
- `pubkey` — the NSS Public Key handle
Key handles.

**Returns:** pointer to KeyData object or NULL if an error occurs.

---

### `xmlSecNssPKIKeyDataGetPubKey`

```c
SECKEYPublicKey * xmlSecNssPKIKeyDataGetPubKey(xmlSecKeyDataPtr data);
```

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

Gets the Public Key from the key data.

**Parameters:**

- `data` — the pointer to NSS Key data.


**Returns:** pointer to SECKEYPublicKey or NULL if an error occurs. Caller is responsible for freeing the key when done

---

### `xmlSecNssPKIKeyDataGetPrivKey`

```c
SECKEYPrivateKey * xmlSecNssPKIKeyDataGetPrivKey(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/nss/pkikeys.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/nss/pkikeys.h#L28)

Gets the Private Key from the key data.

**Parameters:**

- `data` — the pointer to NSS Key data.


**Returns:** pointer to SECKEYPrivateKey or NULL if an error occurs. Caller is responsible for freeing the key when done

---

### `xmlSecNssPKIKeyDataGetKeyType`

```c
KeyType xmlSecNssPKIKeyDataGetKeyType(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/nss/pkikeys.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/nss/pkikeys.h#L30)

Gets the Key Type from the key data.

**Parameters:**

- `data` — the pointer to NSS Key data.


**Returns:** Key Type

---

### `xmlSecNssPKIKeyDataDuplicate`

```c
int xmlSecNssPKIKeyDataDuplicate(xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src);
```

*Source:* [include/xmlsec/nss/pkikeys.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/nss/pkikeys.h#L32)

Duplicates the keydata from src to dst.

xmlSecNssPKIKeyDataDuplicate 

**Parameters:**

- `dst` — the pointer to NSS Key data to copy to.
- `src` — the pointer to NSS Key data to copy from.

**Returns:** -1 on error, 0 on success

---
