Commit bfe4d48d authored by Niels Möller's avatar Niels Möller
Browse files

Reorder declarations.

parent 5a66bb56
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/* nettle, low-level cryptographics library /* nettle, low-level cryptographics library
* *
* Copyright (C) 2013 Nikos Mavrogiannopoulos * Copyright (C) 2013 Nikos Mavrogiannopoulos
* Copyright (C) 2013, 2014 Niels Möller
* *
* The nettle library is free software; you can redistribute it and/or modify * The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
...@@ -26,13 +27,20 @@ ...@@ -26,13 +27,20 @@
#ifndef NETTLE_POLY1305_H_INCLUDED #ifndef NETTLE_POLY1305_H_INCLUDED
#define NETTLE_POLY1305_H_INCLUDED #define NETTLE_POLY1305_H_INCLUDED
#include "nettle-types.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Low level functions/macros for the poly1305 construction. */ /* Name mangling */
#define poly1305_set_key nettle_poly1305_set_key
#define poly1305_set_nonce nettle_poly1305_set_nonce
#define poly1305_update nettle_poly1305_update
#define poly1305_block nettle_poly1305_block
#define poly1305_digest nettle_poly1305_digest
#include "nettle-types.h" /* Low level functions/macros for the poly1305 construction. */
struct poly1305_ctx { struct poly1305_ctx {
/* Key, 128-bit value and some cached multiples. */ /* Key, 128-bit value and some cached multiples. */
...@@ -57,16 +65,6 @@ struct poly1305_ctx { ...@@ -57,16 +65,6 @@ struct poly1305_ctx {
unsigned index; unsigned index;
}; };
/* All-in-one context, with cipher, and state. Cipher must have a 128-bit block */
#define POLY1305_CTX(type) \
{ struct poly1305_ctx pctx; type cipher; }
#define poly1305_set_key nettle_poly1305_set_key
#define poly1305_set_nonce nettle_poly1305_set_nonce
#define poly1305_update nettle_poly1305_update
#define poly1305_block nettle_poly1305_block
#define poly1305_digest nettle_poly1305_digest
void poly1305_set_key(struct poly1305_ctx *ctx, const uint8_t key[16]); void poly1305_set_key(struct poly1305_ctx *ctx, const uint8_t key[16]);
void poly1305_set_nonce (struct poly1305_ctx *ctx, const uint8_t * nonce); void poly1305_set_nonce (struct poly1305_ctx *ctx, const uint8_t * nonce);
void poly1305_block (struct poly1305_ctx *ctx, const uint8_t m[16]); void poly1305_block (struct poly1305_ctx *ctx, const uint8_t m[16]);
...@@ -74,6 +72,10 @@ void poly1305_update (struct poly1305_ctx *ctx, size_t size, const uint8_t *data ...@@ -74,6 +72,10 @@ void poly1305_update (struct poly1305_ctx *ctx, size_t size, const uint8_t *data
void poly1305_digest (struct poly1305_ctx *ctx, void poly1305_digest (struct poly1305_ctx *ctx,
size_t length, uint8_t *digest, const uint8_t *s); size_t length, uint8_t *digest, const uint8_t *s);
/* All-in-one context, with cipher, and state. Cipher must have a 128-bit block */
#define POLY1305_CTX(type) \
{ struct poly1305_ctx pctx; type cipher; }
#define POLY1305_SET_KEY(ctx, set_key, key) \ #define POLY1305_SET_KEY(ctx, set_key, key) \
do { \ do { \
poly1305_set_key(&(ctx)->pctx, (key+16)); \ poly1305_set_key(&(ctx)->pctx, (key+16)); \
...@@ -94,7 +96,6 @@ void poly1305_digest (struct poly1305_ctx *ctx, ...@@ -94,7 +96,6 @@ void poly1305_digest (struct poly1305_ctx *ctx,
} while(0); } while(0);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
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