(void)s_errno;
(void)format;
(void)ap;
+
+ assert(format);
}
void sptps_log_stderr(sptps_t *s, int s_errno, const char *format, va_list ap) {
(void)s;
(void)s_errno;
+
+ assert(format);
+
vfprintf(stderr, format, ap);
fputc('\n', stderr);
}
// Log an error message.
static bool error(sptps_t *s, int s_errno, const char *format, ...) {
+ assert(s_errno);
+ assert(format);
+
if(format) {
va_list ap;
va_start(ap, format);
}
static void warning(sptps_t *s, const char *format, ...) {
+ assert(format);
+
va_list ap;
va_start(ap, format);
sptps_log(s, 0, format, ap);
// Send an application record.
bool sptps_send_record(sptps_t *s, uint8_t type, const void *data, uint16_t len) {
+ assert(!len || data);
+
// Sanity checks: application cannot send data before handshake is finished,
// and only record types 0..127 are allowed.
if(!s->outstate) {
// Generate key material from the shared secret created from the ECDHE key exchange.
static bool generate_key_material(sptps_t *s, const char *shared, size_t len) {
+ assert(shared);
+ assert(len);
+
// Initialise cipher and digest structures if necessary
if(!s->outstate) {
s->incipher = chacha_poly1305_init();
// Force another Key EXchange (for testing purposes).
bool sptps_force_kex(sptps_t *s) {
- if(!s->outstate || s->state != SPTPS_SECONDARY_KEX) {
+ if(!s->outstate) {
return error(s, EINVAL, "Cannot force KEX in current state");
}
+ if(s->state != SPTPS_SECONDARY_KEX) {
+ // We are already in the middle of a key exchange
+ return true;
+ }
+
s->state = SPTPS_KEX;
return send_kex(s);
}