Stateless OpenPGP - ArchWiki

Jump to content

# Stateless OpenPGP

1 language

- 日本語

From ArchWiki

Related articles

- Data-at-rest encryption
- List of applications/Security#Encryption, signing, steganography
- OpenPGP
- OpenPGP card

Stateless OpenPGP (SOP) is a standard for commandline interface (CLI) tools to perform OpenPGP operations. It is defined in a dedicated IETF draft outlining its features and syntax.

SOP is a lean approach to signing/verification and encryption/decryption operations on messages. Certificates and/or keys for all operations must be explicitly specified.

Usually private key operations use software keys. However, private key material on hardware security devices can also be used with some SOP implementations.

Many SOP implementations exist and are cross-tested in an interoperability test suite.

Although implementations provide executables of differing names, they all have the same CLI and the core functionality can be used interchangeably.

## Installation

Several implementations are available for installation:

- gosop
- rsop
- rsop-oct
- sequoia-sop

## Features

While SOP offers a uniform interface, implementations are free to support different subsets of the cryptographic mechanisms that OpenPGP specifies. Different versions of the format as well as hardware backed keys may be supported.

Stateless OpenPGP implementations
Package | RFC 4880 (+ RFC 6637) | draft-koch-librepgp | RFC 9580 | Hardware backed keys
--- | --- | --- | --- | ---
gosop | Yes | No | Yes | No
rsop | Yes | No | Yes | No
rsop-oct | Yes | No | No | Yes
sequoia-sop | Yes | No | No | No

### Hardware device support

When using hardware security devices, SOP parameters that usually specify private key material instead only specify public key material.

This public key material serves as an explicit reference to locate and use a hardware device that provides the corresponding private key material.

## Tips and tricks

The below examples assume, that the name of the SOP executable (e.g. gosop, rsop, rsop-oct or sqop) is stored in the environment variable `$SOP`.

Tip: When using rsop-oct it is possible to use private key material that resides on an OpenPGP card. Relevant private signing or decryption keys are expected to have been added to an OpenPGP card device (e.g. using OpenPGP-card-tools) which is connected to the machine where `rsop-oct` is used.

### Create a private key

To create an OpenPGP transferable secret key (aka. private key) with the User ID `<archie@example.org>` use:

    $ $SOP generate-key "<archie@example.org>" > archie.tsk

### Extract certificate

To extract the certificate (aka. public key) from the created transferable secret key use:

    $ $SOP extract-cert > archie.cert < archie.tsk

### Create detached signature

To create a detached signature for a message use:

    $ echo "Hello world" | $SOP sign archie.tsk > msg.sig

Tip: To create the same signature using an OpenPGP card, `rsop-oct` needs to be provided with a certificate instead of a private key:

    $ echo "Hello world" | rsop-oct sign archie.cert > msg.sig

### Verify detached signature

To verify the detached signature, provide the original message, the signature as well as the OpenPGP certificate:

    $ echo "Hello world" | $SOP verify msg.sig archie.cert

    2024-02-27T17:36:28Z 12b7169b5fc99d1a2d546b8755d1f4d8a355f3cb 12b7169b5fc99d1a2d546b8755d1f4d8a355f3cb mode:binary

### Encrypt a message

Messages can be encrypted by providing the message and the OpenPGP certificate of the recipient:

    $ echo "Hello world" | $SOP encrypt archie.cert > encrypted.msg

### Decrypt a message

Recipients of encrypted messages can decrypt them by providing the encrypted message and their transferable secret key:

    $ $SOP decrypt archie.tsk < encrypted.msg

    Hello world

Tip: To decrypt this message using an OpenPGP card, `rsop-oct` needs to be provided with a certificate instead of a private key:

    $ rsop-oct decrypt archie.cert < encrypted.msg

    Hello world

### Create cleartext signed message

Cleartext signed messages can be created by providing the message and the signer's transferable secret key:

    $ echo "Hello world" | $SOP inline-sign --as clearsigned archie.tsk

    -----BEGIN PGP SIGNED MESSAGE-----

    Hello world

    -----BEGIN PGP SIGNATURE-----

    wnUEARYKAB0WIQQStxabX8mdGi1Ua4dV0fTYo1XzywUCZd4eOgAKCRBV0fTYo1Xz
    yyqJAQDUD/lbhqOHL/O0cjtytXQXnMOx5twW3FT3RJPlu9JZUAEA2OAMhzLmX6Bb
    mXz8Tu0eApqbxu64ksieL8YNN20IwQs=
    =77wU
    -----END PGP SIGNATURE-----

Tip: The OpenPGP card use with `rsop-oct` works analogous to the example outlined in #Create detached signature.

## See also

- IETF draft
- Interoperability test suite
- OpenPGP for application developers

Categories:

- Digital signature
- Encryption
- OpenPGP