This commit is contained in:
Frank Denis 2017-02-23 09:42:15 +01:00
parent 9fbd5c0c18
commit cad6561799
5 changed files with 42 additions and 34 deletions

View File

@ -35,8 +35,7 @@ crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES])
int
crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
const unsigned char *key,
size_t keylen)
const unsigned char *key, size_t keylen)
{
unsigned char pad[64];
unsigned char khash[32];
@ -71,8 +70,7 @@ crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
int
crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
const unsigned char *in,
unsigned long long inlen)
const unsigned char *in, unsigned long long inlen)
{
crypto_hash_sha256_update(&state->ictx, in, inlen);

View File

@ -10,17 +10,20 @@
#include "utils.h"
size_t
crypto_auth_hmacsha512_bytes(void) {
crypto_auth_hmacsha512_bytes(void)
{
return crypto_auth_hmacsha512_BYTES;
}
size_t
crypto_auth_hmacsha512_keybytes(void) {
crypto_auth_hmacsha512_keybytes(void)
{
return crypto_auth_hmacsha512_KEYBYTES;
}
size_t
crypto_auth_hmacsha512_statebytes(void) {
crypto_auth_hmacsha512_statebytes(void)
{
return sizeof(crypto_auth_hmacsha512_state);
}
@ -32,8 +35,7 @@ crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES])
int
crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
const unsigned char *key,
size_t keylen)
const unsigned char *key, size_t keylen)
{
unsigned char pad[128];
unsigned char khash[64];
@ -68,8 +70,7 @@ crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
int
crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
const unsigned char *in,
unsigned long long inlen)
const unsigned char *in, unsigned long long inlen)
{
crypto_hash_sha512_update(&state->ictx, in, inlen);

View File

@ -3,38 +3,41 @@
#include <stdint.h>
#include <string.h>
#include "crypto_auth_hmacsha512256.h"
#include "crypto_auth_hmacsha512.h"
#include "crypto_auth_hmacsha512256.h"
#include "crypto_hash_sha512.h"
#include "crypto_verify_32.h"
#include "randombytes.h"
#include "utils.h"
size_t
crypto_auth_hmacsha512256_bytes(void) {
crypto_auth_hmacsha512256_bytes(void)
{
return crypto_auth_hmacsha512256_BYTES;
}
size_t
crypto_auth_hmacsha512256_keybytes(void) {
crypto_auth_hmacsha512256_keybytes(void)
{
return crypto_auth_hmacsha512256_KEYBYTES;
}
size_t
crypto_auth_hmacsha512256_statebytes(void) {
crypto_auth_hmacsha512256_statebytes(void)
{
return sizeof(crypto_auth_hmacsha512256_state);
}
void
crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES])
crypto_auth_hmacsha512256_keygen(
unsigned char k[crypto_auth_hmacsha512256_KEYBYTES])
{
randombytes_buf(k, crypto_auth_hmacsha512256_KEYBYTES);
}
int
crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
const unsigned char *key,
size_t keylen)
const unsigned char *key, size_t keylen)
{
return crypto_auth_hmacsha512_init((crypto_auth_hmacsha512_state *) state,
key, keylen);
@ -76,8 +79,10 @@ crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in,
}
int
crypto_auth_hmacsha512256_verify(const unsigned char *h, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
crypto_auth_hmacsha512256_verify(const unsigned char *h,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
{
unsigned char correct[32];

View File

@ -1,11 +1,13 @@
#include "crypto_hash_sha256.h"
size_t
crypto_hash_sha256_bytes(void) {
crypto_hash_sha256_bytes(void)
{
return crypto_hash_sha256_BYTES;
}
size_t
crypto_hash_sha256_statebytes(void) {
crypto_hash_sha256_statebytes(void)
{
return sizeof(crypto_hash_sha256_state);
}

View File

@ -1,11 +1,13 @@
#include "crypto_hash_sha512.h"
size_t
crypto_hash_sha512_bytes(void) {
crypto_hash_sha512_bytes(void)
{
return crypto_hash_sha512_BYTES;
}
size_t
crypto_hash_sha512_statebytes(void) {
crypto_hash_sha512_statebytes(void)
{
return sizeof(crypto_hash_sha512_state);
}