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
Receiverin 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
xusing cryptographic keyk- {x}_k <- Encryption.ciphertext
- args (: Data) arguments the
Senderprovides as part of its action request (optional) - inputS (: Data) information from the
Sendernecessary to initialise theEndpointS, e.g. theSender'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
CryptographerSneeds 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
Receivernecessary to initialise theEndpointR, e.g. theReceiver'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
CryptographerRneeds 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
Senderto locate and interact with the createdEndpointS- Tags: Identifier
- er_id (: Data) an identifier which allows the
Receiverto locate and interact with the createdEndpointR- Tags: Identifier
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.
Sendersends its action request and/or data element(s) toEndpointSfor encryption and transmission.- If necessary,
EndpointSandEndpointRnegotiate 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. - The
EndpointSforwards the received plaintext along with the necessary key information to theCryptographerSfor encryption. - The
CryptographerSencrypts the received plaintext and replies the resulting ciphertext to theEndpointS. EndpointSforwards the ciphertext toEndpointR.- After receiving the ciphertext
EndpointRsends it, along with the necessary key information, to theCryptographerRfor decryption. - The
CryptographerRdecrypts the ciphertext and replies the corresponding plaintext to theEndpointR. - The
EndpointRforwards the received plaintext to theReceiverfor 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.

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¶
- TLS primitives provided by OpenSSL and LibreSSL
- Secure Sessions provided by Themis
- OpenSSH
- Java SSLSockets
- Whatsapp for business