*/
void sptps_log_quiet(sptps_t *s, int s_errno, const char *format, va_list ap) {
+ (void)s;
+ (void)s_errno;
+ (void)format;
+ (void)ap;
}
void sptps_log_stderr(sptps_t *s, int s_errno, const char *format, va_list ap) {
+ (void)s;
+ (void)s_errno;
+
vfprintf(stderr, format, ap);
fputc('\n', stderr);
}
// Log an error message.
static bool error(sptps_t *s, int s_errno, const char *format, ...) {
+ (void)s;
+ (void)s_errno;
+
if(format) {
va_list ap;
va_start(ap, format);
// Receive an ACKnowledgement record.
static bool receive_ack(sptps_t *s, const char *data, uint16_t len) {
+ (void)data;
+
if(len) {
return error(s, EIO, "Invalid ACK record length");
}
memcpy(s->hiskex, data, len);
- return send_sig(s);
+ if(s->initiator) {
+ return send_sig(s);
+ } else {
+ return true;
+ }
}
// Receive a SIGnature record, verify it, if it passed, compute the shared secret and calculate the session keys.
return false;
}
+ if(!s->initiator && !send_sig(s)) {
+ return false;
+ }
+
free(s->mykex);
free(s->hiskex);
return false;
}
+ // Fall through
case SPTPS_KEX:
// We have sent our KEX request, we expect our peer to sent one as well.
}
} else if(update_state) {
// We missed some packets. Mark them in the bitmap as being late.
- for(int i = s->inseqno; i < seqno; i++) {
+ for(uint32_t i = s->inseqno; i < seqno; i++) {
s->late[(i / 8) % s->replaywin] |= 1 << i % 8;
}
}
}
// Check datagram for valid HMAC
-bool sptps_verify_datagram(sptps_t *s, const void *data, size_t len) {
+bool sptps_verify_datagram(sptps_t *s, const void *vdata, size_t len) {
if(!s->instate || len < 21) {
return error(s, EIO, "Received short packet");
}
+ const char *data = vdata;
uint32_t seqno;
memcpy(&seqno, data, 4);
seqno = ntohl(seqno);
}
// Receive incoming data. Check if it contains a complete record, if so, handle it.
-size_t sptps_receive_data(sptps_t *s, const void *data, size_t len) {
+size_t sptps_receive_data(sptps_t *s, const void *vdata, size_t len) {
+ const char *data = vdata;
size_t total_read = 0;
if(!s->state) {