]> git.ipfire.org Git - thirdparty/openssl.git/blob - providers/implementations/encode_decode/encoder_ffc_params.c
Fix up issue on AIX caused by broken compiler handling of macro expansion
[thirdparty/openssl.git] / providers / implementations / encode_decode / encoder_ffc_params.c
1 /*
2 * Copyright 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 /* Utility function for printing DSA/DH params. */
11
12 #include "prov/bio.h"
13 #include "encoder_local.h"
14
15 int ffc_params_prov_print(BIO *out, const FFC_PARAMS *ffc)
16 {
17 if (ffc->nid != NID_undef) {
18 #ifndef OPENSSL_NO_DH
19 const char *name = ffc_named_group_from_uid(ffc->nid);
20
21 if (name == NULL)
22 goto err;
23 if (BIO_printf(out, "GROUP: %s\n", name) <= 0)
24 goto err;
25 return 1;
26 #else
27 /* How could this be? We should not have a nid in a no-dh build. */
28 goto err;
29 #endif
30 }
31
32 if (!ossl_prov_print_labeled_bignum(out, "P: ", ffc->p))
33 goto err;
34 if (ffc->q != NULL) {
35 if (!ossl_prov_print_labeled_bignum(out, "Q: ", ffc->q))
36 goto err;
37 }
38 if (!ossl_prov_print_labeled_bignum(out, "G: ", ffc->g))
39 goto err;
40 if (ffc->j != NULL) {
41 if (!ossl_prov_print_labeled_bignum(out, "J: ", ffc->j))
42 goto err;
43 }
44 if (ffc->seed != NULL) {
45 if (!ossl_prov_print_labeled_buf(out, "SEED:", ffc->seed, ffc->seedlen))
46 goto err;
47 }
48 if (ffc->gindex != -1) {
49 if (BIO_printf(out, "gindex: %d\n", ffc->gindex) <= 0)
50 goto err;
51 }
52 if (ffc->pcounter != -1) {
53 if (BIO_printf(out, "pcounter: %d\n", ffc->pcounter) <= 0)
54 goto err;
55 }
56 if (ffc->h != 0) {
57 if (BIO_printf(out, "h: %d\n", ffc->h) <= 0)
58 goto err;
59 }
60 return 1;
61 err:
62 return 0;
63 }