1.\" $OpenBSD: DSA_get0_pqg.3,v 1.11 2024/07/21 08:36:43 tb Exp $ 2.\" full merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400 3.\" 4.\" This file was written by Matt Caswell <matt@openssl.org>. 5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in 16.\" the documentation and/or other materials provided with the 17.\" distribution. 18.\" 19.\" 3. All advertising materials mentioning features or use of this 20.\" software must display the following acknowledgment: 21.\" "This product includes software developed by the OpenSSL Project 22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 23.\" 24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 25.\" endorse or promote products derived from this software without 26.\" prior written permission. For written permission, please contact 27.\" openssl-core@openssl.org. 28.\" 29.\" 5. Products derived from this software may not be called "OpenSSL" 30.\" nor may "OpenSSL" appear in their names without prior written 31.\" permission of the OpenSSL Project. 32.\" 33.\" 6. Redistributions of any form whatsoever must retain the following 34.\" acknowledgment: 35.\" "This product includes software developed by the OpenSSL Project 36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 37.\" 38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" 51.Dd $Mdocdate: July 21 2024 $ 52.Dt DSA_GET0_PQG 3 53.Os 54.Sh NAME 55.Nm DSA_get0_pqg , 56.Nm DSA_get0_p , 57.Nm DSA_get0_q , 58.Nm DSA_get0_g , 59.Nm DSA_set0_pqg , 60.Nm DSA_get0_key , 61.Nm DSA_get0_pub_key , 62.Nm DSA_get0_priv_key , 63.Nm DSA_set0_key , 64.Nm DSA_clear_flags , 65.Nm DSA_test_flags , 66.Nm DSA_set_flags , 67.Nm DSA_get0_engine 68.Nd get data from and set data in a DSA object 69.Sh SYNOPSIS 70.In openssl/dsa.h 71.Ft void 72.Fo DSA_get0_pqg 73.Fa "const DSA *d" 74.Fa "const BIGNUM **p" 75.Fa "const BIGNUM **q" 76.Fa "const BIGNUM **g" 77.Fc 78.Ft "const BIGNUM *" 79.Fo DSA_get0_p 80.Fa "const DSA *d" 81.Fc 82.Ft "const BIGNUM *" 83.Fo DSA_get0_q 84.Fa "const DSA *d" 85.Fc 86.Ft "const BIGNUM *" 87.Fo DSA_get0_g 88.Fa "const DSA *d" 89.Fc 90.Ft int 91.Fo DSA_set0_pqg 92.Fa "DSA *d" 93.Fa "BIGNUM *p" 94.Fa "BIGNUM *q" 95.Fa "BIGNUM *g" 96.Fc 97.Ft void 98.Fo DSA_get0_key 99.Fa "const DSA *d" 100.Fa "const BIGNUM **pub_key" 101.Fa "const BIGNUM **priv_key" 102.Fc 103.Ft "const BIGNUM *" 104.Fo DSA_get0_pub_key 105.Fa "const DSA *d" 106.Fc 107.Ft "const BIGNUM *" 108.Fo DSA_get0_priv_key 109.Fa "const DSA *d" 110.Fc 111.Ft int 112.Fo DSA_set0_key 113.Fa "DSA *d" 114.Fa "BIGNUM *pub_key" 115.Fa "BIGNUM *priv_key" 116.Fc 117.Ft void 118.Fo DSA_clear_flags 119.Fa "DSA *d" 120.Fa "int flags" 121.Fc 122.Ft int 123.Fo DSA_test_flags 124.Fa "const DSA *d" 125.Fa "int flags" 126.Fc 127.Ft void 128.Fo DSA_set_flags 129.Fa "DSA *d" 130.Fa "int flags" 131.Fc 132.Ft ENGINE * 133.Fo DSA_get0_engine 134.Fa "DSA *d" 135.Fc 136.Sh DESCRIPTION 137A 138.Vt DSA 139object contains the parameters 140.Fa p , 141.Fa q , 142and 143.Fa g . 144It also contains a public key 145.Fa pub_key 146and an optional private key 147.Fa priv_key . 148.Pp 149The 150.Fa p , 151.Fa q , 152and 153.Fa g 154parameters can be obtained by calling 155.Fn DSA_get0_pqg . 156If the parameters have not yet been set, then 157.Pf * Fa p , 158.Pf * Fa q , 159and 160.Pf * Fa g 161are set to 162.Dv NULL . 163Otherwise, they are set to pointers to the internal representations 164of the values that should not be freed by the application. 165.Pp 166The 167.Fa p , 168.Fa q , 169and 170.Fa g 171values can be set by calling 172.Fn DSA_set0_pqg . 173Calling this function transfers the memory management of the values to 174.Fa d , 175and therefore they should not be freed by the caller. 176.Pp 177The 178.Fn DSA_get0_key 179function stores pointers to the internal representations 180of the public key in 181.Pf * Fa pub_key 182and to the private key in 183.Pf * Fa priv_key . 184Either may be 185.Dv NULL 186if it has not yet been set. 187If the private key has been set, then the public key must be. 188.Pp 189The public and private key values can be set using 190.Fn DSA_set0_key . 191The public key must be 192.Pf non- Dv NULL 193the first time this function is called on a given 194.Vt DSA 195object. 196The private key may be 197.Dv NULL . 198On subsequent calls, either may be 199.Dv NULL , 200which means the corresponding 201.Vt DSA 202field is left untouched. 203.Fn DSA_set0_key 204transfers the memory management of the key values to 205.Fa d , 206and therefore they should not be freed by the caller. 207.Pp 208Values retrieved with 209.Fn DSA_get0_pqg 210and 211.Fn DSA_get0_key 212are owned by the 213.Vt DSA 214object and may therefore not be passed to 215.Fn DSA_set0_pqg 216or 217.Fn DSA_set0_key . 218If needed, duplicate the received values using 219.Xr BN_dup 3 220and pass the duplicates. 221.Pp 222Any of the values 223.Fa p , 224.Fa q , 225.Fa g , 226.Fa pub_key , 227and 228.Fa priv_key 229can also be retrieved separately by the corresponding functions 230.Fn DSA_get0_p , 231.Fn DSA_get0_q , 232.Fn DSA_get0_g , 233.Fn DSA_get0_pub_key , 234and 235.Fn DSA_get0_priv_key , 236respectively. 237The pointers are owned by the 238.Vt DSA 239object. 240.Pp 241.Fn DSA_clear_flags 242clears the specified 243.Fa flags 244in 245.Fa d . 246.Fn DSA_test_flags 247tests the 248.Fa flags 249in 250.Fa d . 251.Fn DSA_set_flags 252sets the 253.Fa flags 254in 255.Fa d ; 256any flags already set remain set. 257For all three functions, multiple flags can be passed in one call, 258OR'ed together bitwise. 259.Sh RETURN VALUES 260.Fn DSA_get0_p , 261.Fn DSA_get0_q , 262.Fn DSA_get0_g , 263.Fn DSA_get0_pub_key , 264and 265.Fn DSA_get0_priv_key 266return a pointer owned by the 267.Vt DSA 268object if the corresponding value has been set, 269otherwise they return 270.Dv NULL . 271.Fn DSA_set0_pqg 272and 273.Fn DSA_set0_key 274return 1 on success or 0 on failure. 275.Pp 276.Fn DSA_test_flags 277returns those of the given 278.Fa flags 279currently set in 280.Fa d 281or 0 if none of the given 282.Fa flags 283are set. 284.Pp 285.Fn DSA_get0_engine 286always returns 287.Dv NULL . 288.Sh SEE ALSO 289.Xr DSA_do_sign 3 , 290.Xr DSA_dup_DH 3 , 291.Xr DSA_generate_key 3 , 292.Xr DSA_generate_parameters_ex 3 , 293.Xr DSA_new 3 , 294.Xr DSA_print 3 , 295.Xr DSA_security_bits 3 , 296.Xr DSA_sign 3 , 297.Xr DSA_size 3 298.Sh HISTORY 299.Fn DSA_get0_pqg , 300.Fn DSA_set0_pqg , 301.Fn DSA_get0_key , 302.Fn DSA_set0_key , 303.Fn DSA_clear_flags , 304.Fn DSA_test_flags , 305.Fn DSA_set_flags , 306and 307.Fn DSA_get0_engine 308first appeared in OpenSSL 1.1.0 309and have been available since 310.Ox 6.3 . 311.Pp 312.Fn DSA_get0_p , 313.Fn DSA_get0_q , 314.Fn DSA_get0_g , 315.Fn DSA_get0_pub_key , 316and 317.Fn DSA_get0_priv_key 318first appeared in OpenSSL 1.1.1 319and have been available since 320.Ox 7.1 . 321