<!-- HTML header for doxygen 1.8.10-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<title>Intel® Enhanced Privacy ID SDK: epid/member/tiny/math/sha256.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="epidstyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname"><a
onclick="storeLink('index.html')"
id="projectlink"
class="index.html"
href="index.html">Intel® Enhanced Privacy ID SDK</a>
 <span id="projectnumber">6.0.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('sha256_8h.html','');});
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> |
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">sha256.h File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Interface to a SHA-256 implementation.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include <stddef.h></code><br />
<code>#include <stdint.h></code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a9c1fe69ad43d4ca74b84303a0ed64f2f"><td class="memItemLeft" align="right" valign="top"><a id="a9c1fe69ad43d4ca74b84303a0ed64f2f"></a>
#define </td><td class="memItemRight" valign="bottom"><a class="el" href="sha256_8h.html#a9c1fe69ad43d4ca74b84303a0ed64f2f">SHA256_BLOCK_SIZE</a>   (64)</td></tr>
<tr class="memdesc:a9c1fe69ad43d4ca74b84303a0ed64f2f"><td class="mdescLeft"> </td><td class="mdescRight">Block size. <br /></td></tr>
<tr class="separator:a9c1fe69ad43d4ca74b84303a0ed64f2f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a81efbc0fc101b06a914f7ff9e2fbc0e9"><td class="memItemLeft" align="right" valign="top"><a id="a81efbc0fc101b06a914f7ff9e2fbc0e9"></a>
#define </td><td class="memItemRight" valign="bottom"><a class="el" href="sha256_8h.html#a81efbc0fc101b06a914f7ff9e2fbc0e9">SHA256_DIGEST_SIZE</a>   (32)</td></tr>
<tr class="memdesc:a81efbc0fc101b06a914f7ff9e2fbc0e9"><td class="mdescLeft"> </td><td class="mdescRight">Digest size. <br /></td></tr>
<tr class="separator:a81efbc0fc101b06a914f7ff9e2fbc0e9"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0558ee82699b60132c23e0a049ab7a56"><td class="memItemLeft" align="right" valign="top"><a id="a0558ee82699b60132c23e0a049ab7a56"></a>
#define </td><td class="memItemRight" valign="bottom"><a class="el" href="sha256_8h.html#a0558ee82699b60132c23e0a049ab7a56">SHA256_STATE_BLOCKS</a>   (<a class="el" href="sha256_8h.html#a81efbc0fc101b06a914f7ff9e2fbc0e9">SHA256_DIGEST_SIZE</a> / 4)</td></tr>
<tr class="memdesc:a0558ee82699b60132c23e0a049ab7a56"><td class="mdescLeft"> </td><td class="mdescRight">Number of blocks in state. <br /></td></tr>
<tr class="separator:a0558ee82699b60132c23e0a049ab7a56"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a05aad282287c226a9ab8a2eb65d10d1b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="sha256_8h.html#a05aad282287c226a9ab8a2eb65d10d1b">tc_sha256_init</a> (sha256_state *s)</td></tr>
<tr class="memdesc:a05aad282287c226a9ab8a2eb65d10d1b"><td class="mdescLeft"> </td><td class="mdescRight">The SHA state. <a href="#a05aad282287c226a9ab8a2eb65d10d1b">More...</a><br /></td></tr>
<tr class="separator:a05aad282287c226a9ab8a2eb65d10d1b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab42ecba529c48040c34e70cee8d98096"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="sha256_8h.html#ab42ecba529c48040c34e70cee8d98096">tc_sha256_update</a> (sha256_state *s, const uint8_t *data, size_t datalen)</td></tr>
<tr class="memdesc:ab42ecba529c48040c34e70cee8d98096"><td class="mdescLeft"> </td><td class="mdescRight">SHA256 update procedure Hashes data_length bytes addressed by data into state s. <a href="#ab42ecba529c48040c34e70cee8d98096">More...</a><br /></td></tr>
<tr class="separator:ab42ecba529c48040c34e70cee8d98096"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8013bed3e0b388ec654f991b45c00bbf"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="sha256_8h.html#a8013bed3e0b388ec654f991b45c00bbf">tc_sha256_final</a> (uint8_t *digest, sha256_state *s)</td></tr>
<tr class="memdesc:a8013bed3e0b388ec654f991b45c00bbf"><td class="mdescLeft"> </td><td class="mdescRight">SHA256 final procedure Inserts the completed hash computation into digest. <a href="#a8013bed3e0b388ec654f991b45c00bbf">More...</a><br /></td></tr>
<tr class="separator:a8013bed3e0b388ec654f991b45c00bbf"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Interface to a SHA-256 implementation. </p>
<p>Overview: SHA-256 is a NIST approved cryptographic hashing algorithm specified in FIPS 180. A hash algorithm maps data of arbitrary size to data of fixed length.</p>
<p>Security: SHA-256 provides 128 bits of security against collision attacks and 256 bits of security against pre-image attacks. SHA-256 does NOT behave like a random oracle, but it can be used as one if the string being hashed is prefix-free encoded before hashing.</p>
<p>Usage: 1) call tc_sha256_init to initialize a struct tc_sha256_state_struct before hashing a new string.</p>
<p>2) call tc_sha256_update to hash the next string segment; tc_sha256_update can be called as many times as needed to hash all of the segments of a string; the order is important.</p>
<p>3) call tc_sha256_final to out put the digest from a hashing operation. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a8013bed3e0b388ec654f991b45c00bbf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8013bed3e0b388ec654f991b45c00bbf">◆ </a></span>tc_sha256_final()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void tc_sha256_final </td>
<td>(</td>
<td class="paramtype">uint8_t * </td>
<td class="paramname"><em>digest</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">sha256_state * </td>
<td class="paramname"><em>s</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>SHA256 final procedure Inserts the completed hash computation into digest. </p>
<dl class="section return"><dt>Returns</dt><dd>returns 1 returns 0 if: s == NULL, s->iv == NULL, digest == NULL </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Assumes: s has been initialized by tc_sha256_init digest points to at least SHA256_DIGEST_SIZE bytes </dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>The state buffer 'leftover' is left in memory after processing If your application intends to have sensitive data in this buffer, remind to erase it after the data has been processed </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">digest</td><td>unsigned eight bit integer </td></tr>
<tr><td class="paramname">s</td><td>Sha256 state struct </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a05aad282287c226a9ab8a2eb65d10d1b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a05aad282287c226a9ab8a2eb65d10d1b">◆ </a></span>tc_sha256_init()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void tc_sha256_init </td>
<td>(</td>
<td class="paramtype">sha256_state * </td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The SHA state. </p>
<p>SHA256 initialization procedure Initializes s </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td>Sha256 state struct </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="ab42ecba529c48040c34e70cee8d98096"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab42ecba529c48040c34e70cee8d98096">◆ </a></span>tc_sha256_update()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void tc_sha256_update </td>
<td>(</td>
<td class="paramtype">sha256_state * </td>
<td class="paramname"><em>s</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint8_t * </td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>datalen</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>SHA256 update procedure Hashes data_length bytes addressed by data into state s. </p>
<dl class="section note"><dt>Note</dt><dd>Assumes s has been initialized by tc_sha256_init </dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>The state buffer 'leftover' is left in memory after processing If your application intends to have sensitive data in this buffer, remind to erase it after the data has been processed </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td>Sha256 state struct </td></tr>
<tr><td class="paramname">data</td><td>message to hash </td></tr>
<tr><td class="paramname">datalen</td><td>length of message to hash </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_12b90d9c027aaf878a834df729679a56.html">epid</a></li><li class="navelem"><a class="el" href="dir_512d3e62841a8535b716ec4cf8b9e950.html">member</a></li><li class="navelem"><a class="el" href="dir_ea12d375fc1eb79df248c0adf953af4f.html">tiny</a></li><li class="navelem"><a class="el" href="dir_5f2fc2cf41db41de2b55e03ffa7a1d16.html">math</a></li><li class="navelem"><a class="el" href="sha256_8h.html">sha256.h</a></li>
<li class="footer">
© 2016-2017 Intel Corporation
</li>
</ul>
</div>
</body>
</html>