\doxysection{src/gsm/kdf/sha256.c File Reference}
\label{sha256_8c}\index{src/gsm/kdf/sha256.c@{src/gsm/kdf/sha256.c}}
{\ttfamily \#include \char`\"{}common.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}sha256.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}crypto.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ hmac\+\_\+sha256\+\_\+vector} (const \textbf{ u8} $\ast$key, size\+\_\+t key\+\_\+len, size\+\_\+t num\+\_\+elem, const \textbf{ u8} $\ast$addr[$\,$], const size\+\_\+t $\ast$\textbf{ len}, \textbf{ u8} $\ast$mac)
\begin{DoxyCompactList}\small\item\em hmac\+\_\+sha256\+\_\+vector -\/ HMAC-\/\+SHA256 over data vector (RFC 2104) @key\+: Key for HMAC operations @key\+\_\+len\+: Length of the key in bytes @num\+\_\+elem\+: Number of elements in the data vector @addr\+: Pointers to the data areas @len\+: Lengths of the data blocks @mac\+: Buffer for the hash (32 bytes) \end{DoxyCompactList}\item 
void \textbf{ hmac\+\_\+sha256} (const \textbf{ u8} $\ast$key, size\+\_\+t key\+\_\+len, const \textbf{ u8} $\ast$\textbf{ data}, size\+\_\+t data\+\_\+len, \textbf{ u8} $\ast$mac)
\begin{DoxyCompactList}\small\item\em hmac\+\_\+sha256 -\/ HMAC-\/\+SHA256 over data buffer (RFC 2104) @key\+: Key for HMAC operations @key\+\_\+len\+: Length of the key in bytes @data\+: Pointers to the data area @data\+\_\+len\+: Length of the data area @mac\+: Buffer for the hash (20 bytes) \end{DoxyCompactList}\item 
void \textbf{ sha256\+\_\+prf} (const \textbf{ u8} $\ast$key, size\+\_\+t key\+\_\+len, const char $\ast$label, const \textbf{ u8} $\ast$\textbf{ data}, size\+\_\+t data\+\_\+len, \textbf{ u8} $\ast$buf, size\+\_\+t buf\+\_\+len)
\begin{DoxyCompactList}\small\item\em sha256\+\_\+prf -\/ SHA256-\/based Pseudo-\/\+Random Function (IEEE 802.\+11r, 8.\+5.\+1.\+5.\+2) @key\+: Key for PRF @key\+\_\+len\+: Length of the key in bytes @label\+: A unique label for each purpose of the PRF @data\+: Extra data to bind into the key @data\+\_\+len\+: Length of the data @buf\+: Buffer for the generated pseudo-\/random key @buf\+\_\+len\+: Number of bytes of key to generate \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\label{sha256_8c_aab5c2214e831e1ff3358abdf5e09afa5}} 
\index{sha256.c@{sha256.c}!hmac\_sha256@{hmac\_sha256}}
\index{hmac\_sha256@{hmac\_sha256}!sha256.c@{sha256.c}}
\doxysubsubsection{hmac\_sha256()}
{\footnotesize\ttfamily void hmac\+\_\+sha256 (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{key,  }\item[{size\+\_\+t}]{key\+\_\+len,  }\item[{const \textbf{ u8} $\ast$}]{data,  }\item[{size\+\_\+t}]{data\+\_\+len,  }\item[{\textbf{ u8} $\ast$}]{mac }\end{DoxyParamCaption})}



hmac\+\_\+sha256 -\/ HMAC-\/\+SHA256 over data buffer (RFC 2104) @key\+: Key for HMAC operations @key\+\_\+len\+: Length of the key in bytes @data\+: Pointers to the data area @data\+\_\+len\+: Length of the data area @mac\+: Buffer for the hash (20 bytes) 



References \textbf{ data}, and \textbf{ hmac\+\_\+sha256\+\_\+vector()}.

\mbox{\label{sha256_8c_a5fafd5b2a8f791cb6c05beb908663d37}} 
\index{sha256.c@{sha256.c}!hmac\_sha256\_vector@{hmac\_sha256\_vector}}
\index{hmac\_sha256\_vector@{hmac\_sha256\_vector}!sha256.c@{sha256.c}}
\doxysubsubsection{hmac\_sha256\_vector()}
{\footnotesize\ttfamily void hmac\+\_\+sha256\+\_\+vector (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{key,  }\item[{size\+\_\+t}]{key\+\_\+len,  }\item[{size\+\_\+t}]{num\+\_\+elem,  }\item[{const \textbf{ u8} $\ast$}]{addr[$\,$],  }\item[{const size\+\_\+t $\ast$}]{len,  }\item[{\textbf{ u8} $\ast$}]{mac }\end{DoxyParamCaption})}



hmac\+\_\+sha256\+\_\+vector -\/ HMAC-\/\+SHA256 over data vector (RFC 2104) @key\+: Key for HMAC operations @key\+\_\+len\+: Length of the key in bytes @num\+\_\+elem\+: Number of elements in the data vector @addr\+: Pointers to the data areas @len\+: Lengths of the data blocks @mac\+: Buffer for the hash (32 bytes) 



References \textbf{ len}, \textbf{ os\+\_\+memcpy}, \textbf{ os\+\_\+memset}, \textbf{ SHA256\+\_\+\+MAC\+\_\+\+LEN}, and \textbf{ sha256\+\_\+vector()}.



Referenced by \textbf{ hmac\+\_\+sha256()}, and \textbf{ sha256\+\_\+prf()}.

\mbox{\label{sha256_8c_ae75ffcb34eb7260c8b1a20740c314aae}} 
\index{sha256.c@{sha256.c}!sha256\_prf@{sha256\_prf}}
\index{sha256\_prf@{sha256\_prf}!sha256.c@{sha256.c}}
\doxysubsubsection{sha256\_prf()}
{\footnotesize\ttfamily void sha256\+\_\+prf (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{key,  }\item[{size\+\_\+t}]{key\+\_\+len,  }\item[{const char $\ast$}]{label,  }\item[{const \textbf{ u8} $\ast$}]{data,  }\item[{size\+\_\+t}]{data\+\_\+len,  }\item[{\textbf{ u8} $\ast$}]{buf,  }\item[{size\+\_\+t}]{buf\+\_\+len }\end{DoxyParamCaption})}



sha256\+\_\+prf -\/ SHA256-\/based Pseudo-\/\+Random Function (IEEE 802.\+11r, 8.\+5.\+1.\+5.\+2) @key\+: Key for PRF @key\+\_\+len\+: Length of the key in bytes @label\+: A unique label for each purpose of the PRF @data\+: Extra data to bind into the key @data\+\_\+len\+: Length of the data @buf\+: Buffer for the generated pseudo-\/random key @buf\+\_\+len\+: Number of bytes of key to generate 

This function is used to derive new, cryptographically separate keys from a given key. 

References \textbf{ data}, \textbf{ hmac\+\_\+sha256\+\_\+vector()}, \textbf{ len}, \textbf{ os\+\_\+memcpy}, \textbf{ os\+\_\+strlen}, \textbf{ SHA256\+\_\+\+MAC\+\_\+\+LEN}, and \textbf{ WPA\+\_\+\+PUT\+\_\+\+LE16}.

