# Keys

**API Group:** `xmlsec_core_keys`

Key objects and key management.

Crypto key object functions.

## Macros

### `xmlSecKeyUsageSign`

*Defined as:* `0x00000001`

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

Key for signing.

---

### `xmlSecKeyUsageVerify`

*Defined as:* `0x00000002`

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

Key for signature verification.

---

### `xmlSecKeyUsageEncrypt`

*Defined as:* `0x00000004`

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

An encryption key.

---

### `xmlSecKeyUsageDecrypt`

*Defined as:* `0x00000008`

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

A decryption key.

---

### `xmlSecKeyUsageKeyExchange`

*Defined as:* `0x00000010`

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

Deprecated. The key is used for key exchange.

---

### `xmlSecKeyUsageKeyDerive`

*Defined as:* `0x00000020`

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

The key is used for key derivation.

---

### `xmlSecKeyUsageKeyAgreement`

*Defined as:* `0x00000040`

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

The key is used for key agreement.

---

### `xmlSecKeyUsageAny`

*Defined as:* `0xFFFFFFFF`

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

Key can be used in any way.

---

### `xmlSecKeyUseWithPtrListId`

*Defined as:* `xmlSecKeyUseWithPtrListGetKlass()`

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

The keys list klass.

---

### `xmlSecKeyIsValid`

*Defined as:* `((( key ) != NULL) && \
         (( key )->value != NULL) && \
         ((( key )->value->id) != NULL))`

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

Macro. Returns 1 if `key` is valid.

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

**Parameters:**

- `key` — the pointer to key.

---

### `xmlSecKeyCheckId`

*Defined as:* `(xmlSecKeyIsValid(( key )) && \
        ((( key )->value->id) == ( keyId )))`

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

Macro. Returns 1 if `key's` id equals `keyId`.

Macro. Returns 1 if `key` is valid and `key's` id is equal to `keyId`. 

**Parameters:**

- `key` — the pointer to key.
- `keyId` — the key Id.

---

### `xmlSecKeyPtrListId`

*Defined as:* `xmlSecKeyPtrListGetKlass()`

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

The keys list klass.

---

## Typedefs

### `xmlSecKeyUsage`

```c
typedef unsigned int xmlSecKeyUsage;
```

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

The key usage.

---

## Functions

### `xmlSecKeyUseWithInitialize`

```c
int xmlSecKeyUseWithInitialize(xmlSecKeyUseWithPtr keyUseWith);
```

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

Initializes `keyUseWith` object.

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.


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

---

### `xmlSecKeyUseWithFinalize`

```c
void xmlSecKeyUseWithFinalize(xmlSecKeyUseWithPtr keyUseWith);
```

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

Finalizes `keyUseWith` object.

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.

---

### `xmlSecKeyUseWithReset`

```c
void xmlSecKeyUseWithReset(xmlSecKeyUseWithPtr keyUseWith);
```

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

Resets a keyUseWith to its initial state.

Resets the `keyUseWith` to its state after initialization. 

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.

---

### `xmlSecKeyUseWithCopy`

```c
int xmlSecKeyUseWithCopy(xmlSecKeyUseWithPtr dst, xmlSecKeyUseWithPtr src);
```

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

Copies information from `dst` to `src`.

**Parameters:**

- `dst` — the pointer to destination object.
- `src` — the pointer to source object.


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

---

### `xmlSecKeyUseWithCreate`

```c
xmlSecKeyUseWithPtr xmlSecKeyUseWithCreate(const xmlChar *application, const xmlChar *identifier);
```

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

Creates a new xmlSecKeyUseWith object.

Creates new xmlSecKeyUseWith object. The caller is responsible for destroying returned object with `xmlSecKeyUseWithDestroy` function. 

**Parameters:**

- `application` — the application value.
- `identifier` — the identifier value.


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

---

### `xmlSecKeyUseWithDuplicate`

```c
xmlSecKeyUseWithPtr xmlSecKeyUseWithDuplicate(xmlSecKeyUseWithPtr keyUseWith);
```

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

Duplicates a keyUseWith object.

Duplicates `keyUseWith` object. The caller is responsible for destroying returned object with `xmlSecKeyUseWithDestroy` function. 

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.


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

---

### `xmlSecKeyUseWithDestroy`

```c
void xmlSecKeyUseWithDestroy(xmlSecKeyUseWithPtr keyUseWith);
```

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

Destroys a keyUseWith object.

Destroys `keyUseWith` created with `xmlSecKeyUseWithCreate` or `xmlSecKeyUseWithDuplicate` functions. 

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.

---

### `xmlSecKeyUseWithSet`

```c
int xmlSecKeyUseWithSet(xmlSecKeyUseWithPtr keyUseWith, const xmlChar *application, const xmlChar *identifier);
```

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

Sets application and identifier in a keyUseWith object.

Sets `application` and `identifier` in the `keyUseWith`. 

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.
- `application` — the new application value.
- `identifier` — the new identifier value.


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

---

### `xmlSecKeyUseWithDebugDump`

```c
void xmlSecKeyUseWithDebugDump(xmlSecKeyUseWithPtr keyUseWith, FILE *output);
```

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

Prints keyUseWith debug information to a file.

Prints xmlSecKeyUseWith debug information to a file `output`. 

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyUseWithDebugXmlDump`

```c
void xmlSecKeyUseWithDebugXmlDump(xmlSecKeyUseWithPtr keyUseWith, FILE *output);
```

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

Prints keyUseWith debug information in XML format.

Prints xmlSecKeyUseWith debug information to a file `output` in XML format. 

**Parameters:**

- `keyUseWith` — the pointer to information about key application/user.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyUseWithPtrListGetKlass`

```c
xmlSecPtrListId xmlSecKeyUseWithPtrListGetKlass(void);
```

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

The key data list klass.

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

---

### `xmlSecKeyReqInitialize`

```c
int xmlSecKeyReqInitialize(xmlSecKeyReqPtr keyReq);
```

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

Initializes a key requirements object.

Initialize key requirements object. Caller is responsible for cleaning it with `xmlSecKeyReqFinalize` function. 

**Parameters:**

- `keyReq` — the pointer to key requirements object.


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

---

### `xmlSecKeyReqFinalize`

```c
void xmlSecKeyReqFinalize(xmlSecKeyReqPtr keyReq);
```

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

Cleans up a key requirements object.

Cleans the key requirements object initialized with `xmlSecKeyReqInitialize` function. 

**Parameters:**

- `keyReq` — the pointer to key requirements object.

---

### `xmlSecKeyReqReset`

```c
void xmlSecKeyReqReset(xmlSecKeyReqPtr keyReq);
```

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

Resets key requirements for a new key search.

Resets key requirements object for new key search. 

**Parameters:**

- `keyReq` — the pointer to key requirements object.

---

### `xmlSecKeyReqCopy`

```c
int xmlSecKeyReqCopy(xmlSecKeyReqPtr dst, xmlSecKeyReqPtr src);
```

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

Copies key requirements between objects.

Copies key requirements from `src` object to `dst` object. 

**Parameters:**

- `dst` — the pointer to destination object.
- `src` — the pointer to source object.


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

---

### `xmlSecKeyReqMatchKey`

```c
int xmlSecKeyReqMatchKey(xmlSecKeyReqPtr keyReq, xmlSecKeyPtr key);
```

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

Checks whether a key matches the given requirements.

Checks whether `key` matches key requirements `keyReq`. 

**Parameters:**

- `keyReq` — the pointer to key requirements object.
- `key` — the pointer to key.


**Returns:** 1 if key matches requirements, 0 if not and a negative value if an error occurs.

---

### `xmlSecKeyReqMatchKeyValue`

```c
int xmlSecKeyReqMatchKeyValue(xmlSecKeyReqPtr keyReq, xmlSecKeyDataPtr value);
```

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

Checks whether a key value matches the given requirements.

Checks whether `keyValue` matches key requirements `keyReq`. 

**Parameters:**

- `keyReq` — the pointer to key requirements.
- `value` — the pointer to key value.


**Returns:** 1 if key value matches requirements, 0 if not and a negative value if an error occurs.

---

### `xmlSecKeyReqDebugDump`

```c
void xmlSecKeyReqDebugDump(xmlSecKeyReqPtr keyReq, FILE *output);
```

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

Prints key requirements debug information.

Prints debug information about `keyReq` into `output`. 

**Parameters:**

- `keyReq` — the pointer to key requirements object.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyReqDebugXmlDump`

```c
void xmlSecKeyReqDebugXmlDump(xmlSecKeyReqPtr keyReq, FILE *output);
```

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

Prints key requirements debug information in XML format.

Prints debug information about `keyReq` into `output` in XML format. 

**Parameters:**

- `keyReq` — the pointer to key requirements object.
- `output` — the pointer to output FILE.

---

### `xmlSecKeyCreate`

```c
xmlSecKeyPtr xmlSecKeyCreate(void);
```

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

Allocates and initializes a new key object.

Allocates and initializes new key. Caller is responsible for freeing returned object with `xmlSecKeyDestroy` function.

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

---

### `xmlSecKeyDestroy`

```c
void xmlSecKeyDestroy(xmlSecKeyPtr key);
```

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

Destroys a key object.

Destroys the key created using `xmlSecKeyCreate` function. 

**Parameters:**

- `key` — the pointer to key.

---

### `xmlSecKeyEmpty`

```c
void xmlSecKeyEmpty(xmlSecKeyPtr key);
```

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

Clears the `key` data.

**Parameters:**

- `key` — the pointer to key.

---

### `xmlSecKeyDuplicate`

```c
xmlSecKeyPtr xmlSecKeyDuplicate(xmlSecKeyPtr key);
```

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

Creates a duplicate of the given `key`.

**Parameters:**

- `key` — the pointer to the xmlSecKey structure.


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

---

### `xmlSecKeyCopy`

```c
int xmlSecKeyCopy(xmlSecKeyPtr keyDst, xmlSecKeyPtr keySrc);
```

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

Copies key data from `keySrc` to `keyDst`.

**Parameters:**

- `keyDst` — the destination key.
- `keySrc` — the source key.


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

---

### `xmlSecKeySwap`

```c
int xmlSecKeySwap(xmlSecKeyPtr key1, xmlSecKeyPtr key2);
```

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

Swaps key data for `key1` and::key2.

**Parameters:**

- `key1` — the first key.
- `key2` — the second key.


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

---

### `xmlSecKeyGetName`

```c
const xmlChar * xmlSecKeyGetName(xmlSecKeyPtr key);
```

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

Gets the key name.

Gets key name (see also `xmlSecKeySetName` function). 

**Parameters:**

- `key` — the pointer to key.


**Returns:** key name.

---

### `xmlSecKeySetName`

```c
int xmlSecKeySetName(xmlSecKeyPtr key, const xmlChar *name);
```

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

Sets the key name.

Sets key name (see also `xmlSecKeyGetName` function). 

**Parameters:**

- `key` — the pointer to key.
- `name` — the new key name.


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

---

### `xmlSecKeySetNameEx`

```c
int xmlSecKeySetNameEx(xmlSecKeyPtr key, const xmlChar *name, xmlSecSize nameSize);
```

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

Sets the key name with a specific length.

Sets key name (see also `xmlSecKeyGetName` function). 

**Parameters:**

- `key` — the pointer to key.
- `name` — the new key name.
- `nameSize` — the size of `name`.


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

---

### `xmlSecKeyGetType`

```c
xmlSecKeyDataType xmlSecKeyGetType(xmlSecKeyPtr key);
```

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

Gets `key` type.

**Parameters:**

- `key` — the pointer to key.


**Returns:** key type.

---

### `xmlSecKeyGetValue`

```c
xmlSecKeyDataPtr xmlSecKeyGetValue(xmlSecKeyPtr key);
```

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

Gets the key value (crypto material).

Gets key value (see also `xmlSecKeySetValue` function). 

**Parameters:**

- `key` — the pointer to key.


**Returns:** key value (crypto material).

---

### `xmlSecKeySetValue`

```c
int xmlSecKeySetValue(xmlSecKeyPtr key, xmlSecKeyDataPtr value);
```

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

Sets the key value (crypto material).

Sets key value (see also `xmlSecKeyGetValue` function). 

**Parameters:**

- `key` — the pointer to key.
- `value` — the new value.


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

---

### `xmlSecKeyGetSize`

```c
xmlSecSize xmlSecKeyGetSize(xmlSecKeyPtr key);
```

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

Gets the key size in bits.

Gets key size (in bits). Also see `xmlSecKeyDataGetSize` function. 

**Parameters:**

- `key` — the pointer to key.


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

---

### `xmlSecKeyGetData`

```c
xmlSecKeyDataPtr xmlSecKeyGetData(xmlSecKeyPtr key, xmlSecKeyDataId dataId);
```

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

Gets key's data.

**Parameters:**

- `key` — the pointer to key.
- `dataId` — the requested data klass.


**Returns:** additional data associated with the `key` (see also `xmlSecKeyAdoptData` function).

---

### `xmlSecKeyEnsureData`

```c
xmlSecKeyDataPtr xmlSecKeyEnsureData(xmlSecKeyPtr key, xmlSecKeyDataId dataId);
```

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

Ensures key data of the requested klass exists.

If necessary, creates key data of `dataId` klass and adds to `key`. 

**Parameters:**

- `key` — the pointer to key.
- `dataId` — the requested data klass.


**Returns:** pointer to key data or NULL if an error occurs.

---

### `xmlSecKeyAdoptData`

```c
int xmlSecKeyAdoptData(xmlSecKeyPtr key, xmlSecKeyDataPtr data);
```

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

Adds key data to a key object (takes ownership).

Adds `data` to the `key`. The `data` object will be destroyed by `key`. 

**Parameters:**

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


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

---

### `xmlSecKeyDebugDump`

```c
void xmlSecKeyDebugDump(xmlSecKeyPtr key, FILE *output);
```

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

Prints key information for debugging.

Prints the information about the `key` to the `output`. 

**Parameters:**

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

---

### `xmlSecKeyDebugXmlDump`

```c
void xmlSecKeyDebugXmlDump(xmlSecKeyPtr key, FILE *output);
```

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

Prints key information in XML format for debugging.

Prints the information about the `key` to the `output` in XML format. 

**Parameters:**

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

---

### `xmlSecKeyGenerate`

```c
xmlSecKeyPtr xmlSecKeyGenerate(xmlSecKeyDataId dataId, xmlSecSize sizeBits, xmlSecKeyDataType type);
```

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

Generates a new key of the requested klass and type.

Generates new key of requested klass `dataId` and `type`. 

**Parameters:**

- `dataId` — the requested key klass (rsa, dsa, aes, ...).
- `sizeBits` — the new key size (in bits!).
- `type` — the new key type (session, permanent, ...).


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

---

### `xmlSecKeyGenerateByName`

```c
xmlSecKeyPtr xmlSecKeyGenerateByName(const xmlChar *name, xmlSecSize sizeBits, xmlSecKeyDataType type);
```

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

Generates a new key by klass name and type.

Generates new key of requested `klass` and `type`. 

**Parameters:**

- `name` — the requested key klass name (rsa, dsa, aes, ...).
- `sizeBits` — the new key size (in bits!).
- `type` — the new key type (session, permanent, ...).


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

---

### `xmlSecKeyMatch`

```c
int xmlSecKeyMatch(xmlSecKeyPtr key, const xmlChar *name, xmlSecKeyReqPtr keyReq);
```

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

Checks whether a key matches the given criteria.

Checks whether the `key` matches the given criteria. 

**Parameters:**

- `key` — the pointer to key.
- `name` — the pointer to key name (may be NULL).
- `keyReq` — the pointer to key requirements.


**Returns:** 1 if the key satisfies the given criteria or 0 otherwise.

---

### `xmlSecKeyReadBuffer`

```c
xmlSecKeyPtr xmlSecKeyReadBuffer(xmlSecKeyDataId dataId, xmlSecBuffer *buffer);
```

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

Reads a key value from a buffer.

Reads the key value of klass `dataId` from a buffer. 

**Parameters:**

- `dataId` — the key value data klass.
- `buffer` — the buffer that contains the binary data.


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

---

### `xmlSecKeyReadBinaryFile`

```c
xmlSecKeyPtr xmlSecKeyReadBinaryFile(xmlSecKeyDataId dataId, const char *filename);
```

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

Reads a key value from a binary file.

Reads the key value of klass `dataId` from a binary file `filename`. 

**Parameters:**

- `dataId` — the key value data klass.
- `filename` — the key binary filename.


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

---

### `xmlSecKeyReadMemory`

```c
xmlSecKeyPtr xmlSecKeyReadMemory(xmlSecKeyDataId dataId, const xmlSecByte *data, xmlSecSize dataSize);
```

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

Reads a key value from a memory block.

Reads the key value of klass `dataId` from a memory block `data`. 

**Parameters:**

- `dataId` — the key value data klass.
- `data` — the memory containing the key
- `dataSize` — the size of the memory block


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

---

### `xmlSecKeyPtrListGetKlass`

```c
xmlSecPtrListId xmlSecKeyPtrListGetKlass(void);
```

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

The keys list klass.

**Returns:** keys list id.

---
