+ poly1305 streaming interface

This commit is contained in:
Frank Denis 2014-06-19 20:04:48 -07:00
parent ffdbac52ce
commit b6fbb0ca6a
2 changed files with 58 additions and 6 deletions

View File

@ -58,6 +58,35 @@ crypto_onetimeauth_poly1305_donna(unsigned char *out, const unsigned char *m,
return 0;
}
int
crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
const unsigned char *key)
{
poly1305_init((poly1305_context *) state, key);
return 0;
}
int
crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state,
const unsigned char *in,
unsigned long long inlen)
{
poly1305_update((poly1305_context *) state, in, inlen);
return 0;
}
int
crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
unsigned char *out)
{
poly1305_finish((poly1305_context *) state, out);
return 0;
}
const char *
crypto_onetimeauth_poly1305_donna_implementation_name(void)
{
@ -68,5 +97,8 @@ struct crypto_onetimeauth_poly1305_implementation
crypto_onetimeauth_poly1305_donna_implementation = {
_SODIUM_C99(.implementation_name =) crypto_onetimeauth_poly1305_donna_implementation_name,
_SODIUM_C99(.onetimeauth =) crypto_onetimeauth_poly1305_donna,
_SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_poly1305_donna_verify
_SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_poly1305_donna_verify,
_SODIUM_C99(.onetimeauth_init =) crypto_onetimeauth_poly1305_donna_init,
_SODIUM_C99(.onetimeauth_update =) crypto_onetimeauth_poly1305_donna_update,
_SODIUM_C99(.onetimeauth_final =) crypto_onetimeauth_poly1305_donna_final
};

View File

@ -16,6 +16,11 @@ extern "C" {
#include <stdint.h>
#include <stdio.h>
typedef struct crypto_onetimeauth_poly1305_state {
unsigned long long aligner;
unsigned char opaque[136];
} crypto_onetimeauth_poly1305_state;
typedef struct crypto_onetimeauth_poly1305_implementation {
const char *(*implementation_name)(void);
int (*onetimeauth)(unsigned char *out,
@ -26,13 +31,15 @@ typedef struct crypto_onetimeauth_poly1305_implementation {
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k);
int (*onetimeauth_init)(crypto_onetimeauth_poly1305_state *state,
const unsigned char *key);
int (*onetimeauth_update)(crypto_onetimeauth_poly1305_state *state,
const unsigned char *in,
unsigned long long inlen);
int (*onetimeauth_final)(crypto_onetimeauth_poly1305_state *state,
unsigned char *out);
} crypto_onetimeauth_poly1305_implementation;
typedef struct crypto_onetimeauth_poly1305_state {
unsigned long long aligner;
unsigned char opaque[136];
} crypto_onetimeauth_poly1305_state;
#define crypto_onetimeauth_poly1305_BYTES 16U
SODIUM_EXPORT
size_t crypto_onetimeauth_poly1305_bytes(void);
@ -63,6 +70,19 @@ int crypto_onetimeauth_poly1305_verify(const unsigned char *h,
unsigned long long inlen,
const unsigned char *k);
SODIUM_EXPORT
int crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state,
const unsigned char *key);
SODIUM_EXPORT
int crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state,
const unsigned char *in,
unsigned long long inlen);
SODIUM_EXPORT
int crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state,
unsigned char *out);
#ifdef __cplusplus
}
#endif