pub struct SecureChannel { /* private fields */ }
Expand description

Holds all of the security information related to this session

Implementations

Test if the secure channel token needs to be renewed. The algorithm determines it needs to be renewed if the issue period has elapsed by 75% or more.

Makes a security header according to the type of message being sent, symmetric or asymmetric

Creates a nonce for the connection. The nonce should be the same size as the symmetric key

Sets the remote certificate

Obtains the remote certificate as a byte string

Set their nonce which should be the same as the symmetric key

Part 6 6.7.5 Deriving keys Once the SecureChannel is established the Messages are signed and encrypted with keys derived from the Nonces exchanged in the OpenSecureChannel call. These keys are derived by passing the Nonces to a pseudo-random function which produces a sequence of bytes from a set of inputs. A pseudo-random function is represented by the following function declaration:

Byte[] PRF( Byte[] secret,  Byte[] seed,  Int32 length,  Int32 offset)

Where length is the number of bytes to return and offset is a number of bytes from the beginning of the sequence.

The lengths of the keys that need to be generated depend on the SecurityPolicy used for the channel. The following information is specified by the SecurityPolicy:

a) SigningKeyLength (from the DerivedSignatureKeyLength); b) EncryptingKeyLength (implied by the SymmetricEncryptionAlgorithm); c) EncryptingBlockSize (implied by the SymmetricEncryptionAlgorithm).

The parameters passed to the pseudo random function are specified in Table 33.

Table 33 – Cryptography key generation parameters

Key | Secret | Seed | Length | Offset ClientSigningKey | ServerNonce | ClientNonce | SigningKeyLength | 0 ClientEncryptingKey | ServerNonce | ClientNonce | EncryptingKeyLength | SigningKeyLength ClientInitializationVector | ServerNonce | ClientNonce | EncryptingBlockSize | SigningKeyLength + EncryptingKeyLength ServerSigningKey | ClientNonce | ServerNonce | SigningKeyLength | 0 ServerEncryptingKey | ClientNonce | ServerNonce | EncryptingKeyLength | SigningKeyLength ServerInitializationVector | ClientNonce | ServerNonce | EncryptingBlockSize | SigningKeyLength + EncryptingKeyLength

The Client keys are used to secure Messages sent by the Client. The Server keys are used to secure Messages sent by the Server.

Test if the token has expired yet

Calculates the signature size for a message depending on the supplied security header

Calculate the padding size

Padding adds bytes to the body to make it a multiple of the block size so it can be encrypted.

Applies security to a message chunk and yields a encrypted/signed block to be streamed

Decrypts and verifies the body data if the mode / policy requires it

Decrypts and verifies the body data if the mode / policy requires it

Note, that normally we do not have “their” key but for testing purposes and forensics, we might have the key

Encode data using security. Destination buffer is expected to be same size as src and expected to have space for for a signature if a signature is to be appended

Signing is done first and then encryption

S - Message Header S - Security Header S - Sequence Header - E S - Body - E S - Padding - E Signature - E

Decrypts and verifies data.

Returns the size of the decrypted data

S - Message Header S - Security Header S - Sequence Header - E S - Body - E S - Padding - E Signature - E

Trait Implementations

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.