Documentation ¶
Overview ¶
Package crypto is a generated GoMock package.
Package crypto is a generated GoMock package.
Index ¶
- Variables
- func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)
- func BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)
- func CompareHash(value *CryptoValue, comparer []byte, alg HashAlgorithm) error
- func Decrypt(value *CryptoValue, alg EncryptionAlgorithm) ([]byte, error)
- func DecryptAES(text []byte, key string) ([]byte, error)
- func DecryptAESString(data string, key string) (string, error)
- func DecryptString(value *CryptoValue, alg EncryptionAlgorithm) (string, error)
- func EncryptAES(plainText []byte, key string) ([]byte, error)
- func EncryptAESString(data string, key string) (string, error)
- func EncryptKeys(privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey, alg EncryptionAlgorithm) (*CryptoValue, *CryptoValue, error)
- func GenerateEncryptedKeyPair(bits int, alg EncryptionAlgorithm) (*CryptoValue, *CryptoValue, error)
- func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func IsCodeExpired(creationDate time.Time, expiry time.Duration) bool
- func LoadKey(id string, keyStorage KeyStorage) (string, error)
- func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
- func PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)
- func VerifyCode(creationDate time.Time, expiry time.Duration, cryptoCode *CryptoValue, ...) error
- type AESCrypto
- func (a *AESCrypto) Algorithm() string
- func (a *AESCrypto) Decrypt(value []byte, keyID string) ([]byte, error)
- func (a *AESCrypto) DecryptString(value []byte, keyID string) (string, error)
- func (a *AESCrypto) DecryptionKeyIDs() []string
- func (a *AESCrypto) Encrypt(value []byte) ([]byte, error)
- func (a *AESCrypto) EncryptionKeyID() string
- type BCrypt
- type Crypto
- type CryptoType
- type CryptoValue
- type EncryptionAlgorithm
- type Generator
- type GeneratorConfig
- type HashAlgorithm
- type Key
- type KeyConfig
- type KeyStorage
- type Keys
- type MockCrypto
- type MockCryptoMockRecorder
- type MockEncryptionAlgorithm
- func (m *MockEncryptionAlgorithm) Algorithm() string
- func (m *MockEncryptionAlgorithm) Decrypt(hashed []byte, keyID string) ([]byte, error)
- func (m *MockEncryptionAlgorithm) DecryptString(hashed []byte, keyID string) (string, error)
- func (m *MockEncryptionAlgorithm) DecryptionKeyIDs() []string
- func (m *MockEncryptionAlgorithm) EXPECT() *MockEncryptionAlgorithmMockRecorder
- func (m *MockEncryptionAlgorithm) Encrypt(value []byte) ([]byte, error)
- func (m *MockEncryptionAlgorithm) EncryptionKeyID() string
- type MockEncryptionAlgorithmMockRecorder
- func (mr *MockEncryptionAlgorithmMockRecorder) Algorithm() *gomock.Call
- func (mr *MockEncryptionAlgorithmMockRecorder) Decrypt(hashed, keyID interface{}) *gomock.Call
- func (mr *MockEncryptionAlgorithmMockRecorder) DecryptString(hashed, keyID interface{}) *gomock.Call
- func (mr *MockEncryptionAlgorithmMockRecorder) DecryptionKeyIDs() *gomock.Call
- func (mr *MockEncryptionAlgorithmMockRecorder) Encrypt(value interface{}) *gomock.Call
- func (mr *MockEncryptionAlgorithmMockRecorder) EncryptionKeyID() *gomock.Call
- type MockGenerator
- type MockGeneratorMockRecorder
- type MockHashAlgorithm
- type MockHashAlgorithmMockRecorder
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty = errors.New("cannot decode, empty data")
Functions ¶
func BytesToPrivateKey ¶
func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)
func CompareHash ¶
func CompareHash(value *CryptoValue, comparer []byte, alg HashAlgorithm) error
func Decrypt ¶
func Decrypt(value *CryptoValue, alg EncryptionAlgorithm) ([]byte, error)
func DecryptString ¶
func DecryptString(value *CryptoValue, alg EncryptionAlgorithm) (string, error)
func EncryptKeys ¶
func EncryptKeys(privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey, alg EncryptionAlgorithm) (*CryptoValue, *CryptoValue, error)
func GenerateEncryptedKeyPair ¶
func GenerateEncryptedKeyPair(bits int, alg EncryptionAlgorithm) (*CryptoValue, *CryptoValue, error)
func GenerateKeyPair ¶
func PrivateKeyToBytes ¶
func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
func VerifyCode ¶
Types ¶
type AESCrypto ¶
type AESCrypto struct {
// contains filtered or unexported fields
}
func NewAESCrypto ¶
func NewAESCrypto(config *KeyConfig, keyStorage KeyStorage) (*AESCrypto, error)
func (*AESCrypto) DecryptString ¶
func (*AESCrypto) DecryptionKeyIDs ¶
func (*AESCrypto) EncryptionKeyID ¶
type BCrypt ¶
type BCrypt struct {
// contains filtered or unexported fields
}
func (*BCrypt) CompareHash ¶
type CryptoValue ¶
type CryptoValue struct { CryptoType CryptoType Algorithm string KeyID string Crypted []byte }
func Encrypt ¶
func Encrypt(value []byte, alg EncryptionAlgorithm) (*CryptoValue, error)
func Hash ¶
func Hash(value []byte, alg HashAlgorithm) (*CryptoValue, error)
func (*CryptoValue) Scan ¶
func (c *CryptoValue) Scan(src interface{}) error
type EncryptionAlgorithm ¶
type EncryptionAlgorithm interface { Crypto EncryptionKeyID() string DecryptionKeyIDs() []string Encrypt(value []byte) ([]byte, error) Decrypt(hashed []byte, keyID string) ([]byte, error) DecryptString(hashed []byte, keyID string) (string, error) }
func CreateMockEncryptionAlg ¶
func CreateMockEncryptionAlg(ctrl *gomock.Controller) EncryptionAlgorithm
type Generator ¶
func NewEncryptionGenerator ¶
func NewEncryptionGenerator(config GeneratorConfig, algorithm EncryptionAlgorithm) Generator
func NewHashGenerator ¶
func NewHashGenerator(config GeneratorConfig, algorithm HashAlgorithm) Generator
type GeneratorConfig ¶
type HashAlgorithm ¶
type HashAlgorithm interface { Crypto Hash(value []byte) ([]byte, error) CompareHash(hashed, comparer []byte) error }
func CreateMockHashAlg ¶
func CreateMockHashAlg(ctrl *gomock.Controller) HashAlgorithm
type KeyStorage ¶
type MockCrypto ¶
type MockCrypto struct {
// contains filtered or unexported fields
}
MockCrypto is a mock of Crypto interface
func NewMockCrypto ¶
func NewMockCrypto(ctrl *gomock.Controller) *MockCrypto
NewMockCrypto creates a new mock instance
func (*MockCrypto) EXPECT ¶
func (m *MockCrypto) EXPECT() *MockCryptoMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockCryptoMockRecorder ¶
type MockCryptoMockRecorder struct {
// contains filtered or unexported fields
}
MockCryptoMockRecorder is the mock recorder for MockCrypto
func (*MockCryptoMockRecorder) Algorithm ¶
func (mr *MockCryptoMockRecorder) Algorithm() *gomock.Call
Algorithm indicates an expected call of Algorithm
type MockEncryptionAlgorithm ¶
type MockEncryptionAlgorithm struct {
// contains filtered or unexported fields
}
MockEncryptionAlgorithm is a mock of EncryptionAlgorithm interface
func NewMockEncryptionAlgorithm ¶
func NewMockEncryptionAlgorithm(ctrl *gomock.Controller) *MockEncryptionAlgorithm
NewMockEncryptionAlgorithm creates a new mock instance
func (*MockEncryptionAlgorithm) Algorithm ¶
func (m *MockEncryptionAlgorithm) Algorithm() string
Algorithm mocks base method
func (*MockEncryptionAlgorithm) Decrypt ¶
func (m *MockEncryptionAlgorithm) Decrypt(hashed []byte, keyID string) ([]byte, error)
Decrypt mocks base method
func (*MockEncryptionAlgorithm) DecryptString ¶
func (m *MockEncryptionAlgorithm) DecryptString(hashed []byte, keyID string) (string, error)
DecryptString mocks base method
func (*MockEncryptionAlgorithm) DecryptionKeyIDs ¶
func (m *MockEncryptionAlgorithm) DecryptionKeyIDs() []string
DecryptionKeyIDs mocks base method
func (*MockEncryptionAlgorithm) EXPECT ¶
func (m *MockEncryptionAlgorithm) EXPECT() *MockEncryptionAlgorithmMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockEncryptionAlgorithm) Encrypt ¶
func (m *MockEncryptionAlgorithm) Encrypt(value []byte) ([]byte, error)
Encrypt mocks base method
func (*MockEncryptionAlgorithm) EncryptionKeyID ¶
func (m *MockEncryptionAlgorithm) EncryptionKeyID() string
EncryptionKeyID mocks base method
type MockEncryptionAlgorithmMockRecorder ¶
type MockEncryptionAlgorithmMockRecorder struct {
// contains filtered or unexported fields
}
MockEncryptionAlgorithmMockRecorder is the mock recorder for MockEncryptionAlgorithm
func (*MockEncryptionAlgorithmMockRecorder) Algorithm ¶
func (mr *MockEncryptionAlgorithmMockRecorder) Algorithm() *gomock.Call
Algorithm indicates an expected call of Algorithm
func (*MockEncryptionAlgorithmMockRecorder) Decrypt ¶
func (mr *MockEncryptionAlgorithmMockRecorder) Decrypt(hashed, keyID interface{}) *gomock.Call
Decrypt indicates an expected call of Decrypt
func (*MockEncryptionAlgorithmMockRecorder) DecryptString ¶
func (mr *MockEncryptionAlgorithmMockRecorder) DecryptString(hashed, keyID interface{}) *gomock.Call
DecryptString indicates an expected call of DecryptString
func (*MockEncryptionAlgorithmMockRecorder) DecryptionKeyIDs ¶
func (mr *MockEncryptionAlgorithmMockRecorder) DecryptionKeyIDs() *gomock.Call
DecryptionKeyIDs indicates an expected call of DecryptionKeyIDs
func (*MockEncryptionAlgorithmMockRecorder) Encrypt ¶
func (mr *MockEncryptionAlgorithmMockRecorder) Encrypt(value interface{}) *gomock.Call
Encrypt indicates an expected call of Encrypt
func (*MockEncryptionAlgorithmMockRecorder) EncryptionKeyID ¶
func (mr *MockEncryptionAlgorithmMockRecorder) EncryptionKeyID() *gomock.Call
EncryptionKeyID indicates an expected call of EncryptionKeyID
type MockGenerator ¶
type MockGenerator struct {
// contains filtered or unexported fields
}
MockGenerator is a mock of Generator interface
func NewMockGenerator ¶
func NewMockGenerator(ctrl *gomock.Controller) *MockGenerator
NewMockGenerator creates a new mock instance
func (*MockGenerator) EXPECT ¶
func (m *MockGenerator) EXPECT() *MockGeneratorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockGenerator) Expiry ¶
func (m *MockGenerator) Expiry() time.Duration
Expiry mocks base method
type MockGeneratorMockRecorder ¶
type MockGeneratorMockRecorder struct {
// contains filtered or unexported fields
}
MockGeneratorMockRecorder is the mock recorder for MockGenerator
func (*MockGeneratorMockRecorder) Alg ¶
func (mr *MockGeneratorMockRecorder) Alg() *gomock.Call
Alg indicates an expected call of Alg
func (*MockGeneratorMockRecorder) Expiry ¶
func (mr *MockGeneratorMockRecorder) Expiry() *gomock.Call
Expiry indicates an expected call of Expiry
func (*MockGeneratorMockRecorder) Length ¶
func (mr *MockGeneratorMockRecorder) Length() *gomock.Call
Length indicates an expected call of Length
func (*MockGeneratorMockRecorder) Runes ¶
func (mr *MockGeneratorMockRecorder) Runes() *gomock.Call
Runes indicates an expected call of Runes
type MockHashAlgorithm ¶
type MockHashAlgorithm struct {
// contains filtered or unexported fields
}
MockHashAlgorithm is a mock of HashAlgorithm interface
func NewMockHashAlgorithm ¶
func NewMockHashAlgorithm(ctrl *gomock.Controller) *MockHashAlgorithm
NewMockHashAlgorithm creates a new mock instance
func (*MockHashAlgorithm) Algorithm ¶
func (m *MockHashAlgorithm) Algorithm() string
Algorithm mocks base method
func (*MockHashAlgorithm) CompareHash ¶
func (m *MockHashAlgorithm) CompareHash(hashed, comparer []byte) error
CompareHash mocks base method
func (*MockHashAlgorithm) EXPECT ¶
func (m *MockHashAlgorithm) EXPECT() *MockHashAlgorithmMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockHashAlgorithmMockRecorder ¶
type MockHashAlgorithmMockRecorder struct {
// contains filtered or unexported fields
}
MockHashAlgorithmMockRecorder is the mock recorder for MockHashAlgorithm
func (*MockHashAlgorithmMockRecorder) Algorithm ¶
func (mr *MockHashAlgorithmMockRecorder) Algorithm() *gomock.Call
Algorithm indicates an expected call of Algorithm
func (*MockHashAlgorithmMockRecorder) CompareHash ¶
func (mr *MockHashAlgorithmMockRecorder) CompareHash(hashed, comparer interface{}) *gomock.Call
CompareHash indicates an expected call of CompareHash
func (*MockHashAlgorithmMockRecorder) Hash ¶
func (mr *MockHashAlgorithmMockRecorder) Hash(value interface{}) *gomock.Call
Hash indicates an expected call of Hash