mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-14 09:16:07 -04:00
Initialise constants: I think hash_to_p3() working
This commit is contained in:
parent
181d16156d
commit
ade9e3eabf
9 changed files with 1662 additions and 1773 deletions
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.19)
|
cmake_minimum_required(VERSION 3.19)
|
||||||
project(xmr_btc_swap_comit C)
|
project(xmr_btc_swap_comit C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
set(BOOST_ROOT "/usr/local/Cellar/boost/1.75.0_2")
|
set(BOOST_ROOT "/usr/local/Cellar/boost/1.75.0_2")
|
||||||
include_directories(/usr/local/Cellar/boost/1.75.0_2/include)
|
include_directories(/usr/local/Cellar/boost/1.75.0_2/include)
|
||||||
|
@ -9,7 +9,6 @@ include_directories(monero-adaptor/depend/hash)
|
||||||
|
|
||||||
add_library(xmr_btc_swap_comit
|
add_library(xmr_btc_swap_comit
|
||||||
monero-adaptor/depend/hash/hash.c
|
monero-adaptor/depend/hash/hash.c
|
||||||
monero-adaptor/depend/hash/include/hash.h
|
|
||||||
monero-adaptor/depend/hash/include/int-util.h
|
monero-adaptor/depend/hash/include/int-util.h
|
||||||
monero-adaptor/depend/hash/crypto-ops.c
|
monero-adaptor/depend/hash/crypto-ops.c
|
||||||
monero-adaptor/depend/hash/include/crypto-ops.h
|
monero-adaptor/depend/hash/include/crypto-ops.h
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,5 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "include/keccak.h"
|
#include "include/keccak.h"
|
||||||
#include "include/hash.h"
|
|
||||||
#include "include/crypto-ops.h"
|
#include "include/crypto-ops.h"
|
||||||
|
|
||||||
void hash_to_scalar(const uint8_t *in, uint8_t *md) {
|
void hash_to_scalar(const uint8_t *in, uint8_t *md) {
|
||||||
|
|
|
@ -79,14 +79,13 @@ typedef ge_cached ge_dsmp[8];
|
||||||
extern const ge_precomp ge_Bi[8];
|
extern const ge_precomp ge_Bi[8];
|
||||||
void ge_dsm_precomp(ge_dsmp r, const ge_p3 *s);
|
void ge_dsm_precomp(ge_dsmp r, const ge_p3 *s);
|
||||||
void ge_double_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *);
|
void ge_double_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *);
|
||||||
|
void ge_triple_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp);
|
||||||
void ge_triple_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const unsigned char *, const ge_dsmp,
|
|
||||||
const unsigned char *, const ge_dsmp);
|
|
||||||
|
|
||||||
void ge_double_scalarmult_base_vartime_p3(ge_p3 *, const unsigned char *, const ge_p3 *, const unsigned char *);
|
void ge_double_scalarmult_base_vartime_p3(ge_p3 *, const unsigned char *, const ge_p3 *, const unsigned char *);
|
||||||
|
|
||||||
/* From ge_frombytes.c, modified */
|
/* From ge_frombytes.c, modified */
|
||||||
|
|
||||||
|
extern const fe fe_sqrtm1;
|
||||||
|
extern const fe fe_d;
|
||||||
int ge_frombytes_vartime(ge_p3 *, const unsigned char *);
|
int ge_frombytes_vartime(ge_p3 *, const unsigned char *);
|
||||||
|
|
||||||
/* From ge_p1p1_to_p2.c */
|
/* From ge_p1p1_to_p2.c */
|
||||||
|
@ -130,39 +129,28 @@ void sc_reduce(unsigned char *);
|
||||||
/* New code */
|
/* New code */
|
||||||
|
|
||||||
void ge_scalarmult(ge_p2 *, const unsigned char *, const ge_p3 *);
|
void ge_scalarmult(ge_p2 *, const unsigned char *, const ge_p3 *);
|
||||||
|
|
||||||
void ge_scalarmult_p3(ge_p3 *, const unsigned char *, const ge_p3 *);
|
void ge_scalarmult_p3(ge_p3 *, const unsigned char *, const ge_p3 *);
|
||||||
|
void ge_double_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *, const ge_dsmp);
|
||||||
void ge_double_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *,
|
void ge_triple_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp);
|
||||||
const ge_dsmp);
|
void ge_double_scalarmult_precomp_vartime2(ge_p2 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp);
|
||||||
|
void ge_double_scalarmult_precomp_vartime2_p3(ge_p3 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp);
|
||||||
void ge_triple_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_dsmp, const unsigned char *,
|
|
||||||
const ge_dsmp, const unsigned char *, const ge_dsmp);
|
|
||||||
|
|
||||||
void ge_double_scalarmult_precomp_vartime2(ge_p2 *, const unsigned char *, const ge_dsmp, const unsigned char *,
|
|
||||||
const ge_dsmp);
|
|
||||||
|
|
||||||
void ge_double_scalarmult_precomp_vartime2_p3(ge_p3 *, const unsigned char *, const ge_dsmp, const unsigned char *,
|
|
||||||
const ge_dsmp);
|
|
||||||
|
|
||||||
void ge_mul8(ge_p1p1 *, const ge_p2 *);
|
void ge_mul8(ge_p1p1 *, const ge_p2 *);
|
||||||
|
extern const fe fe_ma2;
|
||||||
|
extern const fe fe_ma;
|
||||||
|
extern const fe fe_fffb1;
|
||||||
|
extern const fe fe_fffb2;
|
||||||
|
extern const fe fe_fffb3;
|
||||||
|
extern const fe fe_fffb4;
|
||||||
|
extern const ge_p3 ge_p3_identity;
|
||||||
|
extern const ge_p3 ge_p3_H;
|
||||||
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *);
|
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *);
|
||||||
|
|
||||||
void sc_0(unsigned char *);
|
void sc_0(unsigned char *);
|
||||||
|
|
||||||
void sc_reduce32(unsigned char *);
|
void sc_reduce32(unsigned char *);
|
||||||
|
|
||||||
void sc_add(unsigned char *, const unsigned char *, const unsigned char *);
|
void sc_add(unsigned char *, const unsigned char *, const unsigned char *);
|
||||||
|
|
||||||
void sc_sub(unsigned char *, const unsigned char *, const unsigned char *);
|
void sc_sub(unsigned char *, const unsigned char *, const unsigned char *);
|
||||||
|
|
||||||
void sc_mulsub(unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *);
|
void sc_mulsub(unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *);
|
||||||
|
|
||||||
void sc_mul(unsigned char *, const unsigned char *, const unsigned char *);
|
void sc_mul(unsigned char *, const unsigned char *, const unsigned char *);
|
||||||
|
|
||||||
void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c);
|
void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c);
|
||||||
|
|
||||||
int sc_check(const unsigned char *);
|
int sc_check(const unsigned char *);
|
||||||
int sc_isnonzero(const unsigned char *); /* Doesn't normalize */
|
int sc_isnonzero(const unsigned char *); /* Doesn't normalize */
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ static inline const void *cpadd(const void *p, size_t i) {
|
||||||
PUSH_WARNINGS
|
PUSH_WARNINGS
|
||||||
DISABLE_VS_WARNINGS(4267)
|
DISABLE_VS_WARNINGS(4267)
|
||||||
static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8, "size_t must be 4 or 8 bytes long");
|
static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8, "size_t must be 4 or 8 bytes long");
|
||||||
|
|
||||||
static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) {
|
static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) {
|
||||||
if (sizeof(size_t) == 4) {
|
if (sizeof(size_t) == 4) {
|
||||||
*(uint32_t *) padd(buffer, bufsize - 4) = swap32be(length);
|
*(uint32_t *) padd(buffer, bufsize - 4) = swap32be(length);
|
||||||
|
@ -59,7 +58,6 @@ static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length)
|
||||||
*(uint64_t *) padd(buffer, bufsize - 8) = swap64be(length);
|
*(uint64_t *) padd(buffer, bufsize - 8) = swap64be(length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
POP_WARNINGS
|
POP_WARNINGS
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
@ -71,7 +69,6 @@ union hash_state {
|
||||||
static_assert(sizeof(union hash_state) == 200, "Invalid structure size");
|
static_assert(sizeof(union hash_state) == 200, "Invalid structure size");
|
||||||
|
|
||||||
void hash_permutation(union hash_state *state);
|
void hash_permutation(union hash_state *state);
|
||||||
|
|
||||||
void hash_process(union hash_state *state, const uint8_t *buf, size_t count);
|
void hash_process(union hash_state *state, const uint8_t *buf, size_t count);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,43 +79,19 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
void cn_fast_hash(const void *data, size_t length, char *hash);
|
void cn_fast_hash(const void *data, size_t length, char *hash);
|
||||||
|
|
||||||
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height);
|
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height);
|
||||||
|
|
||||||
void hash_extra_blake(const void *data, size_t length, char *hash);
|
void hash_extra_blake(const void *data, size_t length, char *hash);
|
||||||
|
|
||||||
void hash_extra_groestl(const void *data, size_t length, char *hash);
|
void hash_extra_groestl(const void *data, size_t length, char *hash);
|
||||||
|
|
||||||
void hash_extra_jh(const void *data, size_t length, char *hash);
|
void hash_extra_jh(const void *data, size_t length, char *hash);
|
||||||
|
|
||||||
void hash_extra_skein(const void *data, size_t length, char *hash);
|
void hash_extra_skein(const void *data, size_t length, char *hash);
|
||||||
|
|
||||||
void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash);
|
void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash);
|
||||||
|
|
||||||
bool tree_path(size_t count, size_t idx, uint32_t *path);
|
|
||||||
|
|
||||||
bool
|
|
||||||
tree_branch(const char (*hashes)[HASH_SIZE], size_t count, const char *hash, char (*branch)[HASH_SIZE], size_t *depth,
|
|
||||||
uint32_t *path);
|
|
||||||
|
|
||||||
bool tree_branch_hash(const char hash[HASH_SIZE], const char (*branch)[HASH_SIZE], size_t depth, uint32_t path,
|
|
||||||
char root[HASH_SIZE]);
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_branch_in_tree(const char hash[HASH_SIZE], const char root[HASH_SIZE], const char (*branch)[HASH_SIZE], size_t depth,
|
|
||||||
uint32_t path);
|
|
||||||
|
|
||||||
#define RX_BLOCK_VERSION 12
|
#define RX_BLOCK_VERSION 12
|
||||||
|
|
||||||
void rx_slow_hash_allocate_state(void);
|
void rx_slow_hash_allocate_state(void);
|
||||||
|
|
||||||
void rx_slow_hash_free_state(void);
|
void rx_slow_hash_free_state(void);
|
||||||
|
|
||||||
uint64_t rx_seedheight(const uint64_t height);
|
uint64_t rx_seedheight(const uint64_t height);
|
||||||
|
|
||||||
void rx_seedheights(const uint64_t height, uint64_t *seed_height, uint64_t *next_height);
|
void rx_seedheights(const uint64_t height, uint64_t *seed_height, uint64_t *next_height);
|
||||||
|
void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const char *seedhash, const void *data, size_t length, char *hash, int miners, int is_alt);
|
||||||
void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const char *seedhash, const void *data,
|
|
||||||
size_t length, char *hash, int miners, int is_alt);
|
|
||||||
|
|
||||||
void rx_reorg(const uint64_t split_height);
|
void rx_reorg(const uint64_t split_height);
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
//
|
|
||||||
// Created by Rishab Sharma on 16/4/21.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef XMR_BTC_SWAP_COMIT_HASH_H
|
|
||||||
#define XMR_BTC_SWAP_COMIT_HASH_H
|
|
||||||
|
|
||||||
#endif //XMR_BTC_SWAP_COMIT_HASH_H
|
|
|
@ -112,8 +112,7 @@ static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, ui
|
||||||
}
|
}
|
||||||
|
|
||||||
// Long division with 2^32 base
|
// Long division with 2^32 base
|
||||||
static inline uint32_t
|
static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uint32_t divisor, uint64_t* quotient_hi, uint64_t* quotient_lo) {
|
||||||
div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uint32_t divisor, uint64_t *quotient_hi, uint64_t *quotient_lo) {
|
|
||||||
uint64_t dividend_dwords[4];
|
uint64_t dividend_dwords[4];
|
||||||
uint32_t remainder = 0;
|
uint32_t remainder = 0;
|
||||||
|
|
||||||
|
@ -131,11 +130,10 @@ div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uint32_t divisor, uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
// Long divisor with 2^64 base
|
// Long divisor with 2^64 base
|
||||||
void
|
void div128_64(uint64_t dividend_hi, uint64_t dividend_lo, uint64_t divisor, uint64_t* quotient_hi, uint64_t *quotient_lo, uint64_t *remainder_hi, uint64_t *remainder_lo);
|
||||||
div128_64(uint64_t dividend_hi, uint64_t dividend_lo, uint64_t divisor, uint64_t *quotient_hi, uint64_t *quotient_lo,
|
|
||||||
uint64_t *remainder_hi, uint64_t *remainder_lo);
|
|
||||||
|
|
||||||
static inline void add64clamp(uint64_t *value, uint64_t add) {
|
static inline void add64clamp(uint64_t *value, uint64_t add)
|
||||||
|
{
|
||||||
static const uint64_t maxval = (uint64_t)-1;
|
static const uint64_t maxval = (uint64_t)-1;
|
||||||
if (*value > maxval - add)
|
if (*value > maxval - add)
|
||||||
*value = maxval;
|
*value = maxval;
|
||||||
|
@ -143,7 +141,8 @@ static inline void add64clamp(uint64_t *value, uint64_t add) {
|
||||||
*value += add;
|
*value += add;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void sub64clamp(uint64_t *value, uint64_t sub) {
|
static inline void sub64clamp(uint64_t *value, uint64_t sub)
|
||||||
|
{
|
||||||
if (*value < sub)
|
if (*value < sub)
|
||||||
*value = 0;
|
*value = 0;
|
||||||
else
|
else
|
||||||
|
@ -205,7 +204,6 @@ static inline uint64_t swap64(uint64_t x) {
|
||||||
#else
|
#else
|
||||||
#define UNUSED
|
#define UNUSED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void mem_inplace_ident(void *mem UNUSED, size_t n UNUSED) { }
|
static inline void mem_inplace_ident(void *mem UNUSED, size_t n UNUSED) { }
|
||||||
#undef UNUSED
|
#undef UNUSED
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SHA3 Algorithm context.
|
// SHA3 Algorithm context.
|
||||||
typedef struct KECCAK_CTX {
|
typedef struct KECCAK_CTX
|
||||||
|
{
|
||||||
// 1600 bits algorithm hashing state
|
// 1600 bits algorithm hashing state
|
||||||
uint64_t hash[25];
|
uint64_t hash[25];
|
||||||
// 1088-bit buffer for leftovers, block size = 136 B for 256-bit keccak
|
// 1088-bit buffer for leftovers, block size = 136 B for 256-bit keccak
|
||||||
|
@ -34,9 +35,6 @@ void keccakf(uint64_t st[25], int norounds);
|
||||||
void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md);
|
void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md);
|
||||||
|
|
||||||
void keccak_init(KECCAK_CTX * ctx);
|
void keccak_init(KECCAK_CTX * ctx);
|
||||||
|
|
||||||
void keccak_update(KECCAK_CTX * ctx, const uint8_t *in, size_t inlen);
|
void keccak_update(KECCAK_CTX * ctx, const uint8_t *in, size_t inlen);
|
||||||
|
|
||||||
void keccak_finish(KECCAK_CTX * ctx, uint8_t *md);
|
void keccak_finish(KECCAK_CTX * ctx, uint8_t *md);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
#include "include/hash-ops.h"
|
#include "include/hash-ops.h"
|
||||||
#include "include/keccak.h"
|
#include "include/keccak.h"
|
||||||
|
|
||||||
static void local_abort(const char *msg) {
|
static void local_abort(const char *msg)
|
||||||
|
{
|
||||||
fprintf(stderr, "%s\n", msg);
|
fprintf(stderr, "%s\n", msg);
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
@ -44,7 +45,8 @@ const int keccakf_piln[24] =
|
||||||
|
|
||||||
// update the state with given number of rounds
|
// update the state with given number of rounds
|
||||||
|
|
||||||
void keccakf(uint64_t st[25], int rounds) {
|
void keccakf(uint64_t st[25], int rounds)
|
||||||
|
{
|
||||||
int i, j, round;
|
int i, j, round;
|
||||||
uint64_t t, bc[5];
|
uint64_t t, bc[5];
|
||||||
|
|
||||||
|
@ -85,13 +87,15 @@ void keccakf(uint64_t st[25], int rounds) {
|
||||||
// compute a keccak hash (md) of given byte length from "in"
|
// compute a keccak hash (md) of given byte length from "in"
|
||||||
typedef uint64_t state_t[25];
|
typedef uint64_t state_t[25];
|
||||||
|
|
||||||
void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) {
|
void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
|
||||||
|
{
|
||||||
state_t st;
|
state_t st;
|
||||||
uint8_t temp[144];
|
uint8_t temp[144];
|
||||||
size_t i, rsiz, rsizw;
|
size_t i, rsiz, rsizw;
|
||||||
|
|
||||||
static_assert(HASH_DATA_AREA <= sizeof(temp), "Bad keccak preconditions");
|
static_assert(HASH_DATA_AREA <= sizeof(temp), "Bad keccak preconditions");
|
||||||
if (mdlen <= 0 || (mdlen > 100 && sizeof(st) != (size_t) mdlen)) {
|
if (mdlen <= 0 || (mdlen > 100 && sizeof(st) != (size_t)mdlen))
|
||||||
|
{
|
||||||
local_abort("Bad keccak use");
|
local_abort("Bad keccak use");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +114,8 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// last block and padding
|
// last block and padding
|
||||||
if (inlen + 1 >= sizeof(temp) || inlen > rsiz || rsiz - inlen + inlen + 1 >= sizeof(temp) || rsiz == 0 ||
|
if (inlen + 1 >= sizeof(temp) || inlen > rsiz || rsiz - inlen + inlen + 1 >= sizeof(temp) || rsiz == 0 || rsiz - 1 >= sizeof(temp) || rsizw * 8 > sizeof(temp))
|
||||||
rsiz - 1 >= sizeof(temp) || rsizw * 8 > sizeof(temp)) {
|
{
|
||||||
local_abort("Bad keccak use");
|
local_abort("Bad keccak use");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,13 +130,15 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen) {
|
||||||
|
|
||||||
keccakf(st, KECCAK_ROUNDS);
|
keccakf(st, KECCAK_ROUNDS);
|
||||||
|
|
||||||
if (((size_t) mdlen % sizeof(uint64_t)) != 0) {
|
if (((size_t)mdlen % sizeof(uint64_t)) != 0)
|
||||||
|
{
|
||||||
local_abort("Bad keccak use");
|
local_abort("Bad keccak use");
|
||||||
}
|
}
|
||||||
memcpy_swap64le(md, st, mdlen/sizeof(uint64_t));
|
memcpy_swap64le(md, st, mdlen/sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md) {
|
void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md)
|
||||||
|
{
|
||||||
keccak(in, inlen, md, sizeof(state_t));
|
keccak(in, inlen, md, sizeof(state_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +190,8 @@ void keccak_update(KECCAK_CTX *ctx, const uint8_t *in, size_t inlen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void keccak_finish(KECCAK_CTX * ctx, uint8_t *md){
|
void keccak_finish(KECCAK_CTX * ctx, uint8_t *md){
|
||||||
if (!(ctx->rest & KECCAK_FINALIZED)) {
|
if (!(ctx->rest & KECCAK_FINALIZED))
|
||||||
|
{
|
||||||
// clear the rest of the data queue
|
// clear the rest of the data queue
|
||||||
memset((char*)ctx->message + ctx->rest, 0, KECCAK_BLOCKLEN - ctx->rest);
|
memset((char*)ctx->message + ctx->rest, 0, KECCAK_BLOCKLEN - ctx->rest);
|
||||||
((char*)ctx->message)[ctx->rest] |= 0x01;
|
((char*)ctx->message)[ctx->rest] |= 0x01;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue