1 //**********************************************************************;
2 // Copyright (c) 2017, SUSE GmbH
3 // All rights reserved.
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 // THE POSSIBILITY OF SUCH DAMAGE.
26 //**********************************************************************;
33 #include <tss2/tss2_sys.h>
35 typedef enum tpm2_convert_pubkey_fmt tpm2_convert_pubkey_fmt;
36 enum tpm2_convert_pubkey_fmt {
43 typedef enum tpm2_convert_sig_fmt tpm2_convert_sig_fmt;
44 enum tpm2_convert_sig_fmt {
46 signature_format_plain,
51 * Parses the given command line public key format option string and returns
52 * the corresponding pubkey_format enum value.
54 * LOG_ERR is used to communicate errors.
57 * On error pubkey_format_err is returned.
59 tpm2_convert_pubkey_fmt tpm2_convert_pubkey_fmt_from_optarg(const char *label);
62 * Converts the given public key structure into the requested target format
63 * and writes the result to the given file system path.
65 * LOG_ERR is used to communicate errors.
67 bool tpm2_convert_pubkey_save(TPM2B_PUBLIC *public, tpm2_convert_pubkey_fmt format, const char *path);
70 * Loads a public key in the TSS format from a file.
72 * The public key to load
77 bool tpm2_convert_pubkey_load(TPM2B_PUBLIC *public, const char *path);
80 * Parses the given command line signature format option string and returns
81 * the corresponding signature_format enum value.
83 * LOG_ERR is used to communicate errors.
86 * On error signature_format_err is returned.
88 tpm2_convert_sig_fmt tpm2_convert_sig_fmt_from_optarg(const char *label);
91 * Converts the given signature data into the requested target format and
92 * writes the result to the given file system path.
94 * LOG_ERR is used to communicate errors.
96 bool tpm2_convert_sig(TPMT_SIGNATURE *signature, tpm2_convert_sig_fmt format,
99 #endif /* CONVERSION_H */