github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/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 // SHA256 70 SHA256 = "SHA256" 71 // SHA384 72 SHA384 = "SHA384" 73 // SHA3_256 74 SHA3_256 = "SHA3_256" 75 // SHA3_384 76 SHA3_384 = "SHA3_384" 77 78 // X509Certificate Label for X509 certificate related operation 79 X509Certificate = "X509Certificate" 80 ) 81 82 // ECDSAKeyGenOpts contains options for ECDSA key generation. 83 type ECDSAKeyGenOpts struct { 84 Temporary bool 85 } 86 87 // Algorithm returns the key generation algorithm identifier (to be used). 88 func (opts *ECDSAKeyGenOpts) Algorithm() string { 89 return ECDSA 90 } 91 92 // Ephemeral returns true if the key to generate has to be ephemeral, 93 // false otherwise. 94 func (opts *ECDSAKeyGenOpts) Ephemeral() bool { 95 return opts.Temporary 96 } 97 98 // ECDSAPKIXPublicKeyImportOpts contains options for ECDSA public key importation in PKIX format 99 type ECDSAPKIXPublicKeyImportOpts struct { 100 Temporary bool 101 } 102 103 // Algorithm returns the key importation algorithm identifier (to be used). 104 func (opts *ECDSAPKIXPublicKeyImportOpts) Algorithm() string { 105 return ECDSA 106 } 107 108 // Ephemeral returns true if the key to generate has to be ephemeral, 109 // false otherwise. 110 func (opts *ECDSAPKIXPublicKeyImportOpts) Ephemeral() bool { 111 return opts.Temporary 112 } 113 114 // ECDSAPrivateKeyImportOpts contains options for ECDSA secret key importation in DER format 115 // or PKCS#8 format. 116 type ECDSAPrivateKeyImportOpts struct { 117 Temporary bool 118 } 119 120 // Algorithm returns the key importation algorithm identifier (to be used). 121 func (opts *ECDSAPrivateKeyImportOpts) Algorithm() string { 122 return ECDSA 123 } 124 125 // Ephemeral returns true if the key to generate has to be ephemeral, 126 // false otherwise. 127 func (opts *ECDSAPrivateKeyImportOpts) Ephemeral() bool { 128 return opts.Temporary 129 } 130 131 // ECDSAGoPublicKeyImportOpts contains options for ECDSA key importation from ecdsa.PublicKey 132 type ECDSAGoPublicKeyImportOpts struct { 133 Temporary bool 134 } 135 136 // Algorithm returns the key importation algorithm identifier (to be used). 137 func (opts *ECDSAGoPublicKeyImportOpts) Algorithm() string { 138 return ECDSA 139 } 140 141 // Ephemeral returns true if the key to generate has to be ephemeral, 142 // false otherwise. 143 func (opts *ECDSAGoPublicKeyImportOpts) Ephemeral() bool { 144 return opts.Temporary 145 } 146 147 // ECDSAReRandKeyOpts contains options for ECDSA key re-randomization. 148 type ECDSAReRandKeyOpts struct { 149 Temporary bool 150 Expansion []byte 151 } 152 153 // Algorithm returns the key derivation algorithm identifier (to be used). 154 func (opts *ECDSAReRandKeyOpts) Algorithm() string { 155 return ECDSAReRand 156 } 157 158 // Ephemeral returns true if the key to generate has to be ephemeral, 159 // false otherwise. 160 func (opts *ECDSAReRandKeyOpts) Ephemeral() bool { 161 return opts.Temporary 162 } 163 164 // ExpansionValue returns the re-randomization factor 165 func (opts *ECDSAReRandKeyOpts) ExpansionValue() []byte { 166 return opts.Expansion 167 } 168 169 // AESKeyGenOpts contains options for AES key generation at default security level 170 type AESKeyGenOpts struct { 171 Temporary bool 172 } 173 174 // Algorithm returns the key generation algorithm identifier (to be used). 175 func (opts *AESKeyGenOpts) Algorithm() string { 176 return AES 177 } 178 179 // Ephemeral returns true if the key to generate has to be ephemeral, 180 // false otherwise. 181 func (opts *AESKeyGenOpts) Ephemeral() bool { 182 return opts.Temporary 183 } 184 185 // AESCBCPKCS7ModeOpts contains options for AES encryption in CBC mode 186 // with PKCS7 padding. 187 type AESCBCPKCS7ModeOpts struct{} 188 189 // HMACTruncated256AESDeriveKeyOpts contains options for HMAC truncated 190 // at 256 bits key derivation. 191 type HMACTruncated256AESDeriveKeyOpts struct { 192 Temporary bool 193 Arg []byte 194 } 195 196 // Algorithm returns the key derivation algorithm identifier (to be used). 197 func (opts *HMACTruncated256AESDeriveKeyOpts) Algorithm() string { 198 return HMACTruncated256 199 } 200 201 // Ephemeral returns true if the key to generate has to be ephemeral, 202 // false otherwise. 203 func (opts *HMACTruncated256AESDeriveKeyOpts) Ephemeral() bool { 204 return opts.Temporary 205 } 206 207 // Argument returns the argument to be passed to the HMAC 208 func (opts *HMACTruncated256AESDeriveKeyOpts) Argument() []byte { 209 return opts.Arg 210 } 211 212 // HMACDeriveKeyOpts contains options for HMAC key derivation. 213 type HMACDeriveKeyOpts struct { 214 Temporary bool 215 Arg []byte 216 } 217 218 // Algorithm returns the key derivation algorithm identifier (to be used). 219 func (opts *HMACDeriveKeyOpts) Algorithm() string { 220 return HMAC 221 } 222 223 // Ephemeral returns true if the key to generate has to be ephemeral, 224 // false otherwise. 225 func (opts *HMACDeriveKeyOpts) Ephemeral() bool { 226 return opts.Temporary 227 } 228 229 // Argument returns the argument to be passed to the HMAC 230 func (opts *HMACDeriveKeyOpts) Argument() []byte { 231 return opts.Arg 232 } 233 234 // AES256ImportKeyOpts contains options for importing AES 256 keys. 235 type AES256ImportKeyOpts struct { 236 Temporary bool 237 } 238 239 // Algorithm returns the key importation algorithm identifier (to be used). 240 func (opts *AES256ImportKeyOpts) Algorithm() string { 241 return AES 242 } 243 244 // Ephemeral returns true if the key generated has to be ephemeral, 245 // false otherwise. 246 func (opts *AES256ImportKeyOpts) Ephemeral() bool { 247 return opts.Temporary 248 } 249 250 // HMACImportKeyOpts contains options for importing HMAC keys. 251 type HMACImportKeyOpts struct { 252 Temporary bool 253 } 254 255 // Algorithm returns the key importation algorithm identifier (to be used). 256 func (opts *HMACImportKeyOpts) Algorithm() string { 257 return HMAC 258 } 259 260 // Ephemeral returns true if the key generated has to be ephemeral, 261 // false otherwise. 262 func (opts *HMACImportKeyOpts) Ephemeral() bool { 263 return opts.Temporary 264 } 265 266 // SHAOpts contains options for computing SHA. 267 type SHAOpts struct { 268 } 269 270 // Algorithm returns the hash algorithm identifier (to be used). 271 func (opts *SHAOpts) Algorithm() string { 272 return SHA 273 } 274 275 // RSAKeyGenOpts contains options for RSA key generation. 276 type RSAKeyGenOpts struct { 277 Temporary bool 278 } 279 280 // Algorithm returns the key generation algorithm identifier (to be used). 281 func (opts *RSAKeyGenOpts) Algorithm() string { 282 return RSA 283 } 284 285 // Ephemeral returns true if the key to generate has to be ephemeral, 286 // false otherwise. 287 func (opts *RSAKeyGenOpts) Ephemeral() bool { 288 return opts.Temporary 289 } 290 291 // ECDSAGoPublicKeyImportOpts contains options for RSA key importation from rsa.PublicKey 292 type RSAGoPublicKeyImportOpts struct { 293 Temporary bool 294 } 295 296 // Algorithm returns the key importation algorithm identifier (to be used). 297 func (opts *RSAGoPublicKeyImportOpts) Algorithm() string { 298 return RSA 299 } 300 301 // Ephemeral returns true if the key to generate has to be ephemeral, 302 // false otherwise. 303 func (opts *RSAGoPublicKeyImportOpts) Ephemeral() bool { 304 return opts.Temporary 305 } 306 307 // X509PublicKeyImportOpts contains options for importing public keys from an x509 certificate 308 type X509PublicKeyImportOpts struct { 309 Temporary bool 310 } 311 312 // Algorithm returns the key importation algorithm identifier (to be used). 313 func (opts *X509PublicKeyImportOpts) Algorithm() string { 314 return X509Certificate 315 } 316 317 // Ephemeral returns true if the key to generate has to be ephemeral, 318 // false otherwise. 319 func (opts *X509PublicKeyImportOpts) Ephemeral() bool { 320 return opts.Temporary 321 }