Debian Codegraph @

src/bin/keyconv/softhsm2-keyconv.h

raw
1 /*
2 * Copyright (c) 2010 .SE (The Internet Infrastructure Foundation)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef _SOFTHSM_V2_SOFTHSM2_KEYCONV_H
28 #define _SOFTHSM_V2_SOFTHSM2_KEYCONV_H 1
29
30 #include <stdlib.h>
31
32 typedef struct key_material_t {
33 unsigned long size;
34 void* big;
35 key_material_t() {
36 size = 0;
37 big = NULL;
38 }
39 } key_material_t;
40
41 // Main functions
42
43 void usage();
44 int to_pkcs8(char* in_path, char* out_path, char* file_pin);
45
46 // Support functions
47
48 int save_rsa_pkcs8(char* out_path, char* file_pin, key_material_t* pkey);
49 int save_dsa_pkcs8(char* out_path, char* file_pin, key_material_t* pkey);
50 void free_key_material(key_material_t* pkey);
51 void crypto_init();
52 void crypto_final();
53
54 // base64.c prototypes
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 int b64_pton(const char* , unsigned char*, size_t);
60 int b64_ntop(const unsigned char*, size_t, char*, size_t);
61 #ifdef __cplusplus
62 }
63 #endif
64
65 // The BIND file version number.
66 #define FILE_MAJOR_VERSION 1
67 #define FILE_MINOR_VERSION 3
68
69 // Key algorithm number
70 #define DNS_KEYALG_ERROR -1
71 #define DNS_KEYALG_RSAMD5 1
72 #define DNS_KEYALG_DSA 3
73 #define DNS_KEYALG_ECC 4
74 #define DNS_KEYALG_RSASHA1 5
75 #define DNS_KEYALG_DSA_NSEC3_SHA1 6
76 #define DNS_KEYALG_RSASHA1_NSEC3_SHA1 7
77 #define DNS_KEYALG_RSASHA256 8
78 #define DNS_KEYALG_RSASHA512 10
79 #define DNS_KEYALG_ECC_GOST 12
80
81 // Maximum number of lines / line length
82 #define MAX_LINE 4096
83
84 // The text fields supported
85 #if !defined(KEYCONV_BOTAN) && !defined(KEYCONV_OSSL)
86 static const char* file_tags[] = {
87 "Private-key-format:",
88 "Algorithm:",
89 "Modulus:",
90 "PublicExponent:",
91 "PrivateExponent:",
92 "Prime1:",
93 "Prime2:",
94 "Exponent1:",
95 "Exponent2:",
96 "Coefficient:",
97 "Prime(p):",
98 "Private_value(x):",
99 "Public_value(y):",
100 "Subprime(q):",
101 "Base(g):",
102 "Created:",
103 "Publish:",
104 "Activate:",
105 NULL
106 };
107 #endif
108
109 // The number of each text field.
110 // Must match the tags above.
111 enum FILE_TAGS {
112 TAG_VERSION = 0,
113 TAG_ALGORITHM,
114 TAG_MODULUS,
115 TAG_PUBEXP,
116 TAG_PRIVEXP,
117 TAG_PRIME1,
118 TAG_PRIME2,
119 TAG_EXP1,
120 TAG_EXP2,
121 TAG_COEFF,
122 TAG_PRIME,
123 TAG_PRIVVAL,
124 TAG_PUBVAL,
125 TAG_SUBPRIME,
126 TAG_BASE,
127 TAG_CREATED,
128 TAG_PUBLISH,
129 TAG_ACTIVATE,
130 // So we know how long this list is
131 TAG_MAX
132 };
133
134 #endif /* _SOFTHSM_V2_SOFTHSM2_KEYCONV_H */