Commit 05b85144 authored by bg nerilex's avatar bg nerilex

added SHA2 with Flash-storage support (and hashing + build_log for building)

parent 8f954e88
......@@ -12,3 +12,4 @@
!.gitignore
!.clang-format
build_log.txt
......@@ -335,24 +335,41 @@ all: $(foreach algo, $(ALGORITHMS), $($(algo)_BINOBJ))
#-------------------------------------------------------------------------------
define TestBin_TEMPLATE
$(1)_TESTBIN: $(2)
define DEP_TEMPLATE
$(1): $(2)
endef
$(foreach algo, $(ALGORITHMS), $(eval ALGORITHM = $(algo)) $(eval $(call TestBin_TEMPLATE, \
$(algo), \
$(foreach algo, $(ALGORITHMS), $(eval ALGORITHM = $(algo)) $(eval $(call DEP_TEMPLATE, \
$(algo)_TESTELF, \
$(TEST_DIR)/main-$(call lc, $(algo))-test.elf \
)))
$(foreach algo, $(ALGORITHMS), $(eval ALGORITHM = $(algo)) $(eval $(call DEP_TEMPLATE, \
$(algo)_TESTBIN, \
$(TEST_DIR)/main-$(call lc, $(algo))-test.bin \
)))
$(foreach algo, $(ALGORITHMS), $(eval ALGORITHM = $(algo)) $(eval $(call DEP_TEMPLATE, \
$(algo)_TESTHEX, \
$(TEST_DIR)/main-$(call lc, $(algo))-test.hex \
)))
#-------------------------------------------------------------------------------
%.bin: %.elf
@echo "[objcopy]: $@"
$(D)$(OBJCOPY) -O binary $< $@
$(D)echo -n "[$$($(DATE) -Iseconds)]: " >> $(BUILD_LOG)
$(D)$(HASH) $@ >> $(BUILD_LOG)
@echo "[tag]: " "$$(tail -n 1 $(BUILD_LOG))"
%.hex: %.elf
@echo "[objcopy]: $@"
$(D)$(OBJCOPY) -j .text -j .data -O ihex $< $@
$(D)echo -n "[$$($(DATE) -Iseconds)]: " >> $(BUILD_LOG)
$(D)$(HASH) $@ >> $(BUILD_LOG)
@echo "[tag]: " "$$(tail -n 1 $(BUILD_LOG))"
#-------------------------------------------------------------------------------
......
#
CSTD = gnu99
BUILD_LOG = build_log.txt
\ No newline at end of file
MCU := ATMEGA644
INFO := board with basic ethernet capabilities from pollin ($(MCU) @ 20MHz)
PROGRAMMER = avrispmkII
PROG_PORT = usb
FLASHCMD := avrdude -p $(MCU) -P $(PROG_PORT) -c $(PROGRAMMER) -U flash:w:<PROGRAM_BIN>
RUNCMD = minicom -o 03
F_CPU = 20000000
OPTIMIZE = -Os
DEFS := -D$(call uc, $(MCU)) -DF_CPU=$(F_CPU) -DUART0_BAUD_RATE=115200
# override CFLAGS_A = -MMD -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) $(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
CFLAGS := -mmcu=$(call lc,$(MCU))
LDFLAGS = -gdwarf-2
ASFLAGS := -mmcu=$(call lc,$(MCU)) -Wa,--gdwarf-2
MCU := NRF51822
INFO := alias for pca10001 / nrf51822
OPENOCD_CFG = board_specific/nrf51822/openocd-nrf51.cfg
OPENOCD_RUN_CFG = board_specific/nrf51822/openocd-run.cfg
START_ADDRESS = 0
FLASHCMD = $(OPENOCD) -f $(OPENOCD_CFG) -c "init; reset halt; program <PROGRAM_BIN> $(START_ADDRESS) verify; shutdown;"
RUNCMD = $(OPENOCD) -f $(OPENOCD_CFG) -f $(OPENOCD_RUN_CFG) 2> /dev/null
......@@ -14,6 +14,7 @@ READELF = readelf
CHMOD = chmod
CHOWN = chown
CHGRP = chgrp
DATE = date
RM = rm
RUBY = ruby
GET_TEST = host/get_test.rb
......
......@@ -31,6 +31,7 @@
#include <stdint.h>
#include <string.h> /* for memcpy, memmove, memset */
#include "flash.h"
#include "sha2_small_common.h"
#include "sha224.h"
......@@ -44,9 +45,9 @@
/*************************************************************************/
const uint32_t sha224_init_vector[] = {0xc1059ed8, 0x367cd507, 0x3070dd17,
0xf70e5939, 0xffc00b31, 0x68581511,
0x64f98fa7, 0xbefa4fa4};
const uint32_t sha224_init_vector[] FLASH = {0xc1059ed8, 0x367cd507, 0x3070dd17,
0xf70e5939, 0xffc00b31, 0x68581511,
0x64f98fa7, 0xbefa4fa4};
/*************************************************************************/
......@@ -59,7 +60,7 @@ const uint32_t sha224_init_vector[] = {0xc1059ed8, 0x367cd507, 0x3070dd17,
void sha224_init(sha224_ctx_t *state)
{
state->length = 0;
memcpy(state->h, sha224_init_vector, 8 * 4);
memcpy_F(state->h, sha224_init_vector, 8 * 4);
}
/*************************************************************************/
......
......@@ -31,6 +31,7 @@
#include <stdint.h>
#include <string.h> /* for memcpy, memmove, memset */
#include "flash.h"
#include "sha2_small_common.h"
#include "sha256.h"
......@@ -44,9 +45,9 @@
/*************************************************************************/
const uint32_t sha256_init_vector[] = {0x6A09E667, 0xBB67AE85, 0x3C6EF372,
0xA54FF53A, 0x510E527F, 0x9B05688C,
0x1F83D9AB, 0x5BE0CD19};
const uint32_t sha256_init_vector[] FLASH = {0x6A09E667, 0xBB67AE85, 0x3C6EF372,
0xA54FF53A, 0x510E527F, 0x9B05688C,
0x1F83D9AB, 0x5BE0CD19};
/*************************************************************************/
......@@ -59,7 +60,7 @@ const uint32_t sha256_init_vector[] = {0x6A09E667, 0xBB67AE85, 0x3C6EF372,
void sha256_init(sha256_ctx_t *state)
{
state->length = 0;
memcpy(state->h, sha256_init_vector, 8 * 4);
memcpy_F(state->h, sha256_init_vector, 8 * 4);
}
/*************************************************************************/
......
......@@ -19,9 +19,10 @@
#include <stdint.h>
#include <string.h>
#include "flash.h"
#include "sha2_large_common.h"
static const uint64_t sha2_large_common_const[80] = {
static const uint64_t sha2_large_common_const[80] FLASH = {
0x428a2f98d728ae22LL, 0x7137449123ef65cdLL, 0xb5c0fbcfec4d3b2fLL,
0xe9b5dba58189dbbcLL, 0x3956c25bf348b538LL, 0x59f111f1b605d019LL,
0x923f82a4af194f9bLL, 0xab1c5ed5da6d8118LL, 0xd807aa98a3030242LL,
......@@ -110,7 +111,9 @@ void sha2_large_common_nextBlock(sha2_large_common_ctx_t *ctx,
memmove(&(w[0]), &(w[1]), 15 * 8);
w[15] = wx;
}
t1 = a[7] + SIGMA_1(a[4]) + CH(a[4], a[5], a[6]) + *k++ + wx;
t1 = a[7] + SIGMA_1(a[4]) + CH(a[4], a[5], a[6]) + wx +
((uint64_t)flash_read_32(&((uint32_t *)&k[i])[1]) << 32) +
flash_read_32(&k[i]);
t2 = SIGMA_0(a[0]) + MAJ(a[0], a[1], a[2]);
memmove(&(a[1]), &(a[0]), 7 * 8);
a[0] = t1 + t2;
......
......@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include "flash.h"
#include "sha2_small_common.h"
#define LITTLE_ENDIAN
......@@ -59,7 +60,7 @@ uint32_t change_endian32(uint32_t x){
#define SIGMA_a(x) (rotr32((x), 7) ^ rotl32((x), 14) ^ ((x) >> 3))
#define SIGMA_b(x) (rotl32((x), 15) ^ rotl32((x), 13) ^ ((x) >> 10))
const uint32_t k[] = {
const uint32_t k[] FLASH = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
......@@ -117,7 +118,8 @@ void sha2_small_common_nextBlock(sha2_small_common_ctx_t *state,
memmove(&(w[0]), &(w[1]), 15 * 4);
w[15] = wx;
}
t1 = a[7] + SIGMA_1(a[4]) + CH(a[4], a[5], a[6]) + k[i] + wx;
t1 = a[7] + SIGMA_1(a[4]) + CH(a[4], a[5], a[6]) +
flash_read_32(&k[i]) + wx;
t2 = SIGMA_0(a[0]) + MAJ(a[0], a[1], a[2]);
memmove(&(a[1]), &(a[0]), 7 * 4); /* a[7]=a[6]; a[6]=a[5]; a[5]=a[4];
a[4]=a[3]; a[3]=a[2]; a[2]=a[1];
......
......@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include "flash.h"
#include "sha2_large_common.h"
#include "sha384.h"
......@@ -33,7 +34,7 @@ void sha384_lastBlock(sha384_ctx_t *ctx, const void *block, uint16_t length_b)
length_b);
}
static const uint64_t sha384_init_values[8] = {
static const uint64_t sha384_init_values[8] FLASH = {
0xcbbb9d5dc1059ed8, 0x629a292a367cd507, 0x9159015a3070dd17,
0x152fecd8f70e5939, 0x67332667ffc00b31, 0x8eb44a8768581511,
0xdb0c2e0d64f98fa7, 0x47b5481dbefa4fa4};
......@@ -41,7 +42,7 @@ static const uint64_t sha384_init_values[8] = {
void sha384_init(sha384_ctx_t *ctx)
{
ctx->length = 0;
memcpy(ctx->h, sha384_init_values, 8 * 8);
memcpy_F(ctx->h, sha384_init_values, 8 * 8);
}
void sha384_ctx2hash(void *dest, const sha384_ctx_t *ctx)
......
......@@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include "flash.h"
#include "sha2_large_common.h"
#include "sha512.h"
......@@ -33,7 +34,7 @@ void sha512_lastBlock(sha512_ctx_t *ctx, const void *block, uint16_t length_b)
length_b);
}
static const uint64_t sha512_init_values[8] = {
static const uint64_t sha512_init_values[8] FLASH = {
0x6a09e667f3bcc908LL, 0xbb67ae8584caa73bLL, 0x3c6ef372fe94f82bLL,
0xa54ff53a5f1d36f1LL, 0x510e527fade682d1LL, 0x9b05688c2b3e6c1fLL,
0x1f83d9abfb41bd6bLL, 0x5be0cd19137e2179LL};
......@@ -41,7 +42,7 @@ static const uint64_t sha512_init_values[8] = {
void sha512_init(sha512_ctx_t *ctx)
{
ctx->length = 0;
memcpy(ctx->h, sha512_init_values, 8 * 8);
memcpy_F(ctx->h, sha512_init_values, 8 * 8);
}
void sha512_ctx2hash(void *dest, const sha512_ctx_t *ctx)
......
/* hfal-basic.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HFAL_BASIC_H_
#define HFAL_BASIC_H_
#include "hashfunction_descriptor.h"
uint8_t hfal_hash_init(const hfdesc_t *hash_descriptor, hfgen_ctx_t *ctx);
void hfal_hash_nextBlock(hfgen_ctx_t *ctx, const void *block);
void hfal_hash_lastBlock(hfgen_ctx_t *ctx, const void *block,
uint16_t length_b);
void hfal_hash_ctx2hash(void *dest, hfgen_ctx_t *ctx);
void hfal_hash_free(hfgen_ctx_t *ctx);
void hfal_hash_mem(const hfdesc_t *hash_descriptor, void *dest, const void *msg,
uint32_t length_b);
uint16_t hfal_hash_getCtxsize_B(const hfdesc_t *hash_descriptor);
uint16_t hfal_hash_getBlocksize(const hfdesc_t *hash_descriptor);
uint16_t hfal_hash_getHashsize(const hfdesc_t *hash_descriptor);
#endif /* HFAL_BASIC_H_ */
/* hfal-hmac.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HFAL_HMAC_H_
#define HFAL_HMAC_H_
#include "hashfunction_descriptor.h"
typedef struct
{
const hfdesc_t *desc;
void *ctx;
void *finctx;
} hfhmacgen_ctx_t;
uint8_t hfal_hmac_init(const hfdesc_t *hash_descriptor, hfhmacgen_ctx_t *ctx,
const void *key, uint16_t keylength_b);
uint8_t hfal_hmac_ctxcopy(hfhmacgen_ctx_t *dest, hfhmacgen_ctx_t *src);
void hfal_hmac_nextBlock(hfhmacgen_ctx_t *ctx, const void *block);
void hfal_hmac_lastBlock(hfhmacgen_ctx_t *ctx, const void *block,
uint16_t length_b);
void hfal_hmac_ctx2mac(void *dest, hfhmacgen_ctx_t *ctx);
void hfal_hmac_free(hfhmacgen_ctx_t *ctx);
void hfal_hmac_mem(const hfdesc_t *hash_descriptor, const void *key,
uint16_t keylength_b, void *dest, const void *msg,
uint32_t length_b);
uint16_t hfal_hmac_getBlocksize(const hfdesc_t *hash_descriptor);
uint16_t hfal_hmac_getMACsize(const hfdesc_t *hash_descriptor);
#endif /* HFAL_HMAC_H_ */
/* hfal-nessie.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* \file hfal-nessie.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#ifndef HFAL_NESSIE_H_
#define HFAL_NESSIE_H_
#include "hashfunction_descriptor.h"
void hfal_nessie(const hfdesc_t *hd);
void hfal_nessie_multiple(const hfdesc_t **hd_list);
#endif /* HFAL_NESSIE_H_ */
/* hfal-performance.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* \file hfal-performance.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#ifndef HFAL_PERFORMANCE_H_
#define HFAL_PERFORMANCE_H_
#include "hashfunction_descriptor.h"
void hfal_performance(const hfdesc_t *hd);
void hfal_performance_multiple(const hfdesc_t **hd_list);
#endif /* HFAL_PERFORMANCE_H_ */
/* hfal-test.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* \file hfal-test.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2009-05-10
* \license GPLv3 or later
*
*/
#ifndef HFAL_TEST_H_
#define HFAL_TEST_H_
#include "hashfunction_descriptor.h"
#include <stdint.h>
void hfal_test(const hfdesc_t *hd, const void *msg, uint32_t length_b);
#endif /* HFAL_TEST_H_ */
/* hfal_sha224.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file hfal_sha224.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2011-10-11
* \license GPLv3 or later
*
*/
#ifndef HFAL_SHA224_H_
#define HFAL_SHA224_H_
#include "hashfunction_descriptor.h"
extern const hfdesc_t sha224_desc;
#endif /* HFAL_SHA224_H_ */
/* hfal_sha256.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file hfal_sha256.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2009-02-04
* \license GPLv3 or later
*
*/
#ifndef HFAL_SHA256_H_
#define HFAL_SHA256_H_
#include "hashfunction_descriptor.h"
extern const hfdesc_t sha256_desc;
#endif /* HFAL_SHA256_H_ */
/* hfal_sha384.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file hfal_sha256.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2011-10-07
* \license GPLv3 or later
*
*/
#ifndef HFAL_SHA384_H_
#define HFAL_SHA384_H_
#include "hashfunction_descriptor.h"
extern const hfdesc_t sha384_desc;
#endif /* HFAL_SHA384_H_ */
/* hfal_sha512.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file hfal_sha256.h
* \email daniel.otte@rub.de
* \author Daniel Otte
* \date 2011-10-07
* \license GPLv3 or later
*
*/
#ifndef HFAL_SHA512_H_
#define HFAL_SHA512_H_
#include "hashfunction_descriptor.h"
extern const hfdesc_t sha512_desc;
#endif /* HFAL_SHA512_H_ */
/* sha224.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file sha224.h
* \author Daniel Otte
* \date 2011-10-11
* \license GPLv3 or later
*
*/
#ifndef SHA224_H_
#define SHA224_H_
#include <stdint.h>
#include "sha2_small_common.h"
/** \def SHA224_HASH_BITS
* defines the size of a SHA-224 hash value in bits
*/
/** \def SHA224_HASH_BYTES
* defines the size of a SHA-224 hash value in bytes
*/
/** \def SHA224_BLOCK_BITS
* defines the size of a SHA-224 input block in bits
*/
/** \def SHA224_BLOCK_BYTES
* defines the size of a SHA-224 input block in bytes
*/
#define SHA224_HASH_BITS 224
#define SHA224_HASH_BYTES (SHA224_HASH_BITS / 8)
#define SHA224_BLOCK_BITS 512
#define SHA224_BLOCK_BYTES (SHA224_BLOCK_BITS / 8)
/** \typedef sha224_ctx_t
* \brief SHA-224 context type
*
* A variable of this type may hold the state of a SHA-224 hashing process
*/
typedef sha2_small_common_ctx_t sha224_ctx_t;
/** \fn void sha224_init(sha224_ctx_t *state)
* \brief initialize a SHA-224 context
*
* This function sets a ::sha224_ctx_t to the initial values for hashing.
* \param state pointer to the SHA-224 hashing context
*/
void sha224_init(sha224_ctx_t *state);
/** \fn void sha224_nextBlock (sha224_ctx_t* state, const void* block)
* \brief update the context with a given block
*
* This function updates the SHA-224 hash context by processing the given block
* of fixed length.
* \param state pointer to the SHA-224 hash context
* \param block pointer to the block of fixed length (512 bit = 64 byte)
*/
void sha224_nextBlock(sha224_ctx_t *state, const void *block);
/** \fn void sha224_lastBlock(sha224_ctx_t* state, const void* block, uint16_t
*length_b)
* \brief finalize the context with the given block
*
* This function finalizes the SHA-224 hash context by processing the given
*block
* of variable length.
* \param state pointer to the SHA-224 hash context
* \param block pointer to the block of fixed length (512 bit = 64 byte)
* \param length_b the length of the block in bits
*/
void sha224_lastBlock(sha224_ctx_t *state, const void *block,
uint16_t length_b);
/** \fn void sha224_ctx2hash(sha224_hash_t* dest, const sha224_ctx_t* state)
* \brief convert the hash state into the hash value
* This function reads the context and writes the hash value to the destination
* \param dest pointer to the location where the hash value should be written
* \param state pointer to the SHA-224 hash context
*/
void sha224_ctx2hash(void *dest, const sha224_ctx_t *state);
/** \fn void sha224(sha224_hash_t* dest, const void* msg, uint32_t length_b)
* \brief simple SHA-224 hashing function for direct hashing
*
* This function automatically hashes a given message of arbitary length with
* the SHA-224 hashing algorithm.
* \param dest pointer to the location where the hash value is going to be
*written to
* \param msg pointer to the message thats going to be hashed
* \param length_b length of the message in bits
*/
void sha224(void *dest, const void *msg, uint32_t length_b);
#endif /*SHA224_H_*/
/* sha256.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file sha256.h
* \author Daniel Otte
* \date 2011-10-11
* \license GPLv3 or later
*
*/
#ifndef SHA256_H_
#define SHA256_H_
#include <stdint.h>
#include "sha2_small_common.h"
/** \def SHA256_HASH_BITS
* defines the size of a SHA-256 hash value in bits
*/