Path: blob/master/crypto/hash-ops.h
1297 views
// Copyright (c) 2012-2013 The Cryptonote developers1// Distributed under the MIT/X11 software license, see the accompanying2// file COPYING or http://www.opensource.org/licenses/mit-license.php.34#pragma once56#if !defined(__cplusplus)78#include <assert.h>9#include <stdbool.h>10#include <stddef.h>11#include <stdint.h>1213#include "int-util.h"1415#if 016static inline void *padd(void *p, size_t i) {17return (char *) p + i;18}1920static inline const void *cpadd(const void *p, size_t i) {21return (const char *) p + i;22}2324static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) {25if (sizeof(size_t) == 4) {26*(uint32_t*) padd(buffer, bufsize - 4) = swap32be(length);27} else {28*(uint64_t*) padd(buffer, bufsize - 8) = swap64be(length);29}30}31#endif3233#pragma pack(push, 1)34union hash_state {35uint8_t b[200];36uint64_t w[25];37};38#pragma pack(pop)3940void hash_permutation(union hash_state *state);41void hash_process(union hash_state *state, const uint8_t *buf, int count);4243#endif4445enum {46HASH_SIZE = 32,47HASH_DATA_AREA = 13648};4950void cn_fast_hash(const void *data, int len, char *hash);51void cn_slow_hash(const void *data, size_t length, char *hash);5253void hash_extra_blake(const void *data, size_t length, char *hash);54void hash_extra_groestl(const void *data, size_t length, char *hash);55void hash_extra_jh(const void *data, size_t length, char *hash);56void hash_extra_skein(const void *data, size_t length, char *hash);5758void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash);596061