\doxysection{src/gsm/kdf/sha1.c File Reference}
\label{sha1_8c}\index{src/gsm/kdf/sha1.c@{src/gsm/kdf/sha1.c}}
{\ttfamily \#include \char`\"{}common.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}sha1.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}crypto.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \textbf{ hmac\+\_\+sha1\+\_\+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\+\_\+sha1\+\_\+vector -\/ HMAC-\/\+SHA1 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 (20 bytes) Returns\+: 0 on success, -\/1 on failure \end{DoxyCompactList}\item 
int \textbf{ hmac\+\_\+sha1} (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\+\_\+sha1 -\/ HMAC-\/\+SHA1 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) Returns\+: 0 on success, -\/1 of failure \end{DoxyCompactList}\item 
int \textbf{ sha1\+\_\+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 sha1\+\_\+prf -\/ SHA1-\/based Pseudo-\/\+Random Function (PRF) (IEEE 802.\+11i, 8.\+5.\+1.\+1) @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 Returns\+: 0 on success, -\/1 of failure \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\label{sha1_8c_a746cfe54c780a704239af25ea2953cd4}} 
\index{sha1.c@{sha1.c}!hmac\_sha1@{hmac\_sha1}}
\index{hmac\_sha1@{hmac\_sha1}!sha1.c@{sha1.c}}
\doxysubsubsection{hmac\_sha1()}
{\footnotesize\ttfamily int hmac\+\_\+sha1 (\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\+\_\+sha1 -\/ HMAC-\/\+SHA1 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) Returns\+: 0 on success, -\/1 of failure 



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

\mbox{\label{sha1_8c_aa0ee972a55e1005b2bdaf33e1d608946}} 
\index{sha1.c@{sha1.c}!hmac\_sha1\_vector@{hmac\_sha1\_vector}}
\index{hmac\_sha1\_vector@{hmac\_sha1\_vector}!sha1.c@{sha1.c}}
\doxysubsubsection{hmac\_sha1\_vector()}
{\footnotesize\ttfamily int hmac\+\_\+sha1\+\_\+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\+\_\+sha1\+\_\+vector -\/ HMAC-\/\+SHA1 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 (20 bytes) Returns\+: 0 on success, -\/1 on failure 



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



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

\mbox{\label{sha1_8c_a0a1d5275823b4b039edc8ea21eea154b}} 
\index{sha1.c@{sha1.c}!sha1\_prf@{sha1\_prf}}
\index{sha1\_prf@{sha1\_prf}!sha1.c@{sha1.c}}
\doxysubsubsection{sha1\_prf()}
{\footnotesize\ttfamily int sha1\+\_\+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})}



sha1\+\_\+prf -\/ SHA1-\/based Pseudo-\/\+Random Function (PRF) (IEEE 802.\+11i, 8.\+5.\+1.\+1) @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 Returns\+: 0 on success, -\/1 of failure 

This function is used to derive new, cryptographically separate keys from a given key (e.\+g., PMK in IEEE 802.\+11i). 

References \textbf{ data}, \textbf{ hmac\+\_\+sha1\+\_\+vector()}, \textbf{ len}, \textbf{ os\+\_\+memcpy}, \textbf{ os\+\_\+strlen}, and \textbf{ SHA1\+\_\+\+MAC\+\_\+\+LEN}.

