]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
wolfssl: Support SHA3
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 18 Mar 2021 06:58:21 +0000 (07:58 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sat, 20 Mar 2021 10:15:42 +0000 (11:15 +0100)
src/libstrongswan/plugins/wolfssl/wolfssl_plugin.c
src/libstrongswan/plugins/wolfssl/wolfssl_util.c

index d64be69de54d2ea6a93d83e02737c426ed76cefd..64fb71c2a92a6f64751ae2b1db0674f229277a72 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2019 Sean Parkinson, wolfSSL Inc.
+ * Copyright (C) 2021 Andreas Steffen, strongSec GmbH
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -118,6 +119,18 @@ METHOD(plugin_t, get_features, int,
 #ifdef WOLFSSL_SHA512
                        PLUGIN_PROVIDE(HASHER, HASH_SHA512),
 #endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_224)
+                       PLUGIN_PROVIDE(HASHER, HASH_SHA3_224),
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256)
+                       PLUGIN_PROVIDE(HASHER, HASH_SHA3_256),
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_384)
+                       PLUGIN_PROVIDE(HASHER, HASH_SHA3_384),
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_512)
+                       PLUGIN_PROVIDE(HASHER, HASH_SHA3_512),
+#endif
 #ifndef NO_SHA
                /* keyed sha1 hasher (aka prf) */
                PLUGIN_REGISTER(PRF, wolfssl_sha1_prf_create),
index c83c2982bdf0bca269a882a14a5a22351671fa7a..4d3b33b3b720d6de2dba10d72d90274e1359ec11 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2019 Sean Parkinson, wolfSSL Inc.
+ * Copyright (C) 2021 Andreas Steffen, strongSec GmbH
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -147,6 +148,26 @@ bool wolfssl_hash2type(hash_algorithm_t hash, enum wc_HashType *type)
                case HASH_SHA512:
                        *type = WC_HASH_TYPE_SHA512;
                        break;
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_224)
+               case HASH_SHA3_224:
+                       *type = WC_HASH_TYPE_SHA3_224;
+                       break;
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256)
+               case HASH_SHA3_256:
+                       *type = WC_HASH_TYPE_SHA3_256;
+                       break;
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_384)
+               case HASH_SHA3_384:
+                       *type = WC_HASH_TYPE_SHA3_384;
+                       break;
+#endif
+#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_512)
+               case HASH_SHA3_512:
+                       *type = WC_HASH_TYPE_SHA3_512;
+                       break;
 #endif
                default:
                        return FALSE;