|
iPXE
|
Secure channel abstraction. More...
Go to the source code of this file.
Data Structures | |
| struct | secure_channel_properties |
| Secure channel properties. More... | |
| struct | secure_pipe |
| A secure channel transmit or receive pipe. More... | |
| struct | secure_channel |
| A secure channel. More... | |
| struct | secure_preshared_identity |
| A pre-shared bound peer identity. More... | |
| struct | secure_channel_operations |
| Secure channel operations. More... | |
Macros | |
| #define | channel_ephemeral_algorithm sha256_algorithm |
| Ephemeral master secret digest algorithm. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| static void | channel_init (struct secure_channel *channel, struct secure_channel_operations *op) |
| Initialise secure channel. | |
| static int | channel_is_established (struct secure_channel *channel) |
| Check if secure channel has been established. | |
| static void | channel_clear_preshared (struct secure_preshared_identity *psid) |
| Clear pre-shared bound peer identity. | |
| void | channel_ephemeral (struct secure_channel *channel, const void *info, size_t info_len, void *out, size_t len) |
| Generate ephemeral secret. | |
| void | channel_ephemeral_label (struct secure_channel *channel, const char *label, void *out, size_t len) |
| Generate labelled ephemeral secret. | |
| void | channel_unkey (struct secure_channel *channel) |
| Clear shared secret. | |
| int | channel_key_share (struct secure_channel *channel, struct exchange_algorithm *exchange, void *public) |
| Share public key. | |
| int | channel_key_agree (struct secure_channel *channel, struct exchange_algorithm *exchange, const void *partner) |
| Agree shared secret. | |
| int | channel_bind_verify (struct secure_channel *channel, struct x509_certificate *identity, struct pubkey_algorithm *pubkey, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature) |
| Bind peer identity via ephemeral public key signature verification. | |
| int | channel_bind_encrypt (struct secure_channel *channel, struct x509_certificate *identity, struct exchange_algorithm *exchange, struct pubkey_algorithm *pubkey, struct asn1_builder *ciphertext) |
| Bind peer identity via shared secret encryption. | |
| int | channel_save (struct secure_channel *channel, struct secure_preshared_identity *psid) |
| Save a pre-shared key. | |
| int | channel_load (struct secure_channel *channel, struct secure_preshared_identity *psid) |
| Load a pre-shared key. | |
| int | channel_confirm (struct secure_channel *channel, const void *auth, size_t len) |
| Confirm peer identity. | |
| int | channel_establish (struct secure_channel *channel, const char *name, struct x509_root *root) |
| Establish channel as trusted for application data. | |
| int | channel_set_cipher (struct secure_channel *channel, struct secure_pipe *pipe, struct cipher_algorithm *cipher, const void *key, size_t len) |
| Set cipher algorithm and key. | |
| int | channel_open (struct secure_channel *channel) |
| Open secure channel. | |
| void | channel_reopen (struct secure_channel *channel) |
| Reopen secure channel. | |
| void | channel_close (struct secure_channel *channel) |
| Close secure channel. | |
Variables | |
| struct cipher_algorithm | channel_dead_cipher |
| Dead cipher. | |
Secure channel abstraction.
Definition in file channel.h.
| #define channel_ephemeral_algorithm sha256_algorithm |
Ephemeral master secret digest algorithm.
Definition at line 19 of file channel.h.
Referenced by channel_ephemeral(), and channel_ephemeral_init().
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
inlinestatic |
|
inlinestatic |
Check if secure channel has been established.
| channel | Secure channel |
| is_established | Channel has been established |
Definition at line 271 of file channel.h.
Referenced by tls_channel_save(), and tls_ready().
|
inlinestatic |
Clear pre-shared bound peer identity.
| psid | Pre-shared identity |
Definition at line 282 of file channel.h.
References secure_preshared_identity::bound, NULL, and x509_put().
Referenced by channel_save(), and free_tls_session().
|
extern |
Generate ephemeral secret.
| channel | Secure channel |
| info | Additional information |
| info_len | Length of additional information |
| out | Ephemeral secret to fill in |
| len | Length of ephemeral secret |
Definition at line 195 of file channel.c.
References assert, channel, channel_ephemeral_algorithm, hkdf_expand(), info, info_len, len, NULL, and out.
Referenced by channel_ephemeral_label(), and tls_send_record().
|
extern |
Generate labelled ephemeral secret.
| channel | Secure channel |
| label | Additional information string |
| out | Ephemeral secret to fill in |
| len | Length of ephemeral secret |
Definition at line 215 of file channel.c.
References channel, channel_ephemeral(), DBGC2, DBGC2_HDA, len, out, and strlen().
Referenced by channel_ephemeral_replace(), channel_key_private(), tls_nonce(), and tls_session().
|
extern |
Clear shared secret.
| channel | Secure channel |
Definition at line 273 of file channel.c.
References channel, and channel_unbind().
Referenced by channel_bind_encrypt(), channel_close(), channel_key(), channel_load(), channel_open(), channel_reopen(), and tls_clear_digest().
|
extern |
Share public key.
| channel | Secure channel |
| exchange | Key exchange algorithm |
| public | Public key to fill in |
| rc | Return status code |
Definition at line 320 of file channel.c.
References channel, channel_key_private(), DBGC, DBGC2, DBGC2_HDA, exchange_share(), memset(), exchange_algorithm::name, exchange_algorithm::privsize, exchange_algorithm::pubsize, rc, and strerror().
Referenced by tls_key_share().
|
extern |
Agree shared secret.
| rc | Return status code |
Definition at line 424 of file channel.c.
References channel, channel_key(), DBGC2, DBGC2_HDA, ENOMEM, exchange_algorithm::name, partner, exchange_algorithm::pubsize, rc, exchange_algorithm::sharedsize, tmp, zalloc(), and zfree().
Referenced by tls_key_agree().
|
extern |
Bind peer identity via ephemeral public key signature verification.
| channel | Secure channel |
| identity | Identity to be bound |
| pubkey | Public-key algorithm |
| digest | Digest algorithm |
| value | Digest value (must cover peer's ephemeral public key) |
| signature | Signature |
| rc | Return status code |
The peer may delegate authority to the shared secret by signing a digest that covers at least its own ephemeral public key (e.g. the Diffie-Hellman parameters provided in a ServerKeyExchange record) and a challenge nonce (e.g. the TLS client random bytes).
The consumer asserts to the secure channel that the digest covers at least the peer's ephemeral public key and a nonce. The digest may cover arbitrary additional information (e.g. the entire transcript hash as signed by a CertificateVerify record).
This assertion is an unverifiable promise made by the consumer: there is no way for the secure channel itself to determine what is covered by the digest.
Definition at line 611 of file channel.c.
References channel, channel_bind(), DBGC, key, pubkey_verify(), x509_subject::public_key, x509_public_key::raw, rc, signature, strerror(), x509_certificate::subject, and value.
Referenced by tls_new_server_key_exchange().
|
extern |
Bind peer identity via shared secret encryption.
| channel | Secure channel |
| identity | Identity to be bound |
| exchange | Key exchange algorithm |
| pubkey | Public-key algorithm |
| ciphertext | Encrypted shared secret |
| rc | Return status code |
The local endpoint may delegate authority to the shared secret by encrypting a unilaterally chosen shared secret (e.g. a classic TLS static RSA pre-master secret).
Definition at line 648 of file channel.c.
References channel, channel_bind(), channel_key_transport(), channel_unkey(), asn1_cursor::data, DBGC, ENOMEM, key, asn1_cursor::len, exchange_algorithm::name, pubkey_encrypt(), x509_subject::public_key, x509_public_key::raw, rc, exchange_algorithm::sharedsize, strerror(), x509_certificate::subject, tmp, zalloc(), and zfree().
Referenced by tls_key_encrypt().
|
extern |
Save a pre-shared key.
| channel | Secure channel |
| psid | Pre-shared bound peer identity |
| rc | Return status code |
Definition at line 738 of file channel.c.
References secure_preshared_identity::bound, channel, channel_clear_preshared(), DBGC, ENOTSUP, EPROTO_NOT_BOUND, rc, strerror(), x509_get(), and x509_name().
Referenced by tls_save().
|
extern |
Load a pre-shared key.
| channel | Secure channel |
| psid | Pre-shared bound peer identity |
| rc | Return status code |
Definition at line 783 of file channel.c.
References secure_preshared_identity::bound, channel, channel_bind(), channel_unkey(), DBGC, ENOTSUP, EPROTO_NOT_BOUND, rc, and strerror().
Referenced by tls_resume().
|
extern |
Confirm peer identity.
| rc | Return status code |
The consumer asserts to the secure channel that the authenticator value was received after the receive pipe was transitioned to a cipher capable of providing confidentiality.
This assertion is an unverifiable promise made by the consumer: there is no way for the secure channel itself to determine when the authenticator value was received.
Definition at line 896 of file channel.c.
References assert, channel, channel_unconfirm(), DBGC, EPERM_NOT_CONFIDENTIAL, EPROTO_NOT_BOUND, len, rc, strerror(), x509_get(), and x509_name().
Referenced by tls_new_finished().
|
extern |
Establish channel as trusted for application data.
| channel | Secure channel |
| name | Required peer identity name |
| root | Root certificate list, or NULL to use default |
| rc | Return status code |
Definition at line 986 of file channel.c.
References assert, channel, channel_unestablish(), DBGC, EPERM_NOT_CONFIDENTIAL, EPERM_NOT_VALID, EPROTO_NOT_CONFIRMED, name, rc, root, strerror(), x509_check_name(), x509_get(), x509_is_valid(), and x509_name().
Referenced by tls_establish().
|
extern |
Set cipher algorithm and key.
| channel | Secure channel |
| pipe | Secure channel pipe |
| cipher | Cipher algorithm |
| key | Key |
| len | Length of key |
| rc | Return status code |
The consumer asserts to the secure channel that the key is ultimately derived from the shared secret that was previously provided to the consumer by the secure channel, i.e. that possession of the cipher key implies possession of the shared secret.
This assertion is an unverifiable promise made by the consumer: we can check that a shared secret exists, but there is no way for the secure channel itself to determine how the cipher key is derived.
Definition at line 1136 of file channel.c.
References channel, channel_clear_cipher(), channel_pipe_name(), secure_pipe::cipher, cipher_setkey(), cipher_algorithm::confidential, secure_pipe::ctx, cipher_algorithm::ctxsize, DBGC, ENOMEM, EPERM_NOT_CONFIDENTIAL, EPROTO_NOT_KEYED, key, len, cipher_algorithm::name, rc, strerror(), and zalloc().
Referenced by tls_change_cipher().
|
extern |
Open secure channel.
| channel | Secure channel |
| rc | Return status code |
Definition at line 1205 of file channel.c.
References assert, channel, channel_clear_cipher(), channel_ephemeral_init(), channel_unkey(), cipher_null, DBGC, NULL, and rc.
Referenced by add_tls().
|
extern |
Reopen secure channel.
| channel | Secure channel |
The channel will be returned to a freshly opened state (including a new ephemeral master secret), but with any existing cipher state retained. All security properties will be cleared.
This allows a new secure channel to be established with either or both of the transmit and receive pipes having already transitioned to a cipher capable of providing confidentiality.
The consumer may choose to reopen a fully established channel while leaving the cipher keys intact (as is done in TLS renegotiation), in which case it may choose to treat the channel as remaining established (to the old peer identity) at least until the point that the cipher keys are next changed (and possibly further, depending upon the protocol design). The secure channel itself does not attempt to model any such choice by the consumer: reopening will clear all security properties including the established peer identity.
Definition at line 1269 of file channel.c.
References assert, channel, channel_ephemeral_replace(), channel_unkey(), DBGC, and NULL.
Referenced by tls_restart().
|
extern |
Close secure channel.
| channel | Secure channel |
All secret values held by the secure channel will be destroyed, including the ephemeral master secret.
This function may safely be called on a channel that has already been closed.
Definition at line 1301 of file channel.c.
References assert, channel, channel_clear_cipher(), channel_ephemeral_replace(), channel_unkey(), DBGC, and NULL.
Referenced by add_tls(), and tls_close().
|
extern |
Dead cipher.
We activate this cipher (rather than the null cipher) upon any cipher-related failure, to guard against code paths that may fail to check for cipher errors.
Definition at line 1073 of file channel.c.
Referenced by channel_clear_cipher(), and channel_init().