1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use crate::*;
use std::os::raw::{c_int, c_uchar, c_void};

pub type SECKEYPublicKey = SECKEYPublicKeyStr;
#[repr(C)]
pub struct SECKEYPublicKeyStr {
    pub arena: *mut PLArenaPool,
    pub keyType: u32, /* KeyType */
    pub pkcs11Slot: *mut PK11SlotInfo,
    pub pkcs11ID: CK_OBJECT_HANDLE,
    pub u: SECKEYPublicKeyStr_u,
}

#[repr(C)]
pub union SECKEYPublicKeyStr_u {
    pub rsa: SECKEYRSAPublicKey,
    pub dsa: SECKEYDSAPublicKey,
    pub dh: SECKEYDHPublicKey,
    pub kea: SECKEYKEAPublicKey,
    pub fortezza: SECKEYFortezzaPublicKey,
    pub ec: SECKEYECPublicKey,
}

pub type SECKEYPrivateKey = SECKEYPrivateKeyStr;
#[repr(C)]
pub struct SECKEYPrivateKeyStr {
    pub arena: *mut PLArenaPool,
    pub keyType: u32, /* KeyType */
    pub pkcs11Slot: *mut PK11SlotInfo,
    pub pkcs11ID: CK_OBJECT_HANDLE,
    pub pkcs11IsTemp: PRBool,
    pub wincx: *mut c_void,
    pub staticflags: PRUint32,
}

#[repr(u32)]
pub enum KeyType {
    nullKey = 0,
    rsaKey = 1,
    dsaKey = 2,
    fortezzaKey = 3,
    dhKey = 4,
    keaKey = 5,
    ecKey = 6,
    rsaPssKey = 7,
    rsaOaepKey = 8,
}

pub type SECKEYRSAPublicKey = SECKEYRSAPublicKeyStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYRSAPublicKeyStr {
    pub arena: *mut PLArenaPool,
    pub modulus: SECItem,
    pub publicExponent: SECItem,
}

pub type SECKEYDSAPublicKey = SECKEYDSAPublicKeyStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYDSAPublicKeyStr {
    pub params: SECKEYPQGParams,
    pub publicValue: SECItem,
}

pub type SECKEYPQGParams = SECKEYPQGParamsStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYPQGParamsStr {
    pub arena: *mut PLArenaPool,
    pub prime: SECItem,
    pub subPrime: SECItem,
    pub base: SECItem,
}

pub type SECKEYDHPublicKey = SECKEYDHPublicKeyStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYDHPublicKeyStr {
    pub arena: *mut PLArenaPool,
    pub prime: SECItem,
    pub base: SECItem,
    pub publicValue: SECItem,
}

pub type SECKEYKEAPublicKey = SECKEYKEAPublicKeyStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYKEAPublicKeyStr {
    pub params: SECKEYKEAParams,
    pub publicValue: SECItem,
}

pub type SECKEYKEAParams = SECKEYKEAParamsStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYKEAParamsStr {
    pub arena: *mut PLArenaPool,
    pub hash: SECItem,
}

pub type SECKEYFortezzaPublicKey = SECKEYFortezzaPublicKeyStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYFortezzaPublicKeyStr {
    pub KEAversion: c_int,
    pub DSSversion: c_int,
    pub KMID: [c_uchar; 8usize],
    pub clearance: SECItem,
    pub KEApriviledge: SECItem,
    pub DSSpriviledge: SECItem,
    pub KEAKey: SECItem,
    pub DSSKey: SECItem,
    pub params: SECKEYPQGParams,
    pub keaParams: SECKEYPQGParams,
}

pub type SECKEYECPublicKey = SECKEYECPublicKeyStr;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SECKEYECPublicKeyStr {
    pub DEREncodedParams: SECKEYECParams,
    pub size: c_int,
    pub publicValue: SECItem,
    pub encoding: u32, /* ECPointEncoding */
}

pub type SECKEYECParams = SECItem;

#[repr(u32)]
#[derive(Copy, Clone)]
pub enum ECPointEncoding {
    ECPoint_Uncompressed = 0,
    ECPoint_XOnly = 1,
    ECPoint_Undefined = 2,
}