1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 8.0.0.0 for Windows"> 7<META http-equiv="Content-Style-Type" content="text/css"> 8<title>MATH_CalcHMACSHA256</title> 9<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 10</head> 11 12<body> 13 14<h1 align="left">MATH_CalcHMACSHA256<img src="../../image/NTR.gif"align="middle"><img src="../../image/TWL.gif" align="middle"></H1> 15<H2>Syntax</H2> 16 17<dl> 18 <dd> 19 <PRE><CODE>#include <nitro/math/dgt.h> 20 21static inline void MATH_CalcHMACSHA256( void* digest, const void* data, u32 dataLength, const void* key, u32 keyLength ); 22</CODE></PRE> 23 </dd> 24</dl><h2>Arguments</h2> 25 26<table border="1" width="100%"> 27 <TR> 28<TD width="176"><em><strong><font face="Courier New">digest</font></strong></em></TD> 29<TD width="670">Pointer to the memory location that holds the calculated keyed-hash value.</TD> 30 </TR> 31 <TR> 32<TD width="176"><em><strong><font face="Courier New">data</font></strong></em></TD> 33<TD width="670">Pointer to the input data.</TD> 34 </TR> 35 <TR> 36<TD width="176"><em><strong><font face="Courier New">dataLength</font></strong></em></TD> 37<TD width="670">Size of the input data.</TD> 38 </TR> 39 <TR> 40<TD width="176"><em><strong><font face="Courier New">key</font></strong></em></TD> 41<TD width="670">Pointer to the key.</TD> 42 </TR> 43 <TR> 44<TD width="176"><em><strong><font face="Courier New">keyLength</font></strong></em></TD> 45<TD width="670">The key size.</TD> 46 </TR> 47 </table> 48<h2>Return Values</h2> 49<p>None.</p> 50<H2>Description</H2> 51<P>This function calculates an HMAC (hash message authentication code) using SHA-256. The length of the generated keyed-hash value is 256 bits, or <CODE>MATH_SHA256_DIGEST_SIZE</CODE> (32) bytes. Use the "digest" argument to pass an area that can store a value of this size. Any size and alignment position can be used for the input data and key. However, if the key is smaller than <CODE>MATH_SHA256_DIGEST_SIZE</CODE>, it becomes weaker. Even if the key is larger than <CODE>MATH_SHA256_DIGEST_SIZE</CODE>, little additional strength is gained.<BR><BR> Internally, the stack size will be approximately 90 bytes greater than the size of the <CODE><A href="MATHSHA256Context.html">MATHSHA256Context</A></CODE> structure. Make sure sufficient stack is available when calling. SHA-256 is an algorithm to find the message digest value. For details, refer to the Federal Information Processing Standard, FIPS PUB 180-2. HMAC is a keyed-hashing algorithm for message authentication. The algorithm that uses SHA-256 internally as a hash function is called <code>HMAC-SHA-256</code>. For details, see RFC 2104. 52</P> 53<h2>See Also</h2> 54<P><CODE></CODE></P> 55<H2>Revision History</H2> 56<P> 572008/05/23 Initial version. 58</P> 59<hr><p>CONFIDENTIAL</p></body> 60</html> 61