1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 use crate::*;
6 use std::os::raw::{c_int, c_uchar, c_void};
7 
8 pub type SECKEYPublicKey = SECKEYPublicKeyStr;
9 #[repr(C)]
10 pub struct SECKEYPublicKeyStr {
11     pub arena: *mut PLArenaPool,
12     pub keyType: u32, /* KeyType */
13     pub pkcs11Slot: *mut PK11SlotInfo,
14     pub pkcs11ID: CK_OBJECT_HANDLE,
15     pub u: SECKEYPublicKeyStr_u,
16 }
17 
18 #[repr(C)]
19 pub union SECKEYPublicKeyStr_u {
20     pub rsa: SECKEYRSAPublicKey,
21     pub dsa: SECKEYDSAPublicKey,
22     pub dh: SECKEYDHPublicKey,
23     pub kea: SECKEYKEAPublicKey,
24     pub fortezza: SECKEYFortezzaPublicKey,
25     pub ec: SECKEYECPublicKey,
26 }
27 
28 pub type SECKEYPrivateKey = SECKEYPrivateKeyStr;
29 #[repr(C)]
30 pub struct SECKEYPrivateKeyStr {
31     pub arena: *mut PLArenaPool,
32     pub keyType: u32, /* KeyType */
33     pub pkcs11Slot: *mut PK11SlotInfo,
34     pub pkcs11ID: CK_OBJECT_HANDLE,
35     pub pkcs11IsTemp: PRBool,
36     pub wincx: *mut c_void,
37     pub staticflags: PRUint32,
38 }
39 
40 #[repr(u32)]
41 pub enum KeyType {
42     nullKey = 0,
43     rsaKey = 1,
44     dsaKey = 2,
45     fortezzaKey = 3,
46     dhKey = 4,
47     keaKey = 5,
48     ecKey = 6,
49     rsaPssKey = 7,
50     rsaOaepKey = 8,
51 }
52 
53 pub type SECKEYRSAPublicKey = SECKEYRSAPublicKeyStr;
54 #[repr(C)]
55 #[derive(Copy, Clone)]
56 pub struct SECKEYRSAPublicKeyStr {
57     pub arena: *mut PLArenaPool,
58     pub modulus: SECItem,
59     pub publicExponent: SECItem,
60 }
61 
62 pub type SECKEYDSAPublicKey = SECKEYDSAPublicKeyStr;
63 #[repr(C)]
64 #[derive(Copy, Clone)]
65 pub struct SECKEYDSAPublicKeyStr {
66     pub params: SECKEYPQGParams,
67     pub publicValue: SECItem,
68 }
69 
70 pub type SECKEYPQGParams = SECKEYPQGParamsStr;
71 #[repr(C)]
72 #[derive(Copy, Clone)]
73 pub struct SECKEYPQGParamsStr {
74     pub arena: *mut PLArenaPool,
75     pub prime: SECItem,
76     pub subPrime: SECItem,
77     pub base: SECItem,
78 }
79 
80 pub type SECKEYDHPublicKey = SECKEYDHPublicKeyStr;
81 #[repr(C)]
82 #[derive(Copy, Clone)]
83 pub struct SECKEYDHPublicKeyStr {
84     pub arena: *mut PLArenaPool,
85     pub prime: SECItem,
86     pub base: SECItem,
87     pub publicValue: SECItem,
88 }
89 
90 pub type SECKEYKEAPublicKey = SECKEYKEAPublicKeyStr;
91 #[repr(C)]
92 #[derive(Copy, Clone)]
93 pub struct SECKEYKEAPublicKeyStr {
94     pub params: SECKEYKEAParams,
95     pub publicValue: SECItem,
96 }
97 
98 pub type SECKEYKEAParams = SECKEYKEAParamsStr;
99 #[repr(C)]
100 #[derive(Copy, Clone)]
101 pub struct SECKEYKEAParamsStr {
102     pub arena: *mut PLArenaPool,
103     pub hash: SECItem,
104 }
105 
106 pub type SECKEYFortezzaPublicKey = SECKEYFortezzaPublicKeyStr;
107 #[repr(C)]
108 #[derive(Copy, Clone)]
109 pub struct SECKEYFortezzaPublicKeyStr {
110     pub KEAversion: c_int,
111     pub DSSversion: c_int,
112     pub KMID: [c_uchar; 8usize],
113     pub clearance: SECItem,
114     pub KEApriviledge: SECItem,
115     pub DSSpriviledge: SECItem,
116     pub KEAKey: SECItem,
117     pub DSSKey: SECItem,
118     pub params: SECKEYPQGParams,
119     pub keaParams: SECKEYPQGParams,
120 }
121 
122 pub type SECKEYECPublicKey = SECKEYECPublicKeyStr;
123 #[repr(C)]
124 #[derive(Copy, Clone)]
125 pub struct SECKEYECPublicKeyStr {
126     pub DEREncodedParams: SECKEYECParams,
127     pub size: c_int,
128     pub publicValue: SECItem,
129     pub encoding: u32, /* ECPointEncoding */
130 }
131 
132 pub type SECKEYECParams = SECItem;
133 
134 #[repr(u32)]
135 #[derive(Copy, Clone)]
136 pub enum ECPointEncoding {
137     ECPoint_Uncompressed = 0,
138     ECPoint_XOnly = 1,
139     ECPoint_Undefined = 2,
140 }
141