# Tools

Stateless operations on material you send: hash, MAC, derive, wrap, AEAD, encapsulate, HPKE, combine, verify, random. Aegis Core API, `ToolsService`: 15 operations, generated from the OpenAPI document of Aegis Core 0.13.0.

## Combine

`POST /v1/tools/combine`

Combines shared secrets with an ETSI TS 103 744 combiner.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Combine`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The combiner. |
| `exchanges` | array of [Exchange](#schema-exchange) | The exchanges, in order. |
| `length` | integer (int64) | Output length. |
| `psk` | string (base64) | A pre-shared key of the combiner's length; none when empty. |

Response `200` (`application/json`): [ToolsCombineResponse](#schema-toolscombineresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Decrypt

`POST /v1/tools/decrypt`

Decrypts; an AEAD returns nothing unless every byte authenticates.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Decrypt`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | An AEAD or a storage cipher. |
| `associated_data` | string (base64) | Associated data, for an AEAD. |
| `data` | string (base64) | The ciphertext. |
| `key` | string (base64) | The key. |
| `nonce` | string (base64), nullable | The nonce, for an AEAD. |
| `tweak` | string (base64), nullable | The tweak, for a storage cipher (XTS). |

Response `200` (`application/json`): [ToolsDecryptResponse](#schema-toolsdecryptresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Derive

`POST /v1/tools/derive`

Key derivation: HKDF, SP 800-108, Argon2id, scrypt.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Derive`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The KDF. |
| `associated_data` | string (base64) | Argon2id's associated data, at most 32 bytes. |
| `cost` | [PasswordCost](#schema-passwordcost), nullable | The cost of a password-based function. |
| `info` | string (base64) | The info (for SP 800-108, the context). |
| `legacy` | boolean | Reproduce a hash made elsewhere at a cost below the floor for new derivations. |
| `length` | integer (int64) | 1 to 1,024 bytes. |
| `pepper` | string (base64) | Argon2id's secret input (a pepper). |
| `salt` | string (base64) | The salt (for SP 800-108, the label). |
| `secret` | string (base64) | The secret, or for a password-based function the password. |

Response `200` (`application/json`): [ToolsDeriveResponse](#schema-toolsderiveresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Encapsulate

`POST /v1/tools/encapsulate`

Encapsulates to a public key.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Encapsulate`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The KEM. |
| `public_key` | string (base64) | The encapsulation key. |

Response `200` (`application/json`): [ToolsEncapsulateResponse](#schema-toolsencapsulateresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Encrypt

`POST /v1/tools/encrypt`

An AEAD under a fresh nonce, or a storage cipher under the tweak given.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Encrypt`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | An AEAD or a storage cipher. |
| `associated_data` | string (base64) | Associated data, for an AEAD. |
| `data` | string (base64) | The plaintext. |
| `key` | string (base64) | The key. |
| `tweak` | string (base64), nullable | The tweak, for a storage cipher (XTS). |

Response `200` (`application/json`): [ToolsEncryptResponse](#schema-toolsencryptresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Hash

`POST /v1/tools/hash`

A digest, or extendable output.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Hash`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The hash or extendable-output function. |
| `customisation` | string (base64), nullable | Customisation string (cSHAKE). |
| `data` | string (base64) | The data. |
| `length` | integer (int64), nullable | Output length of an extendable-output function (32 by default, at most 1,024). |

Response `200` (`application/json`): [ToolsHashResponse](#schema-toolshashresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## HPKE export

`POST /v1/tools/hpke/export`

HPKE secret export, as the sender or the recipient.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/HpkeExport`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `aead` | string | The AEAD, or `export-only`. |
| `enc` | string (base64), nullable | As the recipient: the encapsulated key. |
| `exporter_context` | string (base64) | The exporter context. |
| `info` | string (base64) | HPKE info. |
| `kdf` | string | The KDF. |
| `kem` | string | The KEM. |
| `length` | integer (int64) | 1 to 1,024 bytes. |
| `psk` | string (base64) | A pre-shared key. |
| `psk_id` | string (base64) | Its identifier. |
| `public_key` | string (base64), nullable | As the sender: the recipient's public key. |
| `secret_key` | string (base64), nullable | As the recipient: the private key. |

Response `200` (`application/json`): [ToolsHpkeExportResponse](#schema-toolshpkeexportresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## HPKE open

`POST /v1/tools/hpke/open`

Single-shot HPKE decryption.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/HpkeOpen`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `aad` | string (base64) | HPKE aad. |
| `aead` | string | The AEAD. |
| `ciphertext` | string (base64) | The ciphertext. |
| `enc` | string (base64) | The encapsulated key. |
| `info` | string (base64) | HPKE info. |
| `kdf` | string | The KDF. |
| `kem` | string | The KEM. |
| `psk` | string (base64) | A pre-shared key. |
| `psk_id` | string (base64) | Its identifier. |
| `secret_key` | string (base64) | The recipient's private key. |
| `sender_public_key` | string (base64), nullable | The sender's public key (mode auth). |

Response `200` (`application/json`): [ToolsHpkeOpenResponse](#schema-toolshpkeopenresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## HPKE seal

`POST /v1/tools/hpke/seal`

Single-shot HPKE encryption (RFC 9180).

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/HpkeSeal`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `aad` | string (base64) | HPKE aad. |
| `aead` | string | The AEAD. |
| `info` | string (base64) | HPKE info. |
| `kdf` | string | The KDF. |
| `kem` | string | The KEM. |
| `plaintext` | string (base64) | The plaintext. |
| `psk` | string (base64) | A pre-shared key (mode psk), at least 32 bytes. |
| `psk_id` | string (base64) | Its identifier. |
| `public_key` | string (base64) | The recipient's public key. |
| `sender_key` | string (base64), nullable | The sender's private key (mode auth). |

Response `200` (`application/json`): [ToolsHpkeSealResponse](#schema-toolshpkesealresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Mac

`POST /v1/tools/mac`

A MAC under the key given.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Mac`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The MAC. |
| `customisation` | string (base64), nullable | Customisation string (KMAC). |
| `key` | string (base64) | The key. |
| `length` | integer (int64), nullable | Tag length (KMAC, which binds it into the tag). |
| `message` | string (base64) | The message. |

Response `200` (`application/json`): [ToolsMacResponse](#schema-toolsmacresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Random

`POST /v1/tools/random`

Random bytes from the engine's health-tested source.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Random`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `length` | integer (int64) | 1 to 1,024. |

Response `200` (`application/json`): [ToolsRandomResponse](#schema-toolsrandomresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Transport

`POST /v1/tools/transport`

Encrypts a short secret to a key-transport public key (RSA-OAEP).

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Transport`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The key-transport algorithm. |
| `label` | string (base64) | The OAEP label. |
| `plaintext` | string (base64) | The secret. |
| `public_key` | string (base64) | The recipient's public key. |

Response `200` (`application/json`): [ToolsTransportResponse](#schema-toolstransportresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Unwrap

`POST /v1/tools/unwrap`

Unwraps a key; nothing unless its integrity check passes.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Unwrap`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | AES-KW or AES-KWP. |
| `kek` | string (base64) | The key-encryption key. |
| `wrapped` | string (base64) | The wrapped key. |

Response `200` (`application/json`): [ToolsUnwrapResponse](#schema-toolsunwrapresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Verify

`POST /v1/tools/verify`

Verifies a signature under a public key the caller supplies.

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Verify`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The signature algorithm. |
| `context` | string (base64) | The context string (FIPS 204, 205), at most 255 bytes. |
| `message` | string (base64) | The message. |
| `prehash` | string, nullable | The pre-hash function, for HashML-DSA and HashSLH-DSA. |
| `public_key` | string (base64) | The verification key. |
| `signature` | string (base64) | The signature. |

Response `200` (`application/json`): [ToolsVerifyResponse](#schema-toolsverifyresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Wrap

`POST /v1/tools/wrap`

Wraps a key under a key-encryption key (AES-KW, AES-KWP).

- Role: `operator` or higher
- gRPC: `/aegis.v1.ToolsService/Wrap`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | AES-KW or AES-KWP. |
| `kek` | string (base64) | The key-encryption key. |
| `key` | string (base64) | The key to wrap. |

Response `200` (`application/json`): [ToolsWrapResponse](#schema-toolswrapresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Schemas

### Exchange

One key exchange's outputs, for a combiner.

| Field | Type | Description |
| --- | --- | --- |
| `info` | string (base64) | The info. |
| `initiator` | string (base64) | The initiator's public value. |
| `label` | string (base64) | The label. |
| `responder` | string (base64) | The responder's public value. |
| `secret` | string (base64) | The shared secret. |

### PasswordCost

The cost of a password-based function.

| Field | Type | Description |
| --- | --- | --- |
| `block_size` | integer (int64), nullable | scrypt r. |
| `lanes` | integer (int64), nullable | Argon2id lanes. |
| `log_n` | integer (int64), nullable | scrypt log2 N. |
| `memory_kib` | integer (int64), nullable | Argon2id memory in KiB. |
| `parallelism` | integer (int64), nullable | scrypt p. |
| `passes` | integer (int64), nullable | Argon2id passes. |

### ToolsCombineResponse

The combined key.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The combiner. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `key_material` | string (base64) | The key material. |

### ToolsDecryptResponse

The plaintext.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `plaintext` | string (base64) | The plaintext. |

### ToolsDeriveResponse

Derived output.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The KDF. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `legacy` | boolean, nullable | For a password-based function: whether the cost was below the floor. |
| `output` | string (base64) | The output. |

### ToolsEncapsulateResponse

The encapsulation.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The KEM. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `ciphertext` | string (base64) | The ciphertext to send. |
| `shared_secret` | string (base64) | The shared secret. |

### ToolsEncryptResponse

The ciphertext.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `ciphertext` | string (base64) | The ciphertext with its tag. |
| `nonce` | string (base64), nullable | The nonce, for an AEAD. |

### ToolsHashResponse

A digest.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The function. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `digest` | string (base64) | The digest. |

### ToolsHpkeExportResponse

The exported secret.

| Field | Type | Description |
| --- | --- | --- |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `enc` | string (base64), nullable | A fresh encapsulated key, as the sender. |
| `exported` | string (base64) | The exported secret. |

### ToolsHpkeOpenResponse

The opened message.

| Field | Type | Description |
| --- | --- | --- |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `plaintext` | string (base64) | The plaintext. |

### ToolsHpkeSealResponse

The sealed message.

| Field | Type | Description |
| --- | --- | --- |
| `aead` | string | The AEAD. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `ciphertext` | string (base64) | The ciphertext. |
| `enc` | string (base64) | The encapsulated key. |
| `kdf` | string | The KDF. |
| `kem` | string | The KEM. |

### ToolsMacResponse

A tag.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The MAC. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `tag` | string (base64) | The tag. |

### ToolsRandomResponse

Random bytes.

| Field | Type | Description |
| --- | --- | --- |
| `bytes` | string (base64) | The bytes. |

### ToolsTransportResponse

The transported secret.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `ciphertext` | string (base64) | The ciphertext. |

### ToolsUnwrapResponse

The unwrapped key.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `key` | string (base64) | The key. |

### ToolsVerifyResponse

Whether it verifies.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `valid` | boolean | Whether the signature is valid. |

### ToolsWrapResponse

A wrapped key.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm. |
| `caution` | string, nullable | The caution of a retired or broken algorithm. |
| `wrapped` | string (base64) | The wrapped key. |
