Add a skeleton TLS record method
authorMatt Caswell <matt@openssl.org>
Thu, 7 Apr 2022 13:09:25 +0000 (14:09 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 18 Aug 2022 15:38:12 +0000 (16:38 +0100)
It doesn't yet do anything. This is a placeholder which will be filled in
by susbsequent commits.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18132)

ssl/build.info
ssl/record/tlsrecord.c [new file with mode: 0644]

index 2ecf5ccd225a414d2ea82a2e656673a6f2f38890..70b22954d314ab48b821736105be01916ccf36c8 100644 (file)
@@ -32,7 +32,7 @@ SOURCE[../libssl]=\
         ssl_asn1.c ssl_txt.c ssl_init.c ssl_conf.c  ssl_mcnf.c \
         bio_ssl.c ssl_err.c ssl_err_legacy.c tls_srp.c t1_trce.c ssl_utst.c \
         record/ssl3_buffer.c record/ssl3_record.c record/dtls1_bitmap.c \
-        statem/statem.c record/ssl3_record_tls13.c \
+        statem/statem.c record/ssl3_record_tls13.c record/tlsrecord.c\
         tls_depr.c $KTLSSRC
 # For shared builds we need to include the libcrypto packet.c and sources
 # needed in providers (s3_cbc.c and record/tls_pad.c) in libssl as well.
diff --git a/ssl/record/tlsrecord.c b/ssl/record/tlsrecord.c
new file mode 100644 (file)
index 0000000..51fb568
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/bio.h>
+#include <openssl/ssl.h>
+#include "recordmethod.h"
+
+struct ossl_record_layer_st
+{
+    /* Placeholder until we have real data to store */
+    int dummy;
+};
+
+static OSSL_RECORD_LAYER *tls_new_record_layer(int vers, int role, int direction,
+                                               int level, unsigned char *secret,
+                                               size_t secretlen, SSL_CIPHER *c,
+                                               BIO *transport, BIO_ADDR *local,
+                                               BIO_ADDR *peer,
+                                               OSSL_PARAM *settings,
+                                               OSSL_PARAM *options)
+{
+    OSSL_RECORD_LAYER *rl = OPENSSL_zalloc(sizeof(*rl));
+
+    return rl;
+}
+
+static void tls_free(OSSL_RECORD_LAYER *rl)
+{
+    OPENSSL_free(rl);
+}
+
+static int tls_reset(OSSL_RECORD_LAYER *rl)
+{
+    memset(rl, 0, sizeof(*rl));
+    return 1;
+}
+
+static int tls_unprocessed_read_pending(OSSL_RECORD_LAYER *rl)
+{
+    return 0;
+}
+
+static int tls_processed_read_pending(OSSL_RECORD_LAYER *rl)
+{
+    return 0;
+}
+
+static size_t tls_app_data_pending(OSSL_RECORD_LAYER *rl)
+{
+    return 0;
+}
+
+static int tls_write_pending(OSSL_RECORD_LAYER *rl)
+{
+    return 0;
+}
+
+static size_t tls_get_max_record_len(OSSL_RECORD_LAYER *rl)
+{
+    return 0;
+}
+
+static size_t tls_get_max_records(OSSL_RECORD_LAYER *rl)
+{
+    return 0;
+}
+
+static int tls_write_records(OSSL_RECORD_LAYER *rl,
+                             OSSL_RECORD_TEMPLATE **templates, size_t numtempl,
+                             size_t allowance, size_t *sent)
+{
+    return 0;
+}
+
+static int tls_retry_write_records(OSSL_RECORD_LAYER *rl, size_t allowance,
+                                   size_t *sent)
+{
+    return 0;
+}
+
+static int tls_read_record(OSSL_RECORD_LAYER *rl, void **rechandle,
+                           int *rversion, int *type, unsigned char **data,
+                           size_t *datalen, uint16_t *epoch,
+                           unsigned char *seq_num)
+{
+    return 0;
+}
+
+static void tls_release_record(OSSL_RECORD_LAYER *rl, void *rechandle)
+{
+    return;
+}
+
+const OSSL_RECORD_METHOD ossl_tls_record_method = {
+    tls_new_record_layer,
+    tls_free,
+    tls_reset,
+    tls_unprocessed_read_pending,
+    tls_processed_read_pending,
+    tls_app_data_pending,
+    tls_write_pending,
+    tls_get_max_record_len,
+    tls_get_max_records,
+    tls_write_records,
+    tls_retry_write_records,
+    tls_read_record,
+    tls_release_record
+};