github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/hyperledger/fabric/bccsp/opts.go (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package bccsp 18 19 const ( 20 // ECDSA Elliptic Curve Digital Signature Algorithm (key gen, import, sign, verify), 21 // at default security level. 22 // Each BCCSP may or may not support default security level. If not supported than 23 // an error will be returned. 24 ECDSA = "ECDSA" 25 26 // ECDSA Elliptic Curve Digital Signature Algorithm over P-256 curve 27 ECDSAP256 = "ECDSAP256" 28 29 // ECDSA Elliptic Curve Digital Signature Algorithm over P-384 curve 30 ECDSAP384 = "ECDSAP384" 31 32 // ECDSAReRand ECDSA key re-randomization 33 ECDSAReRand = "ECDSA_RERAND" 34 35 // RSA at the default security level. 36 // Each BCCSP may or may not support default security level. If not supported than 37 // an error will be returned. 38 RSA = "RSA" 39 // RSA at 1024 bit security level. 40 RSA1024 = "RSA1024" 41 // RSA at 2048 bit security level. 42 RSA2048 = "RSA2048" 43 // RSA at 3072 bit security level. 44 RSA3072 = "RSA3072" 45 // RSA at 4096 bit security level. 46 RSA4096 = "RSA4096" 47 48 // AES Advanced Encryption Standard at the default security level. 49 // Each BCCSP may or may not support default security level. If not supported than 50 // an error will be returned. 51 AES = "AES" 52 // AES Advanced Encryption Standard at 128 bit security level 53 AES128 = "AES128" 54 // AES Advanced Encryption Standard at 192 bit security level 55 AES192 = "AES192" 56 // AES Advanced Encryption Standard at 256 bit security level 57 AES256 = "AES256" 58 59 // HMAC keyed-hash message authentication code 60 HMAC = "HMAC" 61 // HMACTruncated256 HMAC truncated at 256 bits. 62 HMACTruncated256 = "HMAC_TRUNCATED_256" 63 64 // SHA Secure Hash Algorithm using default family. 65 // Each BCCSP may or may not support default security level. If not supported than 66 // an error will be returned. 67 SHA = "SHA" 68 69 // SHA2 is an identifier for SHA2 hash family 70 SHA2 = "SHA2" 71 // SHA3 is an identifier for SHA3 hash family 72 SHA3 = "SHA3" 73 74 // SHA256 75 SHA256 = "SHA256" 76 // SHA384 77 SHA384 = "SHA384" 78 // SHA3_256 79 SHA3_256 = "SHA3_256" 80 // SHA3_384 81 SHA3_384 = "SHA3_384" 82 83 // X509Certificate Label for X509 certificate related operation 84 X509Certificate = "X509Certificate" 85 ) 86 87 // ECDSAKeyGenOpts contains options for ECDSA key generation. 88 type ECDSAKeyGenOpts struct { 89 Temporary bool 90 } 91 92 // Algorithm returns the key generation algorithm identifier (to be used). 93 func (opts *ECDSAKeyGenOpts) Algorithm() string { 94 return ECDSA 95 } 96 97 // Ephemeral returns true if the key to generate has to be ephemeral, 98 // false otherwise. 99 func (opts *ECDSAKeyGenOpts) Ephemeral() bool { 100 return opts.Temporary 101 } 102 103 // ECDSAPKIXPublicKeyImportOpts contains options for ECDSA public key importation in PKIX format 104 type ECDSAPKIXPublicKeyImportOpts struct { 105 Temporary bool 106 } 107 108 // Algorithm returns the key importation algorithm identifier (to be used). 109 func (opts *ECDSAPKIXPublicKeyImportOpts) Algorithm() string { 110 return ECDSA 111 } 112 113 // Ephemeral returns true if the key to generate has to be ephemeral, 114 // false otherwise. 115 func (opts *ECDSAPKIXPublicKeyImportOpts) Ephemeral() bool { 116 return opts.Temporary 117 } 118 119 // ECDSAPrivateKeyImportOpts contains options for ECDSA secret key importation in DER format 120 // or PKCS#8 format. 121 type ECDSAPrivateKeyImportOpts struct { 122 Temporary bool 123 } 124 125 // Algorithm returns the key importation algorithm identifier (to be used). 126 func (opts *ECDSAPrivateKeyImportOpts) Algorithm() string { 127 return ECDSA 128 } 129 130 // Ephemeral returns true if the key to generate has to be ephemeral, 131 // false otherwise. 132 func (opts *ECDSAPrivateKeyImportOpts) Ephemeral() bool { 133 return opts.Temporary 134 } 135 136 // ECDSAGoPublicKeyImportOpts contains options for ECDSA key importation from ecdsa.PublicKey 137 type ECDSAGoPublicKeyImportOpts struct { 138 Temporary bool 139 } 140 141 // Algorithm returns the key importation algorithm identifier (to be used). 142 func (opts *ECDSAGoPublicKeyImportOpts) Algorithm() string { 143 return ECDSA 144 } 145 146 // Ephemeral returns true if the key to generate has to be ephemeral, 147 // false otherwise. 148 func (opts *ECDSAGoPublicKeyImportOpts) Ephemeral() bool { 149 return opts.Temporary 150 } 151 152 // ECDSAReRandKeyOpts contains options for ECDSA key re-randomization. 153 type ECDSAReRandKeyOpts struct { 154 Temporary bool 155 Expansion []byte 156 } 157 158 // Algorithm returns the key derivation algorithm identifier (to be used). 159 func (opts *ECDSAReRandKeyOpts) Algorithm() string { 160 return ECDSAReRand 161 } 162 163 // Ephemeral returns true if the key to generate has to be ephemeral, 164 // false otherwise. 165 func (opts *ECDSAReRandKeyOpts) Ephemeral() bool { 166 return opts.Temporary 167 } 168 169 // ExpansionValue returns the re-randomization factor 170 func (opts *ECDSAReRandKeyOpts) ExpansionValue() []byte { 171 return opts.Expansion 172 } 173 174 // AESKeyGenOpts contains options for AES key generation at default security level 175 type AESKeyGenOpts struct { 176 Temporary bool 177 } 178 179 // Algorithm returns the key generation algorithm identifier (to be used). 180 func (opts *AESKeyGenOpts) Algorithm() string { 181 return AES 182 } 183 184 // Ephemeral returns true if the key to generate has to be ephemeral, 185 // false otherwise. 186 func (opts *AESKeyGenOpts) Ephemeral() bool { 187 return opts.Temporary 188 } 189 190 // HMACTruncated256AESDeriveKeyOpts contains options for HMAC truncated 191 // at 256 bits key derivation. 192 type HMACTruncated256AESDeriveKeyOpts struct { 193 Temporary bool 194 Arg []byte 195 } 196 197 // Algorithm returns the key derivation algorithm identifier (to be used). 198 func (opts *HMACTruncated256AESDeriveKeyOpts) Algorithm() string { 199 return HMACTruncated256 200 } 201 202 // Ephemeral returns true if the key to generate has to be ephemeral, 203 // false otherwise. 204 func (opts *HMACTruncated256AESDeriveKeyOpts) Ephemeral() bool { 205 return opts.Temporary 206 } 207 208 // Argument returns the argument to be passed to the HMAC 209 func (opts *HMACTruncated256AESDeriveKeyOpts) Argument() []byte { 210 return opts.Arg 211 } 212 213 // HMACDeriveKeyOpts contains options for HMAC key derivation. 214 type HMACDeriveKeyOpts struct { 215 Temporary bool 216 Arg []byte 217 } 218 219 // Algorithm returns the key derivation algorithm identifier (to be used). 220 func (opts *HMACDeriveKeyOpts) Algorithm() string { 221 return HMAC 222 } 223 224 // Ephemeral returns true if the key to generate has to be ephemeral, 225 // false otherwise. 226 func (opts *HMACDeriveKeyOpts) Ephemeral() bool { 227 return opts.Temporary 228 } 229 230 // Argument returns the argument to be passed to the HMAC 231 func (opts *HMACDeriveKeyOpts) Argument() []byte { 232 return opts.Arg 233 } 234 235 // AES256ImportKeyOpts contains options for importing AES 256 keys. 236 type AES256ImportKeyOpts struct { 237 Temporary bool 238 } 239 240 // Algorithm returns the key importation algorithm identifier (to be used). 241 func (opts *AES256ImportKeyOpts) Algorithm() string { 242 return AES 243 } 244 245 // Ephemeral returns true if the key generated has to be ephemeral, 246 // false otherwise. 247 func (opts *AES256ImportKeyOpts) Ephemeral() bool { 248 return opts.Temporary 249 } 250 251 // HMACImportKeyOpts contains options for importing HMAC keys. 252 type HMACImportKeyOpts struct { 253 Temporary bool 254 } 255 256 // Algorithm returns the key importation algorithm identifier (to be used). 257 func (opts *HMACImportKeyOpts) Algorithm() string { 258 return HMAC 259 } 260 261 // Ephemeral returns true if the key generated has to be ephemeral, 262 // false otherwise. 263 func (opts *HMACImportKeyOpts) Ephemeral() bool { 264 return opts.Temporary 265 } 266 267 // SHAOpts contains options for computing SHA. 268 type SHAOpts struct { 269 } 270 271 // Algorithm returns the hash algorithm identifier (to be used). 272 func (opts *SHAOpts) Algorithm() string { 273 return SHA 274 } 275 276 // RSAKeyGenOpts contains options for RSA key generation. 277 type RSAKeyGenOpts struct { 278 Temporary bool 279 } 280 281 // Algorithm returns the key generation algorithm identifier (to be used). 282 func (opts *RSAKeyGenOpts) Algorithm() string { 283 return RSA 284 } 285 286 // Ephemeral returns true if the key to generate has to be ephemeral, 287 // false otherwise. 288 func (opts *RSAKeyGenOpts) Ephemeral() bool { 289 return opts.Temporary 290 } 291 292 // ECDSAGoPublicKeyImportOpts contains options for RSA key importation from rsa.PublicKey 293 type RSAGoPublicKeyImportOpts struct { 294 Temporary bool 295 } 296 297 // Algorithm returns the key importation algorithm identifier (to be used). 298 func (opts *RSAGoPublicKeyImportOpts) Algorithm() string { 299 return RSA 300 } 301 302 // Ephemeral returns true if the key to generate has to be ephemeral, 303 // false otherwise. 304 func (opts *RSAGoPublicKeyImportOpts) Ephemeral() bool { 305 return opts.Temporary 306 } 307 308 // X509PublicKeyImportOpts contains options for importing public keys from an x509 certificate 309 type X509PublicKeyImportOpts struct { 310 Temporary bool 311 } 312 313 // Algorithm returns the key importation algorithm identifier (to be used). 314 func (opts *X509PublicKeyImportOpts) Algorithm() string { 315 return X509Certificate 316 } 317 318 // Ephemeral returns true if the key to generate has to be ephemeral, 319 // false otherwise. 320 func (opts *X509PublicKeyImportOpts) Ephemeral() bool { 321 return opts.Temporary 322 }