meta: rename to fx
This commit is contained in:
@@ -30,8 +30,8 @@
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <fx/core/hash.h>
|
||||
#include <fx/core/misc.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef KECCAKF_ROUNDS
|
||||
@@ -134,7 +134,7 @@ void sha3_keccakf(uint64_t st[25])
|
||||
|
||||
// Initialize the context for SHA3
|
||||
|
||||
int sha3_init(struct b_hash_ctx *c, int mdlen)
|
||||
int sha3_init(struct fx_hash_ctx *c, int mdlen)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -149,7 +149,7 @@ int sha3_init(struct b_hash_ctx *c, int mdlen)
|
||||
|
||||
// update state with more data
|
||||
|
||||
void sha3_update(struct b_hash_ctx *c, const void *data, size_t len)
|
||||
void sha3_update(struct fx_hash_ctx *c, const void *data, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
int j;
|
||||
@@ -168,7 +168,7 @@ void sha3_update(struct b_hash_ctx *c, const void *data, size_t len)
|
||||
|
||||
// finalize and output a hash
|
||||
|
||||
int sha3_final(void *md, struct b_hash_ctx *c)
|
||||
int sha3_final(void *md, struct fx_hash_ctx *c)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -187,7 +187,7 @@ int sha3_final(void *md, struct b_hash_ctx *c)
|
||||
|
||||
void *sha3(const void *in, size_t inlen, void *md, int mdlen)
|
||||
{
|
||||
struct b_hash_ctx sha3;
|
||||
struct fx_hash_ctx sha3;
|
||||
|
||||
sha3_init(&sha3, mdlen);
|
||||
sha3_update(&sha3, in, inlen);
|
||||
@@ -198,7 +198,7 @@ void *sha3(const void *in, size_t inlen, void *md, int mdlen)
|
||||
|
||||
// SHAKE128 and SHAKE256 extensible-output functionality
|
||||
|
||||
void shake_xof(struct b_hash_ctx *c)
|
||||
void shake_xof(struct fx_hash_ctx *c)
|
||||
{
|
||||
c->ctx_state.sha3.st.b[c->ctx_state.sha3.pt] ^= 0x1F;
|
||||
c->ctx_state.sha3.st.b[c->ctx_state.sha3.rsiz - 1] ^= 0x80;
|
||||
@@ -206,7 +206,7 @@ void shake_xof(struct b_hash_ctx *c)
|
||||
c->ctx_state.sha3.pt = 0;
|
||||
}
|
||||
|
||||
void shake_out(struct b_hash_ctx *c, void *out, size_t len)
|
||||
void shake_out(struct fx_hash_ctx *c, void *out, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
int j;
|
||||
@@ -222,111 +222,111 @@ void shake_out(struct b_hash_ctx *c, void *out, size_t len)
|
||||
c->ctx_state.sha3.pt = j;
|
||||
}
|
||||
|
||||
static void sha3_224_init(struct b_hash_ctx *ctx)
|
||||
static void sha3_224_init(struct fx_hash_ctx *ctx)
|
||||
{
|
||||
sha3_init(ctx, B_DIGEST_LENGTH_SHA3_224);
|
||||
sha3_init(ctx, FX_DIGEST_LENGTH_SHA3_224);
|
||||
}
|
||||
|
||||
static void sha3_224_finish(struct b_hash_ctx *ctx, void *out, size_t max)
|
||||
static void sha3_224_finish(struct fx_hash_ctx *ctx, void *out, size_t max)
|
||||
{
|
||||
unsigned char md[B_DIGEST_LENGTH_SHA3_224];
|
||||
unsigned char md[FX_DIGEST_LENGTH_SHA3_224];
|
||||
sha3_final(md, ctx);
|
||||
memcpy(out, md, b_min(size_t, sizeof md, max));
|
||||
memcpy(out, md, fx_min(size_t, sizeof md, max));
|
||||
}
|
||||
|
||||
static void sha3_256_init(struct b_hash_ctx *ctx)
|
||||
static void sha3_256_init(struct fx_hash_ctx *ctx)
|
||||
{
|
||||
sha3_init(ctx, B_DIGEST_LENGTH_SHA3_256);
|
||||
sha3_init(ctx, FX_DIGEST_LENGTH_SHA3_256);
|
||||
}
|
||||
|
||||
static void sha3_256_finish(struct b_hash_ctx *ctx, void *out, size_t max)
|
||||
static void sha3_256_finish(struct fx_hash_ctx *ctx, void *out, size_t max)
|
||||
{
|
||||
unsigned char md[B_DIGEST_LENGTH_SHA3_256];
|
||||
unsigned char md[FX_DIGEST_LENGTH_SHA3_256];
|
||||
sha3_final(md, ctx);
|
||||
memcpy(out, md, b_min(size_t, sizeof md, max));
|
||||
memcpy(out, md, fx_min(size_t, sizeof md, max));
|
||||
}
|
||||
|
||||
static void sha3_384_init(struct b_hash_ctx *ctx)
|
||||
static void sha3_384_init(struct fx_hash_ctx *ctx)
|
||||
{
|
||||
sha3_init(ctx, B_DIGEST_LENGTH_SHA3_384);
|
||||
sha3_init(ctx, FX_DIGEST_LENGTH_SHA3_384);
|
||||
}
|
||||
|
||||
static void sha3_384_finish(struct b_hash_ctx *ctx, void *out, size_t max)
|
||||
static void sha3_384_finish(struct fx_hash_ctx *ctx, void *out, size_t max)
|
||||
{
|
||||
unsigned char md[B_DIGEST_LENGTH_SHA3_384];
|
||||
unsigned char md[FX_DIGEST_LENGTH_SHA3_384];
|
||||
sha3_final(md, ctx);
|
||||
memcpy(out, md, b_min(size_t, sizeof md, max));
|
||||
memcpy(out, md, fx_min(size_t, sizeof md, max));
|
||||
}
|
||||
|
||||
static void sha3_512_init(struct b_hash_ctx *ctx)
|
||||
static void sha3_512_init(struct fx_hash_ctx *ctx)
|
||||
{
|
||||
sha3_init(ctx, B_DIGEST_LENGTH_SHA3_512);
|
||||
sha3_init(ctx, FX_DIGEST_LENGTH_SHA3_512);
|
||||
}
|
||||
|
||||
static void sha3_512_finish(struct b_hash_ctx *ctx, void *out, size_t max)
|
||||
static void sha3_512_finish(struct fx_hash_ctx *ctx, void *out, size_t max)
|
||||
{
|
||||
unsigned char md[B_DIGEST_LENGTH_SHA3_512];
|
||||
unsigned char md[FX_DIGEST_LENGTH_SHA3_512];
|
||||
sha3_final(md, ctx);
|
||||
memcpy(out, md, b_min(size_t, sizeof md, max));
|
||||
memcpy(out, md, fx_min(size_t, sizeof md, max));
|
||||
}
|
||||
|
||||
static void shake128_init(struct b_hash_ctx *ctx)
|
||||
static void shake128_init(struct fx_hash_ctx *ctx)
|
||||
{
|
||||
sha3_init(ctx, B_DIGEST_LENGTH_SHAKE128);
|
||||
sha3_init(ctx, FX_DIGEST_LENGTH_SHAKE128);
|
||||
}
|
||||
|
||||
static void shake128_finish(struct b_hash_ctx *ctx, void *out, size_t max)
|
||||
static void shake128_finish(struct fx_hash_ctx *ctx, void *out, size_t max)
|
||||
{
|
||||
unsigned char md[B_DIGEST_LENGTH_SHAKE128];
|
||||
unsigned char md[FX_DIGEST_LENGTH_SHAKE128];
|
||||
shake_xof(ctx);
|
||||
shake_out(ctx, md, sizeof md);
|
||||
memcpy(out, md, b_min(size_t, sizeof md, max));
|
||||
memcpy(out, md, fx_min(size_t, sizeof md, max));
|
||||
}
|
||||
|
||||
static void shake256_init(struct b_hash_ctx *ctx)
|
||||
static void shake256_init(struct fx_hash_ctx *ctx)
|
||||
{
|
||||
sha3_init(ctx, B_DIGEST_LENGTH_SHAKE256);
|
||||
sha3_init(ctx, FX_DIGEST_LENGTH_SHAKE256);
|
||||
}
|
||||
|
||||
static void shake256_finish(struct b_hash_ctx *ctx, void *out, size_t max)
|
||||
static void shake256_finish(struct fx_hash_ctx *ctx, void *out, size_t max)
|
||||
{
|
||||
unsigned char md[B_DIGEST_LENGTH_SHAKE256];
|
||||
unsigned char md[FX_DIGEST_LENGTH_SHAKE256];
|
||||
shake_xof(ctx);
|
||||
shake_out(ctx, md, sizeof md);
|
||||
memcpy(out, md, b_min(size_t, sizeof md, max));
|
||||
memcpy(out, md, fx_min(size_t, sizeof md, max));
|
||||
}
|
||||
|
||||
struct b_hash_function_ops z__b_sha3_224_ops = {
|
||||
struct fx_hash_function_ops z__fx_sha3_224_ops = {
|
||||
.hash_init = sha3_224_init,
|
||||
.hash_update = sha3_update,
|
||||
.hash_finish = sha3_224_finish,
|
||||
};
|
||||
|
||||
struct b_hash_function_ops z__b_sha3_256_ops = {
|
||||
struct fx_hash_function_ops z__fx_sha3_256_ops = {
|
||||
.hash_init = sha3_256_init,
|
||||
.hash_update = sha3_update,
|
||||
.hash_finish = sha3_256_finish,
|
||||
};
|
||||
|
||||
struct b_hash_function_ops z__b_sha3_384_ops = {
|
||||
struct fx_hash_function_ops z__fx_sha3_384_ops = {
|
||||
.hash_init = sha3_384_init,
|
||||
.hash_update = sha3_update,
|
||||
.hash_finish = sha3_384_finish,
|
||||
};
|
||||
|
||||
struct b_hash_function_ops z__b_sha3_512_ops = {
|
||||
struct fx_hash_function_ops z__fx_sha3_512_ops = {
|
||||
.hash_init = sha3_512_init,
|
||||
.hash_update = sha3_update,
|
||||
.hash_finish = sha3_512_finish,
|
||||
};
|
||||
|
||||
struct b_hash_function_ops z__b_shake128_ops = {
|
||||
struct fx_hash_function_ops z__fx_shake128_ops = {
|
||||
.hash_init = shake128_init,
|
||||
.hash_update = sha3_update,
|
||||
.hash_finish = shake128_finish,
|
||||
};
|
||||
|
||||
struct b_hash_function_ops z__b_shake256_ops = {
|
||||
struct fx_hash_function_ops z__fx_shake256_ops = {
|
||||
.hash_init = shake256_init,
|
||||
.hash_update = sha3_update,
|
||||
.hash_finish = shake256_finish,
|
||||
|
||||
Reference in New Issue
Block a user