aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libkeccak/digest.h15
-rw-r--r--src/libkeccak/files.h15
-rw-r--r--src/libkeccak/generalised-spec.h6
-rw-r--r--src/libkeccak/hex.h8
-rw-r--r--src/libkeccak/internal.h35
-rw-r--r--src/libkeccak/mac/hmac.h47
-rw-r--r--src/libkeccak/spec.h11
-rw-r--r--src/libkeccak/state.h38
8 files changed, 122 insertions, 53 deletions
diff --git a/src/libkeccak/digest.h b/src/libkeccak/digest.h
index 8a69fdb..51a5a6c 100644
--- a/src/libkeccak/digest.h
+++ b/src/libkeccak/digest.h
@@ -21,6 +21,7 @@
#include "state.h"
+#include "internal.h"
/**
@@ -32,7 +33,7 @@
* @param msglen The length of the partial message
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull)))
int libkeccak_fast_update(libkeccak_state_t* restrict state, const char* restrict msg, size_t msglen);
@@ -45,7 +46,7 @@ int libkeccak_fast_update(libkeccak_state_t* restrict state, const char* restric
* @param msglen The length of the partial message
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull)))
int libkeccak_update(libkeccak_state_t* restrict state, const char* restrict msg, size_t msglen);
@@ -61,7 +62,7 @@ int libkeccak_update(libkeccak_state_t* restrict state, const char* restrict msg
* @param hashsum Output parameter for the hashsum, may be `NULL`
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1))))
int libkeccak_fast_digest(libkeccak_state_t* restrict state, const char* restrict msg, size_t msglen,
size_t bits, const char* restrict suffix, char* restrict hashsum);
@@ -78,7 +79,7 @@ int libkeccak_fast_digest(libkeccak_state_t* restrict state, const char* restric
* @param hashsum Output parameter for the hashsum, may be `NULL`
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1))))
int libkeccak_digest(libkeccak_state_t* restrict state, const char* restrict msg, size_t msglen,
size_t bits, const char* restrict suffix, char* restrict hashsum);
@@ -89,7 +90,7 @@ int libkeccak_digest(libkeccak_state_t* restrict state, const char* restrict msg
* @param state The hashing state
* @param times The number of rounds
*/
-__attribute__((nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
void libkeccak_simple_squeeze(register libkeccak_state_t* restrict state, register long times);
@@ -99,7 +100,7 @@ void libkeccak_simple_squeeze(register libkeccak_state_t* restrict state, regist
* @param state The hashing state
* @param times The number of digests
*/
-__attribute__((nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
void libkeccak_fast_squeeze(register libkeccak_state_t* restrict state, register long times);
@@ -109,7 +110,7 @@ void libkeccak_fast_squeeze(register libkeccak_state_t* restrict state, register
* @param state The hashing state
* @param hashsum Output parameter for the hashsum
*/
-__attribute__((nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
void libkeccak_squeeze(register libkeccak_state_t* restrict state, register char* restrict hashsum);
diff --git a/src/libkeccak/files.h b/src/libkeccak/files.h
index 91b25dd..5a0b159 100644
--- a/src/libkeccak/files.h
+++ b/src/libkeccak/files.h
@@ -21,6 +21,7 @@
#include "../libkeccak.h"
+#include "internal.h"
/**
@@ -35,7 +36,7 @@
* at least `(spec->output / 8) * sizeof(char)`, may be `NULL`
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(2, 3)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2, 3))))
int libkeccak_generalised_sum_fd(int fd, libkeccak_state_t* restrict state,
const libkeccak_spec_t* restrict spec,
const char* restrict suffix, char* restrict hashsum);
@@ -52,7 +53,8 @@ int libkeccak_generalised_sum_fd(int fd, libkeccak_state_t* restrict state,
* at least `(spec->output / 8) * sizeof(char)`, may be `NULL`
* @return Zero on success, -1 on error
*/
-static inline __attribute__((nonnull(2, 3), artificial, gnu_inline))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2, 3), artificial, gnu_inline)))
+static inline
int libkeccak_keccaksum_fd(int fd, libkeccak_state_t* restrict state,
const libkeccak_spec_t* restrict spec, char* restrict hashsum)
{
@@ -71,7 +73,8 @@ int libkeccak_keccaksum_fd(int fd, libkeccak_state_t* restrict state,
* at least `(output / 8) * sizeof(char)`, may be `NULL`
* @return Zero on success, -1 on error
*/
-static inline __attribute__((nonnull(2), artificial, gnu_inline))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2), artificial, gnu_inline)))
+static inline
int libkeccak_sha3sum_fd(int fd, libkeccak_state_t* restrict state,
long output, char* restrict hashsum)
{
@@ -93,7 +96,8 @@ int libkeccak_sha3sum_fd(int fd, libkeccak_state_t* restrict state,
* at least `(output / 8) * sizeof(char)`, may be `NULL`
* @return Zero on success, -1 on error
*/
-static inline __attribute__((nonnull(2), artificial, gnu_inline))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2), artificial, gnu_inline)))
+static inline
int libkeccak_rawshakesum_fd(int fd, libkeccak_state_t* restrict state,
long semicapacity, long output, char* restrict hashsum)
{
@@ -115,7 +119,8 @@ int libkeccak_rawshakesum_fd(int fd, libkeccak_state_t* restrict state,
* at least `(output / 8) * sizeof(char)`, may be `NULL`
* @return Zero on success, -1 on error
*/
-static inline __attribute__((nonnull(2), artificial, gnu_inline))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2), artificial, gnu_inline)))
+static inline
int libkeccak_shakesum_fd(int fd, libkeccak_state_t* restrict state,
long semicapacity, long output, char* restrict hashsum)
{
diff --git a/src/libkeccak/generalised-spec.h b/src/libkeccak/generalised-spec.h
index 538c260..1bcfc57 100644
--- a/src/libkeccak/generalised-spec.h
+++ b/src/libkeccak/generalised-spec.h
@@ -21,6 +21,7 @@
#include "spec.h"
+#include "internal.h"
#include <inttypes.h>
@@ -131,7 +132,8 @@ typedef struct libkeccak_generalised_spec
*
* @param spec The specification datastructure to fill in
*/
-static inline __attribute__((nonnull, nothrow, unused))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, unused)))
+static inline
void libkeccak_generalised_spec_initialise(libkeccak_generalised_spec_t* restrict spec)
{
spec->bitrate = LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;
@@ -149,7 +151,7 @@ void libkeccak_generalised_spec_initialise(libkeccak_generalised_spec_t* restric
* @param output_spec The specification datastructure to fill in
* @return Zero if `spec` is valid, a `LIBKECCAK_GENERALISED_SPEC_ERROR_*` if an error was found
*/
-__attribute__((leaf, nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
int libkeccak_degeneralise_spec(libkeccak_generalised_spec_t* restrict spec,
libkeccak_spec_t* restrict output_spec);
diff --git a/src/libkeccak/hex.h b/src/libkeccak/hex.h
index 58e07f8..793f4a1 100644
--- a/src/libkeccak/hex.h
+++ b/src/libkeccak/hex.h
@@ -20,6 +20,8 @@
#define LIBKECCAK_HEX_H 1
+#include "internal.h"
+
#include <stddef.h>
@@ -30,7 +32,7 @@
* @param hashsum The hashsum to convert
* @param n The size of `hashsum`
*/
-__attribute__((leaf, nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
void libkeccak_behex_lower(char* restrict output, const char* restrict hashsum, size_t n);
@@ -41,7 +43,7 @@ void libkeccak_behex_lower(char* restrict output, const char* restrict hashsum,
* @param hashsum The hashsum to convert
* @param n The size of `hashsum`
*/
-__attribute__((leaf, nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
void libkeccak_behex_upper(char* restrict output, const char* restrict hashsum, size_t n);
@@ -52,7 +54,7 @@ void libkeccak_behex_upper(char* restrict output, const char* restrict hashsum,
* @param output Output array, should have an allocation size of at least `strlen(hashsum) / 2`
* @param hashsum The hashsum to convert
*/
-__attribute__((leaf, nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
void libkeccak_unhex(char* restrict output, const char* restrict hashsum);
diff --git a/src/libkeccak/internal.h b/src/libkeccak/internal.h
new file mode 100644
index 0000000..69bc470
--- /dev/null
+++ b/src/libkeccak/internal.h
@@ -0,0 +1,35 @@
+/**
+ * libkeccak – Keccak-family hashing library
+ *
+ * Copyright © 2014, 2015 Mattias Andrée (maandree@member.fsf.org)
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef LIBKECCAK_INTERNAL_H
+#define LIBKECCAK_INTERNAL_H 1
+
+
+/**
+ * Only include some C code (not for CPP directives)
+ * if compiling with GCC.
+ */
+#ifdef __GNUC__
+# define LIBKECCAK_GCC_ONLY(x) x
+#else
+# define LIBKECCAK_GCC_ONLY(x)
+#endif
+
+
+#endif
+
diff --git a/src/libkeccak/mac/hmac.h b/src/libkeccak/mac/hmac.h
index 2b4b264..f85bd3b 100644
--- a/src/libkeccak/mac/hmac.h
+++ b/src/libkeccak/mac/hmac.h
@@ -28,6 +28,7 @@
#include "../spec.h"
#include "../state.h"
+#include "../internal.h"
#include <stddef.h>
#include <stdint.h>
@@ -94,7 +95,7 @@ typedef struct libkeccak_hmac_state
* @param key_length The length of key, in bits
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1), unused))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1), unused)))
int libkeccak_hmac_set_key(libkeccak_hmac_state_t* restrict state, const char* restrict key, size_t key_length);
@@ -107,7 +108,8 @@ int libkeccak_hmac_set_key(libkeccak_hmac_state_t* restrict state, const char* r
* @param key_length The length of key, in bits
* @return Zero on success, -1 on error
*/
-static inline __attribute__((nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull)))
+static inline
int libkeccak_hmac_initialise(libkeccak_hmac_state_t* restrict state, const libkeccak_spec_t* restrict spec,
const char* restrict key, size_t key_length)
{
@@ -131,7 +133,8 @@ int libkeccak_hmac_initialise(libkeccak_hmac_state_t* restrict state, const libk
* @param key_length The length of key, in bits
* @return The state, `NULL` on error
*/
-static inline __attribute__((nonnull, unused, warn_unused_result, malloc))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, unused, warn_unused_result, malloc)))
+static inline
libkeccak_hmac_state_t* libkeccak_hmac_create(const libkeccak_spec_t* restrict spec,
const char* restrict key, size_t key_length)
{
@@ -152,7 +155,8 @@ libkeccak_hmac_state_t* libkeccak_hmac_create(const libkeccak_spec_t* restrict s
* @param key_length The length of key, in bits, ignored if `key == NULL`
* @return Zero on success, -1 on error
*/
-static inline __attribute__((nonnull(1), unused))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1), unused)))
+static inline
int libkeccak_hmac_reset(libkeccak_hmac_state_t* restrict state, const char* restrict key, size_t key_length)
{
libkeccak_state_reset(&(state->sponge));
@@ -165,7 +169,7 @@ int libkeccak_hmac_reset(libkeccak_hmac_state_t* restrict state, const char* res
*
* @param state The state that should be wipe
*/
-__attribute__((nonnull, nothrow, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
void libkeccak_hmac_wipe(volatile libkeccak_hmac_state_t* restrict state);
@@ -194,7 +198,8 @@ void libkeccak_hmac_fast_destroy(libkeccak_hmac_state_t* restrict state)
*
* @param state The state that should be destroyed
*/
-static inline __attribute__((unused, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
+static inline
void libkeccak_hmac_destroy(volatile libkeccak_hmac_state_t* restrict state)
{
if (state == NULL)
@@ -216,7 +221,8 @@ void libkeccak_hmac_destroy(volatile libkeccak_hmac_state_t* restrict state)
*
* @param state The state that should be freed
*/
-static inline __attribute__((unused))
+LIBKECCAK_GCC_ONLY(__attribute__((unused)))
+static inline
void libkeccak_hmac_fast_free(libkeccak_hmac_state_t* restrict state)
{
libkeccak_hmac_fast_destroy(state);
@@ -229,7 +235,8 @@ void libkeccak_hmac_fast_free(libkeccak_hmac_state_t* restrict state)
*
* @param state The state that should be freed
*/
-static inline __attribute__((unused, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
+static inline
void libkeccak_hmac_free(volatile libkeccak_hmac_state_t* restrict state)
{
#ifdef __GNUC__
@@ -251,7 +258,7 @@ void libkeccak_hmac_free(volatile libkeccak_hmac_state_t* restrict state)
* @param src The state to duplicate
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull)))
int libkeccak_hmac_copy(libkeccak_hmac_state_t* restrict dest, const libkeccak_hmac_state_t* restrict src);
@@ -261,7 +268,8 @@ int libkeccak_hmac_copy(libkeccak_hmac_state_t* restrict dest, const libkeccak_h
* @param src The state to duplicate
* @return The duplicate, `NULL` on error
*/
-static inline __attribute__((nonnull, unused, warn_unused_result, malloc))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, unused, warn_unused_result, malloc)))
+static inline
libkeccak_hmac_state_t* libkeccak_hmac_duplicate(const libkeccak_hmac_state_t* restrict src)
{
libkeccak_hmac_state_t* restrict dest = malloc(sizeof(libkeccak_hmac_state_t));
@@ -279,7 +287,8 @@ libkeccak_hmac_state_t* libkeccak_hmac_duplicate(const libkeccak_hmac_state_t* r
* @param state The state as it will be marshalled by a subsequent call to `libkeccak_hamc_marshal`
* @return The allocation size needed for the buffer to which the state will be marshalled
*/
-static inline __attribute__((nonnull, nothrow, unused, warn_unused_result, pure))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, unused, warn_unused_result, pure)))
+static inline
size_t libkeccak_hmac_marshal_size(const libkeccak_hmac_state_t* restrict state)
{
return libkeccak_state_marshal_size(&(state->sponge)) + sizeof(size_t) +
@@ -294,7 +303,8 @@ size_t libkeccak_hmac_marshal_size(const libkeccak_hmac_state_t* restrict state)
* @param data The output buffer
* @return The number of bytes stored to `data`
*/
-static inline __attribute__((nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
+static inline
size_t libkeccak_hmac_marshal(const libkeccak_hmac_state_t* restrict state, char* restrict data)
{
size_t written = libkeccak_state_marshal(&(state->sponge), data);
@@ -316,7 +326,7 @@ size_t libkeccak_hmac_marshal(const libkeccak_hmac_state_t* restrict state, char
* @param data The input buffer
* @return The number of bytes read from `data`, 0 on error
*/
-__attribute__((nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull)))
size_t libkeccak_hmac_unmarshal(libkeccak_hmac_state_t* restrict state, const char* restrict data);
@@ -327,7 +337,8 @@ size_t libkeccak_hmac_unmarshal(libkeccak_hmac_state_t* restrict state, const ch
* @param data The data buffer
* @return The byte size of the stored state
*/
-static inline __attribute__((nonnull, nothrow, warn_unused_result, pure))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, warn_unused_result, pure)))
+static inline
size_t libkeccak_hmac_unmarshal_skip(const char* restrict data)
{
size_t skip = libkeccak_state_unmarshal_skip(data);
@@ -345,7 +356,7 @@ size_t libkeccak_hmac_unmarshal_skip(const char* restrict data)
* @param msglen The length of the partial message, in bytes
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1))))
int libkeccak_hmac_fast_update(libkeccak_hmac_state_t* restrict state, const char* restrict msg, size_t msglen);
@@ -358,7 +369,7 @@ int libkeccak_hmac_fast_update(libkeccak_hmac_state_t* restrict state, const cha
* @param msglen The length of the partial message, in bytes
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1))))
int libkeccak_hmac_update(libkeccak_hmac_state_t* restrict state, const char* restrict msg, size_t msglen);
@@ -376,7 +387,7 @@ int libkeccak_hmac_update(libkeccak_hmac_state_t* restrict state, const char* re
* @param hashsum Output parameter for the hashsum, may be `NULL`
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1))))
int libkeccak_hmac_fast_digest(libkeccak_hmac_state_t* restrict state, const char* restrict msg, size_t msglen,
size_t bits, const char* restrict suffix, char* restrict hashsum);
@@ -395,7 +406,7 @@ int libkeccak_hmac_fast_digest(libkeccak_hmac_state_t* restrict state, const cha
* @param hashsum Output parameter for the hashsum, may be `NULL`
* @return Zero on success, -1 on error
*/
-__attribute__((nonnull(1)))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull(1))))
int libkeccak_hmac_digest(libkeccak_hmac_state_t* restrict state, const char* restrict msg, size_t msglen,
size_t bits, const char* restrict suffix, char* restrict hashsum);
diff --git a/src/libkeccak/spec.h b/src/libkeccak/spec.h
index 3e14f8e..3faecf2 100644
--- a/src/libkeccak/spec.h
+++ b/src/libkeccak/spec.h
@@ -20,6 +20,8 @@
#define LIBKECCAK_SPEC_H 1
+#include "internal.h"
+
#include <stdint.h>
#include <limits.h>
@@ -123,7 +125,8 @@ typedef struct libkeccak_spec
* @param spec The specifications datastructure to fill in
* @param x The value of x in `SHA3-x`, the output size
*/
-static inline __attribute__((nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
+static inline
void libkeccak_spec_sha3(libkeccak_spec_t* restrict spec, long x)
{
spec->bitrate = 1600 - 2 * x;
@@ -139,7 +142,8 @@ void libkeccak_spec_sha3(libkeccak_spec_t* restrict spec, long x)
* @param x The value of x in `RawSHAKEx`, half the capacity
* @param d The output size
*/
-static inline __attribute__((nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
+static inline
void libkeccak_spec_rawshake(libkeccak_spec_t* restrict spec, long x, long d)
{
spec->bitrate = 1600 - 2 * x;
@@ -164,7 +168,8 @@ void libkeccak_spec_rawshake(libkeccak_spec_t* restrict spec, long x, long d)
* @param spec The specifications datastructure to check
* @return Zero if error free, a `LIBKECCAK_SPEC_ERROR_*` if an error was found
*/
-static inline __attribute__((nonnull, nothrow, unused, warn_unused_result, pure))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, unused, warn_unused_result, pure)))
+static inline
int libkeccak_spec_check(const libkeccak_spec_t* restrict spec)
{
long state_size = spec->capacity + spec->bitrate;
diff --git a/src/libkeccak/state.h b/src/libkeccak/state.h
index 4c2c1d8..6bf19f7 100644
--- a/src/libkeccak/state.h
+++ b/src/libkeccak/state.h
@@ -21,6 +21,7 @@
#include "spec.h"
+#include "internal.h"
#include <stddef.h>
#include <stdint.h>
@@ -108,7 +109,7 @@ typedef struct libkeccak_state
* @param spec The specifications for the state
* @return Zero on success, -1 on error
*/
-__attribute__((leaf, nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
int libkeccak_state_initialise(libkeccak_state_t* restrict state, const libkeccak_spec_t* restrict spec);
@@ -117,7 +118,8 @@ int libkeccak_state_initialise(libkeccak_state_t* restrict state, const libkecca
*
* @param state The state that should be reset
*/
-static inline __attribute__((nonnull, nothrow, unused))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, unused)))
+static inline
void libkeccak_state_reset(libkeccak_state_t* restrict state)
{
state->mptr = 0;
@@ -145,7 +147,7 @@ void libkeccak_state_fast_destroy(libkeccak_state_t* restrict state)
*
* @param state The state that should be wipe
*/
-__attribute__((leaf, nonnull, nothrow, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
void libkeccak_state_wipe_message(volatile libkeccak_state_t* restrict state);
/**
@@ -153,7 +155,7 @@ void libkeccak_state_wipe_message(volatile libkeccak_state_t* restrict state);
*
* @param state The state that should be wipe
*/
-__attribute__((leaf, nonnull, nothrow, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
void libkeccak_state_wipe_sponge(volatile libkeccak_state_t* restrict state);
/**
@@ -161,7 +163,7 @@ void libkeccak_state_wipe_sponge(volatile libkeccak_state_t* restrict state);
*
* @param state The state that should be wipe
*/
-__attribute__((nonnull, nothrow, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
void libkeccak_state_wipe(volatile libkeccak_state_t* restrict state);
@@ -170,7 +172,8 @@ void libkeccak_state_wipe(volatile libkeccak_state_t* restrict state);
*
* @param state The state that should be destroyed
*/
-static inline __attribute__((unused, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
+static inline
void libkeccak_state_destroy(volatile libkeccak_state_t* restrict state)
{
if (state == NULL)
@@ -187,7 +190,8 @@ void libkeccak_state_destroy(volatile libkeccak_state_t* restrict state)
* @param spec The specifications for the state
* @return The state, `NULL` on error
*/
-static inline __attribute__((nonnull, unused, warn_unused_result, malloc))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, unused, warn_unused_result, malloc)))
+static inline
libkeccak_state_t* libkeccak_state_create(const libkeccak_spec_t* restrict spec)
{
libkeccak_state_t* restrict state = malloc(sizeof(libkeccak_state_t));
@@ -203,7 +207,8 @@ libkeccak_state_t* libkeccak_state_create(const libkeccak_spec_t* restrict spec)
*
* @param state The state that should be freed
*/
-static inline __attribute__((unused))
+LIBKECCAK_GCC_ONLY(__attribute__((unused)))
+static inline
void libkeccak_state_fast_free(libkeccak_state_t* restrict state)
{
libkeccak_state_fast_destroy(state);
@@ -216,7 +221,8 @@ void libkeccak_state_fast_free(libkeccak_state_t* restrict state)
*
* @param state The state that should be freed
*/
-static inline __attribute__((unused, optimize("-O0")))
+LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
+static inline
void libkeccak_state_free(volatile libkeccak_state_t* restrict state)
{
#ifdef __GNUC__
@@ -238,7 +244,7 @@ void libkeccak_state_free(volatile libkeccak_state_t* restrict state)
* @param src The state to duplicate
* @return Zero on success, -1 on error
*/
-__attribute__((leaf, nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
int libkeccak_state_copy(libkeccak_state_t* restrict dest, const libkeccak_state_t* restrict src);
@@ -248,7 +254,8 @@ int libkeccak_state_copy(libkeccak_state_t* restrict dest, const libkeccak_state
* @param src The state to duplicate
* @return The duplicate, `NULL` on error
*/
-static inline __attribute__((nonnull, unused, warn_unused_result, malloc))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, unused, warn_unused_result, malloc)))
+static inline
libkeccak_state_t* libkeccak_state_duplicate(const libkeccak_state_t* restrict src)
{
libkeccak_state_t* restrict dest = malloc(sizeof(libkeccak_state_t));
@@ -266,7 +273,8 @@ libkeccak_state_t* libkeccak_state_duplicate(const libkeccak_state_t* restrict s
* @param state The state as it will be marshalled by a subsequent call to `libkeccak_state_marshal`
* @return The allocation size needed for the buffer to which the state will be marshalled
*/
-static inline __attribute__((nonnull, nothrow, unused, warn_unused_result, pure))
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, unused, warn_unused_result, pure)))
+static inline
size_t libkeccak_state_marshal_size(const libkeccak_state_t* restrict state)
{
return sizeof(libkeccak_state_t) - sizeof(char*) + state->mptr * sizeof(char);
@@ -280,7 +288,7 @@ size_t libkeccak_state_marshal_size(const libkeccak_state_t* restrict state)
* @param data The output buffer
* @return The number of bytes stored to `data`
*/
-__attribute__((leaf, nonnull, nothrow))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
size_t libkeccak_state_marshal(const libkeccak_state_t* restrict state, char* restrict data);
@@ -291,7 +299,7 @@ size_t libkeccak_state_marshal(const libkeccak_state_t* restrict state, char* re
* @param data The input buffer
* @return The number of bytes read from `data`, 0 on error
*/
-__attribute__((leaf, nonnull))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
size_t libkeccak_state_unmarshal(libkeccak_state_t* restrict state, const char* restrict data);
@@ -302,7 +310,7 @@ size_t libkeccak_state_unmarshal(libkeccak_state_t* restrict state, const char*
* @param data The data buffer
* @return The byte size of the stored state
*/
-__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure))
+LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure)))
size_t libkeccak_state_unmarshal_skip(const char* restrict data);