[#BN_generate_dsa_nonce]
= BN&lowbar;generate&lowbar;dsa&lowbar;nonce
:mrdocs:

Generate a DSA&sol;ECDSA per&hyphen;signature nonce in &lsqb;0, &rsqb;`range)&period;`

== Synopsis

Declared in `&lt;openssl&sol;bn&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
BN&lowbar;generate&lowbar;dsa&lowbar;nonce(
    xref:BIGNUM.adoc[BIGNUM]* out,
    xref:BIGNUM.adoc[BIGNUM] const* range,
    xref:BIGNUM.adoc[BIGNUM] const* priv,
    unsigned char const* message,
    size&lowbar;t message&lowbar;len,
    xref:BN_CTX.adoc[BN&lowbar;CTX]* ctx);
----

== Description

Mixes `priv` and `message` with fresh entropy so an RNG failure alone cannot expose the private key the way a raw BN&lowbar;rand&lowbar;range() nonce would&period;

== Return Value

1 on success, or 0 on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *out*
| Destination BIGNUM that receives the nonce k&period;
| *range*
| Exclusive upper bound (typically the group order)&period;
| *priv*
| Private key value mixed into the nonce derivation&period;
| *message*
| Message&sol;digest octets mixed into the nonce derivation&period;
| *message&lowbar;len*
| Length of `message` in bytes&period;
| *ctx*
| BN&lowbar;CTX for temporary BIGNUMs, or NULL&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
