From ce68fa34ee4af79d5f0324302b17d57cfc6df828 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 9 Jul 2017 12:46:15 +0200 Subject: [PATCH] add rand_bn_X() doc --- doc/crypt.tex | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/crypt.tex b/doc/crypt.tex index ef594b14..12856ac0 100644 --- a/doc/crypt.tex +++ b/doc/crypt.tex @@ -5595,6 +5595,32 @@ to get a prime of the form $p \equiv 3\mbox{ }(\mbox{mod } 4)$. So if you want \textit{len = -128} to the function. Upon success it will return {\bf CRYPT\_OK} and \textit{N} will contain an integer which is very likely prime. +\mysection{Random MPI Generation} +\index{Random MPI Generation} + +Several Public Key Cryptography algorithms require random MPI's for operations like signature generation. +The library provides two API functions to generate random MPI's which allow the utilisation of a user-defined PRNG to aquire the random data. + +\index{rand\_bn\_bits()} +\begin{verbatim} +int rand_bn_bits( void *N, + int bits, + prng_state *prng, + int wprng); +\end{verbatim} + +This sets \textit{N} to a \textit{bits}-long random MPI. + +\index{rand\_bn\_upto()} +\begin{verbatim} +int rand_bn_upto( void *N, + void *limit, + prng_state *prng, + int wprng); +\end{verbatim} + +This ensures that \textit{N} is set to a random MPI in the range $1 \le N < limit$. + \mysection{Dynamic Language Support} \index{Dynamic Language Support} Various LibTomCrypt functions require that their callers define a struct