103#ifndef QSC_TLS_KEYSCHEDULE_H
104#define QSC_TLS_KEYSCHEDULE_H
111QSC_CPLUSPLUS_ENABLED_START
196 size_t ikmlen, uint8_t* output,
size_t outlen);
216 size_t infolen, uint8_t* output,
size_t outlen);
238 const char* label,
size_t labellen,
const uint8_t* context,
size_t contextlen, uint8_t* output,
size_t outlen);
260 const char* label,
size_t labellen,
const uint8_t* transcripthash,
size_t transcripthashlen, uint8_t* output,
size_t outlen);
280 const char* label,
size_t labellen, uint8_t* output,
size_t outlen);
403 const uint8_t* trafficsecret,
size_t trafficsecretlen,
size_t keylen,
size_t ivlen, uint8_t* keyoutput, uint8_t* ivoutput);
421 size_t trafficsecretlen, uint8_t* nexttrafficsecret);
442 const uint8_t* transcripthash,
size_t transcripthashlen, uint8_t* output,
size_t outlen,
size_t* written);
462 const uint8_t* transcripthash,
size_t transcripthashlen,
const uint8_t* candidate,
size_t candidatelen);
482 size_t transcripthashlen, uint8_t* output,
size_t outlen,
size_t* written);
527 size_t noncelen, uint8_t* output,
size_t outlen);
594 const uint8_t* partialtranshash,
size_t transcripthashlen, uint8_t* output,
size_t outlen,
size_t* written);
596QSC_CPLUSPLUS_ENABLED_END
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition qsccommon.h:645
TLS 1.3 key schedule state and derived secret container.
Definition tlskeyschedule.h:129
uint8_t clienthandshaketrafficsecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:133
bool handshakedone
Definition tlskeyschedule.h:147
uint8_t mastersecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:138
uint8_t earlyexportermastersecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:134
bool masterdone
Definition tlskeyschedule.h:149
qsc_tls_hash_algorithm hash
Definition tlskeyschedule.h:143
size_t digestsize
Definition tlskeyschedule.h:142
bool earlydone
Definition tlskeyschedule.h:145
bool binderderived
Definition tlskeyschedule.h:144
uint8_t earlysecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:136
bool earlytrafficderived
Definition tlskeyschedule.h:146
uint8_t clientapplicationtrafficsecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:131
uint8_t handshakesecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:137
uint8_t resumptionmastersecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:139
uint8_t serverapplicationtrafficsecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:141
uint8_t clientearlytrafficsecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:132
uint8_t exportermastersecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:135
uint8_t binderkey[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:130
bool initialized
Definition tlskeyschedule.h:148
uint8_t serverhandshaketrafficsecret[QSC_TLS_HASH_MAX_SIZE]
Definition tlskeyschedule.h:140
#define QSC_TLS_HASH_MAX_SIZE
Defines the maximum supported transcript hash size in bytes.
Definition tlsdefs.h:120
TLS status code definitions and diagnostic string conversion.
qsc_tls_status
Definition tlserrors.h:65
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_extract_handshake_secret(qsc_tls_key_schedule_state *state, const uint8_t *dhe, size_t dhelen)
Extract the TLS 1.3 handshake secret.
Definition tlskeyschedule.c:461
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_extract_master_secret(qsc_tls_key_schedule_state *state)
Extract the TLS 1.3 master secret.
Definition tlskeyschedule.c:500
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_early_exporter_secret(qsc_tls_key_schedule_state *state, const uint8_t *transcripthash, size_t transcripthashlen)
Derive the early exporter master secret.
Definition tlskeyschedule.c:915
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_state_initialize(qsc_tls_key_schedule_state *state, qsc_tls_hash_algorithm hash)
Initialize a TLS key schedule state.
Definition tlskeyschedule.c:383
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_hkdf_expand(qsc_tls_hash_algorithm hash, const uint8_t *prk, size_t prklen, const uint8_t *info, size_t infolen, uint8_t *output, size_t outlen)
Perform HKDF-Expand for the selected TLS hash algorithm.
Definition tlskeyschedule.c:144
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_application_traffic_secrets(qsc_tls_key_schedule_state *state, const uint8_t *transcripthash, size_t transcripthashlen)
Derive the client and server application traffic secrets.
Definition tlskeyschedule.c:556
QSC_EXPORT_API qsc_tls_hash_algorithm qsc_tls_keyschedule_suite_hash(qsc_tls_cipher_suite suite)
Resolve the hash algorithm associated with a TLS cipher suite.
Definition tlskeyschedule.c:807
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_binder_key(qsc_tls_key_schedule_state *state, bool external)
Derive the TLS 1.3 PSK binder key.
Definition tlskeyschedule.c:859
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_suite_record_sizes(qsc_tls_cipher_suite suite, size_t *keylen, size_t *ivlen)
Resolve record protection key and IV lengths for a TLS cipher suite.
Definition tlskeyschedule.c:757
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_resumption_master_secret(qsc_tls_key_schedule_state *state, const uint8_t *transcripthash, size_t transcripthashlen)
Derive the resumption master secret.
Definition tlskeyschedule.c:597
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_extract_early_secret(qsc_tls_key_schedule_state *state, const uint8_t *psk, size_t psklen)
Extract the TLS 1.3 early secret.
Definition tlskeyschedule.c:426
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_exporter_master_secret(qsc_tls_key_schedule_state *state, const uint8_t *transcripthash, size_t transcripthashlen)
Derive the exporter master secret.
Definition tlskeyschedule.c:579
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_verify_finished(qsc_tls_hash_algorithm hash, const uint8_t *basekey, size_t basekeylen, const uint8_t *transcripthash, size_t transcripthashlen, const uint8_t *candidate, size_t candidatelen)
Verify a TLS 1.3 Finished verify_data value.
Definition tlskeyschedule.c:724
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_handshake_traffic_secrets(qsc_tls_key_schedule_state *state, const uint8_t *transcripthash, size_t transcripthashlen)
Derive the client and server handshake traffic secrets.
Definition tlskeyschedule.c:533
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_hkdf_extract(qsc_tls_hash_algorithm hash, const uint8_t *salt, size_t saltlen, const uint8_t *ikm, size_t ikmlen, uint8_t *output, size_t outlen)
Perform HKDF-Extract for the selected TLS hash algorithm.
Definition tlskeyschedule.c:102
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_hkdf_expand_label(qsc_tls_hash_algorithm hash, const uint8_t *secret, size_t secretlen, const char *label, size_t labellen, const uint8_t *context, size_t contextlen, uint8_t *output, size_t outlen)
Perform TLS 1.3 HKDF-Expand-Label.
Definition tlskeyschedule.c:166
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_build_certificate_verify_input(const char *contextstring, const uint8_t *transcripthash, size_t transcripthashlen, uint8_t *output, size_t outlen, size_t *written)
Build the TLS 1.3 CertificateVerify signature input.
Definition tlskeyschedule.c:312
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_client_early_traffic_secret(qsc_tls_key_schedule_state *state, const uint8_t *transcripthash, size_t transcripthashlen)
Derive the client early traffic secret for 0-RTT data.
Definition tlskeyschedule.c:894
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_secret_with_hash(qsc_tls_hash_algorithm hash, const uint8_t *secret, size_t secretlen, const char *label, size_t labellen, const uint8_t *transcripthash, size_t transcripthashlen, uint8_t *output, size_t outlen)
Derive a TLS 1.3 secret using a supplied transcript hash.
Definition tlskeyschedule.c:231
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_secret_empty(qsc_tls_hash_algorithm hash, const uint8_t *secret, size_t secretlen, const char *label, size_t labellen, uint8_t *output, size_t outlen)
Derive a TLS 1.3 secret using the hash of the empty string.
Definition tlskeyschedule.c:258
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_traffic_keys(qsc_tls_hash_algorithm hash, const uint8_t *trafficsecret, size_t trafficsecretlen, size_t keylen, size_t ivlen, uint8_t *keyoutput, uint8_t *ivoutput)
Derive record protection key and IV material from a traffic secret.
Definition tlskeyschedule.c:615
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_derive_resumption_psk(const qsc_tls_key_schedule_state *state, const uint8_t *nonce, size_t noncelen, uint8_t *output, size_t outlen)
Derive a resumption PSK from the resumption master secret.
Definition tlskeyschedule.c:834
QSC_EXPORT_API void qsc_tls_keyschedule_state_dispose(qsc_tls_key_schedule_state *state)
Dispose of a TLS key schedule state.
Definition tlskeyschedule.c:416
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_compute_finished(qsc_tls_hash_algorithm hash, const uint8_t *basekey, size_t basekeylen, const uint8_t *transcripthash, size_t transcripthashlen, uint8_t *output, size_t outlen, size_t *written)
Compute a TLS 1.3 Finished verify_data value.
Definition tlskeyschedule.c:645
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_advance_traffic_secret(qsc_tls_hash_algorithm hash, const uint8_t *currenttrafficsecret, size_t trafficsecretlen, uint8_t *nexttrafficsecret)
Advance an application traffic secret for TLS KeyUpdate.
Definition tlskeyschedule.c:640
QSC_EXPORT_API qsc_tls_status qsc_tls_keyschedule_compute_psk_binder(qsc_tls_hash_algorithm hash, const uint8_t *binderkey, size_t binderkeylen, const uint8_t *partialtranshash, size_t transcripthashlen, uint8_t *output, size_t outlen, size_t *written)
Compute a TLS 1.3 PSK binder MAC.
Definition tlskeyschedule.c:931
TLS internal state container type definitions shared across the record and handshake layers.
Public TLS type definitions.
qsc_tls_cipher_suite
TLS 1.3 cipher-suite identifiers.
Definition tlstypes.h:129
qsc_tls_hash_algorithm
Identifies the transcript and HKDF hash algorithm associated with a TLS cipher suite.
Definition tlstypes.h:69