Indent
This commit is contained in:
parent
9fbd5c0c18
commit
cad6561799
@ -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];
|
||||
@ -46,7 +45,7 @@ crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
|
||||
crypto_hash_sha256_init(&state->ictx);
|
||||
crypto_hash_sha256_update(&state->ictx, key, keylen);
|
||||
crypto_hash_sha256_final(&state->ictx, khash);
|
||||
key = khash;
|
||||
key = khash;
|
||||
keylen = 32;
|
||||
}
|
||||
crypto_hash_sha256_init(&state->ictx);
|
||||
@ -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);
|
||||
|
||||
@ -81,7 +79,7 @@ crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
|
||||
|
||||
int
|
||||
crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
|
||||
unsigned char *out)
|
||||
unsigned char * out)
|
||||
{
|
||||
unsigned char ihash[32];
|
||||
|
||||
@ -116,5 +114,5 @@ crypto_auth_hmacsha256_verify(const unsigned char *h, const unsigned char *in,
|
||||
crypto_auth_hmacsha256(correct, in, inlen, k);
|
||||
|
||||
return crypto_verify_32(h, correct) | (-(h == correct)) |
|
||||
sodium_memcmp(correct, h, 32);
|
||||
sodium_memcmp(correct, h, 32);
|
||||
}
|
||||
|
@ -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];
|
||||
@ -43,7 +45,7 @@ crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
|
||||
crypto_hash_sha512_init(&state->ictx);
|
||||
crypto_hash_sha512_update(&state->ictx, key, keylen);
|
||||
crypto_hash_sha512_final(&state->ictx, khash);
|
||||
key = khash;
|
||||
key = khash;
|
||||
keylen = 64;
|
||||
}
|
||||
crypto_hash_sha512_init(&state->ictx);
|
||||
@ -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);
|
||||
|
||||
@ -78,7 +79,7 @@ crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
|
||||
|
||||
int
|
||||
crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
|
||||
unsigned char *out)
|
||||
unsigned char * out)
|
||||
{
|
||||
unsigned char ihash[64];
|
||||
|
||||
@ -113,5 +114,5 @@ crypto_auth_hmacsha512_verify(const unsigned char *h, const unsigned char *in,
|
||||
crypto_auth_hmacsha512(correct, in, inlen, k);
|
||||
|
||||
return crypto_verify_64(h, correct) | (-(h == correct)) |
|
||||
sodium_memcmp(correct, h, 64);
|
||||
sodium_memcmp(correct, h, 64);
|
||||
}
|
||||
|
@ -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);
|
||||
@ -42,8 +45,8 @@ crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
|
||||
|
||||
int
|
||||
crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen)
|
||||
const unsigned char * in,
|
||||
unsigned long long inlen)
|
||||
{
|
||||
return crypto_auth_hmacsha512_update((crypto_auth_hmacsha512_state *) state,
|
||||
in, inlen);
|
||||
@ -51,7 +54,7 @@ crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
|
||||
|
||||
int
|
||||
crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state,
|
||||
unsigned char *out)
|
||||
unsigned char * out)
|
||||
{
|
||||
unsigned char out0[64];
|
||||
|
||||
@ -76,13 +79,15 @@ 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];
|
||||
|
||||
crypto_auth_hmacsha512256(correct, in, inlen, k);
|
||||
|
||||
return crypto_verify_32(h, correct) | (-(h == correct)) |
|
||||
sodium_memcmp(correct, h, 32);
|
||||
sodium_memcmp(correct, h, 32);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user