github.com/kchristidis/fabric@v1.0.4-0.20171028114726-837acd08cde1/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  // AESCBCPKCS7ModeOpts contains options for AES encryption in CBC mode
   191  // with PKCS7 padding.
   192  type AESCBCPKCS7ModeOpts struct{}
   193  
   194  // HMACTruncated256AESDeriveKeyOpts contains options for HMAC truncated
   195  // at 256 bits key derivation.
   196  type HMACTruncated256AESDeriveKeyOpts struct {
   197  	Temporary bool
   198  	Arg       []byte
   199  }
   200  
   201  // Algorithm returns the key derivation algorithm identifier (to be used).
   202  func (opts *HMACTruncated256AESDeriveKeyOpts) Algorithm() string {
   203  	return HMACTruncated256
   204  }
   205  
   206  // Ephemeral returns true if the key to generate has to be ephemeral,
   207  // false otherwise.
   208  func (opts *HMACTruncated256AESDeriveKeyOpts) Ephemeral() bool {
   209  	return opts.Temporary
   210  }
   211  
   212  // Argument returns the argument to be passed to the HMAC
   213  func (opts *HMACTruncated256AESDeriveKeyOpts) Argument() []byte {
   214  	return opts.Arg
   215  }
   216  
   217  // HMACDeriveKeyOpts contains options for HMAC key derivation.
   218  type HMACDeriveKeyOpts struct {
   219  	Temporary bool
   220  	Arg       []byte
   221  }
   222  
   223  // Algorithm returns the key derivation algorithm identifier (to be used).
   224  func (opts *HMACDeriveKeyOpts) Algorithm() string {
   225  	return HMAC
   226  }
   227  
   228  // Ephemeral returns true if the key to generate has to be ephemeral,
   229  // false otherwise.
   230  func (opts *HMACDeriveKeyOpts) Ephemeral() bool {
   231  	return opts.Temporary
   232  }
   233  
   234  // Argument returns the argument to be passed to the HMAC
   235  func (opts *HMACDeriveKeyOpts) Argument() []byte {
   236  	return opts.Arg
   237  }
   238  
   239  // AES256ImportKeyOpts contains options for importing AES 256 keys.
   240  type AES256ImportKeyOpts struct {
   241  	Temporary bool
   242  }
   243  
   244  // Algorithm returns the key importation algorithm identifier (to be used).
   245  func (opts *AES256ImportKeyOpts) Algorithm() string {
   246  	return AES
   247  }
   248  
   249  // Ephemeral returns true if the key generated has to be ephemeral,
   250  // false otherwise.
   251  func (opts *AES256ImportKeyOpts) Ephemeral() bool {
   252  	return opts.Temporary
   253  }
   254  
   255  // HMACImportKeyOpts contains options for importing HMAC keys.
   256  type HMACImportKeyOpts struct {
   257  	Temporary bool
   258  }
   259  
   260  // Algorithm returns the key importation algorithm identifier (to be used).
   261  func (opts *HMACImportKeyOpts) Algorithm() string {
   262  	return HMAC
   263  }
   264  
   265  // Ephemeral returns true if the key generated has to be ephemeral,
   266  // false otherwise.
   267  func (opts *HMACImportKeyOpts) Ephemeral() bool {
   268  	return opts.Temporary
   269  }
   270  
   271  // SHAOpts contains options for computing SHA.
   272  type SHAOpts struct {
   273  }
   274  
   275  // Algorithm returns the hash algorithm identifier (to be used).
   276  func (opts *SHAOpts) Algorithm() string {
   277  	return SHA
   278  }
   279  
   280  // RSAKeyGenOpts contains options for RSA key generation.
   281  type RSAKeyGenOpts struct {
   282  	Temporary bool
   283  }
   284  
   285  // Algorithm returns the key generation algorithm identifier (to be used).
   286  func (opts *RSAKeyGenOpts) Algorithm() string {
   287  	return RSA
   288  }
   289  
   290  // Ephemeral returns true if the key to generate has to be ephemeral,
   291  // false otherwise.
   292  func (opts *RSAKeyGenOpts) Ephemeral() bool {
   293  	return opts.Temporary
   294  }
   295  
   296  // ECDSAGoPublicKeyImportOpts contains options for RSA key importation from rsa.PublicKey
   297  type RSAGoPublicKeyImportOpts struct {
   298  	Temporary bool
   299  }
   300  
   301  // Algorithm returns the key importation algorithm identifier (to be used).
   302  func (opts *RSAGoPublicKeyImportOpts) Algorithm() string {
   303  	return RSA
   304  }
   305  
   306  // Ephemeral returns true if the key to generate has to be ephemeral,
   307  // false otherwise.
   308  func (opts *RSAGoPublicKeyImportOpts) Ephemeral() bool {
   309  	return opts.Temporary
   310  }
   311  
   312  // X509PublicKeyImportOpts contains options for importing public keys from an x509 certificate
   313  type X509PublicKeyImportOpts struct {
   314  	Temporary bool
   315  }
   316  
   317  // Algorithm returns the key importation algorithm identifier (to be used).
   318  func (opts *X509PublicKeyImportOpts) Algorithm() string {
   319  	return X509Certificate
   320  }
   321  
   322  // Ephemeral returns true if the key to generate has to be ephemeral,
   323  // false otherwise.
   324  func (opts *X509PublicKeyImportOpts) Ephemeral() bool {
   325  	return opts.Temporary
   326  }