QSC Post Quantum Cryptographic Library 1.3.0.0 (C1)
A post quantum secure library written in Ansi C
Loading...
Searching...
No Matches
tlsalert.h File Reference

TLS alert message encoding and decoding functions. More...

#include "qsccommon.h"
#include "tlserrors.h"
#include "tlstypes.h"

Go to the source code of this file.

Functions

QSC_EXPORT_API qsc_tls_status qsc_tls_alert_decode (const uint8_t *input, size_t inlen, qsc_tls_alert_description *description)
 Decode a TLS alert record payload.
QSC_EXPORT_API qsc_tls_status qsc_tls_alert_encode (uint8_t *output, size_t outlen, qsc_tls_alert_description description)
 Encode a TLS alert record payload.
QSC_EXPORT_API qsc_tls_status qsc_tls_alert_encode_record (uint8_t *output, size_t outlen, size_t *written, qsc_tls_alert_description description)
QSC_EXPORT_API qsc_tls_alert_description qsc_tls_alert_from_status (qsc_tls_status status)
QSC_EXPORT_API bool qsc_tls_alert_is_close_notify (qsc_tls_alert_description description)
 Check if alert is close_notify.
QSC_EXPORT_API bool qsc_tls_alert_is_fatal_level (uint8_t level)
 Check if alert level is fatal.
QSC_EXPORT_API bool qsc_tls_alert_is_valid (qsc_tls_alert_description description)
 Validate alert description.
QSC_EXPORT_API const char * qsc_tls_alert_to_string (qsc_tls_alert_description description)
 Convert alert description to string (debug only)

Detailed Description

TLS alert message encoding and decoding functions.

This header declares helpers that convert between the compact two-byte TLS alert wire format and the internal alert description enumeration used by the TLS implementation.

Function Documentation

◆ qsc_tls_alert_decode()

QSC_EXPORT_API qsc_tls_status qsc_tls_alert_decode ( const uint8_t * input,
size_t inlen,
qsc_tls_alert_description * description )

Decode a TLS alert record payload.

Parses the standard two-byte TLS alert payload and extracts the alert description field.

Parameters
input[const uint8_t*] The encoded alert payload.
inlen[size_t] The length of the encoded input in bytes.
description[enum*] Receives the decoded TLS alert description.
Returns
[qsc_tls_status] Returns the operation status.

◆ qsc_tls_alert_encode()

QSC_EXPORT_API qsc_tls_status qsc_tls_alert_encode ( uint8_t * output,
size_t outlen,
qsc_tls_alert_description description )

Encode a TLS alert record payload.

Writes the standard two-byte TLS alert payload to the destination buffer. The severity level is implementation-defined by the encoder and the supplied description is written as the alert description field.

Parameters
output[uint8_t*] The destination buffer receiving the encoded alert payload.
outlen[size_t] The length of the destination buffer in bytes.
description[enum] The TLS alert description to encode.
Returns
[qsc_tls_status] Returns the operation status.

◆ qsc_tls_alert_encode_record()

QSC_EXPORT_API qsc_tls_status qsc_tls_alert_encode_record ( uint8_t * output,
size_t outlen,
size_t * written,
qsc_tls_alert_description description )

Brief Encode a plaintext TLS alert record.

Builds the two-byte alert payload and wraps it in a TLSPlaintext record of content type alert. This is used for alert transmission before encrypted traffic keys are available.

Parameters
output[uint8_t*] The destination buffer receiving the encoded record.
outlen[size_t] The length of the destination buffer in bytes.
written[size_t*] Receives the number of bytes written.
description[enum] The TLS alert description to encode.
Returns
[qsc_tls_status] Returns the operation status.

◆ qsc_tls_alert_from_status()

QSC_EXPORT_API qsc_tls_alert_description qsc_tls_alert_from_status ( qsc_tls_status status)

Brief Map an internal TLS status value to an RFC alert description.

Converts internal parser, state-machine, and authentication failures to the closest TLS alert description used on the wire. This helper is used when the wrapper layer needs to emit a protocol alert in response to a local failure.

Parameters
status[enum] The internal TLS status value.
Returns
[enum] Returns the mapped TLS alert description.

◆ qsc_tls_alert_is_close_notify()

QSC_EXPORT_API bool qsc_tls_alert_is_close_notify ( qsc_tls_alert_description description)

Check if alert is close_notify.

Parameters
description[enum] Alert description
Returns
: true if close_notify

◆ qsc_tls_alert_is_fatal_level()

QSC_EXPORT_API bool qsc_tls_alert_is_fatal_level ( uint8_t level)

Check if alert level is fatal.

Parameters
level[uint8_t] Alert level
Returns
: true if fatal

◆ qsc_tls_alert_is_valid()

QSC_EXPORT_API bool qsc_tls_alert_is_valid ( qsc_tls_alert_description description)

Validate alert description.

Parameters
description[enum] Alert description
Returns
: true if valid

◆ qsc_tls_alert_to_string()

QSC_EXPORT_API const char * qsc_tls_alert_to_string ( qsc_tls_alert_description description)

Convert alert description to string (debug only)

Parameters
description[qsc_tls_alert_description] Alert description enumerator
Returns
: const string name