{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sw\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n\nCopyright IBM Corp. 2016 All Rights Reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n## Functions\n\n```go\nfunc AESCBCPKCS7Decrypt(key, src []byte) ([]byte, error)\n```\nAESCBCPKCS7Decrypt combines CBC decryption and PKCS7 unpadding\n\n```go\nfunc AESCBCPKCS7Encrypt(key, src []byte) ([]byte, error)\n```\nAESCBCPKCS7Encrypt combines CBC encryption and PKCS7 padding\n\n```go\nfunc AESCBCPKCS7EncryptWithIV(IV []byte, key, src []byte) ([]byte, error)\n```\nAESCBCPKCS7Encrypt combines CBC encryption and PKCS7 padding, the IV used is the one passed to the function\n\n```go\nfunc AESCBCPKCS7EncryptWithRand(prng io.Reader, key, src []byte) ([]byte, error)\n```\nAESCBCPKCS7Encrypt combines CBC encryption and PKCS7 padding using as prng the passed to the function\n\n```go\nfunc GetRandomBytes(len int) ([]byte, error)\n```\nGetRandomBytes returns len random looking bytes\n\n```go\nfunc NewDefaultSecurityLevel(keyStorePath string) (bccsp.BCCSP, error)\n```\nNewDefaultSecurityLevel returns a new instance of the software-based BCCSP at security level 256, hash family SHA2 and using FolderBasedKeyStore as KeyStore.\n\n```go\nfunc NewDefaultSecurityLevelWithKeystore(keyStore bccsp.KeyStore) (bccsp.BCCSP, error)\n```\nNewDefaultSecurityLevel returns a new instance of the software-based BCCSP at security level 256, hash family SHA2 and using the passed KeyStore.\n\n```go\nfunc NewDummyKeyStore() bccsp.KeyStore\n```\nNewDummyKeyStore instantiate a dummy key store that neither loads nor stores keys\n\n```go\nfunc NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (bccsp.KeyStore, error)\n```\nNewFileBasedKeyStore instantiated a file-based key store at a given position. The key store can be encrypted if a non-empty password is specified. It can be also be set as read only. In this case, any store operation will be forbidden\n\n```go\nfunc NewInMemoryKeyStore() bccsp.KeyStore\n```\nNewInMemoryKeyStore instantiates an ephemeral in-memory keystore\n\n```go\nfunc NewWithParams(securityLevel int, hashFamily string, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)\n```\nNewWithParams returns a new instance of the software-based BCCSP set at the passed security level, hash family and KeyStore.\n\n## Types\n\n```go\ntype CSP struct {\n\tKeyGenerators map[reflect.Type]KeyGenerator\n\tKeyDerivers   map[reflect.Type]KeyDeriver\n\tKeyImporters  map[reflect.Type]KeyImporter\n\tEncryptors    map[reflect.Type]Encryptor\n\tDecryptors    map[reflect.Type]Decryptor\n\tSigners       map[reflect.Type]Signer\n\tVerifiers     map[reflect.Type]Verifier\n\tHashers       map[reflect.Type]Hasher\n\t// contains filtered or unexported fields\n}\n```\nCSP provides a generic implementation of the BCCSP interface based on wrappers. It can be customized by providing implementations for the following algorithm-based wrappers: KeyGenerator, KeyDeriver, KeyImporter, Encryptor, Decryptor, Signer, Verifier, Hasher. Each wrapper is bound to a goland type representing either an option or a key.\n\n```go\nfunc New(keyStore bccsp.KeyStore) (*CSP, error)\n```\n\n```go\nfunc (csp *CSP) AddWrapper(t reflect.Type, w interface{}) error\n```\nAddWrapper binds the passed type to the passed wrapper. Notice that that wrapper must be an instance of one of the following interfaces: KeyGenerator, KeyDeriver, KeyImporter, Encryptor, Decryptor, Signer, Verifier, Hasher.\n\n```go\nfunc (csp *CSP) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)\n```\nDecrypt decrypts ciphertext using key k. The opts argument should be appropriate for the primitive used.\n\n```go\nfunc (csp *CSP) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) ([]byte, error)\n```\nEncrypt encrypts plaintext using key k. The opts argument should be appropriate for the primitive used.\n\n```go\nfunc (csp *CSP) GetHash(opts bccsp.HashOpts) (h hash.Hash, err error)\n```\nGetHash returns and instance of hash.Hash using options opts. If opts is nil then the default hash function is returned.\n\n```go\nfunc (csp *CSP) GetKey(ski []byte) (k bccsp.Key, err error)\n```\nGetKey returns the key this CSP associates to the Subject Key Identifier ski.\n\n```go\nfunc (csp *CSP) Hash(msg []byte, opts bccsp.HashOpts) (digest []byte, err error)\n```\nHash hashes messages msg using options opts.\n\n```go\nfunc (csp *CSP) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)\n```\nKeyDeriv derives a key from k using opts. The opts argument should be appropriate for the primitive used.\n\n```go\nfunc (csp *CSP) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)\n```\nKeyGen generates a key using opts.\n\n```go\nfunc (csp *CSP) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error)\n```\nKeyImport imports a key from its raw representation using opts. The opts argument should be appropriate for the primitive used.\n\n```go\nfunc (csp *CSP) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error)\n```\nSign signs digest using key k. The opts argument should be appropriate for the primitive used.\n\nNote that when a signature of a hash of a larger message is needed, the caller is responsible for hashing the larger message and passing the hash (as digest).\n\n```go\nfunc (csp *CSP) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error)\n```\nVerify verifies signature against key k and digest\n\n```go\ntype Decryptor interface {\n\n\t// Decrypt decrypts ciphertext using key k.\n\t// The opts argument should be appropriate for the algorithm used.\n\tDecrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)\n}\n```\nDecryptor is a BCCSP-like interface that provides decryption algorithms\n\n```go\ntype Encryptor interface {\n\n\t// Encrypt encrypts plaintext using key k.\n\t// The opts argument should be appropriate for the algorithm used.\n\tEncrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error)\n}\n```\nEncryptor is a BCCSP-like interface that provides encryption algorithms\n\n```go\ntype Hasher interface {\n\n\t// Hash hashes messages msg using options opts.\n\t// If opts is nil, the default hash function will be used.\n\tHash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error)\n\n\t// GetHash returns and instance of hash.Hash using options opts.\n\t// If opts is nil, the default hash function will be returned.\n\tGetHash(opts bccsp.HashOpts) (h hash.Hash, err error)\n}\n```\nHasher is a BCCSP-like interface that provides hash algorithms\n\n```go\ntype KeyDeriver interface {\n\n\t// KeyDeriv derives a key from k using opts.\n\t// The opts argument should be appropriate for the primitive used.\n\tKeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)\n}\n```\nKeyDeriver is a BCCSP-like interface that provides key derivation algorithms\n\n```go\ntype KeyGenerator interface {\n\n\t// KeyGen generates a key using opts.\n\tKeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)\n}\n```\nKeyGenerator is a BCCSP-like interface that provides key generation algorithms\n\n```go\ntype KeyImporter interface {\n\n\t// KeyImport imports a key from its raw representation using opts.\n\t// The opts argument should be appropriate for the primitive used.\n\tKeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error)\n}\n```\nKeyImporter is a BCCSP-like interface that provides key import algorithms\n\n```go\ntype Signer interface {\n\n\t// Sign signs digest using key k.\n\t// The opts argument should be appropriate for the algorithm used.\n\t//\n\t// Note that when a signature of a hash of a larger message is needed,\n\t// the caller is responsible for hashing the larger message and passing\n\t// the hash (as digest).\n\tSign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error)\n}\n```\nSigner is a BCCSP-like interface that provides signing algorithms\n\n```go\ntype Verifier interface {\n\n\t// Verify verifies signature against key k and digest\n\t// The opts argument should be appropriate for the algorithm used.\n\tVerify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error)\n}\n```\nVerifier is a BCCSP-like interface that provides verifying algorithms\n\n","path":"github.com/eric-erki/https-hyperledger.org/bccsp/sw","name":"sw","synopsis":"","isRedistributable":true}
