sw

package
v1.0.0-preview Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 27 Imported by: 1,435

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. 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESCBCPKCS7Decrypt

func AESCBCPKCS7Decrypt(key, src []byte) ([]byte, error)

AESCBCPKCS7Decrypt combines CBC decryption and PKCS7 unpadding

func AESCBCPKCS7Encrypt

func AESCBCPKCS7Encrypt(key, src []byte) ([]byte, error)

AESCBCPKCS7Encrypt combines CBC encryption and PKCS7 padding

func GetRandomBytes

func GetRandomBytes(len int) ([]byte, error)

GetRandomBytes returns len random looking bytes

func New

func New(securityLevel int, hashFamily string, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)

New returns a new instance of the software-based BCCSP set at the passed security level, hash family and KeyStore.

func NewDefaultSecurityLevel

func NewDefaultSecurityLevel(keyStorePath string) (bccsp.BCCSP, error)

NewDefaultSecurityLevel returns a new instance of the software-based BCCSP at security level 256, hash family SHA2 and using FolderBasedKeyStore as KeyStore.

func NewDefaultSecurityLevelWithKeystore

func NewDefaultSecurityLevelWithKeystore(keyStore bccsp.KeyStore) (bccsp.BCCSP, error)

NewDefaultSecurityLevel returns a new instance of the software-based BCCSP at security level 256, hash family SHA2 and using the passed KeyStore.

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.

func (*DummyKeyStore) StoreKey

func (ks *DummyKeyStore) StoreKey(k bccsp.Key) (err error)

StoreKey stores the key k in this KeyStore. If this KeyStore is read only then the method will fail.

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.

func (*FileBasedKeyStore) StoreKey

func (ks *FileBasedKeyStore) StoreKey(k bccsp.Key) (err error)

StoreKey stores the key k in this KeyStore. If this KeyStore is read only then the method will fail.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL