Add sctp authentication to sctp_lib

This only works for linux >=5.4. When enabled, it will use
a shared key to authenticate messages. The functionality is
controlled by a flag and behind a linux version check.

Performance degradation is minimal, even for smaller messages
and unnoticeable when measuring overall system performance.

Change-Id: I836e61ec38a0c116fd7244b771437738ccca9828
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/aos/network/sctp_lib.h b/aos/network/sctp_lib.h
index 8eb57d3..f78934a 100644
--- a/aos/network/sctp_lib.h
+++ b/aos/network/sctp_lib.h
@@ -3,6 +3,7 @@
 
 #include <arpa/inet.h>
 #include <linux/sctp.h>
+#include <linux/version.h>
 
 #include <memory>
 #include <optional>
@@ -15,6 +16,8 @@
 
 #include "aos/unique_malloc_ptr.h"
 
+#define HAS_SCTP_AUTH LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
+
 namespace aos {
 namespace message_bridge {
 
@@ -92,7 +95,7 @@
 // Manages reading and writing SCTP messages.
 class SctpReadWrite {
  public:
-  SctpReadWrite() = default;
+  SctpReadWrite(std::vector<uint8_t> auth_key = {});
   ~SctpReadWrite() { CloseSocket(); }
 
   // Opens a new socket.
@@ -161,6 +164,8 @@
 
   bool use_pool_ = false;
   std::vector<aos::unique_c_ptr<Message>> free_messages_;
+
+  std::vector<uint8_t> auth_key_;
 };
 
 // Returns the max network buffer available for reading for a socket.