2025-06-11 22:53:28 +02:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2025-05-24 10:59:23 +02:00
|
|
|
/* $OpenBSD: sha2.h,v 1.10 2016/09/03 17:00:29 tedu Exp $ */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* FILE: sha2.h
|
|
|
|
|
* AUTHOR: Aaron D. Gifford <me@aarongifford.com>
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2000-2001, Aaron D. Gifford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __SHA2_H__
|
|
|
|
|
#define __SHA2_H__
|
|
|
|
|
|
|
|
|
|
#include "stdint.h"
|
|
|
|
|
|
|
|
|
|
/*** SHA-256/384/512 Various Length Definitions ***********************/
|
|
|
|
|
#define SHA256_BLOCK_LENGTH 64
|
|
|
|
|
#define SHA256_DIGEST_LENGTH 32
|
|
|
|
|
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
|
|
|
|
|
|
|
|
|
|
/*** SHA-224/256/384/512 Context Structure *******************************/
|
|
|
|
|
typedef struct _SHA2_CTX {
|
|
|
|
|
union {
|
|
|
|
|
uint32_t st32[8];
|
|
|
|
|
uint64_t st64[8];
|
|
|
|
|
} state;
|
|
|
|
|
uint64_t bitcount[2];
|
|
|
|
|
uint8_t buffer[SHA256_BLOCK_LENGTH];
|
|
|
|
|
} SHA2_CTX;
|
|
|
|
|
|
|
|
|
|
void SHA256Init(SHA2_CTX *);
|
|
|
|
|
void SHA256Transform(uint32_t state[8], const uint8_t [SHA256_BLOCK_LENGTH]);
|
|
|
|
|
void SHA256Update(SHA2_CTX *, const uint8_t *, size_t);
|
|
|
|
|
void SHA256Pad(SHA2_CTX *);
|
|
|
|
|
void SHA256Final(uint8_t [SHA256_DIGEST_LENGTH], SHA2_CTX *);
|
|
|
|
|
char *SHA256End(SHA2_CTX *, char *);
|
|
|
|
|
|
|
|
|
|
#endif /* __SHA2_H__ */
|