Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1572?usp=email
to look at the new patch set (#23).
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.
The return type of the siphash related function has been also removed as
neither the reference nor the aws-lc implementation can fail. Only the
OpenSSL based implementation needed a return type.
Change-Id: I05e20f8c82494e4abf96fe1e3a73e1c7b9101af6
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/siphash.h
M src/openvpn/siphash_reference.c
2 files changed, 43 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/1572/23
diff --git a/src/openvpn/siphash.h b/src/openvpn/siphash.h
index bddddc3..ade7762 100644
--- a/src/openvpn/siphash.h
+++ b/src/openvpn/siphash.h
@@ -18,26 +18,63 @@
#ifndef SIPHASH_H
#define SIPHASH_H
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
+/* We need to include this to check for the OPENSSL_IS_AWSLC macro */
+#ifdef ENABLE_CRYPTO_OPENSSL
+#include <openssl/opensslv.h>
+#endif
+
/* siphash always uses 128-bit keys */
#define SIPHASH_KEY_SIZE 16
/**
* Calculates SIPHASH using the reference implementation
*/
-int
+void
siphash_reference(const void *in, size_t inlen, const void *k,
uint8_t *out, size_t outlen);
-static inline int
+#if defined(OPENSSL_IS_AWSLC)
+#define USE_CRYPOTOLIB_SIPHASH
+#include <openssl/siphash.h>
+#include <string.h>
+#include "error.h"
+/**
+ * Computes a SipHash value
+ * @param in pointer to input data (read-only)
+ * @param inlen input data length in bytes (any size_t value)
+ * @param k pointer to the key data (read-only), must be 16 bytes
+ * @param out pointer to output data (write-only), outlen bytes must be
allocated
+ * @param outlen length of the output in bytes, must be 8
+ */
+static inline void
+siphash_cryptolib(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));
+}
+#endif
+
+static inline void
siphash(const void *in, size_t inlen, const void *k,
uint8_t *out, size_t outlen)
{
- return siphash_reference(in, inlen, k, out, outlen);
+#if defined(USE_CRYPOTOLIB_SIPHASH)
+ siphash_cryptolib(in, inlen, k, out, outlen);
+#else
+ siphash_reference(in, inlen, k, out, outlen);
+#endif
}
-#endif /* ifndef SIPHASH_H */
\ No newline at end of file
+#endif /* ifndef SIPHASH_H */
diff --git a/src/openvpn/siphash_reference.c b/src/openvpn/siphash_reference.c
index ad19a51..5f0adb9 100644
--- a/src/openvpn/siphash_reference.c
+++ b/src/openvpn/siphash_reference.c
@@ -99,7 +99,7 @@
* 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
+void
siphash_reference(const void *in, const size_t inlen, const void *k, uint8_t
*out,
const size_t outlen)
{
@@ -206,7 +206,7 @@
if (outlen == 8)
{
- return 0;
+ return;
}
v1 ^= 0xdd;
@@ -219,6 +219,4 @@
b = v0 ^ v1 ^ v2 ^ v3;
U64TO8_LE(out + 8, b);
-
- return 0;
}
--
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: 23
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel