Skip to content

Commit f3f839e

Browse files
karel-msjaeckel
authored andcommitted
BLAKE2s + BLAKE2b MAC doc
1 parent 50e52d0 commit f3f839e

1 file changed

Lines changed: 94 additions & 20 deletions

File tree

doc/crypt.tex

Lines changed: 94 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,8 +3287,6 @@ \subsection{F9--MAC Functions}
32873287
The Poly1305--MAC is a cryptographic message authentication code created by Daniel J. Bernstein.
32883288
More info at \url{https://en.wikipedia.org/wiki/Poly1305}.
32893289

3290-
\subsection{Poly1305--MAC Functions}
3291-
32923290
A Poly1305--MAC state is initialized with the following function:
32933291
\index{poly1305\_init()}
32943292
\begin{verbatim}
@@ -3348,27 +3346,103 @@ \subsection{Poly1305--MAC Functions}
33483346

33493347
\mysection{BLAKE2s + BLAKE2b MAC}
33503348

3351-
XXX-TODO see \url{https://tools.ietf.org/html/rfc7693}
3349+
The BLAKE2s and BLAKE2b are cryptographic message authentication code designed by Jean--Philippe Aumasson,
3350+
Samuel Neves, Zooko Wilcox-O'Hearn, and Christian Winnerlein. More info at \url{https://tools.ietf.org/html/rfc7693}.
33523351

3353-
\begin{small}
3352+
A BLAKE2s/b--MAC state is initialized with the following function:
3353+
\index{blake2smac\_init()}
33543354
\begin{verbatim}
3355-
int blake2smac_init(blake2smac_state *st, unsigned long outlen, const unsigned char *key, unsigned long keylen);
3356-
int blake2smac_process(blake2smac_state *st, const unsigned char *in, unsigned long inlen);
3357-
int blake2smac_done(blake2smac_state *st, unsigned char *mac, unsigned long *maclen);
3358-
int blake2smac_test(void);
3359-
int blake2smac_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen);
3360-
int blake2smac_memory_multi(const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen, const unsigned char *in, unsigned long inlen, ...);
3361-
int blake2smac_file(const char *fname, const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen);
3362-
3363-
int blake2bmac_init(blake2bmac_state *st, unsigned long outlen, const unsigned char *key, unsigned long keylen);
3364-
int blake2bmac_process(blake2bmac_state *st, const unsigned char *in, unsigned long inlen);
3365-
int blake2bmac_done(blake2bmac_state *st, unsigned char *mac, unsigned long *maclen);
3366-
int blake2bmac_test(void);
3367-
int blake2bmac_memory(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *mac, unsigned long *maclen);
3368-
int blake2bmac_memory_multi(const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen, const unsigned char *in, unsigned long inlen, ...);
3369-
int blake2bmac_file(const char *fname, const unsigned char *key, unsigned long keylen, unsigned char *mac, unsigned long *maclen);
3355+
int blake2smac_init(blake2smac_state *st,
3356+
unsigned long outlen,
3357+
const unsigned char *key,
3358+
unsigned long keylen);
33703359
\end{verbatim}
3371-
\end{small}
3360+
\index{blake2bmac\_init()}
3361+
\begin{verbatim}
3362+
int blake2bmac_init(blake2smac_state *st,
3363+
unsigned long outlen,
3364+
const unsigned char *key,
3365+
unsigned long keylen);
3366+
\end{verbatim}
3367+
This will initialize the BLAKE2s/b--MAC state \textit{st}, with the key specified in \textit{key} of length \textit{keylen} octets (up to 64).
3368+
The \textit{outlen} specifies the size of the final tag (up to 64 octets).
3369+
3370+
To process data through BLAKE2s/b--MAC use the following function:
3371+
\index{blake2smac\_process()}
3372+
\begin{verbatim}
3373+
int blake2smac_process( blake2smac_state *st,
3374+
const unsigned char *in,
3375+
unsigned long inlen);
3376+
\end{verbatim}
3377+
\index{blake2bmac\_process()}
3378+
\begin{verbatim}
3379+
int blake2bmac_process( blake2bmac_state *st,
3380+
const unsigned char *in,
3381+
unsigned long inlen);
3382+
\end{verbatim}
3383+
3384+
This will add the message octets pointed to by \textit{in} of length \textit{inlen} to the BLAKE2s/b--MAC state pointed to by \textit{st}.
3385+
3386+
To compute the MAC tag value use the following function:
3387+
\index{blake2smac\_done()}
3388+
\begin{verbatim}
3389+
int blake2smac_done(blake2smac_state *st,
3390+
unsigned char *mac,
3391+
unsigned long *maclen);
3392+
\end{verbatim}
3393+
\index{blake2bmac\_done()}
3394+
\begin{verbatim}
3395+
int blake2bmac_done(blake2bmac_state *st,
3396+
unsigned char *mac,
3397+
unsigned long *maclen);
3398+
\end{verbatim}
3399+
3400+
This will retrieve the BLAKE2s/b--MAC tag from the state pointed to by \textit{st}, and store it in the array pointed to by \textit{mac}.
3401+
The \textit{maclen} parameter specifies the maximum size of the destination buffer, and is updated to hold the final size of the tag when
3402+
the function returns.
3403+
3404+
Helper functions are provided to make parsing memory buffers and files easier. The following functions are provided:
3405+
\index{blake2smac\_memory()}
3406+
\begin{verbatim}
3407+
int blake2smac_memory(const unsigned char *key,
3408+
unsigned long keylen,
3409+
const unsigned char *in,
3410+
unsigned long inlen,
3411+
unsigned char *mac,
3412+
unsigned long *maclen);
3413+
\end{verbatim}
3414+
\index{blake2bmac\_memory()}
3415+
\begin{verbatim}
3416+
int blake2bmac_memory(const unsigned char *key,
3417+
unsigned long keylen,
3418+
const unsigned char *in,
3419+
unsigned long inlen,
3420+
unsigned char *mac,
3421+
unsigned long *maclen);
3422+
\end{verbatim}
3423+
This will compute the BLAKE2s/b--MAC of \textit{inlen} bytes of \textit{in}, using the key \textit{key} of length \textit{keylen} bytes.
3424+
It will store the MAC in \textit{mac} with the same rules as blake2smac\_done().
3425+
3426+
To BLAKE2s/b--MAC a file use
3427+
\index{blake2smac\_file()}
3428+
\begin{verbatim}
3429+
int blake2smac_file( const char *fname,
3430+
const unsigned char *key,
3431+
unsigned long keylen,
3432+
unsigned char *mac,
3433+
unsigned long *maclen);
3434+
\end{verbatim}
3435+
\index{blake2bmac\_file()}
3436+
\begin{verbatim}
3437+
int blake2bmac_file( const char *fname,
3438+
const unsigned char *key,
3439+
unsigned long keylen,
3440+
unsigned char *mac,
3441+
unsigned long *maclen);
3442+
\end{verbatim}
3443+
3444+
Which will BLAKE2s/b--MAC the entire contents of the file specified by \textit{fname} using the key \textit{key} of
3445+
length \textit{keylen} bytes. It will store the MAC in \textit{mac} with the same rules as blake2smac\_done().
33723446

33733447
\chapter{Pseudo-Random Number Generators}
33743448
\mysection{Core Functions}

0 commit comments

Comments
 (0)