Skip to content

Encrypted tunnel

Name

Encrypted tunnel

Summary

The sending and receiving entities set up a communication channel over which all exchanges are encrypted. Commonly used technologies to achieve such channels are TLS and SSH.

Parent

None

Problem

  • Ensure the (sensitive) contents of an action request and/or data exchanged between entities do not leak to unauthorised entities.

Solution

The solution of this pattern to avoid leaking information is to encrypt all communication between participating entities. In other words, actions requests, including any arguments, are encrypted as a whole, as well as any exchanged data elements. Typically, the communicating entities do not directly request the appropriate cryptographic actions or manage the communication channel. Instead they delegate these responsibilities to other entities they configured to do this on their behalf. One of the most common instances of this pattern is encrypting communication using TLS.

This pattern thus instantiates the Encryption pattern where encryption happens on the sender side and decryption on the receiver side.

Roles

  • Sender (: Entity) wants to communicate action request(s) and/or data with a Receiver in a confidential manner
  • Receiver (: Entity) wants to receive action request(s) and/or data from a Sender
  • EndpointS (: Entity) an entity that is able to set up and manage a connection with a compatible receiving endpoint
    • EndpointS <- Encryption.EntityA
  • CryptographerS (:Cryptographic primitive) a cryptographic primitive that at least can encrypt given plaintexts
    • CryprographerS <- Encryption.Encryption provider
  • EndpointManagerS (: Entity) initialises and configures the EndpointS, e.g. with an appropriate public key and selection of supported ciphers
  • EndpointR (: Entity) an entity that is able to receive and manage a connection with a compatible sending endpoint
    • EndpointR <- Encryption.EntityB
  • CryptographerR (: Cryptographic primitive) a cryptographic primitive that can at least decrypt received ciphertexts
    • CryptographerR <- Encryption.Encryption provider
  • EndpointManagerR (: Entity) initialises and configures the EndpointS, e.g. with the appropriate public key and selection of supported ciphers

Note

The endpoints and cryptographic libraries used by Sender and Receiver can differ from each other but must provide compatible cryptographic primitives in order for them to be able communicate. For example, they should both support the same cipher (configuration) to successfully encrypt and decrypt messages.

Actions

  • action (: Action) an action request, optionally with arguments
    • action <- Encryption.plaintext
  • encrypt (: Action) the provided plaintext using the identified key and, if provided, encryption cipher configuration
  • decrypt (: Action) the provided ciphertext using the identified key and, if provided, decryption cipher configuration
  • set_up (: Action) request to set up a new endpoint for the calling entity to send or receive actions and/or data elements in a confidential manner
  • initialise (: Action) initialise a new endpoint instance with the given configuration

Data elements

  • d (: Data) a data element or set of data elements
    • d <- Encryption.plaintext
  • {x}_k (: Data) a ciphertext obtained by encrypting an action request or data element x using cryptographic key k
    • {x}_k <- Encryption.ciphertext
  • args (: Data) arguments the Sender provides as part of its action request (optional)
  • inputS (: Data) information from the Sender necessary to initialise the EndpointS, e.g. the Sender's public-private key pair (optional)
    • Tags: Untampered[, Secret]
  • configS (: Data) all information necessary to instantiate a (new) EndpointS
    • Tags: Untampered[, Secret]
    • configS <- Encryption.config
  • keyInfoS (: Data) the information the CryptographerS needs to determine the correct encryption key, e.g. the key itself or some identifier
    • Tags: Untampered[, Secret]
    • keyInfoS <- Encryption.keyInfo
  • inputR (: Data) information from the Receiver necessary to initialise the EndpointR, e.g. the Receiver's public-private key pair (optional)
    • Tags: Untampered[, Secret]
  • configR (: Data) all information necessary to instantiate a (new) EndpointR
    • Tags: Untampered[, Secret]
    • configR <- Encryption.config
  • keyInfoR (: Data) the information the CryptographerR needs to determine the correct decryption key, e.g. the key itself or some identifier
    • Tags: Untampered[, Secret]
    • keyInfoR <-Encryption.keyInfo
  • es_id (: Data) an identifier which allows the Sender to locate and interact with the created EndpointS
  • er_id (: Data) an identifier which allows the Receiver to locate and interact with the created EndpointR

Behaviour

Before an encrypted tunnel can be set up, the Sender and Receiver must set up their respective endpoints. Both entities can do this independently from each other at different times.

  1. Sender sends its action request and/or data element(s) to EndpointS for encryption and transmission.
  2. If necessary, EndpointS and EndpointR negotiate on a common an encryption cipher and (shared) cryptographic key(s). (optional) Possibly the endpoints are already configured with a shared key at, for example, deployment time, in which case a runtime negotiation is not needed.
  3. The EndpointS forwards the received plaintext along with the necessary key information to the CryptographerS for encryption.
  4. The CryptographerS encrypts the received plaintext and replies the resulting ciphertext to the EndpointS.
  5. EndpointS forwards the ciphertext to EndpointR.
  6. After receiving the ciphertext EndpointR sends it, along with the necessary key information, to the CryptographerR for decryption.
  7. The CryptographerR decrypts the ciphertext and replies the corresponding plaintext to the EndpointR.
  8. The EndpointR forwards the received plaintext to the Receiver for further processing.

Note

If the Receiver wants to reply or the Sender wants to transmit multiple messages the same connection between the endpoints is typically used. Depending on the underlying cryptographic ciphers, the used encryption and decryption keys may change in between messages.

Transmit all traffic through encrypted tunnel

Role considerations

Encryption role considerations

All role considerations of the instantiated Encryption pattern should also be followed.

Endpoint configuration (Sender, Receiver, EndpointManagerS/R, EndpointS/R)

In this pattern the the CryptographerS (CryptographerR) is configured indirectly by the Sender (Receiver) via the EndpointManagerS(EndpointManagerR) which in turn initialises the EndpointS (EndpointR) which interacts with the CryptographerS (CryptographerR). The range of available options depends on the selected library and it is highly advised to consult the library's documentation.

For the commonly used OpenSSL library the Mozilla Foundation provides a online configuration generator that easily allows to generate safe configurations.

Cipher negotiation (EndpointS, EndpointR)

The cipher negotiation, also referred to as handshake should always be performed by the endpoints using the operations provided by the cryptographic library at hand. One should never attempt to design or implement a negotiation protocol itself or have the Sender and Receiver negotiate directly.

Data considerations

Encryption data considerations

All data considerations of the instantiated Encryption pattern should be followed.

Implementations

None

References


Last update: February 7, 2022