# Key Data

**API Group:** `xmlsec_core_keysdata`

Key data containers and key-data processing.

Crypto key data object functions.

## Macros

### `xmlSecKeyDataUsageUnknown`

*Defined as:* `0x00000`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L76)

The key data usage is unknown.

---

### `xmlSecKeyDataUsageKeyInfoNodeRead`

*Defined as:* `0x00001`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L82)

The key data can be read from a KeyInfo child.

The key data could be read from a <dsig:KeyInfo/> child.

---

### `xmlSecKeyDataUsageKeyInfoNodeWrite`

*Defined as:* `0x00002`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L88)

The key data can be written to a KeyInfo child.

The key data could be written to a <dsig:KeyInfo /> child.

---

### `xmlSecKeyDataUsageKeyValueNodeRead`

*Defined as:* `0x00004`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L94)

The key data can be read from a KeyValue child.

The key data could be read from a <dsig:KeyValue /> child.

---

### `xmlSecKeyDataUsageKeyValueNodeWrite`

*Defined as:* `0x00008`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L100)

The key data can be written to a KeyValue child.

The key data could be written to a <dsig:KeyValue /> child.

---

### `xmlSecKeyDataUsageRetrievalMethodNodeXml`

*Defined as:* `0x00010`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L107)

The key data can be retrieved via RetrievalMethod in XML format.

The key data could be retrieved using <dsig:RetrievalMethod /> node in XML format.

---

### `xmlSecKeyDataUsageRetrievalMethodNodeBin`

*Defined as:* `0x00020`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L114)

The key data can be retrieved via RetrievalMethod in binary format.

The key data could be retrieved using <dsig:RetrievalMethod /> node in binary format.

---

### `xmlSecKeyDataUsageReadFromFile`

*Defined as:* `0x00040`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L119)

The key data could be read from a file.

---

### `xmlSecKeyDataUsageAny`

*Defined as:* `0xFFFFF`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L124)

Any key data usage.

---

### `xmlSecKeyDataUsageKeyInfoNode`

*Defined as:* `(xmlSecKeyDataUsageKeyInfoNodeRead | xmlSecKeyDataUsageKeyInfoNodeWrite)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L130)

The key data can be read and written from/to a KeyInfo child.

The key data could be read and written from/to a <dsig:KeyInfo /> child.

---

### `xmlSecKeyDataUsageKeyValueNode`

*Defined as:* `(xmlSecKeyDataUsageKeyValueNodeRead | xmlSecKeyDataUsageKeyValueNodeWrite)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L137)

The key data can be read and written from/to a KeyValue child.

The key data could be read and written from/to a <dsig:KeyValue /> child.

---

### `xmlSecKeyDataUsageRetrievalMethodNode`

*Defined as:* `(xmlSecKeyDataUsageRetrievalMethodNodeXml | xmlSecKeyDataUsageRetrievalMethodNodeBin)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L145)

The key data can be retrieved via RetrievalMethod in any format.

The key data could be retrieved using <dsig:RetrievalMethod /> node in any format.

---

### `xmlSecKeyDataTypeUnknown`

*Defined as:* `0x0000`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L163)

The key data type is unknown (same as none).

The key data type is unknown (same as `xmlSecKeyDataTypeNone`).

---

### `xmlSecKeyDataTypeNone`

*Defined as:* `xmlSecKeyDataTypeUnknown`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L169)

The key data type is unknown (same as unknown).

The key data type is unknown (same as `xmlSecKeyDataTypeUnknown`).

---

### `xmlSecKeyDataTypePublic`

*Defined as:* `0x0001`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L174)

The key data contain a public key.

---

### `xmlSecKeyDataTypePrivate`

*Defined as:* `0x0002`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L179)

The key data contain a private key.

---

### `xmlSecKeyDataTypeSymmetric`

*Defined as:* `0x0004`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L184)

The key data contain a symmetric key.

---

### `xmlSecKeyDataTypeSession`

*Defined as:* `0x0008`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L190)

The key data contains a session (one-time) key.

The key data contain session key (one time key, not stored in keys manager).

---

### `xmlSecKeyDataTypePermanent`

*Defined as:* `0x0010`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L196)

The key data contains a permanent key.

The key data contain permanent key (stored in keys manager).

---

### `xmlSecKeyDataTypeTrusted`

*Defined as:* `0x0100`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L201)

The key data is trusted.

---

### `xmlSecKeyDataTypeAny`

*Defined as:* `0xFFFF`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L206)

Any key data.

---

### `xmlSecKeyDataGetName`

*Defined as:* `((xmlSecKeyDataIsValid((data))) ? \
          xmlSecKeyDataKlassGetName((data)->id) : NULL)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L297)

Macro. Returns the key data name.

**Parameters:**

- `data` — the pointer to key data.

---

### `xmlSecKeyDataIsValid`

*Defined as:* `((( data ) != NULL) && \
         (( data )->id != NULL) && \
         (( data )->id->klassSize >= sizeof(xmlSecKeyDataKlass)) && \
         (( data )->id->objSize >= sizeof(xmlSecKeyData)) && \
         (( data )->id->name != NULL))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L307)

Macro. Returns 1 if `data` is valid.

Macro. Returns 1 if `data` is not NULL and `data->id` is not NULL or 0 otherwise. 

**Parameters:**

- `data` — the pointer to data.

---

### `xmlSecKeyDataCheckId`

*Defined as:* `(xmlSecKeyDataIsValid(( data )) && \
        ((( data )->id) == ( dataId )))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L320)

Macro. Returns 1 if `data's` id equals `dataId`.

Macro. Returns 1 if `data` is valid and `data's` id is equal to `dataId`. 

**Parameters:**

- `data` — the pointer to data.
- `dataId` — the data Id.

---

### `xmlSecKeyDataCheckUsage`

*Defined as:* `(xmlSecKeyDataIsValid(( data )) && \
        (((( data )->id->usage) & ( usg )) != 0))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L330)

Macro. Returns 1 if `data` can be used for `usg`.

Macro. Returns 1 if `data` is valid and could be used for `usg`. 

**Parameters:**

- `data` — the pointer to data.
- `usg` — the data usage.

---

### `xmlSecKeyDataCheckSize`

*Defined as:* `(xmlSecKeyDataIsValid(( data )) && \
         (( data )->id->objSize >= size))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L340)

Macro. Returns 1 if `data's` object has at least `size` bytes.

Macro. Returns 1 if `data` is valid and `data's` object has at least `size` bytes. 

**Parameters:**

- `data` — the pointer to data.
- `size` — the expected size.

---

### `xmlSecKeyDataIdUnknown`

*Defined as:* `((xmlSecKeyDataId)NULL)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L352)

The "unknown" id.

---

### `xmlSecKeyDataKlassGetName`

*Defined as:* `(((klass)) ? ((klass)->name) : NULL)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L511)

Macro. Returns data klass name.

**Parameters:**

- `klass` — the data klass.

---

### `xmlSecKeyDataListId`

*Defined as:* `xmlSecKeyDataListGetKlass()`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L535)

The key data klasses list klass id.

---

### `xmlSecKeyDataIdListId`

*Defined as:* `xmlSecKeyDataIdListGetKlass()`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L546)

The key data list klass id.

---

### `xmlSecKeyDataStoreGetName`

*Defined as:* `((xmlSecKeyDataStoreIsValid((store))) ? \
      xmlSecKeyDataStoreKlassGetName((store)->id) : NULL)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L592)

Macro. Returns key data store name.

**Parameters:**

- `store` — the pointer to store.

---

### `xmlSecKeyDataStoreIsValid`

*Defined as:* `((( store ) != NULL) && ((( store )->id) != NULL))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L602)

Macro. Returns 1 if `store` is valid.

Macro. Returns 1 if `store` is not NULL and `store->id` is not NULL or 0 otherwise. 

**Parameters:**

- `store` — the pointer to store.

---

### `xmlSecKeyDataStoreCheckId`

*Defined as:* `(xmlSecKeyDataStoreIsValid(( store )) && \
        ((( store )->id) == ( storeId )))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L610)

Macro. Returns 1 if `store's` id equals `storeId`.

Macro. Returns 1 if `store` is valid and `store's` id is equal to `storeId`. 

**Parameters:**

- `store` — the pointer to store.
- `storeId` — the store Id.

---

### `xmlSecKeyDataStoreCheckSize`

*Defined as:* `(xmlSecKeyDataStoreIsValid(( store )) && \
         (( store )->id->objSize >= size))`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L620)

Macro. Returns 1 if `store's` object has at least `size` bytes.

Macro. Returns 1 if `data` is valid and `stores's` object has at least `size` bytes. 

**Parameters:**

- `store` — the pointer to store.
- `size` — the expected size.

---

### `xmlSecKeyDataStoreIdUnknown`

*Defined as:* `NULL`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L633)

The "unknown" id.

---

### `xmlSecKeyDataStoreKlassGetName`

*Defined as:* `(((klass)) ? ((klass)->name) : NULL)`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L672)

Macro. Returns store klass name.

**Parameters:**

- `klass` — the pointer to store klass.

---

### `xmlSecKeyDataStorePtrListId`

*Defined as:* `xmlSecKeyDataStorePtrListGetKlass()`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L683)

The data store list id (klass).

---

## Typedefs

### `xmlSecKeyDataKlass`

```c
typedef const struct _xmlSecKeyDataKlass xmlSecKeyDataKlass;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L30)

The key data klass.

---

### `xmlSecKeyDataId`

```c
typedef const struct _xmlSecKeyDataKlass* xmlSecKeyDataId;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L34)

Pointer to `xmlSecKeyDataKlass`.

---

### `xmlSecKeyDataStoreKlass`

```c
typedef const struct _xmlSecKeyDataStoreKlass xmlSecKeyDataStoreKlass;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L38)

The key data store klass.

---

### `xmlSecKeyDataStoreId`

```c
typedef const struct _xmlSecKeyDataStoreKlass* xmlSecKeyDataStoreId;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L42)

Pointer to `xmlSecKeyDataStoreKlass`.

---

### `xmlSecKeyDataList`

```c
typedef struct _xmlSecKeyDataList xmlSecKeyDataList;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L46)

The key data list.

---

### `xmlSecKeyDataListPtr`

```c
typedef struct _xmlSecKeyDataList* xmlSecKeyDataListPtr;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L50)

Pointer to `xmlSecKeyDataList`.

---

### `xmlSecKeyDataUsage`

```c
typedef unsigned int xmlSecKeyDataUsage;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L71)

The key data usage bitmask.

The bits mask that determines possible keys data usage.

---

### `xmlSecKeyDataType`

```c
typedef unsigned int xmlSecKeyDataType;
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L157)

The key data type.

The key data type (public/private, session/permanent, etc.).

---

### `xmlSecKeyDataInitMethod`

```c
typedef int(* xmlSecKeyDataInitMethod) (xmlSecKeyDataPtr data))(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L359)

Key data specific initialization method.

**Parameters:**

- `data` — the pointer to key data.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataDuplicateMethod`

```c
typedef int(* xmlSecKeyDataDuplicateMethod) (xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src))(xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L367)

Key data specific duplication (copy) method.

**Parameters:**

- `dst` — the pointer to destination key data.
- `src` — the pointer to source key data.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataFinalizeMethod`

```c
typedef void(* xmlSecKeyDataFinalizeMethod) (xmlSecKeyDataPtr data))(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L376)

Key data specific finalization method.

Key data specific finalization method. All the objects and resources allocated by the key data object must be freed inside this method. 

**Parameters:**

- `data` — the data.

---

### `xmlSecKeyDataXmlReadMethod`

```c
typedef int(* xmlSecKeyDataXmlReadMethod) (xmlSecKeyDataId id, xmlSecKeyPtr key, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx))(xmlSecKeyDataId id, xmlSecKeyPtr key, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L386)

Key data specific method for reading XML node.

**Parameters:**

- `id` — the data id.
- `key` — the key.
- `node` — the pointer to data's value XML node.
- `keyInfoCtx` — the <dsig:KeyInfo/> node processing context.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataXmlWriteMethod`

```c
typedef int(* xmlSecKeyDataXmlWriteMethod) (xmlSecKeyDataId id, xmlSecKeyPtr key, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx))(xmlSecKeyDataId id, xmlSecKeyPtr key, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L398)

Key data specific method for writing XML node.

**Parameters:**

- `id` — the data id.
- `key` — the key.
- `node` — the pointer to data's value XML node.
- `keyInfoCtx` — the <dsig:KeyInfo/> node processing context.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataBinReadMethod`

```c
typedef int(* xmlSecKeyDataBinReadMethod) (xmlSecKeyDataId id, xmlSecKeyPtr key, const xmlSecByte *buf, xmlSecSize bufSize, xmlSecKeyInfoCtxPtr keyInfoCtx))(xmlSecKeyDataId id, xmlSecKeyPtr key, const xmlSecByte *buf, xmlSecSize bufSize, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L412)

Key data specific method to read a binary buffer.

Key data specific method for reading binary buffer. 

**Parameters:**

- `id` — the data id.
- `key` — the key.
- `buf` — the input buffer.
- `bufSize` — the buffer size.
- `keyInfoCtx` — the <dsig:KeyInfo/> node processing context.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataBinWriteMethod`

```c
typedef int(* xmlSecKeyDataBinWriteMethod) (xmlSecKeyDataId id, xmlSecKeyPtr key, xmlSecByte **buf, xmlSecSize *bufSize, xmlSecKeyInfoCtxPtr keyInfoCtx))(xmlSecKeyDataId id, xmlSecKeyPtr key, xmlSecByte **buf, xmlSecSize *bufSize, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L427)

Key data specific method to write a binary buffer.

Key data specific method for reading binary buffer. 

**Parameters:**

- `id` — the data id.
- `key` — the key.
- `buf` — the output buffer.
- `bufSize` — the buffer size.
- `keyInfoCtx` — the <dsig:KeyInfo/> node processing context.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataGenerateMethod`

```c
typedef int(* xmlSecKeyDataGenerateMethod) (xmlSecKeyDataPtr data, xmlSecSize sizeBits, xmlSecKeyDataType type))(xmlSecKeyDataPtr data, xmlSecSize sizeBits, xmlSecKeyDataType type);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L441)

Key data specific key generation method.

Key data specific method for generating new key data. 

**Parameters:**

- `data` — the pointer to key data.
- `sizeBits` — the key data specific size.
- `type` — the required key type (session/permanent, etc.)


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataGetTypeMethod`

```c
typedef xmlSecKeyDataType(* xmlSecKeyDataGetTypeMethod) (xmlSecKeyDataPtr data))(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L450)

Key data specific method to get the key type.

**Parameters:**

- `data` — the data.


**Returns:** the key type.

---

### `xmlSecKeyDataGetSizeMethod`

```c
typedef xmlSecSize(* xmlSecKeyDataGetSizeMethod) (xmlSecKeyDataPtr data))(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L457)

Key data specific method to get the key size.

**Parameters:**

- `data` — the pointer to key data.


**Returns:** the key size in bits.

---

### `xmlSecKeyDataDebugDumpMethod`

```c
typedef void(* xmlSecKeyDataDebugDumpMethod) (xmlSecKeyDataPtr data, FILE *output))(xmlSecKeyDataPtr data, FILE *output);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L464)

Key data specific method for printing debug info.

**Parameters:**

- `data` — the data.
- `output` — the FILE to print debug info (should be open for writing).

---

### `xmlSecKeyDataStoreInitializeMethod`

```c
typedef int(* xmlSecKeyDataStoreInitializeMethod) (xmlSecKeyDataStorePtr store))(xmlSecKeyDataStorePtr store);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L640)

Key data store specific initialization method.

**Parameters:**

- `store` — the data store.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataStoreFinalizeMethod`

```c
typedef void(* xmlSecKeyDataStoreFinalizeMethod) (xmlSecKeyDataStorePtr store))(xmlSecKeyDataStorePtr store);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L647)

Key data store specific finalization method.

Key data store specific finalization (destroy) method. 

**Parameters:**

- `store` — the data store.

---

## Enumerations

### `xmlSecKeyDataFormat`

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L216)

The key data format (binary, der, pem, etc.).

| Value | Initializer | Description |
|-------|-------------|-------------|
| `xmlSecKeyDataFormatUnknown` | `= 0` |  |
| `xmlSecKeyDataFormatBinary` | `` |  |
| `xmlSecKeyDataFormatPem` | `` |  |
| `xmlSecKeyDataFormatDer` | `` |  |
| `xmlSecKeyDataFormatPkcs8Pem` | `` |  |
| `xmlSecKeyDataFormatPkcs8Der` | `` |  |
| `xmlSecKeyDataFormatPkcs12` | `` |  |
| `xmlSecKeyDataFormatCertPem` | `` |  |
| `xmlSecKeyDataFormatCertDer` | `` |  |
| `xmlSecKeyDataFormatEngine` | `` |  |
| `xmlSecKeyDataFormatStore` | `` |  |

---

## Functions

### `xmlSecKeyDataIdsGet`

```c
xmlSecPtrListPtr xmlSecKeyDataIdsGet(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L235)

Gets global registered key data klasses list.

**Returns:** the pointer to list of all registered key data klasses.

---

### `xmlSecKeyDataIdsGetEnabled`

```c
xmlSecPtrListPtr xmlSecKeyDataIdsGetEnabled(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L236)

Gets global enabled key data klasses list.

**Returns:** the pointer to list of all enabled key data klasses.

---

### `xmlSecKeyDataIdsInit`

```c
int xmlSecKeyDataIdsInit(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L237)

Initializes the key data klasses.

Initializes the key data klasses. This function is called from the `xmlSecInit` function and the application should not call it directly.

**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataIdsShutdown`

```c
void xmlSecKeyDataIdsShutdown(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L238)

Shuts down the key data klasses.

Shuts down the keys data klasses. This function is called from the `xmlSecShutdown` function and the application should not call it directly.

---

### `xmlSecKeyDataIdsRegisterDefault`

```c
int xmlSecKeyDataIdsRegisterDefault(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L239)

Registers default key data klasses.

Registers default (implemented by XML Security Library) key data klasses: <dsig:KeyName/> element processing klass, <dsig:KeyValue/> element processing klass, ...

**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataIdsRegister`

```c
int xmlSecKeyDataIdsRegister(xmlSecKeyDataId id);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L240)

Registers a key data klass in the global list (enabled).

Registers `id` in the global list of key data klasses and enable this key data. 

**Parameters:**

- `id` — the key data klass.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataIdsRegisterDisabled`

```c
int xmlSecKeyDataIdsRegisterDisabled(xmlSecKeyDataId id);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L241)

Registers a key data klass in the global list (disabled).

Registers `id` in the global list of key data klasses and but DO NOT enable this key data. 

**Parameters:**

- `id` — the key data klass.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataCreate`

```c
xmlSecKeyDataPtr xmlSecKeyDataCreate(xmlSecKeyDataId id);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L258)

Allocates and initializes new key data of the specified type.

Allocates and initializes new key data of the specified type `id`. Caller is responsible for destroying returned object with `xmlSecKeyDataDestroy` function. 

**Parameters:**

- `id` — the data id.


**Returns:** the pointer to newly allocated key data structure or NULL if an error occurs.

---

### `xmlSecKeyDataDuplicate`

```c
xmlSecKeyDataPtr xmlSecKeyDataDuplicate(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L259)

Creates a duplicate of the given key data.

Creates a duplicate of the given `data`. Caller is responsible for destroying returned object with `xmlSecKeyDataDestroy` function. 

**Parameters:**

- `data` — the pointer to the key data.


**Returns:** the pointer to newly allocated key data structure or NULL if an error occurs.

---

### `xmlSecKeyDataDestroy`

```c
void xmlSecKeyDataDestroy(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L260)

Destroys the data and frees all allocated memory.

**Parameters:**

- `data` — the pointer to the key data.

---

### `xmlSecKeyDataGenerate`

```c
int xmlSecKeyDataGenerate(xmlSecKeyDataPtr data, xmlSecSize sizeBits, xmlSecKeyDataType type);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L261)

Generates new key data of given size and type.

**Parameters:**

- `data` — the pointer to key data.
- `sizeBits` — the desired key data size (in bits).
- `type` — the desired key data type.


**Returns:** 0 on success or a negative value otherwise.

---

### `xmlSecKeyDataGetType`

```c
xmlSecKeyDataType xmlSecKeyDataGetType(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L264)

Gets key data type.

**Parameters:**

- `data` — the pointer to key data.


**Returns:** key data type.

---

### `xmlSecKeyDataGetSize`

```c
xmlSecSize xmlSecKeyDataGetSize(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L265)

Gets key data size (in bits).

**Parameters:**

- `data` — the pointer to key data.


**Returns:** key data size (in bits).

---

### `xmlSecKeyDataDebugDump`

```c
void xmlSecKeyDataDebugDump(xmlSecKeyDataPtr data, FILE *output);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L267)

Prints key data debug info.

**Parameters:**

- `data` — the pointer to key data.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyDataDebugXmlDump`

```c
void xmlSecKeyDataDebugXmlDump(xmlSecKeyDataPtr data, FILE *output);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L269)

Prints key data debug info in XML format.

**Parameters:**

- `data` — the pointer to key data.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyDataXmlRead`

```c
int xmlSecKeyDataXmlRead(xmlSecKeyDataId id, xmlSecKeyPtr key, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L272)

Reads key data from an XML node into a key.

Reads the key data of klass `id` from XML `node` and adds them to `key`. 

**Parameters:**

- `id` — the data klass.
- `key` — the destination key.
- `node` — the pointer to an XML node.
- `keyInfoCtx` — the pointer to <dsig:KeyInfo/> element processing context.


**Returns:** 0 on success or a negative value otherwise.

---

### `xmlSecKeyDataXmlWrite`

```c
int xmlSecKeyDataXmlWrite(xmlSecKeyDataId id, xmlSecKeyPtr key, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L276)

Writes key data from a key into an XML node.

Writes the key data of klass `id` from `key` to an XML `node`. 

**Parameters:**

- `id` — the data klass.
- `key` — the source key.
- `node` — the pointer to an XML node.
- `keyInfoCtx` — the pointer to <dsig:KeyInfo/> element processing context.


**Returns:** 0 on success or a negative value otherwise.

---

### `xmlSecKeyDataBinRead`

```c
int xmlSecKeyDataBinRead(xmlSecKeyDataId id, xmlSecKeyPtr key, const xmlSecByte *buf, xmlSecSize bufSize, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L281)

Reads key data from a binary buffer into a key.

Reads the key data of klass `id` from binary buffer `buf` to `key`. 

**Parameters:**

- `id` — the data klass.
- `key` — the destination key.
- `buf` — the input binary buffer.
- `bufSize` — the input buffer size.
- `keyInfoCtx` — the <dsig:KeyInfo/> node processing context.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataBinWrite`

```c
int xmlSecKeyDataBinWrite(xmlSecKeyDataId id, xmlSecKeyPtr key, xmlSecByte **buf, xmlSecSize *bufSize, xmlSecKeyInfoCtxPtr keyInfoCtx);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L286)

Writes key data from a key into a binary buffer.

Writes the key data of klass `id` from the `key` to a binary buffer `buf`. 

**Parameters:**

- `id` — the data klass.
- `key` — the source key.
- `buf` — the output binary buffer.
- `bufSize` — the output buffer size.
- `keyInfoCtx` — the <dsig:KeyInfo/> node processing context.


**Returns:** 0 on success or a negative value if an error occurs.

---

### `xmlSecKeyDataBinaryValueGetSize`

```c
xmlSecSize xmlSecKeyDataBinaryValueGetSize(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L521)

Gets the binary key data size.

**Parameters:**

- `data` — the pointer to binary key data.


**Returns:** binary key data size in bits.

---

### `xmlSecKeyDataBinaryValueGetBuffer`

```c
xmlSecBufferPtr xmlSecKeyDataBinaryValueGetBuffer(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L522)

Gets the binary key data buffer.

**Parameters:**

- `data` — the pointer to binary key data.


**Returns:** pointer to binary key data buffer.

---

### `xmlSecKeyDataBinaryValueSetBuffer`

```c
int xmlSecKeyDataBinaryValueSetBuffer(xmlSecKeyDataPtr data, const xmlSecByte *buf, xmlSecSize bufSize);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L523)

Sets the value of `data` to `buf`.

**Parameters:**

- `data` — the pointer to binary key data.
- `buf` — the pointer to binary buffer.
- `bufSize` — the binary buffer size.


**Returns:** 0 on success or a negative value otherwise.

---

### `xmlSecKeyDataListGetKlass`

```c
xmlSecPtrListId xmlSecKeyDataListGetKlass(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L536)

The key data list klass.

**Returns:** pointer to the key data list klass.

---

### `xmlSecKeyDataIdListGetKlass`

```c
xmlSecPtrListId xmlSecKeyDataIdListGetKlass(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L547)

The key data id list klass.

**Returns:** pointer to the key data id list klass.

---

### `xmlSecKeyDataIdListFind`

```c
int xmlSecKeyDataIdListFind(xmlSecPtrListPtr list, xmlSecKeyDataId dataId);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L548)

Lookups `dataId` in `list`.

**Parameters:**

- `list` — the pointer to key data ids list.
- `dataId` — the key data klass.


**Returns:** 1 if `dataId` is found in the `list`, 0 if not and a negative value if an error occurs.

---

### `xmlSecKeyDataIdListFindByNode`

```c
xmlSecKeyDataId xmlSecKeyDataIdListFindByNode(xmlSecPtrListPtr list, const xmlChar *nodeName, const xmlChar *nodeNs, xmlSecKeyDataUsage usage);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L550)

Looks up a key data klass by XML node name, namespace, and usage.

Lookups data klass in the list with given `nodeName`, `nodeNs` and `usage` in the `list`. 

**Parameters:**

- `list` — the pointer to key data ids list.
- `nodeName` — the desired key data klass XML node name.
- `nodeNs` — the desired key data klass XML node namespace.
- `usage` — the desired key data usage.


**Returns:** key data klass is found and NULL otherwise.

---

### `xmlSecKeyDataIdListFindByHref`

```c
xmlSecKeyDataId xmlSecKeyDataIdListFindByHref(xmlSecPtrListPtr list, const xmlChar *href, xmlSecKeyDataUsage usage);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L554)

Looks up a key data klass by href and usage.

Lookups data klass in the list with given `href` and `usage` in `list`. 

**Parameters:**

- `list` — the pointer to key data ids list.
- `href` — the desired key data klass href.
- `usage` — the desired key data usage.


**Returns:** key data klass is found and NULL otherwise.

---

### `xmlSecKeyDataIdListFindByName`

```c
xmlSecKeyDataId xmlSecKeyDataIdListFindByName(xmlSecPtrListPtr list, const xmlChar *name, xmlSecKeyDataUsage usage);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L557)

Looks up a key data klass by name and usage.

Lookups data klass in the list with given `name` and `usage` in `list`. 

**Parameters:**

- `list` — the pointer to key data ids list.
- `name` — the desired key data klass name.
- `usage` — the desired key data usage.


**Returns:** key data klass is found and NULL otherwise.

---

### `xmlSecKeyDataIdListDebugDump`

```c
void xmlSecKeyDataIdListDebugDump(xmlSecPtrListPtr list, FILE *output);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L560)

Prints key data ID list debug information.

Prints binary key data debug information to `output`. 

**Parameters:**

- `list` — the pointer to key data ids list.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyDataIdListDebugXmlDump`

```c
void xmlSecKeyDataIdListDebugXmlDump(xmlSecPtrListPtr list, FILE *output);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L562)

Prints key data ID list debug information in XML format.

Prints binary key data debug information to `output` in XML format. 

**Parameters:**

- `list` — the pointer to key data ids list.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyDataStoreCreate`

```c
xmlSecKeyDataStorePtr xmlSecKeyDataStoreCreate(xmlSecKeyDataStoreId id);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L585)

Creates a new key data store of the specified klass.

Creates new key data store of the specified klass `id`. Caller is responsible for freeing returned object with `xmlSecKeyDataStoreDestroy` function. 

**Parameters:**

- `id` — the store id.


**Returns:** the pointer to newly allocated key data store structure or NULL if an error occurs.

---

### `xmlSecKeyDataStoreDestroy`

```c
void xmlSecKeyDataStoreDestroy(xmlSecKeyDataStorePtr store);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L586)

Destroys a key data store.

Destroys the key data store created with `xmlSecKeyDataStoreCreate` function. 

**Parameters:**

- `store` — the pointer to the key data store..

---

### `xmlSecKeyDataStorePtrListGetKlass`

```c
xmlSecPtrListId xmlSecKeyDataStorePtrListGetKlass(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L684)

Key data stores list.

**Returns:** key data stores list klass.

---

### `xmlSecImportSetPersistKey`

```c
void xmlSecImportSetPersistKey(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L686)

Sets global flag to import keys to persistent storage.

Sets global flag to import keys to persistent storage (MSCrypto and MSCNG). Also see PKCS12_NO_PERSIST_KEY.

---

### `xmlSecImportGetPersistKey`

```c
int xmlSecImportGetPersistKey(void);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L687)

Gets global flag for importing keys to persistent storage.

Gets global flag to import keys to persistent storage (MSCrypto and MSCNG). Also see PKCS12_NO_PERSIST_KEY.

**Returns:** 1 if keys should be imported into persistent storage and 0 otherwise.

---

### `xmlSecKeyDataGetIdentifier`

```c
const xmlChar * xmlSecKeyDataGetIdentifier(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/keysdata.h](https://github.com/lsh123/xmlsec/blob/1.3.11/include/xmlsec/keysdata.h#L695)

DEPRECATED. Gets key data identifier string.

**Parameters:**

- `data` — the pointer to key data.


**Returns:** key data id string.

---
