libbtc
bitcoinclibrary
|
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | _SHA256_CTX |
struct | _SHA512_CTX |
Macros | |
#define | SHA256_BLOCK_LENGTH 64 |
#define | SHA256_DIGEST_LENGTH 32 |
#define | SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) |
#define | SHA512_BLOCK_LENGTH 128 |
#define | SHA512_DIGEST_LENGTH 64 |
#define | SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) |
Typedefs | |
typedef struct _SHA256_CTX | SHA256_CTX |
typedef struct _SHA512_CTX | SHA512_CTX |
Functions | |
void | sha256_Init (SHA256_CTX *) |
void | sha256_Update (SHA256_CTX *, const uint8_t *, size_t) |
void | sha256_Final (uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX *) |
void | sha256_Raw (const uint8_t *, size_t, uint8_t[SHA256_DIGEST_LENGTH]) |
void | sha512_Init (SHA512_CTX *) |
void | sha512_Update (SHA512_CTX *, const uint8_t *, size_t) |
void | sha512_Final (uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX *) |
void | sha512_Raw (const uint8_t *, size_t, uint8_t[SHA512_DIGEST_LENGTH]) |
void | hmac_sha256 (const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac) |
void | hmac_sha512 (const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac) |
#define SHA256_BLOCK_LENGTH 64 |
Copyright (c) 2000-2001 Aaron D. Gifford Copyright (c) 2013 Pavol Rusnak Copyright (c) 2015 Jonas Schnelli All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition at line 38 of file sha2.h.
Referenced by hmac_sha256(), sha256_Final(), sha256_Init(), and sha256_Update().
#define SHA256_DIGEST_LENGTH 32 |
Definition at line 39 of file sha2.h.
Referenced by hmac_sha256(), sha256_Final(), and sha256_Init().
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) |
#define SHA512_BLOCK_LENGTH 128 |
Definition at line 41 of file sha2.h.
Referenced by hmac_sha512(), sha512_Init(), sha512_Last(), and sha512_Update().
#define SHA512_DIGEST_LENGTH 64 |
Definition at line 42 of file sha2.h.
Referenced by hmac_sha512(), sha512_Final(), and sha512_Init().
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) |
typedef struct _SHA256_CTX SHA256_CTX |
typedef struct _SHA512_CTX SHA512_CTX |
void hmac_sha256 | ( | const uint8_t * | key, |
const uint32_t | keylen, | ||
const uint8_t * | msg, | ||
const uint32_t | msglen, | ||
uint8_t * | hmac | ||
) |
Definition at line 966 of file sha2.c.
References SHA256_BLOCK_LENGTH, SHA256_DIGEST_LENGTH, sha256_Final(), sha256_Init(), sha256_Raw(), and sha256_Update().
void hmac_sha512 | ( | const uint8_t * | key, |
const uint32_t | keylen, | ||
const uint8_t * | msg, | ||
const uint32_t | msglen, | ||
uint8_t * | hmac | ||
) |
Definition at line 996 of file sha2.c.
References SHA512_BLOCK_LENGTH, SHA512_DIGEST_LENGTH, sha512_Final(), sha512_Init(), sha512_Raw(), and sha512_Update().
Referenced by btc_hdnode_from_seed(), btc_hdnode_private_ckd(), and btc_hdnode_public_ckd().
void sha256_Final | ( | uint8_t | [SHA256_DIGEST_LENGTH], |
SHA256_CTX * | |||
) |
void sha256_Init | ( | SHA256_CTX * | ) |
Definition at line 360 of file sha2.c.
References _SHA256_CTX::bitcount, _SHA256_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, SHA256_BLOCK_LENGTH, SHA256_DIGEST_LENGTH, sha256_initial_hash_value, and _SHA256_CTX::state.
Referenced by hmac_sha256(), and sha256_Raw().
void sha256_Raw | ( | const uint8_t * | , |
size_t | , | ||
uint8_t | [SHA256_DIGEST_LENGTH] | ||
) |
Definition at line 652 of file sha2.c.
References sha256_Final(), sha256_Init(), and sha256_Update().
Referenced by btc_b58check(), btc_base58_encode_check(), btc_hash(), btc_hash_sngl_sha256(), btc_hdnode_private_ckd(), btc_hdnode_public_ckd(), btc_tx_hash(), btc_tx_sighash(), and hmac_sha256().
void sha256_Update | ( | SHA256_CTX * | , |
const uint8_t * | , | ||
size_t | |||
) |
Definition at line 544 of file sha2.c.
References _SHA256_CTX::bitcount, _SHA256_CTX::buffer, MEMCPY_BCOPY, SHA256_BLOCK_LENGTH, and sha256_Transform().
Referenced by hmac_sha256(), and sha256_Raw().
void sha512_Final | ( | uint8_t | [SHA512_DIGEST_LENGTH], |
SHA512_CTX * | |||
) |
void sha512_Init | ( | SHA512_CTX * | ) |
Definition at line 662 of file sha2.c.
References _SHA512_CTX::bitcount, _SHA512_CTX::buffer, MEMCPY_BCOPY, MEMSET_BZERO, SHA512_BLOCK_LENGTH, SHA512_DIGEST_LENGTH, sha512_initial_hash_value, and _SHA512_CTX::state.
Referenced by hmac_sha512(), and sha512_Raw().
void sha512_Raw | ( | const uint8_t * | , |
size_t | , | ||
uint8_t | [SHA512_DIGEST_LENGTH] | ||
) |
Definition at line 958 of file sha2.c.
References sha512_Final(), sha512_Init(), and sha512_Update().
Referenced by hmac_sha512().
void sha512_Update | ( | SHA512_CTX * | , |
const uint8_t * | , | ||
size_t | |||
) |
Definition at line 840 of file sha2.c.
References ADDINC128, _SHA512_CTX::bitcount, _SHA512_CTX::buffer, MEMCPY_BCOPY, SHA512_BLOCK_LENGTH, and sha512_Transform().
Referenced by hmac_sha512(), and sha512_Raw().