+// Pass through unencrypted data.
+bool sptps_send_unencrypted(sptps_t *s, const void *data, uint16_t len) {
+ // Sanity checks: application cannot send data before handshake is finished,
+ // and only non-datagram allowed.
+ if(!s->outstate) {
+ return error(s, EINVAL, "Handshake phase not finished yet");
+ }
+
+ if(s->datagram) {
+ return error(s, EINVAL, "Not allowed for datagrams");
+ }
+
+ return s->send_data(s->handle, SPTPS_UNENCRYPTED, data, len);
+}
+
+// Expect a given number of unencrypted bytes.
+bool sptps_expect_unencrypted(sptps_t *s, uint16_t len) {
+ // Sanity checks: application cannot send data before handshake is finished,
+ // and only non-datagram allowed.
+ if(!s->instate) {
+ return error(s, EINVAL, "Handshake phase not finished yet");
+ }
+
+ if(s->datagram) {
+ return error(s, EINVAL, "Not allowed for datagrams");
+ }
+
+ s->reclen = len;
+ s->passthrough = true;
+ return true;
+}
+