---
title: "af kms"
description: "Manage the organization's encryption and signing keys"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.forge.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# af kms

<!-- Generated by tools/gen-reference.mjs from `af kms --help`. Change the help text in crates/atoll-forge-cli/src/main.rs, then run `npm run gen:reference`. -->

Each key lists who may use it, and how: full use, or encrypt-only (verify-only for a signing key). Data is encrypted, decrypted and signed by the forge. Creating or changing a key, and changing who may use it, are requests that need approval.

## Usage

```text
af kms [OPTIONS] <COMMAND>
```

## Commands

| Command | What it does |
| --- | --- |
| [`list`](#af-kms-list) | List the organization's keys, with who may use each and how |
| [`create`](#af-kms-create) | Request a new key |
| [`grant`](#af-kms-grant) | Request access to a key for a team or person |
| [`revoke`](#af-kms-revoke) | Request that a team or person lose access to a key |
| [`rotate`](#af-kms-rotate) | Request a new version of a key |
| [`disable`](#af-kms-disable) | Request that a key be disabled |
| [`enable`](#af-kms-enable) | Request that a disabled key be enabled again |
| [`schedule-deletion`](#af-kms-schedule-deletion) | Request that a key be deleted after a waiting period |
| [`cancel-deletion`](#af-kms-cancel-deletion) | Request that a key's scheduled deletion be canceled |
| [`encrypt`](#af-kms-encrypt) | Encrypt standard input and print the ciphertext in base64 |
| [`decrypt`](#af-kms-decrypt) | Decrypt a base64 ciphertext from standard input |
| [`sign`](#af-kms-sign) | Sign standard input and print the signature in base64 |
| [`verify`](#af-kms-verify) | Verify a base64 signature of standard input |
| [`public-key`](#af-kms-public-key) | Print a signing key's public key in PEM format |
| [`data-key`](#af-kms-data-key) | Generate a data key for encrypting larger data yourself |

## Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## Examples

```sh
af kms list
af kms create app-secrets --use-person ada@example.com
af kms create releases --spec ml-dsa-65 --use-team release
```

## af kms list {#af-kms-list}

List the organization's keys, with who may use each and how

### Usage

```text
af kms list [OPTIONS]
```

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms create {#af-kms-create}

Request a new key

Name who may use the key with --use-team and --use-person (full use), or --seal-team and --seal-person (encrypt only, or verify only for a signing key). Requires an administrator; it takes effect at once unless the forge requires a second administrator.

### Usage

```text
af kms create [OPTIONS] <NAME>
```

### Arguments

- `<NAME>`

  Name of the key

### Options

- `--spec <SPEC>`

  Kind of key

  Possible values:

  - symmetric: AES-256-GCM key for encryption, decryption and data keys

  - ed25519:   Ed25519 key for signing

  - ml-dsa-65: ML-DSA-65 key for post-quantum signing

  Default: `symmetric`

- `--use-team <USE_TEAM>`

  Team that may fully use the key, as the identity provider names the group; repeatable

- `--use-person <USE_PERSON>`

  Person who may fully use the key, by sign-in email; repeatable

- `--seal-team <SEAL_TEAM>`

  Team that may only encrypt with the key (or verify, for a signing key); repeatable

- `--seal-person <SEAL_PERSON>`

  Person who may only encrypt with the key (or verify, for a signing key); repeatable

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms grant {#af-kms-grant}

Request access to a key for a team or person

An administrator's request takes effect at once unless the forge requires a second administrator. Anyone else's is approved by an administrator, or by someone else who holds the key with at least the access being granted.

### Usage

```text
af kms grant [OPTIONS] --may <MAY> <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--team <TEAM>`

  Team to grant access to, as the identity provider names the group

- `--person <PERSON>`

  Person to grant access to, by sign-in email

- `--may <MAY>`

  Access to grant

  Possible values:

  - use:  Full use: encrypt and decrypt, or sign and verify

  - seal: Encrypt only, or verify only for a signing key

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms revoke {#af-kms-revoke}

Request that a team or person lose access to a key

An administrator's request takes effect at once unless the forge requires a second administrator. Anyone else's is approved by an administrator, or by someone else who holds the key with at least the access being revoked.

### Usage

```text
af kms revoke [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--team <TEAM>`

  Team to revoke access from, as the identity provider names the group

- `--person <PERSON>`

  Person to revoke access from, by sign-in email

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms rotate {#af-kms-rotate}

Request a new version of a key

New encryptions use the new version, and every earlier version can still decrypt. Requires an administrator; it takes effect at once unless the forge requires a second administrator.

### Usage

```text
af kms rotate [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms disable {#af-kms-disable}

Request that a key be disabled

A disabled key can't be used for anything until it is enabled again. Requires an administrator; it takes effect at once unless the forge requires a second administrator.

### Usage

```text
af kms disable [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms enable {#af-kms-enable}

Request that a disabled key be enabled again

Requires an administrator; it takes effect at once unless the forge requires a second administrator.

### Usage

```text
af kms enable [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms schedule-deletion {#af-kms-schedule-deletion}

Request that a key be deleted after a waiting period

The key is deleted once --days have passed. Until then it can't be used, and once it is deleted, nothing encrypted with it can be decrypted again. `af kms cancel-deletion` stops the deletion. Requires an administrator; it takes effect at once unless the forge requires a second administrator.

### Usage

```text
af kms schedule-deletion [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--days <DAYS>`

  Days to wait before deleting the key, from 7 to 30

  Default: `30`

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms cancel-deletion {#af-kms-cancel-deletion}

Request that a key's scheduled deletion be canceled

The key stays disabled until it is enabled again. Requires an administrator; it takes effect at once unless the forge requires a second administrator.

### Usage

```text
af kms cancel-deletion [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--reason <REASON>`

  Reason for the request, recorded with it

  Default: `""`

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms encrypt {#af-kms-encrypt}

Encrypt standard input and print the ciphertext in base64

Encrypts up to 4,096 bytes with a symmetric key; for more data, use `af kms data-key`. Requires full or encrypt-only access to the key.

### Usage

```text
af kms encrypt [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--context <CONTEXT>`

  Encryption context pair, as `name=value` (repeatable); decrypting needs the same pairs

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

### Examples

```sh
printf %s "$TOKEN" | af kms encrypt app-secrets --context env=prod > token.enc
af kms decrypt --context env=prod < token.enc
```

## af kms decrypt {#af-kms-decrypt}

Decrypt a base64 ciphertext from standard input

Writes the plaintext to standard output. The ciphertext identifies its key. Requires full use of the key.

### Usage

```text
af kms decrypt [OPTIONS]
```

### Options

- `--context <CONTEXT>`

  Encryption context pair the data was encrypted with, as `name=value`; repeatable

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms sign {#af-kms-sign}

Sign standard input and print the signature in base64

Signs up to 4,096 bytes with a signing key. Requires full use of the key.

### Usage

```text
af kms sign [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms verify {#af-kms-verify}

Verify a base64 signature of standard input

Prints `valid` if the signature verifies, and fails otherwise.

### Usage

```text
af kms verify [OPTIONS] --signature <SIGNATURE> <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--signature <SIGNATURE>`

  Signature to check, in base64

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms public-key {#af-kms-public-key}

Print a signing key's public key in PEM format

Use it to verify the key's signatures anywhere.

### Usage

```text
af kms public-key [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## af kms data-key {#af-kms-data-key}

Generate a data key for encrypting larger data yourself

Prints JSON with the data key encrypted under KEY and, unless --no-plaintext is given, the data key itself, both in base64. Keep the encrypted copy with your data; `af kms decrypt` recovers the data key from it, given the same context.

### Usage

```text
af kms data-key [OPTIONS] <KEY>
```

### Arguments

- `<KEY>`

  Name of the key

### Options

- `--bytes <BYTES>`

  Length of the data key in bytes, from 1 to 1,024

  Default: `32`

- `--context <CONTEXT>`

  Encryption context pair, as `name=value`; repeatable

- `--no-plaintext`

  Print only the encrypted data key, without the plaintext

### Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

Source: https://docs.forge.workreef.dev/reference/af/kms/index.mdx
