github.com/lzy4123/fabric@v2.1.1+incompatible/bccsp/opts.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package bccsp 8 9 const ( 10 // ECDSA Elliptic Curve Digital Signature Algorithm (key gen, import, sign, verify), 11 // at default security level. 12 // Each BCCSP may or may not support default security level. If not supported than 13 // an error will be returned. 14 ECDSA = "ECDSA" 15 16 // ECDSA Elliptic Curve Digital Signature Algorithm over P-256 curve 17 ECDSAP256 = "ECDSAP256" 18 19 // ECDSA Elliptic Curve Digital Signature Algorithm over P-384 curve 20 ECDSAP384 = "ECDSAP384" 21 22 // ECDSAReRand ECDSA key re-randomization 23 ECDSAReRand = "ECDSA_RERAND" 24 25 // AES Advanced Encryption Standard at the default security level. 26 // Each BCCSP may or may not support default security level. If not supported than 27 // an error will be returned. 28 AES = "AES" 29 // AES Advanced Encryption Standard at 128 bit security level 30 AES128 = "AES128" 31 // AES Advanced Encryption Standard at 192 bit security level 32 AES192 = "AES192" 33 // AES Advanced Encryption Standard at 256 bit security level 34 AES256 = "AES256" 35 36 // HMAC keyed-hash message authentication code 37 HMAC = "HMAC" 38 // HMACTruncated256 HMAC truncated at 256 bits. 39 HMACTruncated256 = "HMAC_TRUNCATED_256" 40 41 // SHA Secure Hash Algorithm using default family. 42 // Each BCCSP may or may not support default security level. If not supported than 43 // an error will be returned. 44 SHA = "SHA" 45 46 // SHA2 is an identifier for SHA2 hash family 47 SHA2 = "SHA2" 48 // SHA3 is an identifier for SHA3 hash family 49 SHA3 = "SHA3" 50 51 // SHA256 52 SHA256 = "SHA256" 53 // SHA384 54 SHA384 = "SHA384" 55 // SHA3_256 56 SHA3_256 = "SHA3_256" 57 // SHA3_384 58 SHA3_384 = "SHA3_384" 59 60 // X509Certificate Label for X509 certificate related operation 61 X509Certificate = "X509Certificate" 62 ) 63 64 // ECDSAKeyGenOpts contains options for ECDSA key generation. 65 type ECDSAKeyGenOpts struct { 66 Temporary bool 67 } 68 69 // Algorithm returns the key generation algorithm identifier (to be used). 70 func (opts *ECDSAKeyGenOpts) Algorithm() string { 71 return ECDSA 72 } 73 74 // Ephemeral returns true if the key to generate has to be ephemeral, 75 // false otherwise. 76 func (opts *ECDSAKeyGenOpts) Ephemeral() bool { 77 return opts.Temporary 78 } 79 80 // ECDSAPKIXPublicKeyImportOpts contains options for ECDSA public key importation in PKIX format 81 type ECDSAPKIXPublicKeyImportOpts struct { 82 Temporary bool 83 } 84 85 // Algorithm returns the key importation algorithm identifier (to be used). 86 func (opts *ECDSAPKIXPublicKeyImportOpts) Algorithm() string { 87 return ECDSA 88 } 89 90 // Ephemeral returns true if the key to generate has to be ephemeral, 91 // false otherwise. 92 func (opts *ECDSAPKIXPublicKeyImportOpts) Ephemeral() bool { 93 return opts.Temporary 94 } 95 96 // ECDSAPrivateKeyImportOpts contains options for ECDSA secret key importation in DER format 97 // or PKCS#8 format. 98 type ECDSAPrivateKeyImportOpts struct { 99 Temporary bool 100 } 101 102 // Algorithm returns the key importation algorithm identifier (to be used). 103 func (opts *ECDSAPrivateKeyImportOpts) Algorithm() string { 104 return ECDSA 105 } 106 107 // Ephemeral returns true if the key to generate has to be ephemeral, 108 // false otherwise. 109 func (opts *ECDSAPrivateKeyImportOpts) Ephemeral() bool { 110 return opts.Temporary 111 } 112 113 // ECDSAGoPublicKeyImportOpts contains options for ECDSA key importation from ecdsa.PublicKey 114 type ECDSAGoPublicKeyImportOpts struct { 115 Temporary bool 116 } 117 118 // Algorithm returns the key importation algorithm identifier (to be used). 119 func (opts *ECDSAGoPublicKeyImportOpts) Algorithm() string { 120 return ECDSA 121 } 122 123 // Ephemeral returns true if the key to generate has to be ephemeral, 124 // false otherwise. 125 func (opts *ECDSAGoPublicKeyImportOpts) Ephemeral() bool { 126 return opts.Temporary 127 } 128 129 // ECDSAReRandKeyOpts contains options for ECDSA key re-randomization. 130 type ECDSAReRandKeyOpts struct { 131 Temporary bool 132 Expansion []byte 133 } 134 135 // Algorithm returns the key derivation algorithm identifier (to be used). 136 func (opts *ECDSAReRandKeyOpts) Algorithm() string { 137 return ECDSAReRand 138 } 139 140 // Ephemeral returns true if the key to generate has to be ephemeral, 141 // false otherwise. 142 func (opts *ECDSAReRandKeyOpts) Ephemeral() bool { 143 return opts.Temporary 144 } 145 146 // ExpansionValue returns the re-randomization factor 147 func (opts *ECDSAReRandKeyOpts) ExpansionValue() []byte { 148 return opts.Expansion 149 } 150 151 // AESKeyGenOpts contains options for AES key generation at default security level 152 type AESKeyGenOpts struct { 153 Temporary bool 154 } 155 156 // Algorithm returns the key generation algorithm identifier (to be used). 157 func (opts *AESKeyGenOpts) Algorithm() string { 158 return AES 159 } 160 161 // Ephemeral returns true if the key to generate has to be ephemeral, 162 // false otherwise. 163 func (opts *AESKeyGenOpts) Ephemeral() bool { 164 return opts.Temporary 165 } 166 167 // HMACTruncated256AESDeriveKeyOpts contains options for HMAC truncated 168 // at 256 bits key derivation. 169 type HMACTruncated256AESDeriveKeyOpts struct { 170 Temporary bool 171 Arg []byte 172 } 173 174 // Algorithm returns the key derivation algorithm identifier (to be used). 175 func (opts *HMACTruncated256AESDeriveKeyOpts) Algorithm() string { 176 return HMACTruncated256 177 } 178 179 // Ephemeral returns true if the key to generate has to be ephemeral, 180 // false otherwise. 181 func (opts *HMACTruncated256AESDeriveKeyOpts) Ephemeral() bool { 182 return opts.Temporary 183 } 184 185 // Argument returns the argument to be passed to the HMAC 186 func (opts *HMACTruncated256AESDeriveKeyOpts) Argument() []byte { 187 return opts.Arg 188 } 189 190 // HMACDeriveKeyOpts contains options for HMAC key derivation. 191 type HMACDeriveKeyOpts struct { 192 Temporary bool 193 Arg []byte 194 } 195 196 // Algorithm returns the key derivation algorithm identifier (to be used). 197 func (opts *HMACDeriveKeyOpts) Algorithm() string { 198 return HMAC 199 } 200 201 // Ephemeral returns true if the key to generate has to be ephemeral, 202 // false otherwise. 203 func (opts *HMACDeriveKeyOpts) Ephemeral() bool { 204 return opts.Temporary 205 } 206 207 // Argument returns the argument to be passed to the HMAC 208 func (opts *HMACDeriveKeyOpts) Argument() []byte { 209 return opts.Arg 210 } 211 212 // AES256ImportKeyOpts contains options for importing AES 256 keys. 213 type AES256ImportKeyOpts struct { 214 Temporary bool 215 } 216 217 // Algorithm returns the key importation algorithm identifier (to be used). 218 func (opts *AES256ImportKeyOpts) Algorithm() string { 219 return AES 220 } 221 222 // Ephemeral returns true if the key generated has to be ephemeral, 223 // false otherwise. 224 func (opts *AES256ImportKeyOpts) Ephemeral() bool { 225 return opts.Temporary 226 } 227 228 // HMACImportKeyOpts contains options for importing HMAC keys. 229 type HMACImportKeyOpts struct { 230 Temporary bool 231 } 232 233 // Algorithm returns the key importation algorithm identifier (to be used). 234 func (opts *HMACImportKeyOpts) Algorithm() string { 235 return HMAC 236 } 237 238 // Ephemeral returns true if the key generated has to be ephemeral, 239 // false otherwise. 240 func (opts *HMACImportKeyOpts) Ephemeral() bool { 241 return opts.Temporary 242 } 243 244 // SHAOpts contains options for computing SHA. 245 type SHAOpts struct{} 246 247 // Algorithm returns the hash algorithm identifier (to be used). 248 func (opts *SHAOpts) Algorithm() string { 249 return SHA 250 } 251 252 // X509PublicKeyImportOpts contains options for importing public keys from an x509 certificate 253 type X509PublicKeyImportOpts struct { 254 Temporary bool 255 } 256 257 // Algorithm returns the key importation algorithm identifier (to be used). 258 func (opts *X509PublicKeyImportOpts) Algorithm() string { 259 return X509Certificate 260 } 261 262 // Ephemeral returns true if the key to generate has to be ephemeral, 263 // false otherwise. 264 func (opts *X509PublicKeyImportOpts) Ephemeral() bool { 265 return opts.Temporary 266 }