Debian Codegraph @

lib_pypy/_cffi_ssl/_cffi_src/openssl/dsa.py

raw symbols SCIP
1 # This file is dual licensed under the terms of the Apache License, Version
2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3 # for complete details.
4
5 from __future__ import absolute_import, division, print_function
6
7 INCLUDES = """
8 #include <openssl/dsa.h>
9 """
10
11 TYPES = """
12 typedef ... DSA;
13 """
14
15 FUNCTIONS = """
16 int DSA_generate_key(DSA *);
17 DSA *DSA_new(void);
18 void DSA_free(DSA *);
19 DSA *DSAparams_dup(DSA *);
20 int DSA_size(const DSA *);
21 int DSA_sign(int, const unsigned char *, int, unsigned char *, unsigned int *,
22 DSA *);
23 int DSA_verify(int, const unsigned char *, int, const unsigned char *, int,
24 DSA *);
25
26 /* added in 1.1.0 to access the opaque struct */
27 void DSA_get0_pqg(const DSA *, const BIGNUM **, const BIGNUM **,
28 const BIGNUM **);
29 int DSA_set0_pqg(DSA *, BIGNUM *, BIGNUM *, BIGNUM *);
30 void DSA_get0_key(const DSA *, const BIGNUM **, const BIGNUM **);
31 int DSA_set0_key(DSA *, BIGNUM *, BIGNUM *);
32 int DSA_generate_parameters_ex(DSA *, int, unsigned char *, int,
33 int *, unsigned long *, BN_GENCB *);
34 """
35
36 CUSTOMIZATIONS = """
37 /* These functions were added in OpenSSL 1.1.0 */
38 #if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 && !CRYPTOGRAPHY_LIBRESSL_27_OR_GREATER
39 void DSA_get0_pqg(const DSA *d,
40 const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
41 {
42 if (p != NULL)
43 *p = d->p;
44 if (q != NULL)
45 *q = d->q;
46 if (g != NULL)
47 *g = d->g;
48 }
49 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
50 {
51 /* If the fields p, q and g in d are NULL, the corresponding input
52 * parameters MUST be non-NULL.
53 */
54 if ((d->p == NULL && p == NULL)
55 || (d->q == NULL && q == NULL)
56 || (d->g == NULL && g == NULL))
57 return 0;
58
59 if (p != NULL) {
60 BN_free(d->p);
61 d->p = p;
62 }
63 if (q != NULL) {
64 BN_free(d->q);
65 d->q = q;
66 }
67 if (g != NULL) {
68 BN_free(d->g);
69 d->g = g;
70 }
71
72 return 1;
73 }
74 void DSA_get0_key(const DSA *d,
75 const BIGNUM **pub_key, const BIGNUM **priv_key)
76 {
77 if (pub_key != NULL)
78 *pub_key = d->pub_key;
79 if (priv_key != NULL)
80 *priv_key = d->priv_key;
81 }
82 int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
83 {
84 /* If the field pub_key in d is NULL, the corresponding input
85 * parameters MUST be non-NULL. The priv_key field may
86 * be left NULL.
87 */
88 if (d->pub_key == NULL && pub_key == NULL)
89 return 0;
90
91 if (pub_key != NULL) {
92 BN_free(d->pub_key);
93 d->pub_key = pub_key;
94 }
95 if (priv_key != NULL) {
96 BN_free(d->priv_key);
97 d->priv_key = priv_key;
98 }
99
100 return 1;
101 }
102 #endif
103 """