]>
Commit | Line | Data |
---|---|---|
b03ec3b5 SL |
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 "serializer_local.h" | |
14 | ||
15 | int ffc_params_prov_print(BIO *out, const FFC_PARAMS *ffc) | |
16 | { | |
17 | if (ffc->nid != NID_undef) { | |
a033c9a2 | 18 | #ifndef OPENSSL_NO_DH |
7165593c | 19 | const char *name = ffc_named_group_from_uid(ffc->nid); |
b03ec3b5 SL |
20 | |
21 | if (name == NULL) | |
22 | goto err; | |
d40b42ab | 23 | if (BIO_printf(out, "GROUP: %s\n", name) <= 0) |
b03ec3b5 SL |
24 | goto err; |
25 | return 1; | |
a033c9a2 MC |
26 | #else |
27 | /* How could this be? We should not have a nid in a no-dh build. */ | |
28 | goto err; | |
29 | #endif | |
b03ec3b5 SL |
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) { | |
d40b42ab | 49 | if (BIO_printf(out, "gindex: %d\n", ffc->gindex) <= 0) |
b03ec3b5 SL |
50 | goto err; |
51 | } | |
52 | if (ffc->pcounter != -1) { | |
d40b42ab | 53 | if (BIO_printf(out, "pcounter: %d\n", ffc->pcounter) <= 0) |
b03ec3b5 SL |
54 | goto err; |
55 | } | |
56 | if (ffc->h != 0) { | |
d40b42ab | 57 | if (BIO_printf(out, "h: %d\n", ffc->h) <= 0) |
b03ec3b5 SL |
58 | goto err; |
59 | } | |
60 | return 1; | |
61 | err: | |
62 | return 0; | |
63 | } |