You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will import the DSA key from the buffer \textit{in} of length \textit{inlen} to the \textit{key}. If the process fails the function
5327
5327
will automatically free all of the heap allocated in the process (you don't have to call dsa\_free()).
5328
5328
5329
-
\subsection{Other DSA Functions}
5329
+
\mysection{Other DSA Functions}
5330
5330
5331
-
XXX-TODO
5331
+
The following functions allow to create a DSA key in 2 steps:
5332
5332
5333
-
\begin{small}
5333
+
\begin{enumerate}
5334
+
\item Load or generate \textit{p}, \textit{q}, \textit{g} part of the key via \textit{dsa\_set\_pqg()}, \textit{dsa\_set\_pqg\_dsaparam()} or \textit{dsa\_generate\_pqg()}.
5335
+
\item Load or generate the actual DSA key -- private (\textit{x} and \textit{y} values) or public (\textit{y} value).
5336
+
\end{enumerate}
5337
+
5338
+
\index{dsa\_set\_pqg()}
5334
5339
\begin{verbatim}
5335
5340
int dsa_set_pqg(const unsigned char *p, unsigned long plen,
5336
5341
const unsigned char *q, unsigned long qlen,
5337
5342
const unsigned char *g, unsigned long glen,
5338
5343
dsa_key *key);
5339
-
int dsa_set_pqg_dsaparam(const unsigned char *dsaparam, unsigned long dsaparamlen, dsa_key *key);
5340
-
int dsa_generate_pqg(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key);
5341
-
int dsa_set_key(const unsigned char *in, unsigned long inlen, int type, dsa_key *key);
5342
-
int dsa_generate_key(prng_state *prng, int wprng, dsa_key *key);
5343
5344
\end{verbatim}
5344
-
\end{small}
5345
+
5346
+
This will initialise the \textit{p}, \textit{q} and \textit{g} part of \textit{key} structure by directly loading binary
5347
+
representation of \textit{p} (with length of \textit{plen}), \textit{q} (with length of \textit{qlen}) and \textit{g} (with length of \textit{glen}).
5348
+
A simple DSA key validity check (without primality testing) is performed at the end of this function.
5349
+
5350
+
\index{dsa\_set\_pqg\_dsaparam()}
5351
+
\begin{verbatim}
5352
+
int dsa_set_pqg_dsaparam(const unsigned char *dsaparam,
5353
+
unsigned long dsaparamlen,
5354
+
dsa_key *key);
5355
+
\end{verbatim}
5356
+
5357
+
This will initialise the \textit{p}, \textit{q} and \textit{g} part of \textit{key} structure by directly loading binary representation
5358
+
of DSA parameters stored as a binary data in a buffer \textit{dsaparam} (with length of \textit{dsaparamlen}). A simple DSA key validity
5359
+
check (without primality testing) is performed at the end of this function. The \textit{dsaparam} can be generated via:
5360
+
\begin{verbatim}
5361
+
openssl dsaparam 2048 -outform DER -out dsaparam.der
5362
+
\end{verbatim}
5363
+
5364
+
\index{dsa\_generate\_pqg()}
5365
+
\begin{verbatim}
5366
+
int dsa_generate_pqg(prng_state *prng,
5367
+
int wprng,
5368
+
int group_size,
5369
+
int modulus_size,
5370
+
dsa_key *key);
5371
+
\end{verbatim}
5372
+
5373
+
This will initialise the \textit{p}, \textit{q} and \textit{g} part of \textit{key} structure with newly generated random values.
5374
+
As for the parameters they are the same as by \textit{dsa\_make\_key}.
5375
+
5376
+
\index{dsa\_set\_key()}
5377
+
\begin{verbatim}
5378
+
int dsa_set_key(const unsigned char *in,
5379
+
unsigned long inlen,
5380
+
int type,
5381
+
dsa_key *key);
5382
+
\end{verbatim}
5383
+
5384
+
This function can be used for setting the actual DSA key. If \textit{type} is \textit{PK\_PRIVATE} then the buffer \textit{in}
5385
+
(with length of \textit{inlen}) contains a binary representation of \textit{x} part of the key (the public part \textit{y} is computed).
5386
+
If \textit{type} is \textit{PK\_PUBLIC} then the buffer \textit{in} contains a binary representation of \textit{y} part of the key.
5387
+
5388
+
\index{dsa\_generate\_key()}
5389
+
\begin{verbatim}
5390
+
int dsa_generate_key(prng_state *prng,
5391
+
int wprng,
5392
+
dsa_key *key);
5393
+
\end{verbatim}
5394
+
5395
+
This function generates a private DSA key containing both \textit{x} and \textit{y} parts.
0 commit comments