Skip to contentSkip to conversation

Change in openvpn[master]: Add aws-lc siphash implementation

Openvpn-devel plaisthos (Code Review) 1 participant 2 messages Mar 11 – Mar 19 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1773251317000.I05e20f8c82494e4abf96fe1e3a73e1c7b9101af6@...2715...

#1 lore raw

plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1572?usp=email )

Change subject: Add aws-lc siphash implementation
......................................................................

Add aws-lc siphash implementation

AWS-LC has a siphash implementation that is just a simple function call that also performs the same/better than the reference implementation that it looks to be based on. AWS-lc variant seems to have come from boringssl according to the Google copyright.

Change-Id: I05e20f8c82494e4abf96fe1e3a73e1c7b9101af6
---
M src/openvpn/siphash_openssl.c

1 file changed, 41 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/1572/1

src/openvpn/siphash_openssl.c +41 -0
index 61d9501..5095e4f 100644
@@ -119,7 +119,48 @@
     EVP_MAC_free(sip->mac);
     free(sip_context);
 }
+#elif defined(OPENSSL_IS_AWSLC)
+#include <openssl/siphash.h>
 
+/*
+ *  Computes a SipHash value
+ * in: pointer to input data (read-only)
+ *  inlen: input data length in bytes (any size_t value)
+ * k: pointer to the key data (read-only), must be 16 bytes
+ * out: pointer to output data (write-only), outlen bytes must be allocated
+ *  outlen: length of the output in bytes, must be 8 or 16
+ */
+int
+siphash_cryptolib(void *sip_context, const void *in, const size_t inlen,
+                  const void *k, uint8_t *out, const size_t outlen)
+{
+    ASSERT(outlen == sizeof(uint64_t));
+    uint64_t sipout = SIPHASH_24(k, in, inlen);
+
+    memcpy(out, &sipout, sizeof(uint64_t));
+    return 0;
+}
+
+void *
+siphash_cryptolib_init(size_t hash_size)
+{
+    /* This library only supports 64 bit */
+    ASSERT(hash_size == sizeof(uint64_t));
+    /* AWS LC does not need a context */
+    return NULL;
+}
+
+bool
+siphash_cryptolib_available(void *sip_context)
+{
+    return true;
+}
+
+void
+siphash_cryptolib_uninit(void *sip_context)
+{
+    /* The context is already NULL */
+}
 #else /* if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L */
 /* for now, we only have one implementation of SIPHASH in a libray, so put the
  * dummy functions also here */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1572?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I05e20f8c82494e4abf96fe1e3a73e1c7b9101af6
Gerrit-Change-Number: 1572
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#2 lore raw
In reply to a message not in the archive

plaisthos has uploaded a new patch set (#4). ( http://gerrit.openvpn.net/c/openvpn/+/1572?usp=email )

Change subject: Add aws-lc siphash implementation
......................................................................

Add aws-lc siphash implementation

AWS-LC has a siphash implementation that is just a simple function call that also performs the same/better than the reference implementation that it looks to be based on. AWS-lc variant seems to have come from boringssl according to the Google copyright.

Change-Id I05e20f8c82494e4abf96fe1e3a73e1c7b9101af6

---
M src/openvpn/siphash_openssl.c

1 file changed, 40 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/1572/4

src/openvpn/siphash_openssl.c +40 -2
index bb42a38..2a8e64a 100644
@@ -118,7 +118,47 @@
     EVP_MAC_free(sip->mac);
     free(sip_context);
 }
+#elif defined(OPENSSL_IS_AWSLC)
+#include <openssl/siphash.h>
+/*
+ *  Computes a SipHash value
+ * in: pointer to input data (read-only)
+ *  inlen: input data length in bytes (any size_t value)
+ * k: pointer to the key data (read-only), must be 16 bytes
+ * out: pointer to output data (write-only), outlen bytes must be allocated
+ *  outlen: length of the output in bytes, must be 8 or 16
+ */
+int
+siphash_cryptolib(void *sip_context, const void *in, const size_t inlen,
+                  const void *k, uint8_t *out, const size_t outlen)
+{
+    ASSERT(outlen == sizeof(uint64_t));
+    uint64_t sipout = SIPHASH_24(k, in, inlen);
 
+    memcpy(out, &sipout, sizeof(uint64_t));
+    return 0;
+}
+
+void *
+siphash_cryptolib_init(size_t hash_size)
+{
+    /* This library only supports 64 bit */
+    ASSERT(hash_size == sizeof(uint64_t));
+    /* AWS LC does not need a context */
+    return NULL;
+}
+
+bool
+siphash_cryptolib_available(void *sip_context)
+{
+    return true;
+}
+
+void
+siphash_cryptolib_uninit(void *sip_context)
+{
+    /* The context is already NULL */
+}
 #else
 /* for now, we only have one implementation of SIPHASH in a libray, so put the
  * dummy functions also here */
@@ -145,6 +185,4 @@
 siphash_cryptolib_uninit(void *sip_context)
 {
 }
-
-
 #endif /* if defined(ENABLE_CRYPTO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x30000000L */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1572?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I05e20f8c82494e4abf96fe1e3a73e1c7b9101af6
Gerrit-Change-Number: 1572
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>