Commit 1f54f5c8 authored by Michael Hamburg's avatar Michael Hamburg

change __attribute__((nonnull(list of pointers))) to __attribute__((nonnull))

parent 0a043c34
......@@ -49,14 +49,14 @@ typedef struct {
void $(c_ns)_derive_private_key (
$(c_ns)_private_key_t priv,
const $(c_ns)_symmetric_key_t proto
) NONNULL2 API_VIS;
) NONNULL API_VIS;
/**
* Destroy a private key.
*/
void $(c_ns)_destroy_private_key (
$(c_ns)_private_key_t priv
) NONNULL1 API_VIS;
) NONNULL API_VIS;
/**
* Convert a private key to a public one.
......@@ -66,7 +66,7 @@ void $(c_ns)_destroy_private_key (
void $(c_ns)_private_to_public (
$(c_ns)_public_key_t pub,
const $(c_ns)_private_key_t priv
) NONNULL2 API_VIS;
) NONNULL API_VIS;
/**
* Compute a Diffie-Hellman shared secret.
......@@ -90,7 +90,7 @@ $(c_ns)_shared_secret (
const $(c_ns)_private_key_t my_privkey,
const $(c_ns)_public_key_t your_pubkey,
int me_first
) NONNULL134 WARN_UNUSED API_VIS;
) NONNULL WARN_UNUSED API_VIS;
/**
* Sign a message from a STROBE context.
......@@ -104,7 +104,7 @@ $(c_ns)_sign_strobe (
keccak_strobe_t strobe,
$(c_ns)_signature_t sig,
const $(c_ns)_private_key_t priv
) NONNULL3 API_VIS;
) NONNULL API_VIS;
/**
* Sign a message.
......@@ -120,7 +120,7 @@ $(c_ns)_sign (
const $(c_ns)_private_key_t priv,
const unsigned char *message,
size_t message_len
) NONNULL3 API_VIS;
) NONNULL API_VIS;
/**
* Verify a signed message from its STROBE context.
......@@ -137,7 +137,7 @@ $(c_ns)_verify_strobe (
keccak_strobe_t strobe,
const $(c_ns)_signature_t sig,
const $(c_ns)_public_key_t pub
) NONNULL3 API_VIS WARN_UNUSED;
) NONNULL API_VIS WARN_UNUSED;
/**
* Verify a signed message.
......@@ -156,7 +156,7 @@ $(c_ns)_verify (
const $(c_ns)_public_key_t pub,
const unsigned char *message,
size_t message_len
) NONNULL3 API_VIS WARN_UNUSED;
) NONNULL API_VIS WARN_UNUSED;
#ifdef __cplusplus
} /* extern "C" */
......
This diff is collapsed.
......@@ -27,13 +27,7 @@ extern "C" {
#define API_VIS __attribute__((visibility("default")))
#define NOINLINE __attribute__((noinline))
#define WARN_UNUSED __attribute__((warn_unused_result))
#define NONNULL1 __attribute__((nonnull(1)))
#define NONNULL2 __attribute__((nonnull(1,2)))
#define NONNULL3 __attribute__((nonnull(1,2,3)))
#define NONNULL13 __attribute__((nonnull(1,3)))
#define NONNULL134 __attribute__((nonnull(1,3,4)))
#define NONNULL4 __attribute__((nonnull(1,2,3,4)))
#define NONNULL5 __attribute__((nonnull(1,2,3,4,5)))
#define NONNULL __attribute__((nonnull))
#define INLINE inline __attribute__((always_inline))
#define UNUSED __attribute__((unused))
/** @endcond */
......@@ -101,14 +95,14 @@ decaf_successful(decaf_error_t e) {
void decaf_bzero (
void *data,
size_t size
) NONNULL1 API_VIS;
) NONNULL API_VIS;
/** Compare two buffers, returning DECAF_TRUE if they are equal. */
decaf_bool_t decaf_memeq (
const void *data1,
const void *data2,
size_t size
) NONNULL2 WARN_UNUSED API_VIS;
) NONNULL WARN_UNUSED API_VIS;
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -116,46 +116,46 @@ void sponge_hash (
#define DECSHAKE(n) \
extern const struct kparams_s SHAKE##n##_params_s API_VIS; \
typedef struct shake##n##_ctx_s { keccak_sponge_t s; } shake##n##_ctx_t[1]; \
static inline void NONNULL1 shake##n##_init(shake##n##_ctx_t sponge) { \
static inline void NONNULL shake##n##_init(shake##n##_ctx_t sponge) { \
sponge_init(sponge->s, &SHAKE##n##_params_s); \
} \
static inline void NONNULL1 shake##n##_gen_init(keccak_sponge_t sponge) { \
static inline void NONNULL shake##n##_gen_init(keccak_sponge_t sponge) { \
sponge_init(sponge, &SHAKE##n##_params_s); \
} \
static inline void NONNULL2 shake##n##_update(shake##n##_ctx_t sponge, const uint8_t *in, size_t inlen ) { \
static inline void NONNULL shake##n##_update(shake##n##_ctx_t sponge, const uint8_t *in, size_t inlen ) { \
sha3_update(sponge->s, in, inlen); \
} \
static inline void NONNULL2 shake##n##_final(shake##n##_ctx_t sponge, uint8_t *out, size_t outlen ) { \
static inline void NONNULL shake##n##_final(shake##n##_ctx_t sponge, uint8_t *out, size_t outlen ) { \
sha3_output(sponge->s, out, outlen); \
sponge_init(sponge->s, &SHAKE##n##_params_s); \
} \
static inline void NONNULL13 shake##n##_hash(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen) { \
static inline void NONNULL shake##n##_hash(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen) { \
sponge_hash(in,inlen,out,outlen,&SHAKE##n##_params_s); \
} \
static inline void NONNULL1 shake##n##_destroy( shake##n##_ctx_t sponge ) { \
static inline void NONNULL shake##n##_destroy( shake##n##_ctx_t sponge ) { \
sponge_destroy(sponge->s); \
}
#define DECSHA3(n) \
extern const struct kparams_s SHA3_##n##_params_s API_VIS; \
typedef struct sha3_##n##_ctx_s { keccak_sponge_t s; } sha3_##n##_ctx_t[1]; \
static inline void NONNULL1 sha3_##n##_init(sha3_##n##_ctx_t sponge) { \
static inline void NONNULL sha3_##n##_init(sha3_##n##_ctx_t sponge) { \
sponge_init(sponge->s, &SHA3_##n##_params_s); \
} \
static inline void NONNULL1 sha3_##n##_gen_init(keccak_sponge_t sponge) { \
static inline void NONNULL sha3_##n##_gen_init(keccak_sponge_t sponge) { \
sponge_init(sponge, &SHA3_##n##_params_s); \
} \
static inline void NONNULL2 sha3_##n##_update(sha3_##n##_ctx_t sponge, const uint8_t *in, size_t inlen ) { \
static inline void NONNULL sha3_##n##_update(sha3_##n##_ctx_t sponge, const uint8_t *in, size_t inlen ) { \
sha3_update(sponge->s, in, inlen); \
} \
static inline void NONNULL2 sha3_##n##_final(sha3_##n##_ctx_t sponge, uint8_t *out, size_t outlen ) { \
static inline void NONNULL sha3_##n##_final(sha3_##n##_ctx_t sponge, uint8_t *out, size_t outlen ) { \
sha3_output(sponge->s, out, outlen); \
sponge_init(sponge->s, &SHA3_##n##_params_s); \
} \
static inline void NONNULL13 sha3_##n##_hash(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen) { \
static inline void NONNULL sha3_##n##_hash(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen) { \
sponge_hash(in,inlen,out,outlen,&SHA3_##n##_params_s); \
} \
static inline void NONNULL1 sha3_##n##_destroy(sha3_##n##_ctx_t sponge) { \
static inline void NONNULL sha3_##n##_destroy(sha3_##n##_ctx_t sponge) { \
sponge_destroy(sponge->s); \
}
/** @endcond */
......
......@@ -32,7 +32,7 @@ void spongerng_init_from_buffer (
const uint8_t *__restrict__ in, /**< [in] The initialization data. */
size_t len, /**< [in] The length of the initialization data. */
int deterministic /**< [in] If zero, allow RNG to stir in nondeterministic data from RDRAND or RDTSC.*/
) NONNULL2 API_VIS;
) NONNULL API_VIS;
/**
* @brief Initialize a sponge-based CSPRNG from a file.
......@@ -45,7 +45,7 @@ decaf_error_t spongerng_init_from_file (
const char *file, /**< [in] A name of a file containing initial data. */
size_t len, /**< [in] The length of the initial data. Must be positive. */
int deterministic /**< [in] If zero, allow RNG to stir in nondeterministic data from RDRAND or RDTSC. */
) NONNULL2 API_VIS WARN_UNUSED;
) NONNULL API_VIS WARN_UNUSED;
/**
* @brief Initialize a nondeterministic sponge-based CSPRNG from /dev/urandom.
......@@ -69,7 +69,7 @@ void spongerng_stir (
keccak_prng_t prng, /**< [out] The PRNG object. */
const uint8_t * __restrict__ in, /**< [in] The entropy data. */
size_t len /**< [in] The length of the initial data. */
) NONNULL2 API_VIS;
) NONNULL API_VIS;
/** Securely destroy a sponge RNG object by overwriting it. */
static INLINE UNUSED void
......
......@@ -44,7 +44,7 @@ void strobe_init (
const struct kparams_s *params, /**< [in] Parameter set descriptor. */
const char *proto, /**< [in] Unique identifier for the protocol. TODO: define namespaces for this */
uint8_t am_client /**< [in] Nonzero if this party. */
) NONNULL2 API_VIS;
) NONNULL API_VIS;
/** Run a transaction against a STROBE state. */
void strobe_transact (
......@@ -53,10 +53,10 @@ void strobe_transact (
const unsigned char *in, /**< [in] The input. */
size_t len, /**< [in] The length of the input/output. */
uint32_t cw_flags /**< [in] The control word with flags. */
) NONNULL1 API_VIS;
) __attribute__((nonnull(1))) API_VIS;
/** Record a message sent in plaintext */
static INLINE UNUSED void strobe_plaintext (
static INLINE UNUSED NONNULL void strobe_plaintext (
keccak_strobe_t strobe, /**< [inout] The STROBE object */
const unsigned char *in, /**< [in] The message. */
uint16_t len, /**< [in] The length of the message. */
......@@ -64,7 +64,7 @@ static INLINE UNUSED void strobe_plaintext (
);
/** Report authenticated data in strobe context. */
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_ad (
keccak_strobe_t strobe, /**< [inout] The strobe object. */
const unsigned char *in, /**< [in] The plaintext. */
......@@ -72,7 +72,7 @@ strobe_ad (
);
/** Set nonce in strobe context. */
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_nonce (
keccak_strobe_t strobe, /**< [inout] The initialized strobe object. */
const unsigned char *in, /**< [in] The nonce. */
......@@ -80,7 +80,7 @@ strobe_nonce (
);
/** Set fixed key in strobe context. */
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_fixed_key (
keccak_strobe_t strobe, /**< [inout] The initialized strobe object. */
const unsigned char *in, /**< [in] The key. */
......@@ -88,7 +88,7 @@ strobe_fixed_key (
);
/** Set Diffie-Hellman key in strobe context. */
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_dh_key (
keccak_strobe_t strobe, /**< [inout] The initialized strobe object. */
const unsigned char *in, /**< [in] The key. */
......@@ -99,7 +99,7 @@ strobe_dh_key (
#define STROBE_MAX_AUTH_BYTES 32
/** Produce an authenticator. */
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_produce_auth (
keccak_strobe_t strobe, /**< [inout] The Strobe protocol context. */
unsigned char *out, /**< [out] The authenticator. */
......@@ -116,13 +116,13 @@ decaf_error_t strobe_verify_auth (
keccak_strobe_t strobe, /**< [inout] The Strobe protocol context */
const unsigned char *in, /**< [in] The authenticator */
uint16_t len /**< [in] The length, at most STROBE_MAX_AUTH_BYTES. */
) WARN_UNUSED NONNULL2 API_VIS;
) WARN_UNUSED NONNULL API_VIS;
/**
* @brief Encrypt bytes from in to out.
* @warning Doesn't produce an auth tag.
*/
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_encrypt (
keccak_strobe_t strobe, /**< [inout] strobe The Strobe protocol context. */
unsigned char *out, /**< [out] The ciphertext. */
......@@ -134,7 +134,7 @@ strobe_encrypt (
* Decrypt bytes from in to out.
* @warning Doesn't check an auth tag.
*/
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_decrypt (
keccak_strobe_t strobe, /**< [inout] The Strobe protocol context. */
unsigned char *out, /**< [out] The plaintext. */
......@@ -149,7 +149,7 @@ strobe_decrypt (
* refreshing forward secrecy! It's to replace things
* like TCP session hash.
*/
static inline void strobe_prng (
static inline void NONNULL strobe_prng (
keccak_strobe_t strobe, /**< [inout] The Strobe protocol context */
unsigned char *out, /**< [out] The output random data. */
uint16_t len /**< The length. */
......@@ -159,10 +159,10 @@ static inline void strobe_prng (
void strobe_respec (
keccak_strobe_t strobe, /**< [inout] The initialized strobe context. */
const struct kparams_s *params /**< [in] Strobe parameter descriptor. */
) NONNULL2 API_VIS;
) NONNULL API_VIS;
/** Securely destroy a STROBE object by overwriting it. */
static INLINE UNUSED void
static INLINE UNUSED NONNULL void
strobe_destroy (
keccak_strobe_t doomed /**< [in] The object to destroy. */
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment