Documentation ¶
Overview ¶
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Copyright IBM Corp. 2017 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless 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.
Index ¶
- func AESCBCPKCS7Decrypt(key, src []byte) ([]byte, error)
- func AESCBCPKCS7Encrypt(key, src []byte) ([]byte, error)
- func FindPKCS11Lib() (lib, pin, label string)
- func GetRandomBytes(len int) ([]byte, error)
- func New(opts PKCS11Opts, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)
- type DummyKeyStore
- type DummyKeystoreOpts
- type FileBasedKeyStore
- type FileKeystoreOpts
- type PKCS11Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESCBCPKCS7Decrypt ¶
AESCBCPKCS7Decrypt combines CBC decryption and PKCS7 unpadding
func AESCBCPKCS7Encrypt ¶
AESCBCPKCS7Encrypt combines CBC encryption and PKCS7 padding
func FindPKCS11Lib ¶
func FindPKCS11Lib() (lib, pin, label string)
THIS IS ONLY USED FOR TESTING This is a convenience function. Useful to self-configure, for tests where usual configuration is not available
func GetRandomBytes ¶
GetRandomBytes returns len random looking bytes
Types ¶
type DummyKeyStore ¶
type DummyKeyStore struct { }
dummyKeyStore is a read-only KeyStore that neither loads nor stores keys.
func (*DummyKeyStore) GetKey ¶
func (ks *DummyKeyStore) GetKey(ski []byte) (k bccsp.Key, err error)
GetKey returns a key object whose SKI is the one passed.
func (*DummyKeyStore) ReadOnly ¶
func (ks *DummyKeyStore) ReadOnly() bool
ReadOnly returns true if this KeyStore is read only, false otherwise. If ReadOnly is true then StoreKey will fail.
type DummyKeystoreOpts ¶
type DummyKeystoreOpts struct{}
type FileBasedKeyStore ¶
type FileBasedKeyStore struct {
// contains filtered or unexported fields
}
FileBasedKeyStore is a folder-based KeyStore. Each key is stored in a separated file whose name contains the key's SKI and flags to identity the key's type. All the keys are stored in a folder whose path is provided at initialization time. The KeyStore can be initialized with a password, this password is used to encrypt and decrypt the files storing the keys. A KeyStore can be read only to avoid the overwriting of keys.
func (*FileBasedKeyStore) GetKey ¶
func (ks *FileBasedKeyStore) GetKey(ski []byte) (k bccsp.Key, err error)
GetKey returns a key object whose SKI is the one passed.
func (*FileBasedKeyStore) Init ¶
func (ks *FileBasedKeyStore) Init(pwd []byte, path string, readOnly bool) error
Init initializes this KeyStore with a password, a path to a folder where the keys are stored and a read only flag. Each key is stored in a separated file whose name contains the key's SKI and flags to identity the key's type. If the KeyStore is initialized with a password, this password is used to encrypt and decrypt the files storing the keys. The pwd can be nil for non-encrypted KeyStores. If an encrypted key-store is initialized without a password, then retrieving keys from the KeyStore will fail. A KeyStore can be read only to avoid the overwriting of keys.
func (*FileBasedKeyStore) ReadOnly ¶
func (ks *FileBasedKeyStore) ReadOnly() bool
ReadOnly returns true if this KeyStore is read only, false otherwise. If ReadOnly is true then StoreKey will fail.
type FileKeystoreOpts ¶
type FileKeystoreOpts struct {
KeyStorePath string `mapstructure:"keystore" json:"keystore" yaml:"KeyStore"`
}
Since currently only ECDSA operations go to PKCS11, need a keystore still Pluggable Keystores, could add JKS, P12, etc..
type PKCS11Opts ¶
type PKCS11Opts struct { // Default algorithms when not specified (Deprecated?) SecLevel int `mapstructure:"security" json:"security"` HashFamily string `mapstructure:"hash" json:"hash"` // Keystore options Ephemeral bool `mapstructure:"tempkeys,omitempty" json:"tempkeys,omitempty"` FileKeystore *FileKeystoreOpts `mapstructure:"filekeystore,omitempty" json:"filekeystore,omitempty"` DummyKeystore *DummyKeystoreOpts `mapstructure:"dummykeystore,omitempty" json:"dummykeystore,omitempty"` // PKCS11 options Library string `mapstructure:"library" json:"library"` Label string `mapstructure:"label" json:"label"` Pin string `mapstructure:"pin" json:"pin"` Sensitive bool `mapstructure:"sensitivekeys,omitempty" json:"sensitivekeys,omitempty"` SoftVerify bool `mapstructure:"softwareverify,omitempty" json:"softwareverify,omitempty"` }
PKCS11Opts contains options for the P11Factory