github.com/true-sqn/fabric@v2.1.1+incompatible/bccsp/aesopts.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 import "io" 20 21 // AES128KeyGenOpts contains options for AES key generation at 128 security level 22 type AES128KeyGenOpts struct { 23 Temporary bool 24 } 25 26 // Algorithm returns the key generation algorithm identifier (to be used). 27 func (opts *AES128KeyGenOpts) Algorithm() string { 28 return AES128 29 } 30 31 // Ephemeral returns true if the key to generate has to be ephemeral, 32 // false otherwise. 33 func (opts *AES128KeyGenOpts) Ephemeral() bool { 34 return opts.Temporary 35 } 36 37 // AES192KeyGenOpts contains options for AES key generation at 192 security level 38 type AES192KeyGenOpts struct { 39 Temporary bool 40 } 41 42 // Algorithm returns the key generation algorithm identifier (to be used). 43 func (opts *AES192KeyGenOpts) Algorithm() string { 44 return AES192 45 } 46 47 // Ephemeral returns true if the key to generate has to be ephemeral, 48 // false otherwise. 49 func (opts *AES192KeyGenOpts) Ephemeral() bool { 50 return opts.Temporary 51 } 52 53 // AES256KeyGenOpts contains options for AES key generation at 256 security level 54 type AES256KeyGenOpts struct { 55 Temporary bool 56 } 57 58 // Algorithm returns the key generation algorithm identifier (to be used). 59 func (opts *AES256KeyGenOpts) Algorithm() string { 60 return AES256 61 } 62 63 // Ephemeral returns true if the key to generate has to be ephemeral, 64 // false otherwise. 65 func (opts *AES256KeyGenOpts) Ephemeral() bool { 66 return opts.Temporary 67 } 68 69 // AESCBCPKCS7ModeOpts contains options for AES encryption in CBC mode 70 // with PKCS7 padding. 71 // Notice that both IV and PRNG can be nil. In that case, the BCCSP implementation 72 // is supposed to sample the IV using a cryptographic secure PRNG. 73 // Notice also that either IV or PRNG can be different from nil. 74 type AESCBCPKCS7ModeOpts struct { 75 // IV is the initialization vector to be used by the underlying cipher. 76 // The length of IV must be the same as the Block's block size. 77 // It is used only if different from nil. 78 IV []byte 79 // PRNG is an instance of a PRNG to be used by the underlying cipher. 80 // It is used only if different from nil. 81 PRNG io.Reader 82 }