1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?xml version='1.0' encoding='iso-8859-1'?>
- <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
- <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
- <head>
- <title>
- SHA256Fetch.c
- </title>
- <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
- <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
- <meta name='author' content='cmaier@cmassoc.net'/>
- <meta name='robots' content='noindex,nofollow'/>
- <link href='toolkit.css' rel='stylesheet' type='text/css'/>
- </head>
- <body>
- <div class='headerlink'>
- [<a href='SHA256.c.html' title=' SHA256.c '>PREV</a>]
- [<a href='toolkit.html' title=' Index '>HOME</a>]
- [<a href='SHA256Ident.c.html' title=' SHA256Ident.c '>NEXT</a>]
- </div>
- <pre>
- /*====================================================================*
- *
- * void SHA256Fetch (struct sha256 * sha256, uint8_t digest []);
- *
- * SHA256.h
- *
- * read the SHA256 digest; this function works like function read()
- * but the function returns no value and the digest buffer is fixed
- * length;
- *
- * to start a digest, use function SHA256Reset(); to write data to
- * the digest use function SHA256Write();
- *
- * Read standard FIPS180-2 sec 5.3.2 for an explanation;
- *
- * Motley Tools by Charles Maier <cmaier@cmassoc.net>;
- * Copyright (c) 2001-2006 by Charles Maier Associates;
- * Licensed under the Internet Software Consortium License;
- *
- *--------------------------------------------------------------------*/
- #ifndef SHA256FETCH_SOURCE
- #define SHA256FETCH_SOURCE
- #include "../key/SHA256.h"
- static void encode (uint8_t memory [], uint32_t number)
- {
- *memory++ = (uint8_t)(number >> 24);
- *memory++ = (uint8_t)(number >> 16);
- *memory++ = (uint8_t)(number >> 8);
- *memory++ = (uint8_t)(number >> 0);
- return;
- }
- void SHA256Fetch (struct sha256 * sha256, uint8_t digest [])
- {
- unsigned word;
- uint8_t bits [8];
- uint32_t upper = (sha256->count [0] >> 29) | (sha256->count [1] << 3);
- uint32_t lower = (sha256->count [0] << 3);
- uint32_t final = (sha256->count [0] & 0x3F);
- uint32_t extra = (final < 56)? (56 - final): (120 - final);
- encode (&bits [0], upper);
- encode (&bits [4], lower);
- SHA256Write (sha256, sha256->extra, extra);
- SHA256Write (sha256, bits, sizeof (bits));
- for (word = 0; word < sizeof (sha256->state) / sizeof (uint32_t); word++)
- {
- encode (digest, sha256->state [word]);
- digest += sizeof (uint32_t);
- }
- memset (sha256, 0, sizeof (struct sha256));
- return;
- }
- #endif
- </pre>
- <div class='footerlink'>
- [<a href='SHA256.c.html' title=' SHA256.c '>PREV</a>]
- [<a href='toolkit.html' title=' Index '>HOME</a>]
- [<a href='SHA256Ident.c.html' title=' SHA256Ident.c '>NEXT</a>]
- </div>
- </body>
- </html>
|