]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/internal/ffc.h
Fix no-tls1_3
[thirdparty/openssl.git] / include / internal / ffc.h
1 /*
2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 #ifndef OSSL_INTERNAL_FFC_H
11 # define OSSL_INTERNAL_FFC_H
12
13 # include <openssl/bn.h>
14
15 /*
16 * Finite field cryptography (FFC) domain parameters are used by DH and DSA.
17 * Refer to FIPS186_4 Appendix A & B.
18 */
19 typedef struct ffc_params_st {
20 /* Primes */
21 BIGNUM *p;
22 BIGNUM *q;
23 /* Generator */
24 BIGNUM *g;
25 /* DH X9.42 Optional Subgroup factor j >= 2 where p = j * q + 1 */
26 BIGNUM *j;
27
28 /* Required for FIPS186_4 validation of p, q and optionally canonical g */
29 unsigned char *seed;
30 /* If this value is zero the hash size is used as the seed length */
31 size_t seedlen;
32 /* Required for FIPS186_4 validation of p and q */
33 int pcounter;
34 int nid; /* The identity of a named group */
35
36 } FFC_PARAMS;
37
38 void ffc_params_init(FFC_PARAMS *params);
39 void ffc_params_cleanup(FFC_PARAMS *params);
40 void ffc_params_set0_pqg(FFC_PARAMS *params, BIGNUM *p, BIGNUM *q, BIGNUM *g);
41 void ffc_params_get0_pqg(const FFC_PARAMS *params, const BIGNUM **p,
42 const BIGNUM **q, const BIGNUM **g);
43 void ffc_params_set0_j(FFC_PARAMS *d, BIGNUM *j);
44 int ffc_params_set_validate_params(FFC_PARAMS *params,
45 const unsigned char *seed, size_t seedlen,
46 int counter);
47 void ffc_params_get_validate_params(const FFC_PARAMS *params,
48 unsigned char **seed, size_t *seedlen,
49 int *pcounter);
50
51 int ffc_params_copy(FFC_PARAMS *dst, const FFC_PARAMS *src);
52 int ffc_params_cmp(const FFC_PARAMS *a, const FFC_PARAMS *b, int ignore_q);
53
54 #ifndef FIPS_MODE
55 int ffc_params_print(BIO *bp, const FFC_PARAMS *ffc, int indent);
56 #endif /* FIPS_MODE */
57
58 #endif /* OSSL_INTERNAL_FFC_H */