<HTML>
<TITLE>
ethz_sha2/simvectors/sph_types.h
</TITLE>
<BODY>
<PRE>
/* $Id: sph_types.h 260 2011-07-21 01:02:38Z tp $ */
/**
* Basic type definitions.
*
* This header file defines the generic integer types that will be used
* for the implementation of hash functions; it also contains helper
* functions which encode and decode multi-byte integer values, using
* either little-endian or big-endian conventions.
*
* This file contains a compile-time test on the size of a byte
* (the <code>unsigned char</code> C type). If bytes are not octets,
* i.e. if they do not have a size of exactly 8 bits, then compilation
* is aborted. Architectures where bytes are not octets are relatively
* rare, even in the embedded devices market. We forbid non-octet bytes
* because there is no clear convention on how octet streams are encoded
* on such systems.
*
* ==========================(LICENSE BEGIN)============================
*
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ===========================(LICENSE END)=============================
*
* @file sph_types.h
* @author Thomas Pornin <thomas.pornin@cryptolog.com>
*/
#ifndef SPH_TYPES_H__
#define SPH_TYPES_H__
#include <limits.h>
/*
* All our I/O functions are defined over octet streams. We do not know
* how to handle input data if bytes are not octets.
*/
#if CHAR_BIT != 8
#error This code requires 8-bit bytes
#endif
/* ============= BEGIN documentation block for Doxygen ============ */
#ifdef DOXYGEN_IGNORE
/** @mainpage sphlib C code documentation
*
* @section overview Overview
*
* <code>sphlib</code> is a library which contains implementations of
* various cryptographic hash functions. These pages have been generated
* with <a href="http://www.doxygen.org/index.html">doxygen</a> and
* document the API for the C implementations.
*
* The API is described in appropriate header files, which are available
* in the "Files" section. Each hash function family has its own header,
* whose name begins with <code>"sph_"</code> and contains the family
* name. For instance, the API for the RIPEMD hash functions is available
* in the header file <code>sph_ripemd.h</code>.
*
* @section principles API structure and conventions
*
* @subsection io Input/output conventions
*
* In all generality, hash functions operate over strings of bits.
* Individual bits are rarely encountered in C programming or actual
* communication protocols; most protocols converge on the ubiquitous
* "octet" which is a group of eight bits. Data is thus expressed as a
* stream of octets. The C programming language contains the notion of a
* "byte", which is a data unit managed under the type <code>"unsigned
* char"</code>. The C standard prescribes that a byte should hold at
* least eight bits, but possibly more. Most modern architectures, even
* in the embedded world, feature eight-bit bytes, i.e. map bytes to
* octets.
*
* Nevertheless, for some of the implemented hash functions, an extra
* API has been added, which allows the input of arbitrary sequences of
* bits: when the computation is about to be closed, 1 to 7 extra bits
* can be added. The functions for which this API is implemented include
* the SHA-2 functions and all SHA-3 candidates.
*
* <code>sphlib</code> defines hash function which may hash octet streams,
* i.e. streams of bits where the number of bits is a multiple of eight.
* The data input functions in the <code>sphlib</code> API expect data
* as anonymous pointers (<code>"const void *"</code>) with a length
* (of type <code>"size_t"</code>) which gives the input data chunk length
* in bytes. A byte is assumed to be an octet; the <code>sph_types.h</code>
* header contains a compile-time test which prevents compilation on
* architectures where this property is not met.
*
* The hash function output is also converted into bytes. All currently
* implemented hash functions have an output width which is a multiple of
* eight, and this is likely to remain true for new designs.
*
* Most hash functions internally convert input data into 32-bit of 64-bit
* words, using either little-endian or big-endian conversion. The hash
* output also often consists of such words, which are encoded into output
* bytes with a similar endianness convention. Some hash functions have
* been only loosely specified on that subject; when necessary,
* <code>sphlib</code> has been tested against published "reference"
* implementations in order to use the same conventions.
*
* @subsection shortname Function short name
*
* Each implemented hash function has a "short name" which is used
* internally to derive the identifiers for the functions and context
* structures which the function uses. For instance, MD5 has the short
* name <code>"md5"</code>. Short names are listed in the next section,
* for the implemented hash functions. In subsequent sections, the
* short name will be assumed to be <code>"XXX"</code>: replace with the
* actual hash function name to get the C identifier.
*
* Note: some functions within the same family share the same core
* elements, such as update function or context structure. Correspondingly,
* some of the defined types or functions may actually be macros which
* transparently evaluate to another type or function name.
*
* @subsection context Context structure
*
* Each implemented hash fonction has its own context structure, available
* under the type name <code>"sph_XXX_context"</code> for the hash function
* with short name <code>"XXX"</code>. This structure holds all needed
* state for a running hash computation.
*
* The contents of these structures are meant to be opaque, and private
* to the implementation. However, these contents are specified in the
* header files so that application code which uses <code>sphlib</code>
* may access the size of those structures.
*
* The caller is responsible for allocating the context structure,
* whether by dynamic allocation (<code>malloc()</code> or equivalent),
* static allocation (a global permanent variable), as an automatic
* variable ("on the stack"), or by any other mean which ensures proper
* structure alignment. <code>sphlib</code> code performs no dynamic
* allocation by itself.
*
* The context must be initialized before use, using the
* <code>sph_XXX_init()</code> function. This function sets the context
* state to proper initial values for hashing.
*
* Since all state data is contained within the context structure,
* <code>sphlib</code> is thread-safe and reentrant: several hash
* computations may be performed in parallel, provided that they do not
* operate on the same context. Moreover, a running computation can be
* cloned by copying the context (with a simple <code>memcpy()</code>):
* the context and its clone are then independant and may be updated
* with new data and/or closed without
没有合适的资源?快使用搜索试试~ 我知道了~
ethz_sha2.tar.gz_sha2 code
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2022-09-14
22:46:07
上传
评论
收藏 68KB GZ 举报
温馨提示
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共42个文件
html:42个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
SHA2 algorithm source code
资源推荐
资源详情
资源评论
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
共 42 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/fca2fc36c4174e7caf12f1c9ba2c9265_weixin_42657024.jpg!1)
邓凌佳
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)