1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-28 22:21:15 -07:00

Get rid of poly1305_state to reduce the number of indirections

This commit is contained in:
Frank Denis 2015-11-14 00:19:18 +01:00
parent 8bced53601
commit 580c22fd21
4 changed files with 9 additions and 13 deletions

View File

@ -10,7 +10,7 @@
#include "../onetimeauth_poly1305.h"
static void
poly1305_update(poly1305_context *ctx, const unsigned char *m,
poly1305_update(crypto_onetimeauth_poly1305_state *ctx, const unsigned char *m,
unsigned long long bytes) {
poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
unsigned long long i;
@ -52,7 +52,7 @@ crypto_onetimeauth_poly1305_donna(unsigned char *out, const unsigned char *m,
unsigned long long inlen,
const unsigned char *key)
{
poly1305_context ctx;
crypto_onetimeauth_poly1305_state ctx;
poly1305_init(&ctx, key);
poly1305_update(&ctx, m, inlen);
poly1305_finish(&ctx, out);
@ -65,10 +65,8 @@ crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
const unsigned char *key)
{
(void) sizeof(int[sizeof (crypto_onetimeauth_poly1305_state) >=
sizeof (poly1305_context) ? 1 : -1]);
(void) sizeof(int[sizeof (poly1305_context) >=
sizeof (poly1305_state_internal_t) ? 1 : -1]);
poly1305_init((poly1305_context *) state, key);
poly1305_init((crypto_onetimeauth_poly1305_state *) state, key);
return 0;
}
@ -78,7 +76,7 @@ crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *stat
const unsigned char *in,
unsigned long long inlen)
{
poly1305_update((poly1305_context *) state, in, inlen);
poly1305_update((crypto_onetimeauth_poly1305_state *) state, in, inlen);
return 0;
}
@ -87,7 +85,7 @@ static int
crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
unsigned char *out)
{
poly1305_finish((poly1305_context *) state, out);
poly1305_finish((crypto_onetimeauth_poly1305_state *) state, out);
return 0;
}

View File

@ -5,8 +5,6 @@
#include "crypto_onetimeauth_poly1305.h"
typedef crypto_onetimeauth_poly1305_state poly1305_context;
extern struct crypto_onetimeauth_poly1305_implementation
crypto_onetimeauth_poly1305_donna_implementation;

View File

@ -42,7 +42,7 @@ U32TO8(unsigned char *p, unsigned long v) {
}
static void
poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
poly1305_init(crypto_onetimeauth_poly1305_state *ctx, const unsigned char key[32]) {
poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
@ -131,7 +131,7 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned
}
static POLY1305_NOINLINE void
poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
poly1305_finish(crypto_onetimeauth_poly1305_state *ctx, unsigned char mac[16]) {
poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
unsigned long h0,h1,h2,h3,h4,c;
unsigned long g0,g1,g2,g3,g4;

View File

@ -56,7 +56,7 @@ U64TO8(unsigned char *p, unsigned long long v) {
}
static void
poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
poly1305_init(crypto_onetimeauth_poly1305_state *ctx, const unsigned char key[32]) {
poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
unsigned long long t0,t1;
@ -135,7 +135,7 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned
static POLY1305_NOINLINE void
poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
poly1305_finish(crypto_onetimeauth_poly1305_state *ctx, unsigned char mac[16]) {
poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
unsigned long long h0,h1,h2,c;
unsigned long long g0,g1,g2;